* reorganize the way the gstreamer pipeline is built. Fix some usages

of emotion_object_file_set()
 * move the "frame_decode" evas event to _emotion_frame_new() a,d
   replace it in _emotion_video_pos_update() by "position_update"
 * fix a mem leak in the gstreamer backend and in the smart object


SVN revision: 34581
This commit is contained in:
doursse 2008-05-15 16:52:04 +00:00 committed by doursse
parent e5d9afb26f
commit caea856117
3 changed files with 59 additions and 82 deletions

View File

@ -235,6 +235,7 @@ emotion_object_file_set(Evas_Object *obj, const char *file)
{ {
int w, h; int w, h;
if (sd->file) free(sd->file);
sd->file = strdup(file); sd->file = strdup(file);
if (sd->module) if (sd->module)
{ {
@ -256,6 +257,8 @@ emotion_object_file_set(Evas_Object *obj, const char *file)
sd->module->file_close(sd->video); sd->module->file_close(sd->video);
evas_object_image_size_set(sd->obj, 0, 0); evas_object_image_size_set(sd->obj, 0, 0);
} }
if (sd->file) free(sd->file);
sd->file = NULL;
} }
} }
@ -838,6 +841,7 @@ _emotion_frame_new(Evas_Object *obj)
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME); E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
// printf("pix get set 1 %p\n", sd->obj); // printf("pix get set 1 %p\n", sd->obj);
evas_object_image_pixels_dirty_set(sd->obj, 1); evas_object_image_pixels_dirty_set(sd->obj, 1);
evas_object_smart_callback_call(obj, "frame_decode", NULL);
} }
EAPI void EAPI void
@ -851,7 +855,7 @@ _emotion_video_pos_update(Evas_Object *obj, double pos, double len)
if (len != sd->len) nlen = 1; if (len != sd->len) nlen = 1;
sd->pos = pos; sd->pos = pos;
sd->len = len; sd->len = len;
if (npos) evas_object_smart_callback_call(obj, "frame_decode", NULL); if (npos) evas_object_smart_callback_call(obj, "position_update", NULL);
if (nlen) evas_object_smart_callback_call(obj, "length_change", NULL); if (nlen) evas_object_smart_callback_call(obj, "length_change", NULL);
} }

View File

