Mercurial > sdl-ios-xcode
annotate src/audio/dummy/SDL_dummyaudio.c @ 1532:30f189cdd82b
Implemented dummy audio driver.
Fixes Bugzilla #161.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 14 Mar 2006 08:53:33 +0000 |
parents | |
children | 38c1eb6b0083 |
rev | line source |
---|---|
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 /* |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 Sam Lantinga |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 This file hacked^H^H^H^H^H^Hwritten by Ryan C. Gordon |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 (icculus@icculus.org) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 #include "SDL_config.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 /* Output raw audio data to a file. */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 #if HAVE_STDIO_H |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 #include <stdio.h> |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 #endif |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 #include "SDL_rwops.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 #include "SDL_timer.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 #include "SDL_audio.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 #include "../SDL_audiomem.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 #include "../SDL_audio_c.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 #include "../SDL_audiodev_c.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 #include "SDL_dummyaudio.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 /* The tag name used by DUMMY audio */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 #define DUMMYAUD_DRIVER_NAME "dummy" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
43 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
44 /* environment variables and defaults. */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
45 #define DUMMYENVR_WRITEDELAY "SDL_DUMMYAUDIODELAY" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 #define DUMMYDEFAULT_WRITEDELAY 150 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
48 /* Audio driver functions */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 static void DUMMYAUD_WaitAudio(_THIS); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 static void DUMMYAUD_PlayAudio(_THIS); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 static Uint8 *DUMMYAUD_GetAudioBuf(_THIS); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
53 static void DUMMYAUD_CloseAudio(_THIS); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
54 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
55 /* Audio driver bootstrap functions */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 static int DUMMYAUD_Available(void) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
57 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
58 const char *envr = SDL_getenv("SDL_AUDIODRIVER"); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
60 return(1); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 return(0); |
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 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 static void DUMMYAUD_DeleteDevice(SDL_AudioDevice *device) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
66 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 SDL_free(device->hidden); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 SDL_free(device); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 static SDL_AudioDevice *DUMMYAUD_CreateDevice(int devindex) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
73 SDL_AudioDevice *this; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
74 const char *envr; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
75 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
76 /* Initialize all variables that we clean on shutdown */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
77 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
78 if ( this ) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
79 SDL_memset(this, 0, (sizeof *this)); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
80 this->hidden = (struct SDL_PrivateAudioData *) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
81 SDL_malloc((sizeof *this->hidden)); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
82 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
83 if ( (this == NULL) || (this->hidden == NULL) ) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
84 SDL_OutOfMemory(); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
85 if ( this ) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
86 SDL_free(this); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
87 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
88 return(0); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
89 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
90 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
91 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
92 envr = SDL_getenv(DUMMYENVR_WRITEDELAY); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
93 this->hidden->write_delay = (envr) ? SDL_atoi(envr) : DUMMYDEFAULT_WRITEDELAY; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
94 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
95 /* Set the function pointers */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
96 this->OpenAudio = DUMMYAUD_OpenAudio; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
97 this->WaitAudio = DUMMYAUD_WaitAudio; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
98 this->PlayAudio = DUMMYAUD_PlayAudio; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
99 this->GetAudioBuf = DUMMYAUD_GetAudioBuf; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
100 this->CloseAudio = DUMMYAUD_CloseAudio; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
101 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
102 this->free = DUMMYAUD_DeleteDevice; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
103 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
104 return this; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
105 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
106 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
107 AudioBootStrap DUMMYAUD_bootstrap = { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
108 DUMMYAUD_DRIVER_NAME, "SDL dummy audio driver", |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
109 DUMMYAUD_Available, DUMMYAUD_CreateDevice |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
110 }; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
111 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
112 /* This function waits until it is possible to write a full sound buffer */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
113 static void DUMMYAUD_WaitAudio(_THIS) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
114 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
115 SDL_Delay(this->hidden->write_delay); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
116 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
117 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
118 static void DUMMYAUD_PlayAudio(_THIS) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
119 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
120 /* no-op...this is a null driver. */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
121 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
122 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
123 static Uint8 *DUMMYAUD_GetAudioBuf(_THIS) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
124 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
125 return(this->hidden->mixbuf); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
126 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
127 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
128 static void DUMMYAUD_CloseAudio(_THIS) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
129 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
130 if ( this->hidden->mixbuf != NULL ) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
131 SDL_FreeAudioMem(this->hidden->mixbuf); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 this->hidden->mixbuf = NULL; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
133 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
134 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
136 static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 #if HAVE_STDIO_H |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
139 fprintf(stderr, "\nWARNING: You are using the SDL dummy audio driver!" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
140 " No sound will be output!\n\n"); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 #endif |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
142 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
143 /* Allocate mixing buffer */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
144 this->hidden->mixlen = spec->size; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
145 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
146 if ( this->hidden->mixbuf == NULL ) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
147 return(-1); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
148 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
149 SDL_memset(this->hidden->mixbuf, spec->silence, spec->size); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
150 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
151 /* We're ready to rock and roll. :-) */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
152 return(0); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
153 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
154 |