ext/alsa/gstalsasink.c: Don't update the time of the clock sync to the clock given to alsasink, not the own clock

Original commit message from CVS:
2004-01-15  Benjamin Otte  <in7y118@public.uni-hamburg.de>

* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event):
Don't update the time of the clock
(gst_alsa_sink_loop):
sync to the clock given to alsasink, not the own clock
* sys/oss/gstosssink.c: (gst_osssink_chain):
sync to the clock
(gst_osssink_change_state):
activate the clock
* sys/ximage/ximagesink.c: (gst_ximagesink_chain):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_chain):
remove bogus code that made DISCONT events unhandled
* gst/asfdemux/gstasfdemux.c: (gst_asf_demux_video_caps):
explicitly case to double in _set_simple. (fixes 2nd warning in bug
#131502)
* gst/asfdemux/gstasfdemux.c: (gst_asf_demux_read_object_header),
(gst_asf_demux_handle_sink_event), (gst_asf_demux_audio_caps),
(gst_asf_demux_add_audio_stream), (gst_asf_demux_video_caps):
convert g_warning because of wrong asf data to GST_WARNINGs (fixes
2nd warning in bug #131502)
This commit is contained in:
Benjamin Otte 2004-01-15 02:14:54 +00:00
parent 185fa362d6
commit 7944a55503
2 changed files with 67 additions and 7 deletions

View file

@ -1,3 +1,25 @@
2004-01-15 Benjamin Otte <in7y118@public.uni-hamburg.de>
* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event):
Don't update the time of the clock
(gst_alsa_sink_loop):
sync to the clock given to alsasink, not the own clock
* sys/oss/gstosssink.c: (gst_osssink_chain):
sync to the clock
(gst_osssink_change_state):
activate the clock
* sys/ximage/ximagesink.c: (gst_ximagesink_chain):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_chain):
remove bogus code that made DISCONT events unhandled
* gst/asfdemux/gstasfdemux.c: (gst_asf_demux_video_caps):
explicitly case to double in _set_simple. (fixes 2nd warning in bug
#131502)
* gst/asfdemux/gstasfdemux.c: (gst_asf_demux_read_object_header),
(gst_asf_demux_handle_sink_event), (gst_asf_demux_audio_caps),
(gst_asf_demux_add_audio_stream), (gst_asf_demux_video_caps):
convert g_warning because of wrong asf data to GST_WARNINGs (fixes
2nd warning in bug #131502)
2004-01-14 Julien MOUTTE <julien@moutte.net> 2004-01-14 Julien MOUTTE <julien@moutte.net>
* gst/videofilter/gstvideobalance.c: (gst_videobalance_init), * gst/videofilter/gstvideobalance.c: (gst_videobalance_init),

View file

@ -324,7 +324,9 @@ gst_osssink_chain (GstPad *pad, GstData *_data)
{ {
GstBuffer *buf = GST_BUFFER (_data); GstBuffer *buf = GST_BUFFER (_data);
GstOssSink *osssink; GstOssSink *osssink;
GstClockTime buftime; GstClockTime buftime, elementtime, soundtime;
guchar *data;
guint to_write;
/* this has to be an audio buffer */ /* this has to be an audio buffer */
osssink = GST_OSSSINK (gst_pad_get_parent (pad)); osssink = GST_OSSSINK (gst_pad_get_parent (pad));
@ -342,8 +344,7 @@ gst_osssink_chain (GstPad *pad, GstData *_data)
gst_pad_event_default (pad, event); gst_pad_event_default (pad, event);
return; return;
} }
gst_event_unref (event); g_assert_not_reached ();
return;
} }
if (!GST_OSSELEMENT (osssink)->bps) { if (!GST_OSSELEMENT (osssink)->bps) {
@ -352,12 +353,48 @@ gst_osssink_chain (GstPad *pad, GstData *_data)
return; return;
} }
data = GST_BUFFER_DATA (buf);
to_write = GST_BUFFER_SIZE (buf);
/* sync audio with buffers timestamp */
elementtime = gst_element_get_time (GST_ELEMENT (osssink));
soundtime = elementtime + gst_osssink_get_delay (osssink) * GST_SECOND / GST_OSSELEMENT (osssink)->bps;
if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
buftime = GST_BUFFER_TIMESTAMP (buf); buftime = GST_BUFFER_TIMESTAMP (buf);
} else {
buftime = soundtime;
}
GST_LOG_OBJECT (osssink, "time: element %"G_GUINT64_FORMAT", real %"G_GUINT64_FORMAT", buffer: %"G_GUINT64_FORMAT,
elementtime, soundtime, buftime);
if (MAX (buftime, soundtime) - MIN (buftime, soundtime) > GST_SECOND / 10) {
/* we need to adjust to the buffers here */
GST_INFO_OBJECT (osssink, "need sync: element %"G_GUINT64_FORMAT", real %"G_GUINT64_FORMAT", buffer: %"G_GUINT64_FORMAT,
elementtime, soundtime, buftime);
if (soundtime > buftime) {
/* full frames */
guint throw_away = (soundtime - buftime) * GST_OSSELEMENT (osssink)->bps / GST_SECOND
/ GST_OSSELEMENT (osssink)->width / GST_OSSELEMENT (osssink)->channels
* GST_OSSELEMENT (osssink)->width * GST_OSSELEMENT (osssink)->channels;
if (throw_away >= GST_BUFFER_SIZE (buf)) {
gst_data_unref (_data);
return;
}
to_write -= throw_away;
data += throw_away;
} else {
guint64 to_handle = (buftime - soundtime) * GST_OSSELEMENT (osssink)->bps / GST_SECOND
/ GST_OSSELEMENT (osssink)->width / GST_OSSELEMENT (osssink)->channels
* GST_OSSELEMENT (osssink)->width * GST_OSSELEMENT (osssink)->channels;
/* FIXME: we really should output silence here */
/* round to full frames */
g_usleep (to_handle * G_USEC_PER_SEC / GST_OSSELEMENT (osssink)->bps);
osssink->handled += (buftime - soundtime) * GST_OSSELEMENT (osssink)->bps / GST_SECOND
/ GST_OSSELEMENT (osssink)->width / GST_OSSELEMENT (osssink)->channels
* GST_OSSELEMENT (osssink)->width * GST_OSSELEMENT (osssink)->channels;
}
}
if (GST_OSSELEMENT (osssink)->fd >= 0) { if (GST_OSSELEMENT (osssink)->fd >= 0) {
if (!osssink->mute) { if (!osssink->mute) {
guchar *data = GST_BUFFER_DATA (buf);
gint to_write = GST_BUFFER_SIZE (buf);
while (to_write > 0) { while (to_write > 0) {
gint done = write (GST_OSSELEMENT (osssink)->fd, data, gint done = write (GST_OSSELEMENT (osssink)->fd, data,
@ -378,7 +415,7 @@ gst_osssink_chain (GstPad *pad, GstData *_data)
} }
} }
gst_audio_clock_update_time ((GstAudioClock*)osssink->provided_clock, buftime); gst_audio_clock_update_time ((GstAudioClock*)osssink->provided_clock, gst_osssink_get_time (osssink->provided_clock, osssink));
gst_buffer_unref (buf); gst_buffer_unref (buf);
} }
@ -533,6 +570,7 @@ gst_osssink_change_state (GstElement *element)
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
break; break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
gst_audio_clock_set_active (GST_AUDIO_CLOCK (osssink->provided_clock), TRUE);
break; break;
case GST_STATE_PLAYING_TO_PAUSED: case GST_STATE_PLAYING_TO_PAUSED:
if (GST_FLAG_IS_SET (element, GST_OSSSINK_OPEN)) if (GST_FLAG_IS_SET (element, GST_OSSSINK_OPEN))