annotate src/audio/dummy/SDL_dummyaudio.c @ 1537:60620d71e324

Corrected dummy audio callback firing to be realistic, cleaned up tabs.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 14 Mar 2006 19:12:49 +0000
parents 38c1eb6b0083
children b1f8c14f0df5
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 const char *envr;
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 /* Initialize all variables that we clean on shutdown */
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69 if ( this ) {
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 SDL_memset(this, 0, (sizeof *this));
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 this->hidden = (struct SDL_PrivateAudioData *)
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 SDL_malloc((sizeof *this->hidden));
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73 }
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74 if ( (this == NULL) || (this->hidden == NULL) ) {
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
75 SDL_OutOfMemory();
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
76 if ( this ) {
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77 SDL_free(this);
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78 }
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
79 return(0);
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
80 }
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
81 SDL_memset(this->hidden, 0, (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 /* Set the function pointers */
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84 this->OpenAudio = DUMMYAUD_OpenAudio;
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
85 this->WaitAudio = DUMMYAUD_WaitAudio;
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86 this->PlayAudio = DUMMYAUD_PlayAudio;
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
87 this->GetAudioBuf = DUMMYAUD_GetAudioBuf;
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88 this->CloseAudio = DUMMYAUD_CloseAudio;
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 this->free = DUMMYAUD_DeleteDevice;
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 return this;
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
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
95 AudioBootStrap DUMMYAUD_bootstrap = {
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
96 DUMMYAUD_DRIVER_NAME, "SDL dummy audio driver",
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
97 DUMMYAUD_Available, DUMMYAUD_CreateDevice
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
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
100 /* 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
101 static void DUMMYAUD_WaitAudio(_THIS)
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102 {
1537
60620d71e324 Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 1533
diff changeset
103 /* 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
104 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
105 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
106 else
60620d71e324 Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 1533
diff changeset
107 SDL_Delay(this->hidden->write_delay);
1532
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
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
110 static void DUMMYAUD_PlayAudio(_THIS)
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111 {
1537
60620d71e324 Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 1533
diff changeset
112 /* no-op...this is a null driver. */
1532
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
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115 static Uint8 *DUMMYAUD_GetAudioBuf(_THIS)
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 return(this->hidden->mixbuf);
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
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
120 static void DUMMYAUD_CloseAudio(_THIS)
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 if ( this->hidden->mixbuf != NULL ) {
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123 SDL_FreeAudioMem(this->hidden->mixbuf);
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
124 this->hidden->mixbuf = NULL;
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
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
128 static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129 {
1537
60620d71e324 Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 1533
diff changeset
130 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
131
1532
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132 /* Allocate mixing buffer */
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
133 this->hidden->mixlen = spec->size;
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
134 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135 if ( this->hidden->mixbuf == NULL ) {
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136 return(-1);
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 SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
139
1537
60620d71e324 Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 1533
diff changeset
140 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
141 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
142
60620d71e324 Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 1533
diff changeset
143 /*
60620d71e324 Corrected dummy audio callback firing to be realistic, cleaned up tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 1533
diff changeset
144 * 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
145 * 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
146 * 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
147 * 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
148 * 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
149 */
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->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
151 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
152 (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
153
1532
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 /* We're ready to rock and roll. :-) */
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155 return(0);
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156 }
30f189cdd82b Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157