From: <wt...@fr...> - 2005-01-07 17:57:07
|
CVS Root: /cvs/gstreamer Module: gst-plugins Changes by: wtay Date: Fri Jan 07 2005 09:57:03 PST Branch: BRANCH-THREADED Log message: Fix osssink state changes. Reset the ogg stream when seeking. Modified files: . : ChangeLog ext/ogg : gstoggdemux.c sys/oss : gstosssink.c gstosssink.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ChangeLog.diff?r1=1.1367.2.7&r2=1.1367.2.8 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/ogg/gstoggdemux.c.diff?r1=1.61.2.7&r2=1.61.2.8 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/sys/oss/gstosssink.c.diff?r1=1.99.2.2&r2=1.99.2.3 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/sys/oss/gstosssink.h.diff?r1=1.20&r2=1.20.4.1 ====Begin Diffs==== Index: gstoggdemux.c =================================================================== RCS file: /cvs/gstreamer/gst-plugins/ext/ogg/gstoggdemux.c,v retrieving revision 1.61.2.7 retrieving revision 1.61.2.8 diff -u -d -r1.61.2.7 -r1.61.2.8 --- gstoggdemux.c 7 Jan 2005 16:04:33 -0000 1.61.2.7 +++ gstoggdemux.c 7 Jan 2005 17:56:51 -0000 1.61.2.8 @@ -1192,6 +1192,23 @@ /* now grab the stream lock so that streaming cannot continue */ GST_STREAM_LOCK (ogg->sinkpad); + { + gint i; + + /* reset all ogg streams now, need to do this from within the lock to + * make sure the streaming thread is not messing with the stream */ + for (i = 0; i < ogg->chains->len; i++) { + GstOggChain *chain = g_array_index (ogg->chains, GstOggChain *, i); + gint j; + for (j = 0; j < chain->streams->len; j++) { + GstOggPad *pad = g_array_index (chain->streams, GstOggPad *, j); + ogg_stream_reset (&pad->stream); + } + } + } /* first find the chain to search in */ for (i = ogg->chains->len - 1; i >= 0; i--) { chain = g_array_index (ogg->chains, GstOggChain *, i); Index: ChangeLog RCS file: /cvs/gstreamer/gst-plugins/ChangeLog,v retrieving revision 1.1367.2.7 retrieving revision 1.1367.2.8 diff -u -d -r1.1367.2.7 -r1.1367.2.8 --- ChangeLog 7 Jan 2005 16:04:32 -0000 1.1367.2.7 +++ ChangeLog 7 Jan 2005 17:56:51 -0000 1.1367.2.8 @@ -1,5 +1,35 @@ 2005-01-07 Wim Taymans <wi...@fl...> + * ext/ogg/gstoggdemux.c: (gst_ogg_pad_get_type), + (gst_ogg_pad_init), (gst_ogg_pad_dispose), (gst_ogg_pad_src_query), + (gst_ogg_pad_event), (gst_ogg_demux_factory_filter), + (compare_ranks), (gst_ogg_pad_internal_chain), + (gst_ogg_pad_typefind), (gst_ogg_pad_submit_packet), + (gst_ogg_pad_submit_page), (gst_ogg_chain_new), + (gst_ogg_chain_free), (gst_ogg_chain_new_stream), + (gst_ogg_chain_get_stream), (gst_ogg_chain_has_stream), + (gst_ogg_demux_base_init), (gst_ogg_demux_init), + (gst_ogg_demux_submit_buffer), (gst_ogg_demux_seek), + (gst_ogg_demux_get_data), (gst_ogg_demux_get_next_page), + (gst_ogg_demux_get_prev_page), + (gst_ogg_demux_deactivate_current_chain), + (gst_ogg_demux_activate_chain), (gst_ogg_demux_perform_seek), + (gst_ogg_demux_bisect_forward_serialno), + (gst_ogg_demux_read_chain), (gst_ogg_demux_read_end_chain), + (gst_ogg_demux_find_pad), (gst_ogg_demux_find_chain), + (gst_ogg_demux_find_chains), (gst_ogg_demux_chain_unlocked), + (gst_ogg_demux_chain), (gst_ogg_demux_send_eos), + (gst_ogg_demux_loop), (gst_ogg_demux_sink_activate), + (gst_ogg_print): + * sys/oss/gstosssink.c: (gst_osssink_setcaps), + (gst_osssink_finish_preroll), (gst_osssink_handle_event), + (gst_osssink_chain), (gst_osssink_change_state): + * sys/oss/gstosssink.h: + Fix osssink state changes. + Reset the ogg stream when seeking. +2005-01-07 Wim Taymans <wi...@fl...> * examples/seeking/seek.c: (dynamic_link), (make_vorbis_pipeline), (make_theora_pipeline), (do_seek), (start_seek), (stop_seek): * ext/ogg/gstoggdemux.c: (gst_ogg_pad_get_type), Index: gstosssink.c RCS file: /cvs/gstreamer/gst-plugins/sys/oss/gstosssink.c,v retrieving revision 1.99.2.2 retrieving revision 1.99.2.3 diff -u -d -r1.99.2.2 -r1.99.2.3 --- gstosssink.c 29 Dec 2004 11:04:28 -0000 1.99.2.2 +++ gstosssink.c 7 Jan 2005 17:56:51 -0000 1.99.2.3 @@ -364,6 +364,55 @@ osssink->clock = clock; } +static GstFlowReturn +gst_osssink_finish_preroll (GstOssSink * osssink, GstPad * pad) +{ + GstFlowReturn result = GST_FLOW_OK; + /* grab state change lock */ + GST_STATE_LOCK (osssink); + /* if we are going to PAUSED, we can commit the state change */ + if (GST_STATE_PENDING (osssink) == GST_STATE_PAUSED) { + gst_element_commit_state (GST_ELEMENT (osssink)); + /* if we are paused we need to wait for playing to continue */ + if (GST_STATE (osssink) == GST_STATE_PAUSED) { + GST_DEBUG_OBJECT (osssink, + "element %s wants to finish preroll", GST_ELEMENT_NAME (osssink)); + /* here we wait for the next state change */ + while (GST_STATE (osssink) == GST_STATE_PAUSED) { + if (GST_RPAD_IS_FLUSHING (pad)) { + GST_DEBUG_OBJECT (osssink, "pad is flushing"); + result = GST_FLOW_UNEXPECTED; + goto done; + GST_DEBUG_OBJECT (osssink, "waiting for next state change"); + GST_STATE_WAIT (osssink); + GST_DEBUG_OBJECT (osssink, "got unlocked, maybe a state change"); + /* check if we got playing */ + if (GST_STATE (osssink) != GST_STATE_PLAYING) { + /* not playing, we can't accept the buffer */ + result = GST_FLOW_WRONG_STATE; + GST_DEBUG_OBJECT (osssink, "done preroll"); +done: + GST_STATE_UNLOCK (osssink); + return result; +} static gboolean gst_osssink_handle_event (GstPad * pad, GstEvent * event) { @@ -372,21 +421,37 @@ osssink = GST_OSSSINK (GST_PAD_PARENT (pad)); - GST_STREAM_LOCK (pad); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: + GST_STREAM_LOCK (pad); ioctl (GST_OSSELEMENT (osssink)->fd, SNDCTL_DSP_SYNC, 0); gst_audio_clock_set_active (GST_AUDIO_CLOCK (osssink->provided_clock), FALSE); - gst_element_finish_preroll (GST_ELEMENT (osssink), - GST_STREAM_GET_LOCK (pad)); + gst_osssink_finish_preroll (osssink, pad); gst_element_post_message (GST_ELEMENT (osssink), gst_message_new_eos (GST_OBJECT (osssink))); + GST_STATE_LOCK (osssink); + osssink->in_eos = TRUE; + GST_STATE_UNLOCK (osssink); + GST_STREAM_UNLOCK (pad); + break; + case GST_EVENT_FLUSH: + /* make sure we are not blocked on anything */ + ioctl (GST_OSSELEMENT (osssink)->fd, SNDCTL_DSP_RESET, 0); + /* unlock from a possible state change/preroll */ + osssink->in_eos = FALSE; + g_cond_broadcast (GST_STATE_GET_COND (osssink)); + /* now we are completely unblocked and the _chain method + * will return */ + result = TRUE; break; default: } - GST_STREAM_UNLOCK (pad); return result; @@ -414,9 +479,7 @@ GST_STREAM_LOCK (pad); - result = - GST_STREAM_GET_LOCK (pad)); + result = gst_osssink_finish_preroll (osssink, pad); if (result != GST_FLOW_OK) { goto done; @@ -670,7 +733,8 @@ case GST_STATE_NULL_TO_READY: case GST_STATE_READY_TO_PAUSED: - result = GST_STATE_ASYNC; + if (!osssink->in_eos) + result = GST_STATE_ASYNC; case GST_STATE_PAUSED_TO_PLAYING: @@ -681,6 +745,8 @@ ioctl (GST_OSSELEMENT (osssink)->fd, SNDCTL_DSP_RESET, 0); case GST_STATE_PAUSED_TO_READY: if (GST_FLAG_IS_SET (element, GST_OSSSINK_OPEN)) Index: gstosssink.h RCS file: /cvs/gstreamer/gst-plugins/sys/oss/gstosssink.h,v retrieving revision 1.20 retrieving revision 1.20.4.1 diff -u -d -r1.20 -r1.20.4.1 --- gstosssink.h 5 Jun 2004 18:50:48 -0000 1.20 +++ gstosssink.h 7 Jan 2005 17:56:51 -0000 1.20.4.1 @@ -61,6 +61,7 @@ GstClock *clock; gboolean sync; guint64 handled; + gboolean in_eos; gboolean mute; guint bufsize; |