@ -237,7 +237,7 @@ em_init(Evas_Object *obj,
if (!emotion_video) if (!emotion_video)
return 0; return 0;
printf ("Init gstreamer...\n"); fprintf (stderr, "[Emotion] [gst] Init\n");
ev = calloc(1, sizeof(Emotion_Gstreamer_Video)); ev = calloc(1, sizeof(Emotion_Gstreamer_Video));
if (!ev) return 0; if (!ev) return 0;
@ -249,14 +249,6 @@ em_init(Evas_Object *obj,
if (!gst_init_check (NULL, NULL, &error)) if (!gst_init_check (NULL, NULL, &error))
goto failure_gstreamer; goto failure_gstreamer;
ev->pipeline = gst_pipeline_new ("pipeline");
if (!ev->pipeline)
goto failure_pipeline;
ev->eos_bus = gst_pipeline_get_bus (GST_PIPELINE (ev->pipeline));
if (!ev->eos_bus)
goto failure_bus;
/* We allocate the sinks lists */ /* We allocate the sinks lists */
ev->video_sinks = ecore_list_new (); ev->video_sinks = ecore_list_new ();
if (!ev->video_sinks) if (!ev->video_sinks)
@ -297,12 +289,6 @@ em_init(Evas_Object *obj,
failure_audio_sinks: failure_audio_sinks:
ecore_list_destroy (ev->video_sinks); ecore_list_destroy (ev->video_sinks);
failure_video_sinks: failure_video_sinks:
gst_object_unref (GST_OBJECT (ev->eos_bus));
failure_bus:
/* this call is not really necessary */
gst_element_set_state (ev->pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (ev->pipeline));
failure_pipeline:
failure_gstreamer: failure_gstreamer:
free (ev); free (ev);
@ -318,19 +304,18 @@ em_shutdown(void *video)
if (!ev) if (!ev)
return 0; return 0;
gst_element_set_state (ev->pipeline, GST_STATE_NULL); fprintf(stderr, "[Emotion] [gst] shutdown\n");
gst_object_unref (GST_OBJECT (ev->pipeline));
gst_object_unref (GST_OBJECT (ev->eos_bus));
ecore_list_destroy (ev->video_sinks); ecore_main_fd_handler_del(ev->fd_ev_handler);
ecore_list_destroy (ev->audio_sinks);
close(ev->fd_ev_write);
close(ev->fd_ev_read);
/* FIXME: and the evas object ? */ /* FIXME: and the evas object ? */
if (ev->obj_data) free(ev->obj_data); if (ev->obj_data) free(ev->obj_data);
ecore_main_fd_handler_del(ev->fd_ev_handler); ecore_list_destroy (ev->video_sinks);
close(ev->fd_ev_write); ecore_list_destroy (ev->audio_sinks);
close(ev->fd_ev_read);
free(ev); free(ev);
@ -346,6 +331,19 @@ em_file_open(const char *file,
ev = (Emotion_Gstreamer_Video *)video; ev = (Emotion_Gstreamer_Video *)video;
fprintf(stderr, "[Emotion] [gst] open\n");
ev->pipeline = gst_pipeline_new ("pipeline");
if (!ev->pipeline)
return 0;
ev->eos_bus = gst_pipeline_get_bus (GST_PIPELINE (ev->pipeline));
if (!ev->eos_bus)
{
gst_object_unref(ev->pipeline);
return 0;
}
/* Evas Object */ /* Evas Object */
ev->obj = obj; ev->obj = obj;
@ -370,6 +368,7 @@ em_file_open(const char *file,
fprintf (stderr, "[Emotion] [gst] build CD Audio pipeline\n"); fprintf (stderr, "[Emotion] [gst] build CD Audio pipeline\n");
if (!(emotion_pipeline_cdda_build (ev, device, track))) { if (!(emotion_pipeline_cdda_build (ev, device, track))) {
fprintf (stderr, "[Emotion] [gst] error while building CD Audio pipeline\n"); fprintf (stderr, "[Emotion] [gst] error while building CD Audio pipeline\n");
gst_object_unref(ev->pipeline);
return 0; return 0;
} }
} }
@ -379,6 +378,7 @@ em_file_open(const char *file,
fprintf (stderr, "[Emotion] [gst] build DVD pipeline \n"); fprintf (stderr, "[Emotion] [gst] build DVD pipeline \n");
if (!(emotion_pipeline_dvd_build (ev, NULL))) { if (!(emotion_pipeline_dvd_build (ev, NULL))) {
fprintf (stderr, "[Emotion] [gst] error while building DVD pipeline\n"); fprintf (stderr, "[Emotion] [gst] error while building DVD pipeline\n");
gst_object_unref(ev->pipeline);
return 0; return 0;
} }
} }
@ -387,6 +387,7 @@ em_file_open(const char *file,
fprintf (stderr, "[Emotion] [gst] build URI pipeline \n"); fprintf (stderr, "[Emotion] [gst] build URI pipeline \n");
if (!(emotion_pipeline_uri_build (ev, file))) { if (!(emotion_pipeline_uri_build (ev, file))) {
fprintf (stderr, "[Emotion] [gst] error while building URI pipeline\n"); fprintf (stderr, "[Emotion] [gst] error while building URI pipeline\n");
gst_object_unref(ev->pipeline);
return 0; return 0;
} }
} }
@ -401,6 +402,7 @@ em_file_open(const char *file,
fprintf (stderr, "[Emotion] [gst] build file pipeline \n"); fprintf (stderr, "[Emotion] [gst] build file pipeline \n");
if (!(emotion_pipeline_file_build (ev, filename))) { if (!(emotion_pipeline_file_build (ev, filename))) {
fprintf (stderr, "[Emotion] [gst] error while building File pipeline\n"); fprintf (stderr, "[Emotion] [gst] error while building File pipeline\n");
gst_object_unref(ev->pipeline);
return 0; return 0;
} }
} }
@ -414,20 +416,20 @@ em_file_open(const char *file,
vsink = (Emotion_Video_Sink *)ecore_list_first_goto (ev->video_sinks); vsink = (Emotion_Video_Sink *)ecore_list_first_goto (ev->video_sinks);
if (vsink) { if (vsink) {
g_print ("video : \n"); fprintf (stderr, "video : \n");
g_print (" size : %dx%d\n", vsink->width, vsink->height); fprintf (stderr, " size : %dx%d\n", vsink->width, vsink->height);
g_print (" fps : %d/%d\n", vsink->fps_num, vsink->fps_den); fprintf (stderr, " fps : %d/%d\n", vsink->fps_num, vsink->fps_den);
g_print (" fourcc : %" GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS (vsink->fourcc)); fprintf (stderr, " fourcc : %" GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS (vsink->fourcc));
g_print (" length : %" GST_TIME_FORMAT "\n\n", fprintf (stderr, " length : %" GST_TIME_FORMAT "\n\n",
GST_TIME_ARGS ((guint64)(vsink->length_time * GST_SECOND))); GST_TIME_ARGS ((guint64)(vsink->length_time * GST_SECOND)));
} }
asink = (Emotion_Audio_Sink *)ecore_list_first_goto (ev->audio_sinks); asink = (Emotion_Audio_Sink *)ecore_list_first_goto (ev->audio_sinks);
if (asink) { if (asink) {
g_print ("audio : \n"); fprintf (stderr, "audio : \n");
g_print (" chan : %d\n", asink->channels); fprintf (stderr, " chan : %d\n", asink->channels);
g_print (" rate : %d\n", asink->samplerate); fprintf (stderr, " rate : %d\n", asink->samplerate);
g_print (" length : %" GST_TIME_FORMAT "\n\n", fprintf (stderr, " length : %" GST_TIME_FORMAT "\n\n",
GST_TIME_ARGS ((guint64)(asink->length_time * GST_SECOND))); GST_TIME_ARGS ((guint64)(asink->length_time * GST_SECOND)));
} }
} }
@ -447,51 +449,6 @@ em_file_close(void *video)
if (!ev) if (!ev)
return; return;
printf("EX pause end...\n");
if (!emotion_object_play_get(ev->obj))
{
printf(" ... unpause\n");
emotion_pipeline_pause (ev->pipeline);
}
printf("EX stop\n");
gst_element_set_state (ev->pipeline, GST_STATE_READY);
/* we remove all the elements in the pipeline */
iter = gst_bin_iterate_elements (GST_BIN (ev->pipeline));
done = FALSE;
while (!done) {
switch (gst_iterator_next (iter, &data)) {
case GST_ITERATOR_OK: {
GstElement *element;
element = GST_ELEMENT (data);
if (element) {
gst_bin_remove (GST_BIN (ev->pipeline), element);
}
break;
}
case GST_ITERATOR_RESYNC: {
GstElement *element;
element = GST_ELEMENT (data);
if (element) {
gst_bin_remove (GST_BIN (ev->pipeline), element);
}
gst_iterator_resync (iter);
break;
}
case GST_ITERATOR_ERROR:
printf("error iter\n");
done = TRUE;
break;
case GST_ITERATOR_DONE:
done = TRUE;
break;
}
}
gst_iterator_free (iter);
/* we clear the sink lists */ /* we clear the sink lists */
ecore_list_clear (ev->video_sinks); ecore_list_clear (ev->video_sinks);
ecore_list_clear (ev->audio_sinks); ecore_list_clear (ev->audio_sinks);
@ -501,6 +458,18 @@ em_file_close(void *video)
ecore_timer_del (ev->eos_timer); ecore_timer_del (ev->eos_timer);
ev->eos_timer = NULL; ev->eos_timer = NULL;
} }
if (ev->eos_bus)
{
gst_object_unref (GST_OBJECT (ev->eos_bus));
ev->eos_bus = NULL;
}
if (ev->pipeline)
{
gst_element_set_state (ev->pipeline, GST_STATE_NULL);
gst_object_unref(ev->pipeline);
ev->pipeline = NULL;
}
} }
static void static void
@ -509,6 +478,7 @@ em_play(void *video,
{ {
Emotion_Gstreamer_Video *ev; Emotion_Gstreamer_Video *ev;
fprintf(stderr, "[Emotion] [gst] play %p\n", ev->pipeline);
ev = (Emotion_Gstreamer_Video *)video; ev = (Emotion_Gstreamer_Video *)video;
gst_element_set_state (ev->pipeline, GST_STATE_PLAYING); gst_element_set_state (ev->pipeline, GST_STATE_PLAYING);
ev->play = 1; ev->play = 1;
@ -524,14 +494,15 @@ em_stop(void *video)
ev = (Emotion_Gstreamer_Video *)video; ev = (Emotion_Gstreamer_Video *)video;
gst_element_set_state (ev->pipeline, GST_STATE_PAUSED);
ev->play = 0;
/* shutdown eos */ /* shutdown eos */
if (ev->eos_timer) { if (ev->eos_timer) {
ecore_timer_del (ev->eos_timer); ecore_timer_del (ev->eos_timer);
ev->eos_timer = NULL; ev->eos_timer = NULL;
} }
/* fprintf(stderr, "[Emotion] [gst] stop\n"); */
gst_element_set_state (ev->pipeline, GST_STATE_PAUSED);
ev->play = 0;
} }
static void static void
@ -1299,7 +1270,7 @@ _em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh)
buffer = buf[1]; buffer = buf[1];
_emotion_frame_new(ev->obj); _emotion_frame_new(ev->obj);
vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr); vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
_emotion_video_pos_update(ev->obj, ev->position, vsink->length_time); if (vsink) _emotion_video_pos_update(ev->obj, ev->position, vsink->length_time);
} }
} }
return 1; return 1;

View File

@ -122,6 +122,8 @@ file_new_decoded_pad_cb (GstElement *decodebin,
gst_pad_link(new_pad, audiopad); gst_pad_link(new_pad, audiopad);
gst_element_set_state (asink->sink, GST_STATE_PAUSED); gst_element_set_state (asink->sink, GST_STATE_PAUSED);
} }
free(str);
} }
Emotion_Video_Sink * Emotion_Video_Sink *