summaryrefslogtreecommitdiff
path: root/sys/directsound
diff options
context:
space:
mode:
authorThomas Roos <thomas.roos@industronic.de>2015-12-11 11:39:08 +0100
committerSebastian Dröge <sebastian@centricular.com>2015-12-11 12:46:41 +0200
commitd794908dfdb726a2156512a495044a3941cad1a9 (patch)
treec89a97b64c7e803bb2d1e4440c05434d3666d83f /sys/directsound
parent7ae23d13c88e3650730e3be252706f21d4771bea (diff)
downloadgstreamer-plugins-bad-d794908dfdb726a2156512a495044a3941cad1a9.tar.gz
directsoundsrc: Check return values of DirectSound functions in read loop
Otherwise we might end up in an infinite loop because of errors. Also take the element's mutex in unprepare(). https://bugzilla.gnome.org/show_bug.cgi?id=738292
Diffstat (limited to 'sys/directsound')
-rw-r--r--sys/directsound/gstdirectsoundsrc.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/directsound/gstdirectsoundsrc.c b/sys/directsound/gstdirectsoundsrc.c
index 18f49f881..3b01f0684 100644
--- a/sys/directsound/gstdirectsoundsrc.c
+++ b/sys/directsound/gstdirectsoundsrc.c
@@ -545,12 +545,14 @@ gst_directsound_src_unprepare (GstAudioSrc * asrc)
dsoundsrc = GST_DIRECTSOUND_SRC (asrc);
+ GST_DSOUND_LOCK (dsoundsrc);
+
/* Stop capturing */
IDirectSoundCaptureBuffer_Stop (dsoundsrc->pDSBSecondary);
/* Release buffer */
IDirectSoundCaptureBuffer_Release (dsoundsrc->pDSBSecondary);
-
+ GST_DSOUND_UNLOCK (dsoundsrc);
return TRUE;
}
@@ -583,6 +585,11 @@ gst_directsound_src_read (GstAudioSrc * asrc, gpointer data, guint length,
hRes = IDirectSoundCaptureBuffer_GetStatus (dsoundsrc->pDSBSecondary,
&dwStatus);
+ if (FAILED (hRes)) {
+ GST_DSOUND_UNLOCK (dsoundsrc);
+ return -1;
+ }
+
/* Starting capturing if not already */
if (!(dwStatus & DSCBSTATUS_CAPTURING)) {
hRes = IDirectSoundCaptureBuffer_Start (dsoundsrc->pDSBSecondary,
@@ -598,6 +605,11 @@ gst_directsound_src_read (GstAudioSrc * asrc, gpointer data, guint length,
IDirectSoundCaptureBuffer_GetCurrentPosition (dsoundsrc->pDSBSecondary,
&dwCurrentCaptureCursor, NULL);
+ if (FAILED (hRes)) {
+ GST_DSOUND_UNLOCK (dsoundsrc);
+ return -1;
+ }
+
/* calculate the buffer */
if (dwCurrentCaptureCursor < dsoundsrc->current_circular_offset) {
dwBufferSize = dsoundsrc->buffer_size -