author | Ryan C. Gordon <icculus@icculus.org> |
Wed, 03 Aug 2016 16:54:10 -0400 | |
changeset 10235 | 0e83beda6d8b |
parent 10234 | 05e2142bcd69 |
child 10240 | 0ba7106e9a6d |
permissions | -rw-r--r-- |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
2 |
Simple DirectMedia Layer |
9998
f67cf37e9cd4
Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents:
9619
diff
changeset
|
3 |
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
7 |
arising from the use of this software. |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
11 |
freely, subject to the following restrictions: |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 |
*/ |
8093
b43765095a6f
Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents:
7038
diff
changeset
|
21 |
#include "../../SDL_internal.h" |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 |
|
1533
38c1eb6b0083
By default all the real targets have dummy audio/video and disk audio.
Sam Lantinga <slouken@libsdl.org>
parents:
1532
diff
changeset
|
23 |
/* Output audio to nowhere... */ |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 |
|
10235
0e83beda6d8b
dummy audio: Patched to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
10234
diff
changeset
|
25 |
#include "SDL_timer.h" |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 |
#include "SDL_audio.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 |
#include "../SDL_audio_c.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 |
#include "SDL_dummyaudio.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 |
|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1538
diff
changeset
|
30 |
static int |
9394
bb28e5281770
Bunch of reworking to how we manage audio devices.
Ryan C. Gordon <icculus@icculus.org>
parents:
8149
diff
changeset
|
31 |
DUMMYAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 |
{ |
7038
7f22b9ba218f
Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents:
6885
diff
changeset
|
33 |
return 0; /* always succeeds. */ |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 |
} |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
36 |
static int |
10234
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
37 |
DUMMYAUD_CaptureFromDevice(_THIS, void *buffer, int buflen) |
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
38 |
{ |
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
39 |
/* Delay to make this sort of simulate real audio input. */ |
10235
0e83beda6d8b
dummy audio: Patched to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
10234
diff
changeset
|
40 |
SDL_Delay((this->spec.samples * 1000) / this->spec.freq); |
10234
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
41 |
|
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
42 |
/* always return a full buffer of silence. */ |
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
43 |
SDL_memset(buffer, this->spec.silence, buflen); |
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
44 |
return buflen; |
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
45 |
} |
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
46 |
|
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
47 |
static int |
2060 | 48 |
DUMMYAUD_Init(SDL_AudioDriverImpl * impl) |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 |
{ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1538
diff
changeset
|
50 |
/* Set the function pointers */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
51 |
impl->OpenDevice = DUMMYAUD_OpenDevice; |
10234
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
52 |
impl->CaptureFromDevice = DUMMYAUD_CaptureFromDevice; |
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
53 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
54 |
impl->OnlyHasDefaultOutputDevice = 1; |
10234
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
55 |
impl->OnlyHasDefaultInputDevice = 1; |
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
56 |
impl->HasCaptureSupport = SDL_TRUE; |
05e2142bcd69
dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
57 |
|
3699
4160ba33b597
Removed test for "driver is valid, but doesn't see any audio devices."
Ryan C. Gordon <icculus@icculus.org>
parents:
3697
diff
changeset
|
58 |
return 1; /* this audio target is available. */ |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 |
} |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
60 |
|
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 |
AudioBootStrap DUMMYAUD_bootstrap = { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
62 |
"dummy", "SDL dummy audio driver", DUMMYAUD_Init, 1 |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 |
}; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 |
|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1538
diff
changeset
|
65 |
/* vi: set ts=4 sw=4 expandtab: */ |