dummy audio: Implemented dummy audio capture support. :)
authorRyan C. Gordon <icculus@icculus.org>
Wed, 03 Aug 2016 02:18:47 -0400
changeset 10234 05e2142bcd69
parent 10233 449a75328029
child 10235 0e83beda6d8b
dummy audio: Implemented dummy audio capture support. :)
src/audio/dummy/SDL_dummyaudio.c
--- a/src/audio/dummy/SDL_dummyaudio.c	Wed Aug 03 01:57:41 2016 -0400
+++ b/src/audio/dummy/SDL_dummyaudio.c	Wed Aug 03 02:18:47 2016 -0400
@@ -33,11 +33,27 @@
 }
 
 static int
+DUMMYAUD_CaptureFromDevice(_THIS, void *buffer, int buflen)
+{
+    /* Delay to make this sort of simulate real audio input. */
+    SDL_Delay((device->spec.samples * 1000) / device->spec.freq);
+
+    /* always return a full buffer of silence. */
+    SDL_memset(buffer, this->spec.silence, buflen);
+    return buflen;
+}
+
+static int
 DUMMYAUD_Init(SDL_AudioDriverImpl * impl)
 {
     /* Set the function pointers */
     impl->OpenDevice = DUMMYAUD_OpenDevice;
+    impl->CaptureFromDevice = DUMMYAUD_CaptureFromDevice;
+
     impl->OnlyHasDefaultOutputDevice = 1;
+    impl->OnlyHasDefaultInputDevice = 1;
+    impl->HasCaptureSupport = SDL_TRUE;
+
     return 1;   /* this audio target is available. */
 }