Skip to content

Commit

Permalink
dummy audio: Implemented dummy audio capture support. :)
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Aug 3, 2016
1 parent 9dd8477 commit 17246ba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/audio/dummy/SDL_dummyaudio.c
Expand Up @@ -32,12 +32,28 @@ DUMMYAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
return 0; /* always succeeds. */
}

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. */
}

Expand Down

0 comments on commit 17246ba

Please sign in to comment.