static gboolean ensure_loaded (RBAndroidSource *source) { RBAndroidSourcePrivate *priv = GET_PRIVATE (source); RBSourceLoadStatus status; RhythmDBEntryType *entry_type; GMount *mount; GFile *root; RBTaskList *tasklist; RBShell *shell; char *name; char *label; if (priv->loaded) { g_object_get (source, "load-status", &status, NULL); return (status == RB_SOURCE_LOAD_STATUS_LOADED); } priv->loaded = TRUE; rb_media_player_source_load (RB_MEDIA_PLAYER_SOURCE (source)); /* identify storage containers and find music dirs within them */ g_object_get (source, "mount", &mount, "entry-type", &entry_type, NULL); root = g_mount_get_root (mount); g_object_unref (mount); priv->cancel = g_cancellable_new (); priv->import_job = rhythmdb_import_job_new (priv->db, entry_type, priv->ignore_type, priv->error_type); g_signal_connect_object (priv->import_job, "complete", G_CALLBACK (import_complete_cb), source, 0); priv->scanned = 0; g_queue_init (&priv->to_scan); g_queue_push_tail (&priv->to_scan, root); g_object_unref (entry_type); find_music_dirs (RB_ANDROID_SOURCE (source)); g_object_get (source, "name", &name, "shell", &shell, NULL); label = g_strdup_printf (_("Scanning %s"), name); g_object_set (priv->import_job, "task-label", label, NULL); g_object_get (shell, "task-list", &tasklist, NULL); rb_task_list_add_task (tasklist, RB_TASK_PROGRESS (priv->import_job)); g_object_unref (tasklist); g_object_unref (shell); g_free (label); g_free (name); return FALSE; }
static gboolean ensure_loaded (RBGenericPlayerSource *source) { RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (source); RBSourceLoadStatus status; if (priv->loaded) { g_object_get (source, "load-status", &status, NULL); return (status == RB_SOURCE_LOAD_STATUS_LOADED); } else { priv->loaded = TRUE; rb_media_player_source_load (RB_MEDIA_PLAYER_SOURCE (source)); load_songs (source); return FALSE; } }
static gboolean device_opened_idle (DeviceOpenedData *data) { RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (data->source); int i; gboolean has_mp3 = FALSE; if (data->name != NULL) { g_object_set (data->source, "name", data->name, NULL); } /* when the source name changes after this, try to update the device name */ g_signal_connect (G_OBJECT (data->source), "notify::name", (GCallback)rb_mtp_source_name_changed_cb, NULL); rb_media_player_source_load (RB_MEDIA_PLAYER_SOURCE (data->source)); for (i = 0; i < data->num_types; i++) { const char *mediatype; if (i <= LIBMTP_FILETYPE_UNKNOWN) { priv->supported_types[data->types[i]] = 1; } /* this has to work with the remapping done in * rb-removable-media-source.c:impl_paste. */ switch (data->types[i]) { case LIBMTP_FILETYPE_WAV: mediatype = "audio/x-wav"; break; case LIBMTP_FILETYPE_MP3: /* special handling for mp3: always put it at the front of the list * if it's supported. */ has_mp3 = TRUE; mediatype = NULL; break; case LIBMTP_FILETYPE_WMA: mediatype = "audio/x-ms-wma"; break; case LIBMTP_FILETYPE_OGG: mediatype = "application/ogg"; break; case LIBMTP_FILETYPE_MP4: case LIBMTP_FILETYPE_M4A: case LIBMTP_FILETYPE_AAC: mediatype = "audio/aac"; break; case LIBMTP_FILETYPE_WMV: mediatype = "audio/x-ms-wmv"; break; case LIBMTP_FILETYPE_ASF: mediatype = "video/x-ms-asf"; break; case LIBMTP_FILETYPE_FLAC: mediatype = "audio/flac"; break; case LIBMTP_FILETYPE_JPEG: rb_debug ("JPEG (album art) supported"); mediatype = NULL; priv->album_art_supported = TRUE; break; default: rb_debug ("unknown libmtp filetype %s supported", LIBMTP_Get_Filetype_Description (data->types[i])); mediatype = NULL; break; } if (mediatype != NULL) { rb_debug ("media type %s supported", mediatype); priv->mediatypes = g_list_prepend (priv->mediatypes, g_strdup (mediatype)); } } if (has_mp3) { rb_debug ("audio/mpeg supported"); priv->mediatypes = g_list_prepend (priv->mediatypes, g_strdup ("audio/mpeg")); } g_object_unref (data->source); free (data->types); g_free (data->name); g_free (data); return FALSE; }
static gboolean device_opened_idle (DeviceOpenedData *data) { RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (data->source); int i; GstEncodingTarget *target; GList *profiles = NULL; if (data->name != NULL) { g_object_set (data->source, "name", data->name, NULL); } /* when the source name changes after this, try to update the device name */ g_signal_connect (G_OBJECT (data->source), "notify::name", (GCallback)rb_mtp_source_name_changed_cb, NULL); rb_media_player_source_load (RB_MEDIA_PLAYER_SOURCE (data->source)); for (i = 0; i < data->num_types; i++) { const char *mediatype; gboolean prepend; if (i <= LIBMTP_FILETYPE_UNKNOWN) { priv->supported_types[data->types[i]] = 1; } mediatype = NULL; prepend = FALSE; switch (data->types[i]) { case LIBMTP_FILETYPE_WAV: /*mediatype = "audio/x-wav";*/ /* don't bother including this? */ break; case LIBMTP_FILETYPE_MP3: mediatype = "audio/mpeg"; prepend = TRUE; /* always goes first if supported */ break; case LIBMTP_FILETYPE_WMA: mediatype = "audio/x-wma"; break; case LIBMTP_FILETYPE_OGG: mediatype = "audio/x-vorbis"; break; case LIBMTP_FILETYPE_MP4: case LIBMTP_FILETYPE_M4A: case LIBMTP_FILETYPE_AAC: mediatype = "audio/x-aac"; break; case LIBMTP_FILETYPE_WMV: mediatype = "audio/x-ms-wmv"; /* media type? */ break; case LIBMTP_FILETYPE_ASF: mediatype = "video/x-ms-asf"; /* media type? */ break; case LIBMTP_FILETYPE_FLAC: mediatype = "audio/x-flac"; break; case LIBMTP_FILETYPE_JPEG: rb_debug ("JPEG (album art) supported"); priv->album_art_supported = TRUE; break; default: rb_debug ("unknown libmtp filetype %s supported", LIBMTP_Get_Filetype_Description (data->types[i])); break; } if (mediatype != NULL) { GstEncodingProfile *profile; profile = rb_gst_get_encoding_profile (mediatype); if (profile != NULL) { rb_debug ("media type %s supported", mediatype); if (prepend) { profiles = g_list_prepend (profiles, profile); } else { profiles = g_list_append (profiles, profile); } } else { rb_debug ("no encoding profile for supported media type %s", mediatype); } } } if (priv->album_art_supported) { priv->art_store = rb_ext_db_new ("album-art"); } target = gst_encoding_target_new ("mtpdevice", "device", "", profiles); g_object_set (data->source, "encoding-target", target, NULL); g_object_unref (data->source); free (data->types); g_free (data->name); g_free (data); return FALSE; }