player->pipeline->mainbin, MM_ERROR_PLAYER_NOT_INITIALIZED);
src_element = GST_ELEMENT_CAST(message->src);
- if (!src_element)
- return MM_ERROR_PLAYER_INTERNAL;
-
src_element_name = GST_ELEMENT_NAME(src_element);
if (!src_element_name)
return MM_ERROR_PLAYER_INTERNAL;
g_return_val_if_fail(player, FALSE);
g_return_val_if_fail(msg && GST_IS_MESSAGE(msg), FALSE);
-
gst_message_ref(msg);
g_mutex_lock(&player->bus_msg_q_lock);
{
mmplayer_t *player = (mmplayer_t *)(data);
GstMessage *msg = NULL;
- GstBus *bus = NULL;
MMPLAYER_FENTER();
MMPLAYER_RETURN_VAL_IF_FAIL(player &&
player->pipeline->mainbin[MMPLAYER_M_PIPE].gst,
NULL);
- bus = gst_pipeline_get_bus(GST_PIPELINE(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst));
- if (!bus) {
- LOGE("cannot get BUS from the pipeline");
- return NULL;
- }
-
MMPLAYER_BUS_MSG_THREAD_LOCK(player);
LOGD("[handle: %p] gst bus msg thread will be started.", player);
}
MMPLAYER_BUS_MSG_THREAD_UNLOCK(player);
- gst_object_unref(GST_OBJECT(bus));
-
MMPLAYER_FLEAVE();
+
return NULL;
}
return MM_ERROR_PLAYER_INTERNAL;
}
- player->bus_watcher = gst_bus_add_watch(bus, (GstBusFunc)__mmplayer_gst_msg_push, player);
+ player->bus_watcher = gst_bus_add_watch_full(bus, G_PRIORITY_DEFAULT,
+ (GstBusFunc)__mmplayer_gst_msg_push, player,
+ (GDestroyNotify)_mmplayer_watcher_removed_notify);
+ if (player->bus_watcher == 0) {
+ LOGE("failed to add bus watch");
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
+
+ g_mutex_init(&player->bus_watcher_mutex);
+ g_cond_init(&player->bus_watcher_cond);
+
player->context.thread_default = g_main_context_get_thread_default();
if (player->context.thread_default == NULL) {
player->context.thread_default = g_main_context_default();
goto ERROR;
}
- if (gst_element_set_state(mainbin[MMPLAYER_M_SRC].gst, target) == GST_STATE_CHANGE_FAILURE) {
- LOGE("Failed to change state of src element");
- goto ERROR;
- }
-
if (!MMPLAYER_IS_HTTP_STREAMING(player)) {
if (gst_element_set_state(mainbin[MMPLAYER_M_AUTOPLUG].gst, target) == GST_STATE_CHANGE_FAILURE) {
LOGE("Failed to change state of decodebin");
}
}
+ if (gst_element_set_state(mainbin[MMPLAYER_M_SRC].gst, target) == GST_STATE_CHANGE_FAILURE) {
+ LOGE("Failed to change state of src element");
+ goto ERROR;
+ }
+
player->gapless.stream_changed = TRUE;
player->gapless.running = TRUE;
MMPLAYER_FLEAVE();