diff options
author | Thomas Roos <thomas.roos@industronic.de> | 2015-12-21 11:37:26 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-12-21 12:44:55 +0100 |
commit | 51f94288ce66a0a6a28e45801f4e17eb74044298 (patch) | |
tree | 475acaf372a1844552a0846eaae362bd4ec1b8be /sys | |
parent | 2da5c8506854d80dec3e543deef9312bc0eaff58 (diff) | |
download | gstreamer-plugins-good-51f94288ce66a0a6a28e45801f4e17eb74044298.tar.gz |
directsoundsink: Fix sleep for buffer-time lower than 200000
https://bugzilla.gnome.org/show_bug.cgi?id=748680
Diffstat (limited to 'sys')
-rw-r--r-- | sys/directsound/gstdirectsoundsink.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/directsound/gstdirectsoundsink.c b/sys/directsound/gstdirectsoundsink.c index 6f05d8041..ffd1bfe89 100644 --- a/sys/directsound/gstdirectsoundsink.c +++ b/sys/directsound/gstdirectsoundsink.c @@ -615,7 +615,8 @@ gst_directsound_sink_write (GstAudioSink * asink, gpointer data, guint length) &dwCurrentPlayCursor, NULL); if (SUCCEEDED (hRes) && SUCCEEDED (hRes2) && (dwStatus & DSBSTATUS_PLAYING)) { - DWORD dwFreeBufferSize; + DWORD dwFreeBufferSize = 0; + DWORD sleepTime = 0; calculate_freesize: /* calculate the free size of the circular buffer */ @@ -628,7 +629,17 @@ gst_directsound_sink_write (GstAudioSink * asink, gpointer data, guint length) dwCurrentPlayCursor - dsoundsink->current_circular_offset; if (length >= dwFreeBufferSize) { - Sleep (100); + sleepTime = + ((length - + dwFreeBufferSize) * 1000) / (dsoundsink->bytes_per_sample * + GST_AUDIO_BASE_SINK (asink)->ringbuffer->spec.info.rate); + if (sleepTime > 0) { + GST_DEBUG_OBJECT (dsoundsink, + "gst_directsound_sink_write: length:%i, FreeBufSiz: %ld, sleepTime: %ld, bps: %i, rate: %i", + length, dwFreeBufferSize, sleepTime, dsoundsink->bytes_per_sample, + GST_AUDIO_BASE_SINK (asink)->ringbuffer->spec.info.rate); + Sleep (sleepTime); + } hRes = IDirectSoundBuffer_GetCurrentPosition (dsoundsink->pDSBSecondary, &dwCurrentPlayCursor, NULL); |