Mercurial > sdl-ios-xcode
annotate src/audio/dummy/SDL_dummyaudio.c @ 1826:cf7528eded83
Add missing include file
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Fri, 12 May 2006 16:25:04 +0000 |
parents | b1f8c14f0df5 |
children | 782fd950bd46 c121d94672cb a1b03ba2fcd0 |
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 |
1537
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
22 This file written by Ryan C. Gordon (icculus@icculus.org) |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 #include "SDL_config.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 |
1533
38c1eb6b0083
By default all the real targets have dummy audio/video and disk audio.
Sam Lantinga <slouken@libsdl.org>
parents:
1532
diff
changeset
|
26 /* Output audio to nowhere... */ |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 #include "SDL_rwops.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 #include "SDL_timer.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 #include "SDL_audio.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 #include "../SDL_audiomem.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 #include "../SDL_audio_c.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 #include "../SDL_audiodev_c.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 #include "SDL_dummyaudio.h" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 /* The tag name used by DUMMY audio */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 #define DUMMYAUD_DRIVER_NAME "dummy" |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 /* Audio driver functions */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 static void DUMMYAUD_WaitAudio(_THIS); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 static void DUMMYAUD_PlayAudio(_THIS); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
43 static Uint8 *DUMMYAUD_GetAudioBuf(_THIS); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
44 static void DUMMYAUD_CloseAudio(_THIS); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
45 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 /* Audio driver bootstrap functions */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 static int DUMMYAUD_Available(void) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
48 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 const char *envr = SDL_getenv("SDL_AUDIODRIVER"); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 return(1); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
53 return(0); |
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 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 static void DUMMYAUD_DeleteDevice(SDL_AudioDevice *device) |
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 SDL_free(device->hidden); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 SDL_free(device); |
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 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 static SDL_AudioDevice *DUMMYAUD_CreateDevice(int devindex) |
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 SDL_AudioDevice *this; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
66 /* Initialize all variables that we clean on shutdown */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 if ( this ) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 SDL_memset(this, 0, (sizeof *this)); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 this->hidden = (struct SDL_PrivateAudioData *) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 SDL_malloc((sizeof *this->hidden)); |
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 if ( (this == NULL) || (this->hidden == NULL) ) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
74 SDL_OutOfMemory(); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
75 if ( this ) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
76 SDL_free(this); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
77 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
78 return(0); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
79 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
80 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
81 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
82 /* Set the function pointers */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
83 this->OpenAudio = DUMMYAUD_OpenAudio; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
84 this->WaitAudio = DUMMYAUD_WaitAudio; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
85 this->PlayAudio = DUMMYAUD_PlayAudio; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
86 this->GetAudioBuf = DUMMYAUD_GetAudioBuf; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
87 this->CloseAudio = DUMMYAUD_CloseAudio; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
88 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
89 this->free = DUMMYAUD_DeleteDevice; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
90 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
91 return this; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
92 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
93 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
94 AudioBootStrap DUMMYAUD_bootstrap = { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
95 DUMMYAUD_DRIVER_NAME, "SDL dummy audio driver", |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
96 DUMMYAUD_Available, DUMMYAUD_CreateDevice |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
97 }; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
98 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
99 /* 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
|
100 static void DUMMYAUD_WaitAudio(_THIS) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
101 { |
1537
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
102 /* Don't block on first calls to simulate initial fragment filling. */ |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
103 if (this->hidden->initial_calls) |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
104 this->hidden->initial_calls--; |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
105 else |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
106 SDL_Delay(this->hidden->write_delay); |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
107 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
108 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
109 static void DUMMYAUD_PlayAudio(_THIS) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
110 { |
1537
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
111 /* no-op...this is a null driver. */ |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
112 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
113 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
114 static Uint8 *DUMMYAUD_GetAudioBuf(_THIS) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
115 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
116 return(this->hidden->mixbuf); |
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 |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
119 static void DUMMYAUD_CloseAudio(_THIS) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
120 { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
121 if ( this->hidden->mixbuf != NULL ) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
122 SDL_FreeAudioMem(this->hidden->mixbuf); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
123 this->hidden->mixbuf = NULL; |
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 } |
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 static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
128 { |
1537
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
129 float bytes_per_sec = 0.0f; |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
130 |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
131 /* Allocate mixing buffer */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 this->hidden->mixlen = spec->size; |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
133 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
134 if ( this->hidden->mixbuf == NULL ) { |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 return(-1); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
136 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 SDL_memset(this->hidden->mixbuf, spec->silence, spec->size); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 |
1537
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
139 bytes_per_sec = (float) (((spec->format & 0xFF) / 8) * |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
140 spec->channels * spec->freq); |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
141 |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
142 /* |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
143 * We try to make this request more audio at the correct rate for |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
144 * a given audio spec, so timing stays fairly faithful. |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
145 * Also, we have it not block at all for the first two calls, so |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
146 * it seems like we're filling two audio fragments right out of the |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
147 * gate, like other SDL drivers tend to do. |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
148 */ |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
149 this->hidden->initial_calls = 2; |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
150 this->hidden->write_delay = |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
151 (Uint32) ((((float) spec->size) / bytes_per_sec) * 1000.0f); |
60620d71e324
Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1533
diff
changeset
|
152 |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
153 /* We're ready to rock and roll. :-) */ |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
154 return(0); |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
155 } |
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
156 |