1.1 --- a/src/audio/dummy/SDL_dummyaudio.c Thu Jul 06 18:01:37 2006 +0000
1.2 +++ b/src/audio/dummy/SDL_dummyaudio.c Mon Jul 10 21:04:37 2006 +0000
1.3 @@ -37,120 +37,129 @@
1.4 #define DUMMYAUD_DRIVER_NAME "dummy"
1.5
1.6 /* Audio driver functions */
1.7 -static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec);
1.8 +static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec * spec);
1.9 static void DUMMYAUD_WaitAudio(_THIS);
1.10 static void DUMMYAUD_PlayAudio(_THIS);
1.11 static Uint8 *DUMMYAUD_GetAudioBuf(_THIS);
1.12 static void DUMMYAUD_CloseAudio(_THIS);
1.13
1.14 /* Audio driver bootstrap functions */
1.15 -static int DUMMYAUD_Available(void)
1.16 +static int
1.17 +DUMMYAUD_Available(void)
1.18 {
1.19 - const char *envr = SDL_getenv("SDL_AUDIODRIVER");
1.20 - if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) {
1.21 - return(1);
1.22 - }
1.23 - return(0);
1.24 + const char *envr = SDL_getenv("SDL_AUDIODRIVER");
1.25 + if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) {
1.26 + return (1);
1.27 + }
1.28 + return (0);
1.29 }
1.30
1.31 -static void DUMMYAUD_DeleteDevice(SDL_AudioDevice *device)
1.32 +static void
1.33 +DUMMYAUD_DeleteDevice(SDL_AudioDevice * device)
1.34 {
1.35 - SDL_free(device->hidden);
1.36 - SDL_free(device);
1.37 + SDL_free(device->hidden);
1.38 + SDL_free(device);
1.39 }
1.40
1.41 -static SDL_AudioDevice *DUMMYAUD_CreateDevice(int devindex)
1.42 +static SDL_AudioDevice *
1.43 +DUMMYAUD_CreateDevice(int devindex)
1.44 {
1.45 - SDL_AudioDevice *this;
1.46 + SDL_AudioDevice *this;
1.47
1.48 - /* Initialize all variables that we clean on shutdown */
1.49 - this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
1.50 - if ( this ) {
1.51 - SDL_memset(this, 0, (sizeof *this));
1.52 - this->hidden = (struct SDL_PrivateAudioData *)
1.53 - SDL_malloc((sizeof *this->hidden));
1.54 - }
1.55 - if ( (this == NULL) || (this->hidden == NULL) ) {
1.56 - SDL_OutOfMemory();
1.57 - if ( this ) {
1.58 - SDL_free(this);
1.59 - }
1.60 - return(0);
1.61 - }
1.62 - SDL_memset(this->hidden, 0, (sizeof *this->hidden));
1.63 + /* Initialize all variables that we clean on shutdown */
1.64 + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice));
1.65 + if (this) {
1.66 + SDL_memset(this, 0, (sizeof *this));
1.67 + this->hidden = (struct SDL_PrivateAudioData *)
1.68 + SDL_malloc((sizeof *this->hidden));
1.69 + }
1.70 + if ((this == NULL) || (this->hidden == NULL)) {
1.71 + SDL_OutOfMemory();
1.72 + if (this) {
1.73 + SDL_free(this);
1.74 + }
1.75 + return (0);
1.76 + }
1.77 + SDL_memset(this->hidden, 0, (sizeof *this->hidden));
1.78
1.79 - /* Set the function pointers */
1.80 - this->OpenAudio = DUMMYAUD_OpenAudio;
1.81 - this->WaitAudio = DUMMYAUD_WaitAudio;
1.82 - this->PlayAudio = DUMMYAUD_PlayAudio;
1.83 - this->GetAudioBuf = DUMMYAUD_GetAudioBuf;
1.84 - this->CloseAudio = DUMMYAUD_CloseAudio;
1.85 + /* Set the function pointers */
1.86 + this->OpenAudio = DUMMYAUD_OpenAudio;
1.87 + this->WaitAudio = DUMMYAUD_WaitAudio;
1.88 + this->PlayAudio = DUMMYAUD_PlayAudio;
1.89 + this->GetAudioBuf = DUMMYAUD_GetAudioBuf;
1.90 + this->CloseAudio = DUMMYAUD_CloseAudio;
1.91
1.92 - this->free = DUMMYAUD_DeleteDevice;
1.93 + this->free = DUMMYAUD_DeleteDevice;
1.94
1.95 - return this;
1.96 + return this;
1.97 }
1.98
1.99 AudioBootStrap DUMMYAUD_bootstrap = {
1.100 - DUMMYAUD_DRIVER_NAME, "SDL dummy audio driver",
1.101 - DUMMYAUD_Available, DUMMYAUD_CreateDevice
1.102 + DUMMYAUD_DRIVER_NAME, "SDL dummy audio driver",
1.103 + DUMMYAUD_Available, DUMMYAUD_CreateDevice
1.104 };
1.105
1.106 /* This function waits until it is possible to write a full sound buffer */
1.107 -static void DUMMYAUD_WaitAudio(_THIS)
1.108 +static void
1.109 +DUMMYAUD_WaitAudio(_THIS)
1.110 {
1.111 - /* Don't block on first calls to simulate initial fragment filling. */
1.112 - if (this->hidden->initial_calls)
1.113 - this->hidden->initial_calls--;
1.114 - else
1.115 - SDL_Delay(this->hidden->write_delay);
1.116 + /* Don't block on first calls to simulate initial fragment filling. */
1.117 + if (this->hidden->initial_calls)
1.118 + this->hidden->initial_calls--;
1.119 + else
1.120 + SDL_Delay(this->hidden->write_delay);
1.121 }
1.122
1.123 -static void DUMMYAUD_PlayAudio(_THIS)
1.124 +static void
1.125 +DUMMYAUD_PlayAudio(_THIS)
1.126 {
1.127 - /* no-op...this is a null driver. */
1.128 + /* no-op...this is a null driver. */
1.129 }
1.130
1.131 -static Uint8 *DUMMYAUD_GetAudioBuf(_THIS)
1.132 +static Uint8 *
1.133 +DUMMYAUD_GetAudioBuf(_THIS)
1.134 {
1.135 - return(this->hidden->mixbuf);
1.136 + return (this->hidden->mixbuf);
1.137 }
1.138
1.139 -static void DUMMYAUD_CloseAudio(_THIS)
1.140 +static void
1.141 +DUMMYAUD_CloseAudio(_THIS)
1.142 {
1.143 - if ( this->hidden->mixbuf != NULL ) {
1.144 - SDL_FreeAudioMem(this->hidden->mixbuf);
1.145 - this->hidden->mixbuf = NULL;
1.146 - }
1.147 + if (this->hidden->mixbuf != NULL) {
1.148 + SDL_FreeAudioMem(this->hidden->mixbuf);
1.149 + this->hidden->mixbuf = NULL;
1.150 + }
1.151 }
1.152
1.153 -static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
1.154 +static int
1.155 +DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec * spec)
1.156 {
1.157 - float bytes_per_sec = 0.0f;
1.158 + float bytes_per_sec = 0.0f;
1.159
1.160 - /* Allocate mixing buffer */
1.161 - this->hidden->mixlen = spec->size;
1.162 - this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
1.163 - if ( this->hidden->mixbuf == NULL ) {
1.164 - return(-1);
1.165 - }
1.166 - SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
1.167 + /* Allocate mixing buffer */
1.168 + this->hidden->mixlen = spec->size;
1.169 + this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
1.170 + if (this->hidden->mixbuf == NULL) {
1.171 + return (-1);
1.172 + }
1.173 + SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
1.174
1.175 - bytes_per_sec = (float) (((spec->format & 0xFF) / 8) *
1.176 - spec->channels * spec->freq);
1.177 + bytes_per_sec = (float) (((spec->format & 0xFF) / 8) *
1.178 + spec->channels * spec->freq);
1.179
1.180 - /*
1.181 - * We try to make this request more audio at the correct rate for
1.182 - * a given audio spec, so timing stays fairly faithful.
1.183 - * Also, we have it not block at all for the first two calls, so
1.184 - * it seems like we're filling two audio fragments right out of the
1.185 - * gate, like other SDL drivers tend to do.
1.186 - */
1.187 - this->hidden->initial_calls = 2;
1.188 - this->hidden->write_delay =
1.189 - (Uint32) ((((float) spec->size) / bytes_per_sec) * 1000.0f);
1.190 + /*
1.191 + * We try to make this request more audio at the correct rate for
1.192 + * a given audio spec, so timing stays fairly faithful.
1.193 + * Also, we have it not block at all for the first two calls, so
1.194 + * it seems like we're filling two audio fragments right out of the
1.195 + * gate, like other SDL drivers tend to do.
1.196 + */
1.197 + this->hidden->initial_calls = 2;
1.198 + this->hidden->write_delay =
1.199 + (Uint32) ((((float) spec->size) / bytes_per_sec) * 1000.0f);
1.200
1.201 - /* We're ready to rock and roll. :-) */
1.202 - return(0);
1.203 + /* We're ready to rock and roll. :-) */
1.204 + return (0);
1.205 }
1.206
1.207 +/* vi: set ts=4 sw=4 expandtab: */