本文整理汇总了C++中MTP_SOURCE_GET_PRIVATE函数的典型用法代码示例。如果您正苦于以下问题:C++ MTP_SOURCE_GET_PRIVATE函数的具体用法?C++ MTP_SOURCE_GET_PRIVATE怎么用?C++ MTP_SOURCE_GET_PRIVATE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MTP_SOURCE_GET_PRIVATE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: request_album_art_idle
static gboolean
request_album_art_idle (RequestAlbumArtData *data)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (data->source);
const char *album;
/* pretty sure we don't need any extra locking here - we only touch the artwork
* request map on the main thread anyway.
*/
album = rhythmdb_entry_get_string (data->entry, RHYTHMDB_PROP_ALBUM);
if (g_hash_table_lookup (priv->artwork_request_map, album) == NULL) {
GValue *metadata;
RhythmDB *db = get_db_for_source (data->source);
rb_debug ("requesting cover art image for album %s", album);
g_hash_table_insert (priv->artwork_request_map, (gpointer) album, GINT_TO_POINTER (1));
metadata = rhythmdb_entry_request_extra_metadata (db, data->entry, "rb:coverArt");
if (metadata) {
artwork_notify_cb (db, data->entry, "rb:coverArt", metadata, data->source);
g_value_unset (metadata);
g_free (metadata);
}
g_object_unref (db);
}
g_object_unref (data->source);
rhythmdb_entry_unref (data->entry);
g_free (data);
return FALSE;
}
示例2: mimetype_to_filetype
static LIBMTP_filetype_t
mimetype_to_filetype (RBMtpSource *source, const char *mimetype)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
if (!strcmp (mimetype, "audio/mpeg") || !strcmp (mimetype, "application/x-id3")) {
return LIBMTP_FILETYPE_MP3;
} else if (!strcmp (mimetype, "audio/x-wav")) {
return LIBMTP_FILETYPE_WAV;
} else if (!strcmp (mimetype, "application/ogg")) {
return LIBMTP_FILETYPE_OGG;
} else if (!strcmp (mimetype, "audio/x-m4a") || !strcmp (mimetype, "video/quicktime")) {
/* try a few different filetypes that might work */
if (priv->supported_types[LIBMTP_FILETYPE_M4A])
return LIBMTP_FILETYPE_M4A;
else if (!priv->supported_types[LIBMTP_FILETYPE_AAC] && priv->supported_types[LIBMTP_FILETYPE_MP4])
return LIBMTP_FILETYPE_MP4;
else
return LIBMTP_FILETYPE_AAC;
} else if (!strcmp (mimetype, "audio/x-ms-wma") || !strcmp (mimetype, "audio/x-ms-asf")) {
return LIBMTP_FILETYPE_WMA;
} else if (!strcmp (mimetype, "video/x-ms-asf")) {
return LIBMTP_FILETYPE_ASF;
} else if (!strcmp (mimetype, "audio/x-flac")) {
return LIBMTP_FILETYPE_FLAC;
} else {
rb_debug ("\"%s\" is not a supported mimetype", mimetype);
return LIBMTP_FILETYPE_UNKNOWN;
}
}
示例3: queue_free_space_update
static void
queue_free_space_update (RBMtpSource *source)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
rb_mtp_thread_queue_callback (priv->device_thread,
(RBMtpThreadCallback) update_free_space_cb, source, NULL);
}
示例4: unmount_done_cb
static void
unmount_done_cb (GObject *object, GAsyncResult *result, gpointer psource)
{
GMount *mount;
RBMtpSource *source;
gboolean ok;
GError *error = NULL;
RBMtpSourcePrivate *priv;
mount = G_MOUNT (object);
source = RB_MTP_SOURCE (psource);
priv = MTP_SOURCE_GET_PRIVATE (source);
ok = g_mount_unmount_with_operation_finish (mount, result, &error);
if (ok) {
rb_debug ("successfully unmounted mtp device");
priv->remount_volume = g_mount_get_volume (mount);
open_device (source);
} else {
g_warning ("Unable to unmount MTP device: %s", error->message);
g_error_free (error);
}
g_object_unref (mount);
g_object_unref (source);
}
示例5: prepare_source
static void
prepare_source (RBMtpSource *source, const char *stream_uri, GObject *src)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
RhythmDBEntry *entry;
RhythmDB *db;
/* make sure this stream is for a file on our device */
if (g_str_has_prefix (stream_uri, "xrbmtp://") == FALSE)
return;
db = get_db_for_source (source);
entry = rhythmdb_entry_lookup_by_location (db, stream_uri);
g_object_unref (db);
if (entry == NULL)
return;
if (_rb_source_check_entry_type (RB_SOURCE (source), entry) == FALSE) {
rhythmdb_entry_unref (entry);
return;
}
rb_debug ("setting device-thread for stream %s", stream_uri);
g_object_set (src, "device-thread", priv->device_thread, NULL);
rhythmdb_entry_unref (entry);
}
示例6: MTP_SOURCE_GET_PRIVATE
static guint64
impl_get_free_space (RBMediaPlayerSource *source)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
/* probably need a lock for this */
return priv->free_space;
}
示例7: rb_mtp_source_set_property
static void
rb_mtp_source_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (object);
LIBMTP_raw_device_t *raw_device;
switch (prop_id) {
case PROP_RAW_DEVICE:
raw_device = g_value_get_pointer (value);
priv->raw_device = *raw_device;
break;
#if defined(HAVE_GUDEV)
case PROP_UDEV_DEVICE:
priv->udev_device = g_value_dup_object (value);
break;
#else
case PROP_UDI:
priv->udi = g_value_dup_string (value);
break;
#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
示例8: artwork_notify_cb
static void
artwork_notify_cb (RhythmDB *db,
RhythmDBEntry *entry,
const char *property_name,
const GValue *metadata,
RBMtpSource *source)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
GdkPixbuf *pixbuf;
const char *album_name;
album_name = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM);
/* check if we're looking for art for this entry, and if we actually got some */
if (g_hash_table_remove (priv->artwork_request_map, album_name) == FALSE)
return;
if (G_VALUE_HOLDS (metadata, GDK_TYPE_PIXBUF) == FALSE)
return;
pixbuf = GDK_PIXBUF (g_value_get_object (metadata));
rb_mtp_thread_set_album_image (priv->device_thread, album_name, pixbuf);
queue_free_space_update (source);
}
示例9: ensure_loaded
static gboolean
ensure_loaded (RBMtpSource *source)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
#if defined(HAVE_GUDEV)
GMount *mount;
#endif
if (priv->tried_open) {
RBSourceLoadStatus status;
g_object_get (source, "load-status", &status, NULL);
return (status == RB_SOURCE_LOAD_STATUS_LOADED);
}
priv->tried_open = TRUE;
/* try to open the device. if gvfs has mounted it, unmount it first */
#if defined(HAVE_GUDEV)
mount = find_mount_for_device (priv->udev_device);
if (mount != NULL) {
rb_debug ("device is already mounted, waiting until activated");
g_mount_unmount_with_operation (mount,
G_MOUNT_UNMOUNT_NONE,
NULL,
NULL,
unmount_done_cb,
g_object_ref (source));
/* mount gets unreffed in callback */
} else {
rb_debug ("device isn't mounted");
open_device (source);
}
#else
open_device (source);
#endif
return FALSE;
}
示例10: rb_mtp_source_get_property
static void
rb_mtp_source_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (object);
switch (prop_id) {
case PROP_RAW_DEVICE:
g_value_set_pointer (value, &priv->raw_device);
break;
#if defined(HAVE_GUDEV)
case PROP_UDEV_DEVICE:
g_value_set_object (value, priv->udev_device);
break;
#else
case PROP_UDI:
g_value_set_string (value, priv->udi);
break;
#endif
case PROP_DEVICE_SERIAL:
g_value_set_string (value, priv->serial);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
示例11: rb_mtp_source_get_playback_uri
static char *
rb_mtp_source_get_playback_uri (RhythmDBEntry *entry, gpointer data)
{
RBMtpSourcePrivate *priv;
LIBMTP_track_t *track;
char *path;
char *uri = NULL;
GError *error = NULL;
priv = MTP_SOURCE_GET_PRIVATE (data);
track = g_hash_table_lookup (priv->entry_map, entry);
path = g_strdup_printf ("%s/%s-%s",
g_get_tmp_dir (),
rhythmdb_entry_dup_string (entry, RHYTHMDB_PROP_ARTIST),
rhythmdb_entry_dup_string (entry, RHYTHMDB_PROP_TITLE));
uri = g_filename_to_uri (path, NULL, &error);
g_free (path);
if (error != NULL) {
g_warning ("unable to convert path %s to filename: %s", path, error->message);
g_error_free (error);
g_free (path);
return NULL;
}
if (rb_mtp_source_transfer_track_to_disk (priv->device, track, uri) == TRUE) {
rb_debug ("playback URI for %s: %s",
rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION),
uri);
return uri;
} else {
g_free (uri);
return NULL;
}
}
示例12: mtp_device_open_cb
/* this callback runs on the device handling thread, so it can call libmtp directly */
static void
mtp_device_open_cb (LIBMTP_mtpdevice_t *device, RBMtpSource *source)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
DeviceOpenedData *data;
if (device == NULL) {
/* can't delete the source on this thread, so move it to the main thread */
g_idle_add ((GSourceFunc) device_open_failed_idle, g_object_ref (source));
return;
}
/* set the source name to match the device, ignoring some
* particular broken device names.
*/
data = g_new0 (DeviceOpenedData, 1);
data->source = g_object_ref (source);
data->name = LIBMTP_Get_Friendlyname (device);
if (data->name == NULL || strcmp (data->name, "?????") == 0) {
g_free (data->name);
data->name = LIBMTP_Get_Modelname (device);
}
if (data->name == NULL) {
data->name = g_strdup (_("Digital Audio Player"));
}
/* get some other device information that doesn't change */
priv->manufacturer = LIBMTP_Get_Manufacturername (device);
priv->device_version = LIBMTP_Get_Deviceversion (device);
priv->model_name = LIBMTP_Get_Modelname (device);
priv->serial = LIBMTP_Get_Serialnumber (device);
/* calculate the device capacity */
priv->capacity = 0;
if (LIBMTP_Get_Storage (device, LIBMTP_STORAGE_SORTBY_NOTSORTED) == 0) {
LIBMTP_devicestorage_t *storage;
for (storage = device->storage;
storage != NULL;
storage = storage->next) {
priv->capacity += storage->MaxCapacity;
}
}
update_free_space_cb (device, RB_MTP_SOURCE (source));
/* figure out the set of formats supported by the device */
if (LIBMTP_Get_Supported_Filetypes (device, &data->types, &data->num_types) != 0) {
rb_mtp_thread_report_errors (priv->device_thread, FALSE);
}
g_idle_add ((GSourceFunc) device_opened_idle, data);
/* now get the track list */
rb_mtp_thread_get_track_list (priv->device_thread, (RBMtpTrackListCallback) mtp_tracklist_cb, g_object_ref (source), g_object_unref);
}
示例13: rb_mtp_source_init
static void
rb_mtp_source_init (RBMtpSource *source)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
priv->entry_map = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
(GDestroyNotify) LIBMTP_destroy_track_t);
priv->track_transfer_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
}
示例14: rb_mtp_source_name_changed_cb
static void
rb_mtp_source_name_changed_cb (RBMtpSource *source,
GParamSpec *spec,
gpointer data)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
char *name = NULL;
g_object_get (source, "name", &name, NULL);
rb_mtp_thread_set_device_name (priv->device_thread, name);
g_free (name);
}
示例15: open_device
static void
open_device (RBMtpSource *source)
{
RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
rb_debug ("actually opening device");
priv->device_thread = rb_mtp_thread_new ();
rb_mtp_thread_open_device (priv->device_thread,
&priv->raw_device,
(RBMtpOpenCallback)mtp_device_open_cb,
g_object_ref (source),
g_object_unref);
}