Commit 05a29201 authored by Sam Lantinga's avatar Sam Lantinga

indent is evil

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402208
parent 3d24370c
...@@ -91,12 +91,10 @@ typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, ...@@ -91,12 +91,10 @@ typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
#endif #endif
extern DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int (SDLCALL * f) (void *), extern DECLSPEC SDL_Thread *SDLCALL
void *data, SDL_CreateThread(int (SDLCALL * f) (void *), void *data,
pfnSDL_CurrentBeginThread pfnSDL_CurrentBeginThread pfnBeginThread,
pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
pfnSDL_CurrentEndThread
pfnEndThread);
#ifdef __OS2__ #ifdef __OS2__
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread) #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
......
This diff is collapsed.
...@@ -47,14 +47,15 @@ ...@@ -47,14 +47,15 @@
#endif #endif
static inline void static inline void
test_device(const char *fname, int flags, int (*test)(int fd), test_device(const char *fname, int flags, int (*test) (int fd),
char ***devices, int *devCount) char ***devices, int *devCount)
{ {
struct stat sb; struct stat sb;
if ( (stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode)) ) { if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
int audio_fd = open(fname, flags, 0); int audio_fd = open(fname, flags, 0);
if ( (audio_fd >= 0) && (test(audio_fd)) ) { if ((audio_fd >= 0) && (test(audio_fd))) {
void *p = SDL_realloc(*devices, ((*devCount)+1) * sizeof (char *)); void *p =
SDL_realloc(*devices, ((*devCount) + 1) * sizeof(char *));
if (p != NULL) { if (p != NULL) {
size_t len = strlen(fname) + 1; size_t len = strlen(fname) + 1;
char *str = (char *) SDL_malloc(len); char *str = (char *) SDL_malloc(len);
...@@ -75,7 +76,7 @@ SDL_FreeUnixAudioDevices(char ***devices, int *devCount) ...@@ -75,7 +76,7 @@ SDL_FreeUnixAudioDevices(char ***devices, int *devCount)
int i = *devCount; int i = *devCount;
if ((i > 0) && (*devices != NULL)) { if ((i > 0) && (*devices != NULL)) {
while (i--) { while (i--) {
SDL_free( (*devices)[*devCount] ); SDL_free((*devices)[*devCount]);
} }
} }
...@@ -94,7 +95,7 @@ test_stub(int fd) ...@@ -94,7 +95,7 @@ test_stub(int fd)
} }
void void
SDL_EnumUnixAudioDevices(int flags, int classic, int (*test)(int fd), SDL_EnumUnixAudioDevices(int flags, int classic, int (*test) (int fd),
char ***devices, int *devCount) char ***devices, int *devCount)
{ {
const char *audiodev; const char *audiodev;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
*/ */
#include "SDL_config.h" #include "SDL_config.h"
void SDL_EnumUnixAudioDevices(int flags, int classic, int (*test)(int fd), void SDL_EnumUnixAudioDevices(int flags, int classic, int (*test) (int fd),
char ***devs, int *count); char ***devs, int *count);
void SDL_FreeUnixAudioDevices(char ***devices, int *devCount); void SDL_FreeUnixAudioDevices(char ***devices, int *devCount);
......
...@@ -33,8 +33,8 @@ typedef struct SDL_AudioDevice SDL_AudioDevice; ...@@ -33,8 +33,8 @@ typedef struct SDL_AudioDevice SDL_AudioDevice;
typedef struct SDL_AudioDriverImpl typedef struct SDL_AudioDriverImpl
{ {
int (*DetectDevices)(int iscapture); int (*DetectDevices) (int iscapture);
const char *(*GetDeviceName)(int index, int iscapture); const char *(*GetDeviceName) (int index, int iscapture);
int (*OpenDevice) (_THIS, const char *devname, int iscapture); int (*OpenDevice) (_THIS, const char *devname, int iscapture);
void (*ThreadInit) (_THIS); /* Called by audio thread at start */ void (*ThreadInit) (_THIS); /* Called by audio thread at start */
void (*WaitDevice) (_THIS); void (*WaitDevice) (_THIS);
...@@ -107,8 +107,8 @@ typedef struct AudioBootStrap ...@@ -107,8 +107,8 @@ typedef struct AudioBootStrap
{ {
const char *name; const char *name;
const char *desc; const char *desc;
int (*init) (SDL_AudioDriverImpl *impl); int (*init) (SDL_AudioDriverImpl * impl);
int demand_only:1; /* 1==request explicitly, or it won't be available. */ int demand_only:1; /* 1==request explicitly, or it won't be available. */
} AudioBootStrap; } AudioBootStrap;
#endif /* _SDL_sysaudio_h */ #endif /* _SDL_sysaudio_h */
......
...@@ -43,41 +43,43 @@ ...@@ -43,41 +43,43 @@
#define DEFAULT_DEVICE "default" #define DEFAULT_DEVICE "default"
static int (*ALSA_snd_pcm_open) static int (*ALSA_snd_pcm_open)
(snd_pcm_t **, const char *, snd_pcm_stream_t, int); (snd_pcm_t **, const char *, snd_pcm_stream_t, int);
static int (*ALSA_snd_pcm_close)(snd_pcm_t * pcm); static int (*ALSA_snd_pcm_close) (snd_pcm_t * pcm);
static snd_pcm_sframes_t(*ALSA_snd_pcm_writei) static snd_pcm_sframes_t(*ALSA_snd_pcm_writei)
(snd_pcm_t *,const void *, snd_pcm_uframes_t); (snd_pcm_t *, const void *, snd_pcm_uframes_t);
static int (*ALSA_snd_pcm_resume)(snd_pcm_t *); static int (*ALSA_snd_pcm_resume) (snd_pcm_t *);
static int (*ALSA_snd_pcm_prepare)(snd_pcm_t *); static int (*ALSA_snd_pcm_prepare) (snd_pcm_t *);
static int (*ALSA_snd_pcm_drain)(snd_pcm_t *); static int (*ALSA_snd_pcm_drain) (snd_pcm_t *);
static const char *(*ALSA_snd_strerror)(int); static const char *(*ALSA_snd_strerror) (int);
static size_t(*ALSA_snd_pcm_hw_params_sizeof)(void); static size_t(*ALSA_snd_pcm_hw_params_sizeof) (void);
static size_t(*ALSA_snd_pcm_sw_params_sizeof)(void); static size_t(*ALSA_snd_pcm_sw_params_sizeof) (void);
static int (*ALSA_snd_pcm_hw_params_any)(snd_pcm_t *, snd_pcm_hw_params_t *); static int (*ALSA_snd_pcm_hw_params_any) (snd_pcm_t *, snd_pcm_hw_params_t *);
static int (*ALSA_snd_pcm_hw_params_set_access) static int (*ALSA_snd_pcm_hw_params_set_access)
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t); (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_access_t);
static int (*ALSA_snd_pcm_hw_params_set_format) static int (*ALSA_snd_pcm_hw_params_set_format)
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t); (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t);
static int (*ALSA_snd_pcm_hw_params_set_channels) static int (*ALSA_snd_pcm_hw_params_set_channels)
(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int); (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int);
static int (*ALSA_snd_pcm_hw_params_get_channels)(const snd_pcm_hw_params_t *); static int (*ALSA_snd_pcm_hw_params_get_channels) (const snd_pcm_hw_params_t
*);
static unsigned int (*ALSA_snd_pcm_hw_params_set_rate_near) static unsigned int (*ALSA_snd_pcm_hw_params_set_rate_near)
(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int, int *); (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int, int *);
static snd_pcm_uframes_t (*ALSA_snd_pcm_hw_params_set_period_size_near) static snd_pcm_uframes_t(*ALSA_snd_pcm_hw_params_set_period_size_near)
(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t, int *); (snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t, int *);
static snd_pcm_sframes_t (*ALSA_snd_pcm_hw_params_get_period_size) static snd_pcm_sframes_t(*ALSA_snd_pcm_hw_params_get_period_size)
(const snd_pcm_hw_params_t *); (const snd_pcm_hw_params_t *);
static unsigned int (*ALSA_snd_pcm_hw_params_set_periods_near) static unsigned int (*ALSA_snd_pcm_hw_params_set_periods_near)
(snd_pcm_t *,snd_pcm_hw_params_t *, unsigned int, int *); (snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int, int *);
static int (*ALSA_snd_pcm_hw_params_get_periods)(snd_pcm_hw_params_t *); static int (*ALSA_snd_pcm_hw_params_get_periods) (snd_pcm_hw_params_t *);
static int (*ALSA_snd_pcm_hw_params)(snd_pcm_t *, snd_pcm_hw_params_t *); static int (*ALSA_snd_pcm_hw_params) (snd_pcm_t *, snd_pcm_hw_params_t *);
static int (*ALSA_snd_pcm_sw_params_current)(snd_pcm_t*, snd_pcm_sw_params_t*); static int (*ALSA_snd_pcm_sw_params_current) (snd_pcm_t *,
snd_pcm_sw_params_t *);
static int (*ALSA_snd_pcm_sw_params_set_start_threshold) static int (*ALSA_snd_pcm_sw_params_set_start_threshold)
(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
static int (*ALSA_snd_pcm_sw_params_set_avail_min) static int (*ALSA_snd_pcm_sw_params_set_avail_min)
(snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
static int (*ALSA_snd_pcm_sw_params)(snd_pcm_t *, snd_pcm_sw_params_t *); static int (*ALSA_snd_pcm_sw_params) (snd_pcm_t *, snd_pcm_sw_params_t *);
static int (*ALSA_snd_pcm_nonblock)(snd_pcm_t *, int); static int (*ALSA_snd_pcm_nonblock) (snd_pcm_t *, int);
#define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof #define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof
#define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof #define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof
...@@ -118,7 +120,8 @@ load_alsa_sym(const char *fn, void **addr) ...@@ -118,7 +120,8 @@ load_alsa_sym(const char *fn, void **addr)
#define SDL_ALSA_SYM(x) ALSA_##x = x #define SDL_ALSA_SYM(x) ALSA_##x = x
#endif #endif
static int load_alsa_syms(void) static int
load_alsa_syms(void)
{ {
SDL_ALSA_SYM(snd_pcm_open); SDL_ALSA_SYM(snd_pcm_open);
SDL_ALSA_SYM(snd_pcm_close); SDL_ALSA_SYM(snd_pcm_close);
...@@ -147,6 +150,7 @@ static int load_alsa_syms(void) ...@@ -147,6 +150,7 @@ static int load_alsa_syms(void)
SDL_ALSA_SYM(snd_pcm_nonblock); SDL_ALSA_SYM(snd_pcm_nonblock);
return 0; return 0;
} }
#undef SDL_ALSA_SYM #undef SDL_ALSA_SYM
#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
...@@ -169,7 +173,7 @@ LoadALSALibrary(void) ...@@ -169,7 +173,7 @@ LoadALSALibrary(void)
if (alsa_handle == NULL) { if (alsa_handle == NULL) {
retval = -1; retval = -1;
SDL_SetError("ALSA: dlopen('%s') failed: %s\n", SDL_SetError("ALSA: dlopen('%s') failed: %s\n",
alsa_library, strerror(errno)); alsa_library, strerror(errno));
} else { } else {
retval = load_alsa_syms(); retval = load_alsa_syms();
if (retval < 0) { if (retval < 0) {
...@@ -376,7 +380,7 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -376,7 +380,7 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -422,7 +426,7 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -422,7 +426,7 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
status = -1; status = -1;
for (test_format = SDL_FirstAudioFormat(this->spec.format); for (test_format = SDL_FirstAudioFormat(this->spec.format);
test_format && (status < 0);) { test_format && (status < 0);) {
status = 0; /* if we can't support a format, it'll become -1. */ status = 0; /* if we can't support a format, it'll become -1. */
switch (test_format) { switch (test_format) {
case AUDIO_U8: case AUDIO_U8:
format = SND_PCM_FORMAT_U8; format = SND_PCM_FORMAT_U8;
...@@ -512,15 +516,15 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -512,15 +516,15 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
ALSA_snd_strerror(status)); ALSA_snd_strerror(status));
return 0; return 0;
} }
#if AUDIO_DEBUG #if AUDIO_DEBUG
{ {
snd_pcm_sframes_t bufsize; snd_pcm_sframes_t bufsize;
int fragments; int fragments;
bufsize = ALSA_snd_pcm_hw_params_get_period_size(hwparams); bufsize = ALSA_snd_pcm_hw_params_get_period_size(hwparams);
fragments = ALSA_snd_pcm_hw_params_get_periods(hwparams); fragments = ALSA_snd_pcm_hw_params_get_periods(hwparams);
fprintf(stderr,"ALSA: bufsize = %ld, fragments = %d\n",bufsize,fragments); fprintf(stderr, "ALSA: bufsize = %ld, fragments = %d\n", bufsize,
} fragments);
}
#endif #endif
/* Set the software parameters */ /* Set the software parameters */
...@@ -532,14 +536,16 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -532,14 +536,16 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
ALSA_snd_strerror(status)); ALSA_snd_strerror(status));
return 0; return 0;
} }
status = ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle,swparams,0); status =
ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, 0);
if (status < 0) { if (status < 0) {
ALSA_CloseDevice(this); ALSA_CloseDevice(this);
SDL_SetError("ALSA: Couldn't set start threshold: %s", SDL_SetError("ALSA: Couldn't set start threshold: %s",
ALSA_snd_strerror(status)); ALSA_snd_strerror(status));
return 0; return 0;
} }
status = ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, frames); status =
ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, frames);
if (status < 0) { if (status < 0) {
ALSA_CloseDevice(this); ALSA_CloseDevice(this);
SDL_SetError("Couldn't set avail min: %s", ALSA_snd_strerror(status)); SDL_SetError("Couldn't set avail min: %s", ALSA_snd_strerror(status));
...@@ -583,7 +589,7 @@ ALSA_Deinitialize(void) ...@@ -583,7 +589,7 @@ ALSA_Deinitialize(void)
} }
static int static int
ALSA_Init(SDL_AudioDriverImpl *impl) ALSA_Init(SDL_AudioDriverImpl * impl)
{ {
if (LoadALSALibrary() < 0) { if (LoadALSALibrary() < 0) {
return 0; return 0;
...@@ -596,7 +602,7 @@ ALSA_Init(SDL_AudioDriverImpl *impl) ...@@ -596,7 +602,7 @@ ALSA_Init(SDL_AudioDriverImpl *impl)
impl->PlayDevice = ALSA_PlayDevice; impl->PlayDevice = ALSA_PlayDevice;
impl->CloseDevice = ALSA_CloseDevice; impl->CloseDevice = ALSA_CloseDevice;
impl->Deinitialize = ALSA_Deinitialize; impl->Deinitialize = ALSA_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Add device enum! */ impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Add device enum! */
return 1; return 1;
} }
......
...@@ -66,15 +66,13 @@ static struct ...@@ -66,15 +66,13 @@ static struct
const char *name; const char *name;
void **func; void **func;
} arts_functions[] = { } arts_functions[] = {
SDL_ARTS_SYM(arts_init), SDL_ARTS_SYM(arts_init),
SDL_ARTS_SYM(arts_free), SDL_ARTS_SYM(arts_free),
SDL_ARTS_SYM(arts_play_stream), SDL_ARTS_SYM(arts_play_stream),
SDL_ARTS_SYM(arts_stream_set), SDL_ARTS_SYM(arts_stream_set),
SDL_ARTS_SYM(arts_stream_get), SDL_ARTS_SYM(arts_stream_get),
SDL_ARTS_SYM(arts_write), SDL_ARTS_SYM(arts_write),
SDL_ARTS_SYM(arts_close_stream), SDL_ARTS_SYM(arts_close_stream), SDL_ARTS_SYM(arts_error_text),};
SDL_ARTS_SYM(arts_error_text),
};
#undef SDL_ARTS_SYM #undef SDL_ARTS_SYM
static void static void
...@@ -147,7 +145,8 @@ ARTS_WaitDevice(_THIS) ...@@ -147,7 +145,8 @@ ARTS_WaitDevice(_THIS)
} }
/* Use timer for general audio synchronization */ /* Use timer for general audio synchronization */
ticks = ((Sint32) (this->hidden->next_frame-SDL_GetTicks())) - FUDGE_TICKS; ticks =
((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
if (ticks > 0) { if (ticks > 0) {
SDL_Delay(ticks); SDL_Delay(ticks);
} }
...@@ -157,10 +156,9 @@ static void ...@@ -157,10 +156,9 @@ static void
ARTS_PlayDevice(_THIS) ARTS_PlayDevice(_THIS)
{ {
/* Write the audio data */ /* Write the audio data */
int written = SDL_NAME(arts_write) ( int written = SDL_NAME(arts_write) (this->hidden->stream,
this->hidden->stream, this->hidden->mixbuf,
this->hidden->mixbuf, this->hidden->mixlen);
this->hidden->mixlen);
/* If timer synchronization is enabled, set the next write frame */ /* If timer synchronization is enabled, set the next write frame */
if (this->hidden->frame_ticks) { if (this->hidden->frame_ticks) {
...@@ -218,7 +216,7 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -218,7 +216,7 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -257,14 +255,14 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -257,14 +255,14 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
if ((rc = SDL_NAME(arts_init) ()) != 0) { if ((rc = SDL_NAME(arts_init) ()) != 0) {
ARTS_CloseDevice(this); ARTS_CloseDevice(this);
SDL_SetError( "Unable to initialize ARTS: %s", SDL_SetError("Unable to initialize ARTS: %s",
SDL_NAME(arts_error_text)(rc) ); SDL_NAME(arts_error_text) (rc));
return 0; return 0;
} }
this->hidden->stream = SDL_NAME(arts_play_stream) ( this->hidden->stream = SDL_NAME(arts_play_stream) (this->spec.freq,
this->spec.freq, bits,
bits, this->spec.channels, this->spec.channels,
"SDL"); "SDL");
/* Calculate the final parameters for this audio specification */ /* Calculate the final parameters for this audio specification */
SDL_CalculateAudioSpec(&this->spec); SDL_CalculateAudioSpec(&this->spec);
...@@ -280,7 +278,7 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -280,7 +278,7 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
#ifdef ARTS_P_PACKET_SETTINGS #ifdef ARTS_P_PACKET_SETTINGS
SDL_NAME(arts_stream_set) (this->hidden->stream, SDL_NAME(arts_stream_set) (this->hidden->stream,
ARTS_P_PACKET_SETTINGS, frag_spec); ARTS_P_PACKET_SETTINGS, frag_spec);
#else #else
SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_SIZE, SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_SIZE,
frag_spec & 0xffff); frag_spec & 0xffff);
...@@ -316,7 +314,7 @@ ARTS_Deinitialize(void) ...@@ -316,7 +314,7 @@ ARTS_Deinitialize(void)
static int static int
ARTS_Init(SDL_AudioDriverImpl *impl) ARTS_Init(SDL_AudioDriverImpl * impl)
{ {
if (LoadARTSLibrary() < 0) { if (LoadARTSLibrary() < 0) {
return 0; return 0;
......
...@@ -58,15 +58,15 @@ FillSound(void *device, void *stream, size_t len, ...@@ -58,15 +58,15 @@ FillSound(void *device, void *stream, size_t len,
if (audio->convert.needed) { if (audio->convert.needed) {
SDL_mutexP(audio->mixer_lock); SDL_mutexP(audio->mixer_lock);
(*audio->spec.callback) (audio->spec.userdata, (*audio->spec.callback) (audio->spec.userdata,
(Uint8 *) audio->convert.buf, (Uint8 *) audio->convert.buf,
audio->convert.len); audio->convert.len);
SDL_mutexV(audio->mixer_lock); SDL_mutexV(audio->mixer_lock);
SDL_ConvertAudio(&audio->convert); SDL_ConvertAudio(&audio->convert);
SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt); SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt);
} else { } else {
SDL_mutexP(audio->mixer_lock); SDL_mutexP(audio->mixer_lock);
(*audio->spec.callback) (audio->spec.userdata, (*audio->spec.callback) (audio->spec.userdata,
(Uint8 *) stream, len); (Uint8 *) stream, len);
SDL_mutexV(audio->mixer_lock); SDL_mutexV(audio->mixer_lock);
} }
} }
...@@ -106,56 +106,56 @@ BEOSAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -106,56 +106,56 @@ BEOSAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
SDL_memset(&format, '\0', sizeof(media_raw_audio_format)); SDL_memset(&format, '\0', sizeof(media_raw_audio_format));
format.byte_order = B_MEDIA_LITTLE_ENDIAN; format.byte_order = B_MEDIA_LITTLE_ENDIAN;
format.frame_rate = (float) _this->spec.freq; format.frame_rate = (float) _this->spec.freq;
format.channel_count = _this->spec.channels; /* !!! FIXME: support > 2? */ format.channel_count = _this->spec.channels; /* !!! FIXME: support > 2? */
while ((!valid_datatype) && (test_format)) { while ((!valid_datatype) && (test_format)) {
valid_datatype = 1; valid_datatype = 1;
_this->spec.format = test_format; _this->spec.format = test_format;
switch (test_format) { switch (test_format) {
case AUDIO_S8: case AUDIO_S8:
format.format = media_raw_audio_format::B_AUDIO_CHAR; format.format = media_raw_audio_format::B_AUDIO_CHAR;
break; break;
case AUDIO_U8: case AUDIO_U8:
format.format = media_raw_audio_format::B_AUDIO_UCHAR; format.format = media_raw_audio_format::B_AUDIO_UCHAR;
break; break;
case AUDIO_S16LSB: case AUDIO_S16LSB:
format.format = media_raw_audio_format::B_AUDIO_SHORT; format.format = media_raw_audio_format::B_AUDIO_SHORT;
break; break;
case AUDIO_S16MSB: case AUDIO_S16MSB:
format.format = media_raw_audio_format::B_AUDIO_SHORT; format.format = media_raw_audio_format::B_AUDIO_SHORT;
format.byte_order = B_MEDIA_BIG_ENDIAN; format.byte_order = B_MEDIA_BIG_ENDIAN;
break; break;
case AUDIO_S32LSB: case AUDIO_S32LSB:
format.format = media_raw_audio_format::B_AUDIO_INT; format.format = media_raw_audio_format::B_AUDIO_INT;
break; break;
case AUDIO_S32MSB: case AUDIO_S32MSB:
format.format = media_raw_audio_format::B_AUDIO_INT; format.format = media_raw_audio_format::B_AUDIO_INT;
format.byte_order = B_MEDIA_BIG_ENDIAN; format.byte_order = B_MEDIA_BIG_ENDIAN;
break; break;
case AUDIO_F32LSB: case AUDIO_F32LSB:
format.format = media_raw_audio_format::B_AUDIO_FLOAT; format.format = media_raw_audio_format::B_AUDIO_FLOAT;
break; break;
case AUDIO_F32MSB: case AUDIO_F32MSB:
format.format = media_raw_audio_format::B_AUDIO_FLOAT; format.format = media_raw_audio_format::B_AUDIO_FLOAT;
format.byte_order = B_MEDIA_BIG_ENDIAN; format.byte_order = B_MEDIA_BIG_ENDIAN;
break; break;
default: default:
valid_datatype = 0; valid_datatype = 0;
test_format = SDL_NextAudioFormat(); test_format = SDL_NextAudioFormat();
break; break;
} }
} }
format.buffer_size = _this->spec.samples; format.buffer_size = _this->spec.samples;
if (!valid_datatype) { /* shouldn't happen, but just in case... */ if (!valid_datatype) { /* shouldn't happen, but just in case... */
BEOSAUDIO_CloseDevice(_this); BEOSAUDIO_CloseDevice(_this);
SDL_SetError("Unsupported audio format"); SDL_SetError("Unsupported audio format");
return 0; return 0;
...@@ -190,7 +190,7 @@ BEOSAUDIO_Deinitialize(void) ...@@ -190,7 +190,7 @@ BEOSAUDIO_Deinitialize(void)
} }
static int static int
BEOSAUDIO_Init(SDL_AudioDriverImpl *impl) BEOSAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
/* Initialize the Be Application, if it's not already started */ /* Initialize the Be Application, if it's not already started */
if (SDL_InitBeApp() < 0) { if (SDL_InitBeApp() < 0) {
...@@ -207,10 +207,12 @@ BEOSAUDIO_Init(SDL_AudioDriverImpl *impl) ...@@ -207,10 +207,12 @@ BEOSAUDIO_Init(SDL_AudioDriverImpl *impl)
return 1; return 1;
} }
extern "C" { extern AudioBootStrap BEOSAUDIO_bootstrap; } extern "C"
{
extern AudioBootStrap BEOSAUDIO_bootstrap;
}
AudioBootStrap BEOSAUDIO_bootstrap = { AudioBootStrap BEOSAUDIO_bootstrap = {
"baudio", "BeOS BSoundPlayer", BEOSAUDIO_Init, 0 "baudio", "BeOS BSoundPlayer", BEOSAUDIO_Init, 0
}; };
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -122,7 +122,7 @@ BSDAUDIO_DetectDevices(int iscapture) ...@@ -122,7 +122,7 @@ BSDAUDIO_DetectDevices(int iscapture)
return outputDeviceCount; return outputDeviceCount;
} }
return 0; /* shouldn't ever hit this. */ return 0; /* shouldn't ever hit this. */
} }
static const char * static const char *
...@@ -149,7 +149,7 @@ BSDAUDIO_Status(_THIS) ...@@ -149,7 +149,7 @@ BSDAUDIO_Status(_THIS)
fprintf(stderr, "AUDIO_GETINFO failed.\n"); fprintf(stderr, "AUDIO_GETINFO failed.\n");
return; return;
} }
/* *INDENT-OFF* */
fprintf(stderr, "\n" fprintf(stderr, "\n"
"[play/record info]\n" "[play/record info]\n"
"buffer size : %d bytes\n" "buffer size : %d bytes\n"
...@@ -177,7 +177,9 @@ BSDAUDIO_Status(_THIS) ...@@ -177,7 +177,9 @@ BSDAUDIO_Status(_THIS)
info.play.error ? "yes" : "no", info.play.error ? "yes" : "no",
info.play.waiting ? "yes" : "no", info.play.waiting ? "yes" : "no",
info.play.active ? "yes" : "no"); info.play.active ? "yes" : "no");
/* *INDENT-ON* */
/* *INDENT-OFF* */
fprintf(stderr, "\n" fprintf(stderr, "\n"
"[audio info]\n" "[audio info]\n"
"monitor_gain : %i\n" "monitor_gain : %i\n"
...@@ -192,6 +194,7 @@ BSDAUDIO_Status(_THIS) ...@@ -192,6 +194,7 @@ BSDAUDIO_Status(_THIS)
(info.mode == AUMODE_PLAY) ? "PLAY" (info.mode == AUMODE_PLAY) ? "PLAY"
: (info.mode = AUMODE_RECORD) ? "RECORD" : (info.mode = AUMODE_RECORD) ? "RECORD"
: (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" : "?")); : (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" : "?"));
/* *INDENT-ON* */
#endif /* DEBUG_AUDIO */ #endif /* DEBUG_AUDIO */
} }
...@@ -206,7 +209,9 @@ BSDAUDIO_WaitDevice(_THIS) ...@@ -206,7 +209,9 @@ BSDAUDIO_WaitDevice(_THIS)
/* Use timer for general audio synchronization */ /* Use timer for general audio synchronization */
Sint32 ticks; Sint32 ticks;
ticks = ((Sint32)(this->hidden->next_frame-SDL_GetTicks()))-FUDGE_TICKS; ticks =
((Sint32) (this->hidden->next_frame - SDL_GetTicks())) -
FUDGE_TICKS;
if (ticks > 0) { if (ticks > 0) {
SDL_Delay(ticks); SDL_Delay(ticks);
} }
...@@ -222,7 +227,8 @@ BSDAUDIO_WaitDevice(_THIS) ...@@ -222,7 +227,8 @@ BSDAUDIO_WaitDevice(_THIS)
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
fprintf(stderr, "Waiting for audio to get ready\n"); fprintf(stderr, "Waiting for audio to get ready\n");
#endif #endif
if (select(this->hidden->audio_fd+1,NULL,&fdset,NULL,&timeout) <= 0) { if (select(this->hidden->audio_fd + 1, NULL, &fdset, NULL, &timeout)
<= 0) {
const char *message = const char *message =
"Audio timeout - buggy audio driver? (disabled)"; "Audio timeout - buggy audio driver? (disabled)";
/* In general we should never print to the screen, /* In general we should never print to the screen,
...@@ -252,8 +258,7 @@ BSDAUDIO_PlayDevice(_THIS) ...@@ -252,8 +258,7 @@ BSDAUDIO_PlayDevice(_THIS)
/* Write the audio data, checking for EAGAIN on broken audio drivers */ /* Write the audio data, checking for EAGAIN on broken audio drivers */
do { do {
written = write(this->hidden->audio_fd, written = write(this->hidden->audio_fd,
&this->hidden->mixbuf[p], &this->hidden->mixbuf[p], this->hidden->mixlen - p);
this->hidden->mixlen - p);
if (written > 0) if (written > 0)
p += written; p += written;
...@@ -317,8 +322,8 @@ BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -317,8 +322,8 @@ BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
/* We don't care what the devname is...we'll try to open anything. */ /* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */ /* ...but default to first name in the list... */
if (devname == NULL) { if (devname == NULL) {
if ( ((iscapture) && (inputDeviceCount == 0)) || if (((iscapture) && (inputDeviceCount == 0)) ||
((!iscapture) && (outputDeviceCount == 0)) ) { ((!iscapture) && (outputDeviceCount == 0))) {
SDL_SetError("No such audio device"); SDL_SetError("No such audio device");
return 0; return 0;
} }
...@@ -327,7 +332,7 @@ BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -327,7 +332,7 @@ BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -429,7 +434,7 @@ BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -429,7 +434,7 @@ BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
} }
static int static int
BSDAUDIO_Init(SDL_AudioDriverImpl *impl) BSDAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->DetectDevices = BSDAUDIO_DetectDevices; impl->DetectDevices = BSDAUDIO_DetectDevices;
......
...@@ -90,7 +90,7 @@ DART_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -90,7 +90,7 @@ DART_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
_this->hidden = (struct SDL_PrivateAudioData *) _this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *_this->hidden)); SDL_malloc((sizeof *_this->hidden));
if (_this->hidden == NULL) { if (_this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -108,12 +108,11 @@ DART_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -108,12 +108,11 @@ DART_OpenDevice(_THIS, const char *devname, int iscapture)
iOpenMode |= MCI_OPEN_SHAREABLE; iOpenMode |= MCI_OPEN_SHAREABLE;
rc = mciSendCommand(0, MCI_OPEN, iOpenMode, (PVOID) & AmpOpenParms, 0); rc = mciSendCommand(0, MCI_OPEN, iOpenMode, (PVOID) & AmpOpenParms, 0);
if (rc != MCIERR_SUCCESS) { // No audio available?? if (rc != MCIERR_SUCCESS) { // No audio available??
DART_CloseDevice(_this); DART_CloseDevice(_this);
SDL_SetError("DART: Couldn't open audio device."); SDL_SetError("DART: Couldn't open audio device.");
return 0; return 0;
} }
// Save the device ID we got from DART! // Save the device ID we got from DART!
// We will use this in the next calls! // We will use this in the next calls!
_this->hidden->iCurrDeviceOrd = iDeviceOrd = AmpOpenParms.usDeviceID; _this->hidden->iCurrDeviceOrd = iDeviceOrd = AmpOpenParms.usDeviceID;
...@@ -361,7 +360,7 @@ DART_WaitDone(_THIS) ...@@ -361,7 +360,7 @@ DART_WaitDone(_THIS)
APIRET rc = NO_ERROR; APIRET rc = NO_ERROR;
pBufDesc = (pMixBufferDesc) pBufDesc = (pMixBufferDesc)
_this->hidden->pMixBuffers[_this->hidden->iLastPlayedBuf].ulUserParm; _this->hidden->pMixBuffers[_this->hidden->iLastPlayedBuf].ulUserParm;
while ((pBufDesc->iBufferUsage != BUFFER_EMPTY) && (rc == NO_ERROR)) { while ((pBufDesc->iBufferUsage != BUFFER_EMPTY) && (rc == NO_ERROR)) {
DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount); DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount);
...@@ -388,13 +387,11 @@ DART_CloseDevice(_THIS) ...@@ -388,13 +387,11 @@ DART_CloseDevice(_THIS)
} }
#endif #endif
} }
// Close event semaphore // Close event semaphore
if (_this->hidden->hevAudioBufferPlayed) { if (_this->hidden->hevAudioBufferPlayed) {
DosCloseEventSem(_this->hidden->hevAudioBufferPlayed); DosCloseEventSem(_this->hidden->hevAudioBufferPlayed);
_this->hidden->hevAudioBufferPlayed = 0; _this->hidden->hevAudioBufferPlayed = 0;
} }
// Free memory of buffer descriptions // Free memory of buffer descriptions
for (i = 0; i < _this->hidden->iCurrNumBufs; i++) { for (i = 0; i < _this->hidden->iCurrNumBufs; i++) {
SDL_free((void *) (_this->hidden->pMixBuffers[i].ulUserParm)); SDL_free((void *) (_this->hidden->pMixBuffers[i].ulUserParm));
...@@ -408,13 +405,11 @@ DART_CloseDevice(_THIS) ...@@ -408,13 +405,11 @@ DART_CloseDevice(_THIS)
MCI_WAIT | MCI_DEALLOCATE_MEMORY, MCI_WAIT | MCI_DEALLOCATE_MEMORY,
&(_this->hidden->BufferParms), 0); &(_this->hidden->BufferParms), 0);
} }
// Free bufferlist // Free bufferlist
if (_this->hidden->pMixBuffers != NULL) { if (_this->hidden->pMixBuffers != NULL) {
SDL_free(_this->hidden->pMixBuffers); SDL_free(_this->hidden->pMixBuffers);
_this->hidden->pMixBuffers = NULL; _this->hidden->pMixBuffers = NULL;
} }
// Close dart // Close dart
if (_this->hidden->iCurrDeviceOrd) { if (_this->hidden->iCurrDeviceOrd) {
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE, rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE,
...@@ -429,7 +424,7 @@ DART_CloseDevice(_THIS) ...@@ -429,7 +424,7 @@ DART_CloseDevice(_THIS)
static int static int
DART_Init(SDL_AudioDriverImpl *impl) DART_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = DART_OpenDevice; impl->OpenDevice = DART_OpenDevice;
...@@ -439,7 +434,7 @@ DART_Init(SDL_AudioDriverImpl *impl) ...@@ -439,7 +434,7 @@ DART_Init(SDL_AudioDriverImpl *impl)
impl->PlayDevice = DART_PlayDevice; impl->PlayDevice = DART_PlayDevice;
impl->WaitDone = DART_WaitDone; impl->WaitDone = DART_WaitDone;
impl->CloseDevice = DART_CloseDevice; impl->CloseDevice = DART_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this right? */ impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this right? */
return 1; return 1;
} }
......
...@@ -170,7 +170,7 @@ DCAUD_OpenDevice(_THIS, SDL_AudioSpec * spec) ...@@ -170,7 +170,7 @@ DCAUD_OpenDevice(_THIS, SDL_AudioSpec * spec)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -225,7 +225,7 @@ DCAUD_OpenDevice(_THIS, SDL_AudioSpec * spec) ...@@ -225,7 +225,7 @@ DCAUD_OpenDevice(_THIS, SDL_AudioSpec * spec)
} }
static int static int
DCAUD_Init(SDL_AudioDriverImpl *impl) DCAUD_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = DCAUD_OpenDevice; impl->OpenDevice = DCAUD_OpenDevice;
......
...@@ -112,12 +112,12 @@ DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -112,12 +112,12 @@ DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
const char *fname = DISKAUD_GetOutputFilename(devname); const char *fname = DISKAUD_GetOutputFilename(devname);
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof (*this->hidden)); SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
} }
SDL_memset(this->hidden, 0, sizeof (*this->hidden)); SDL_memset(this->hidden, 0, sizeof(*this->hidden));
/* Open the audio device */ /* Open the audio device */
this->hidden->output = SDL_RWFromFile(fname, "wb"); this->hidden->output = SDL_RWFromFile(fname, "wb");
...@@ -149,7 +149,7 @@ DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -149,7 +149,7 @@ DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
} }
static int static int
DISKAUD_Init(SDL_AudioDriverImpl *impl) DISKAUD_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = DISKAUD_OpenDevice; impl->OpenDevice = DISKAUD_OpenDevice;
......
...@@ -74,8 +74,7 @@ test_for_mmap(int fd) ...@@ -74,8 +74,7 @@ test_for_mmap(int fd)
struct audio_buf_info info; struct audio_buf_info info;
if ((ioctl(fd, SNDCTL_DSP_GETCAPS, &caps) == 0) && if ((ioctl(fd, SNDCTL_DSP_GETCAPS, &caps) == 0) &&
(caps & DSP_CAP_TRIGGER) && (caps & DSP_CAP_MMAP) && (caps & DSP_CAP_TRIGGER) && (caps & DSP_CAP_MMAP) &&
(ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) == 0)) (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) == 0)) {
{
size_t len = info.fragstotal * info.fragsize; size_t len = info.fragstotal * info.fragsize;
Uint8 *buf = (Uint8 *) mmap(NULL, len, PROT_WRITE, MAP_SHARED, fd, 0); Uint8 *buf = (Uint8 *) mmap(NULL, len, PROT_WRITE, MAP_SHARED, fd, 0);
if (buf != MAP_FAILED) { if (buf != MAP_FAILED) {
...@@ -117,7 +116,8 @@ free_device_lists(void) ...@@ -117,7 +116,8 @@ free_device_lists(void)
} }
static void DMA_Deinitialize(void) static void
DMA_Deinitialize(void)
{ {
free_device_lists(); free_device_lists();
} }
...@@ -133,7 +133,7 @@ DMA_DetectDevices(int iscapture) ...@@ -133,7 +133,7 @@ DMA_DetectDevices(int iscapture)
return outputDeviceCount; return outputDeviceCount;
} }
return 0; /* shouldn't ever hit this. */ return 0; /* shouldn't ever hit this. */
} }
...@@ -240,8 +240,8 @@ DMA_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -240,8 +240,8 @@ DMA_OpenDevice(_THIS, const char *devname, int iscapture)
/* We don't care what the devname is...we'll try to open anything. */ /* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */ /* ...but default to first name in the list... */
if (devname == NULL) { if (devname == NULL) {
if ( ((iscapture) && (inputDeviceCount == 0)) || if (((iscapture) && (inputDeviceCount == 0)) ||
((!iscapture) && (outputDeviceCount == 0)) ) { ((!iscapture) && (outputDeviceCount == 0))) {
SDL_SetError("No such audio device"); SDL_SetError("No such audio device");
return 0; return 0;
} }
...@@ -250,7 +250,7 @@ DMA_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -250,7 +250,7 @@ DMA_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -380,7 +380,8 @@ DMA_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -380,7 +380,8 @@ DMA_OpenDevice(_THIS, const char *devname, int iscapture)
char *workaround; char *workaround;
workaround = SDL_getenv("SDL_DSP_NOSELECT"); workaround = SDL_getenv("SDL_DSP_NOSELECT");
if (workaround) { if (workaround) {
frame_ticks = (float) (this->spec.samples*1000) / this->spec.freq; frame_ticks =
(float) (this->spec.samples * 1000) / this->spec.freq;
next_frame = SDL_GetTicks() + frame_ticks; next_frame = SDL_GetTicks() + frame_ticks;
} }
} }
...@@ -511,7 +512,7 @@ DMA_GetDeviceBuf(_THIS) ...@@ -511,7 +512,7 @@ DMA_GetDeviceBuf(_THIS)
static int static int
DMA_Init(SDL_AudioDriverImpl *impl) DMA_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->DetectDevices = DMA_DetectDevices; impl->DetectDevices = DMA_DetectDevices;
......
...@@ -104,7 +104,7 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -104,7 +104,7 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -160,15 +160,17 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -160,15 +160,17 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
valid = 0; valid = 0;
if (audio_config) { if (audio_config) {
if (alSetChannels(audio_config, this->spec.channels) < 0) { if (alSetChannels(audio_config, this->spec.channels) < 0) {
if (this->spec.channels > 2) { /* can't handle > stereo? */ if (this->spec.channels > 2) { /* can't handle > stereo? */
this->spec.channels = 2; /* try again below. */ this->spec.channels = 2; /* try again below. */
} }
} }
if ((alSetSampFmt(audio_config, fmt) >= 0) && if ((alSetSampFmt(audio_config, fmt) >= 0) &&
((!width) || (alSetWidth(audio_config, width) >= 0)) && ((!width) || (alSetWidth(audio_config, width) >= 0)) &&
(alSetQueueSize(audio_config,this->spec.samples*2) >= 0) && (alSetQueueSize(audio_config, this->spec.samples * 2) >=
(alSetChannels(audio_config, this->spec.channels) >= 0)) { 0)
&& (alSetChannels(audio_config, this->spec.channels) >=
0)) {
this->hidden->audio_port = alOpenPort("SDL audio", "w", this->hidden->audio_port = alOpenPort("SDL audio", "w",
audio_config); audio_config);
...@@ -178,8 +180,8 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -178,8 +180,8 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
if (err == AL_BAD_CHANNELS) { if (err == AL_BAD_CHANNELS) {
this->spec.channels = 2; this->spec.channels = 2;
alSetChannels(audio_config, this->spec.channels); alSetChannels(audio_config, this->spec.channels);
this->hidden->audio_port = alOpenPort("SDL audio", "w", this->hidden->audio_port =
audio_config); alOpenPort("SDL audio", "w", audio_config);
} }
} }
...@@ -216,7 +218,7 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -216,7 +218,7 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
} }
static int static int
IRIXAUDIO_Init(SDL_AudioDriverImpl *impl) IRIXAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = DSP_OpenDevice; impl->OpenDevice = DSP_OpenDevice;
...@@ -224,7 +226,7 @@ IRIXAUDIO_Init(SDL_AudioDriverImpl *impl) ...@@ -224,7 +226,7 @@ IRIXAUDIO_Init(SDL_AudioDriverImpl *impl)
impl->WaitDevice = DSP_WaitDevice; impl->WaitDevice = DSP_WaitDevice;
impl->GetDeviceBuf = DSP_GetDeviceBuf; impl->GetDeviceBuf = DSP_GetDeviceBuf;
impl->CloseDevice = DSP_CloseDevice; impl->CloseDevice = DSP_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: not true, I think. */ impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: not true, I think. */
return 1; return 1;
} }
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
struct SDL_PrivateAudioData struct SDL_PrivateAudioData
{ {
ALport audio_port; /* The handle for the audio device */ ALport audio_port; /* The handle for the audio device */
Uint8 *mixbuf; /* The app mixing buffer */ Uint8 *mixbuf; /* The app mixing buffer */
}; };
#endif /* _SDL_irixaudio_h */ #endif /* _SDL_irixaudio_h */
......
...@@ -111,7 +111,7 @@ DSP_DetectDevices(int iscapture) ...@@ -111,7 +111,7 @@ DSP_DetectDevices(int iscapture)
return outputDeviceCount; return outputDeviceCount;
} }
return 0; /* shouldn't ever hit this. */ return 0; /* shouldn't ever hit this. */
} }
static const char * static const char *
...@@ -158,8 +158,8 @@ DSP_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -158,8 +158,8 @@ DSP_OpenDevice(_THIS, const char *devname, int iscapture)
/* We don't care what the devname is...we'll try to open anything. */ /* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */ /* ...but default to first name in the list... */
if (devname == NULL) { if (devname == NULL) {
if ( ((iscapture) && (inputDeviceCount == 0)) || if (((iscapture) && (inputDeviceCount == 0)) ||
((!iscapture) && (outputDeviceCount == 0)) ) { ((!iscapture) && (outputDeviceCount == 0))) {
SDL_SetError("No such audio device"); SDL_SetError("No such audio device");
return 0; return 0;
} }
...@@ -168,7 +168,7 @@ DSP_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -168,7 +168,7 @@ DSP_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -265,8 +265,8 @@ DSP_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -265,8 +265,8 @@ DSP_OpenDevice(_THIS, const char *devname, int iscapture)
/* Set the audio format */ /* Set the audio format */
value = format; value = format;
if ( (ioctl(this->hidden->audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || if ((ioctl(this->hidden->audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
(value != format) ) { (value != format)) {
perror("SNDCTL_DSP_SETFMT"); perror("SNDCTL_DSP_SETFMT");
DSP_CloseDevice(this); DSP_CloseDevice(this);
SDL_SetError("Couldn't set audio format"); SDL_SetError("Couldn't set audio format");
...@@ -360,7 +360,7 @@ DSP_GetDeviceBuf(_THIS) ...@@ -360,7 +360,7 @@ DSP_GetDeviceBuf(_THIS)
} }
static int static int
DSP_Init(SDL_AudioDriverImpl *impl) DSP_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->DetectDevices = DSP_DetectDevices; impl->DetectDevices = DSP_DetectDevices;
......
...@@ -32,11 +32,11 @@ ...@@ -32,11 +32,11 @@
static int static int
DUMMYAUD_OpenDevice(_THIS, const char *devname, int iscapture) DUMMYAUD_OpenDevice(_THIS, const char *devname, int iscapture)
{ {
return 1; /* always succeeds. */ return 1; /* always succeeds. */
} }
static int static int
DUMMYAUD_Init(SDL_AudioDriverImpl *impl) DUMMYAUD_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = DUMMYAUD_OpenDevice; impl->OpenDevice = DUMMYAUD_OpenDevice;
......
...@@ -61,10 +61,8 @@ static struct ...@@ -61,10 +61,8 @@ static struct
const char *name; const char *name;
void **func; void **func;
} esd_functions[] = { } esd_functions[] = {
SDL_ESD_SYM(esd_open_sound), SDL_ESD_SYM(esd_open_sound),
SDL_ESD_SYM(esd_close), SDL_ESD_SYM(esd_close), SDL_ESD_SYM(esd_play_stream),};
SDL_ESD_SYM(esd_play_stream),
};
#undef SDL_ESD_SYM #undef SDL_ESD_SYM
static void static void
...@@ -137,7 +135,8 @@ ESD_WaitDevice(_THIS) ...@@ -137,7 +135,8 @@ ESD_WaitDevice(_THIS)
} }
/* Use timer for general audio synchronization */ /* Use timer for general audio synchronization */
ticks = ((Sint32) (this->hidden->next_frame-SDL_GetTicks())) - FUDGE_TICKS; ticks =
((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
if (ticks > 0) { if (ticks > 0) {
SDL_Delay(ticks); SDL_Delay(ticks);
} }
...@@ -151,8 +150,7 @@ ESD_PlayDevice(_THIS) ...@@ -151,8 +150,7 @@ ESD_PlayDevice(_THIS)
/* Write the audio data, checking for EAGAIN on broken audio drivers */ /* Write the audio data, checking for EAGAIN on broken audio drivers */
do { do {
written = write(this->hidden->audio_fd, written = write(this->hidden->audio_fd,
this->hidden->mixbuf, this->hidden->mixbuf, this->hidden->mixlen);
this->hidden->mixlen);
if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) { if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) {
SDL_Delay(1); /* Let a little CPU time go by */ SDL_Delay(1); /* Let a little CPU time go by */
} }
...@@ -229,7 +227,7 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -229,7 +227,7 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -246,15 +244,15 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -246,15 +244,15 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture)
#endif #endif
found = 1; found = 1;
switch (test_format) { switch (test_format) {
case AUDIO_U8: case AUDIO_U8:
format |= ESD_BITS8; format |= ESD_BITS8;
break; break;
case AUDIO_S16SYS: case AUDIO_S16SYS:
format |= ESD_BITS16; format |= ESD_BITS16;
break; break;
default: default:
found = 0; found = 0;
break; break;
} }
} }
...@@ -270,12 +268,13 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -270,12 +268,13 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture)
format |= ESD_STEREO; format |= ESD_STEREO;
} }
#if 0 #if 0
this->spec.samples = ESD_BUF_SIZE; /* Darn, no way to change this yet */ this->spec.samples = ESD_BUF_SIZE; /* Darn, no way to change this yet */
#endif #endif
/* Open a connection to the ESD audio server */ /* Open a connection to the ESD audio server */
this->hidden->audio_fd = this->hidden->audio_fd =
SDL_NAME(esd_play_stream)(format,this->spec.freq,NULL,get_progname()); SDL_NAME(esd_play_stream) (format, this->spec.freq, NULL,
get_progname());
if (this->hidden->audio_fd < 0) { if (this->hidden->audio_fd < 0) {
ESD_CloseDevice(this); ESD_CloseDevice(this);
...@@ -285,7 +284,8 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -285,7 +284,8 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture)
/* Calculate the final parameters for this audio specification */ /* Calculate the final parameters for this audio specification */
SDL_CalculateAudioSpec(&this->spec); SDL_CalculateAudioSpec(&this->spec);
this->hidden->frame_ticks = (float) (this->spec.samples*1000) / this->spec.freq; this->hidden->frame_ticks =
(float) (this->spec.samples * 1000) / this->spec.freq;
this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks; this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks;
/* Allocate mixing buffer */ /* Allocate mixing buffer */
...@@ -312,7 +312,7 @@ ESD_Deinitialize(void) ...@@ -312,7 +312,7 @@ ESD_Deinitialize(void)
} }
static int static int
ESD_Init(SDL_AudioDriverImpl *impl) ESD_Init(SDL_AudioDriverImpl * impl)
{ {
if (LoadESDLibrary() < 0) { if (LoadESDLibrary() < 0) {
return 0; return 0;
......
This diff is collapsed.
...@@ -190,7 +190,7 @@ SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -190,7 +190,7 @@ SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -292,7 +292,7 @@ SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -292,7 +292,7 @@ SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture)
} }
static int static int
SNDMGR_Init(SDL_AudioDriverImpl *impl) SNDMGR_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = SNDMGR_OpenDevice; impl->OpenDevice = SNDMGR_OpenDevice;
......
...@@ -101,7 +101,8 @@ MINTDMA8_CloseDevice(_THIS) ...@@ -101,7 +101,8 @@ MINTDMA8_CloseDevice(_THIS)
DEBUG_PRINT((DEBUG_NAME "closeaudio: interrupt disabled\n")); DEBUG_PRINT((DEBUG_NAME "closeaudio: interrupt disabled\n"));
/* Wait if currently playing sound */ /* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {} while (SDL_MintAudio_mutex != 0) {
}
DEBUG_PRINT((DEBUG_NAME "closeaudio: no more interrupt running\n")); DEBUG_PRINT((DEBUG_NAME "closeaudio: no more interrupt running\n"));
...@@ -127,12 +128,13 @@ MINTDMA8_CheckAudio(_THIS) ...@@ -127,12 +128,13 @@ MINTDMA8_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(this->spec.format))); SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels)); DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq)); DEBUG_PRINT(("freq=%d\n", this->spec.freq));
if (this->spec.channels > 2) { if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */ this->spec.channels = 2; /* no more than stereo! */
} }
/* Check formats available */ /* Check formats available */
...@@ -184,7 +186,8 @@ MINTDMA8_CheckAudio(_THIS) ...@@ -184,7 +186,8 @@ MINTDMA8_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(this->spec.format))); SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels)); DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq)); DEBUG_PRINT(("freq=%d\n", this->spec.freq));
...@@ -255,7 +258,7 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -255,7 +258,7 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -267,7 +270,8 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -267,7 +270,8 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture)
/* Allocate memory for audio buffers in DMA-able RAM */ /* Allocate memory for audio buffers in DMA-able RAM */
DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); SDL_MintAudio_audiobuf[0] =
Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
if (SDL_MintAudio_audiobuf[0] == NULL) { if (SDL_MintAudio_audiobuf[0] == NULL) {
SDL_free(this->hidden); SDL_free(this->hidden);
this->hidden = NULL; this->hidden = NULL;
...@@ -276,7 +280,8 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -276,7 +280,8 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture)
} }
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
SDL_MintAudio_numbuf = 0; SDL_MintAudio_numbuf = 0;
SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
this->spec.size * 2);
SDL_MintAudio_audiosize = this->spec.size; SDL_MintAudio_audiosize = this->spec.size;
SDL_MintAudio_mutex = 0; SDL_MintAudio_mutex = 0;
...@@ -290,11 +295,11 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -290,11 +295,11 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture)
/* Setup audio hardware */ /* Setup audio hardware */
MINTDMA8_InitAudio(this); MINTDMA8_InitAudio(this);
return 1; /* good to go. */ return 1; /* good to go. */
} }
static int static int
MINTDMA8_Init(SDL_AudioDriverImpl *impl) MINTDMA8_Init(SDL_AudioDriverImpl * impl)
{ {
/* Cookie _MCH present ? if not, assume ST machine */ /* Cookie _MCH present ? if not, assume ST machine */
if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
......
...@@ -94,7 +94,8 @@ MINTGSXB_CloseDevice(_THIS) ...@@ -94,7 +94,8 @@ MINTGSXB_CloseDevice(_THIS)
} }
/* Wait if currently playing sound */ /* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {} while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */ /* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) { if (SDL_MintAudio_audiobuf[0]) {
...@@ -130,7 +131,7 @@ MINTGSXB_CheckAudio(_THIS) ...@@ -130,7 +131,7 @@ MINTGSXB_CheckAudio(_THIS)
DEBUG_PRINT(("freq=%d\n", this->spec.freq)); DEBUG_PRINT(("freq=%d\n", this->spec.freq));
if (this->spec.channels > 2) { if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */ this->spec.channels = 2; /* no more than stereo! */
} }
while ((!valid_datatype) && (test_format)) { while ((!valid_datatype) && (test_format)) {
...@@ -141,37 +142,37 @@ MINTGSXB_CheckAudio(_THIS) ...@@ -141,37 +142,37 @@ MINTGSXB_CheckAudio(_THIS)
format_signed = SDL_AUDIO_ISSIGNED(this->spec.format); format_signed = SDL_AUDIO_ISSIGNED(this->spec.format);
format_bigendian = SDL_AUDIO_ISBIGENDIAN(this->spec.format); format_bigendian = SDL_AUDIO_ISBIGENDIAN(this->spec.format);
switch (test_format) { switch (test_format) {
case AUDIO_U8: case AUDIO_U8:
case AUDIO_S8: case AUDIO_S8:
if (snd_format & SND_FORMAT8) { if (snd_format & SND_FORMAT8) {
valid_datatype = 1; valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY8BIT); snd_format = Sndstatus(SND_QUERY8BIT);
} }
break; break;
case AUDIO_U16LSB: case AUDIO_U16LSB:
case AUDIO_S16LSB: case AUDIO_S16LSB:
case AUDIO_U16MSB: case AUDIO_U16MSB:
case AUDIO_S16MSB: case AUDIO_S16MSB:
if (snd_format & SND_FORMAT16) { if (snd_format & SND_FORMAT16) {
valid_datatype = 1; valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY16BIT); snd_format = Sndstatus(SND_QUERY16BIT);
} }
break; break;
case AUDIO_S32LSB: case AUDIO_S32LSB:
case AUDIO_S32MSB: case AUDIO_S32MSB:
if (snd_format & SND_FORMAT32) { if (snd_format & SND_FORMAT32) {
valid_datatype = 1; valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY32BIT); snd_format = Sndstatus(SND_QUERY32BIT);
} }
break; break;
/* no float support... */ /* no float support... */
default: default:
test_format = SDL_NextAudioFormat(); test_format = SDL_NextAudioFormat();
break; break;
} }
} }
...@@ -238,7 +239,8 @@ MINTGSXB_CheckAudio(_THIS) ...@@ -238,7 +239,8 @@ MINTGSXB_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(this->spec.format))); SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels)); DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq)); DEBUG_PRINT(("freq=%d\n", this->spec.freq));
...@@ -326,7 +328,7 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -326,7 +328,7 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -338,7 +340,8 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -338,7 +340,8 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture)
/* Allocate memory for audio buffers in DMA-able RAM */ /* Allocate memory for audio buffers in DMA-able RAM */
DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); SDL_MintAudio_audiobuf[0] =
Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
if (SDL_MintAudio_audiobuf[0] == NULL) { if (SDL_MintAudio_audiobuf[0] == NULL) {
SDL_free(this->hidden); SDL_free(this->hidden);
this->hidden = NULL; this->hidden = NULL;
...@@ -347,7 +350,8 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -347,7 +350,8 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture)
} }
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
SDL_MintAudio_numbuf = 0; SDL_MintAudio_numbuf = 0;
SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
this->spec.size * 2);
SDL_MintAudio_audiosize = this->spec.size; SDL_MintAudio_audiosize = this->spec.size;
SDL_MintAudio_mutex = 0; SDL_MintAudio_mutex = 0;
...@@ -361,7 +365,7 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -361,7 +365,7 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture)
/* Setup audio hardware */ /* Setup audio hardware */
MINTGSXB_InitAudio(this); MINTGSXB_InitAudio(this);
return 1; /* good to go. */ return 1; /* good to go. */
} }
static void static void
...@@ -388,7 +392,7 @@ MINTGSXB_GsxbNullInterrupt(void) ...@@ -388,7 +392,7 @@ MINTGSXB_GsxbNullInterrupt(void)
} }
static int static int
MINTGSXB_Init(SDL_AudioDriverImpl *impl) MINTGSXB_Init(SDL_AudioDriverImpl * impl)
{ {
/* Cookie _SND present ? if not, assume ST machine */ /* Cookie _SND present ? if not, assume ST machine */
if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
......
...@@ -93,7 +93,8 @@ MINTMCSN_CloseDevice(_THIS) ...@@ -93,7 +93,8 @@ MINTMCSN_CloseDevice(_THIS)
} }
/* Wait if currently playing sound */ /* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {} while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */ /* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) { if (SDL_MintAudio_audiobuf[0]) {
...@@ -119,12 +120,13 @@ MINTMCSN_CheckAudio(_THIS) ...@@ -119,12 +120,13 @@ MINTMCSN_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(this->spec.format))); SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels)); DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq)); DEBUG_PRINT(("freq=%d\n", this->spec.freq));
if (this->spec.channels > 2) { if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */ this->spec.channels = 2; /* no more than stereo! */
} }
/* Check formats available */ /* Check formats available */
...@@ -132,7 +134,7 @@ MINTMCSN_CheckAudio(_THIS) ...@@ -132,7 +134,7 @@ MINTMCSN_CheckAudio(_THIS)
switch (cookie_mcsn->play) { switch (cookie_mcsn->play) {
case MCSN_ST: case MCSN_ST:
this->spec.channels = 1; this->spec.channels = 1;
this->spec.format = AUDIO_S8; /* FIXME: is it signed or unsigned ? */ this->spec.format = AUDIO_S8; /* FIXME: is it signed or unsigned ? */
SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1); SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1);
break; break;
case MCSN_TT: /* Also STE, Mega STE */ case MCSN_TT: /* Also STE, Mega STE */
...@@ -170,10 +172,10 @@ MINTMCSN_CheckAudio(_THIS) ...@@ -170,10 +172,10 @@ MINTMCSN_CheckAudio(_THIS)
(1 << i) - 1, -1); (1 << i) - 1, -1);
} }
} }
this->spec.format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */ this->spec.format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
if ((SDL_AUDIO_BITSIZE(this->spec.format)) == 16) { if ((SDL_AUDIO_BITSIZE(this->spec.format)) == 16) {
this->spec.format |= SDL_AUDIO_MASK_ENDIAN; /* Audio is always big endian */ this->spec.format |= SDL_AUDIO_MASK_ENDIAN; /* Audio is always big endian */
this->spec.channels = 2; /* 16 bits always stereo */ this->spec.channels = 2; /* 16 bits always stereo */
} }
break; break;
} }
...@@ -194,7 +196,8 @@ MINTMCSN_CheckAudio(_THIS) ...@@ -194,7 +196,8 @@ MINTMCSN_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(this->spec.format))); SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels)); DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq)); DEBUG_PRINT(("freq=%d\n", this->spec.freq));
...@@ -288,7 +291,7 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -288,7 +291,7 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -300,7 +303,8 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -300,7 +303,8 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture)
/* Allocate memory for audio buffers in DMA-able RAM */ /* Allocate memory for audio buffers in DMA-able RAM */
DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); SDL_MintAudio_audiobuf[0] =
Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
if (SDL_MintAudio_audiobuf[0] == NULL) { if (SDL_MintAudio_audiobuf[0] == NULL) {
SDL_free(this->hidden); SDL_free(this->hidden);
this->hidden = NULL; this->hidden = NULL;
...@@ -309,7 +313,8 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -309,7 +313,8 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture)
} }
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
SDL_MintAudio_numbuf = 0; SDL_MintAudio_numbuf = 0;
SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
this->spec.size * 2);
SDL_MintAudio_audiosize = this->spec.size; SDL_MintAudio_audiosize = this->spec.size;
SDL_MintAudio_mutex = 0; SDL_MintAudio_mutex = 0;
...@@ -323,11 +328,11 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -323,11 +328,11 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture)
/* Setup audio hardware */ /* Setup audio hardware */
MINTMCSN_InitAudio(this); MINTMCSN_InitAudio(this);
return 1; /* good to go. */ return 1; /* good to go. */
} }
static int static int
MINTMCSN_Init(SDL_AudioDriverImpl *impl) MINTMCSN_Init(SDL_AudioDriverImpl * impl)
{ {
unsigned long dummy = 0; unsigned long dummy = 0;
......
...@@ -98,7 +98,8 @@ MINTSTFA_CloseDevice(_THIS) ...@@ -98,7 +98,8 @@ MINTSTFA_CloseDevice(_THIS)
Super(oldpile); Super(oldpile);
/* Wait if currently playing sound */ /* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {} while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */ /* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) { if (SDL_MintAudio_audiobuf[0]) {
...@@ -120,16 +121,17 @@ MINTSTFA_CheckAudio(_THIS) ...@@ -120,16 +121,17 @@ MINTSTFA_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(this->spec.format))); SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels)); DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq)); DEBUG_PRINT(("freq=%d\n", this->spec.freq));
if (SDL_AUDIO_BITSIZE(this->spec.format) > 16) { if (SDL_AUDIO_BITSIZE(this->spec.format) > 16) {
this->spec.format = AUDIO_S16SYS; /* clamp out int32/float32 ... */ this->spec.format = AUDIO_S16SYS; /* clamp out int32/float32 ... */
} }
if (this->spec.channels > 2) { if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */ this->spec.channels = 2; /* no more than stereo! */
} }
/* Check formats available */ /* Check formats available */
...@@ -154,7 +156,8 @@ MINTSTFA_CheckAudio(_THIS) ...@@ -154,7 +156,8 @@ MINTSTFA_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(this->spec.format))); SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels)); DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq)); DEBUG_PRINT(("freq=%d\n", this->spec.freq));
...@@ -221,7 +224,7 @@ MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -221,7 +224,7 @@ MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -233,16 +236,18 @@ MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -233,16 +236,18 @@ MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture)
/* Allocate memory for audio buffers in DMA-able RAM */ /* Allocate memory for audio buffers in DMA-able RAM */
DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); SDL_MintAudio_audiobuf[0] =
Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
if (SDL_MintAudio_audiobuf[0] == NULL) { if (SDL_MintAudio_audiobuf[0] == NULL) {
SDL_OutOfMemory() SDL_OutOfMemory()
SDL_free(this->hidden); SDL_free(this->hidden);
this->hidden = NULL; this->hidden = NULL;
return 0; return 0;
} }
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
SDL_MintAudio_numbuf = 0; SDL_MintAudio_numbuf = 0;
SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
this->spec.size * 2);
SDL_MintAudio_audiosize = this->spec.size; SDL_MintAudio_audiosize = this->spec.size;
SDL_MintAudio_mutex = 0; SDL_MintAudio_mutex = 0;
...@@ -256,12 +261,12 @@ MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -256,12 +261,12 @@ MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture)
/* Setup audio hardware */ /* Setup audio hardware */
MINTSTFA_InitAudio(this); MINTSTFA_InitAudio(this);
return 1; /* good to go. */ return 1; /* good to go. */
} }
static int static int
MINTSTFA_Init(SDL_AudioDriverImpl *impl) MINTSTFA_Init(SDL_AudioDriverImpl * impl)
{ {
/* Cookie _MCH present ? if not, assume ST machine */ /* Cookie _MCH present ? if not, assume ST machine */
if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
......
...@@ -90,7 +90,8 @@ MINTXBIOS_CloseDevice(_THIS) ...@@ -90,7 +90,8 @@ MINTXBIOS_CloseDevice(_THIS)
} }
/* Wait if currently playing sound */ /* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {} while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */ /* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) { if (SDL_MintAudio_audiobuf[0]) {
...@@ -267,18 +268,19 @@ MINTXBIOS_CheckAudio(_THIS) ...@@ -267,18 +268,19 @@ MINTXBIOS_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(this->spec.format))); SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels)); DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq)); DEBUG_PRINT(("freq=%d\n", this->spec.freq));
this->spec.format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */ this->spec.format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
/* clamp out int32/float32 */ /* clamp out int32/float32 */
if (SDL_AUDIO_BITSIZE(this->spec.format) >= 16) { if (SDL_AUDIO_BITSIZE(this->spec.format) >= 16) {
this->spec.format = AUDIO_S16MSB; /* Audio is always big endian */ this->spec.format = AUDIO_S16MSB; /* Audio is always big endian */
this->spec.channels = 2; /* 16 bits always stereo */ this->spec.channels = 2; /* 16 bits always stereo */
} else if (this->spec.channels > 2) { } else if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */ this->spec.channels = 2; /* no more than stereo! */
} }
MINTAUDIO_freqcount = 0; MINTAUDIO_freqcount = 0;
...@@ -314,7 +316,8 @@ MINTXBIOS_CheckAudio(_THIS) ...@@ -314,7 +316,8 @@ MINTXBIOS_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(this->spec.format))); SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels)); DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq)); DEBUG_PRINT(("freq=%d\n", this->spec.freq));
...@@ -405,7 +408,7 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -405,7 +408,7 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -417,7 +420,8 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -417,7 +420,8 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture)
/* Allocate memory for audio buffers in DMA-able RAM */ /* Allocate memory for audio buffers in DMA-able RAM */
DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); SDL_MintAudio_audiobuf[0] =
Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
if (SDL_MintAudio_audiobuf[0] == NULL) { if (SDL_MintAudio_audiobuf[0] == NULL) {
SDL_free(this->hidden); SDL_free(this->hidden);
this->hidden = NULL; this->hidden = NULL;
...@@ -426,7 +430,8 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -426,7 +430,8 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture)
} }
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
SDL_MintAudio_numbuf = 0; SDL_MintAudio_numbuf = 0;
SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
this->spec.size * 2);
SDL_MintAudio_audiosize = this->spec.size; SDL_MintAudio_audiosize = this->spec.size;
SDL_MintAudio_mutex = 0; SDL_MintAudio_mutex = 0;
...@@ -440,11 +445,11 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -440,11 +445,11 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture)
/* Setup audio hardware */ /* Setup audio hardware */
MINTXBIOS_InitAudio(this); MINTXBIOS_InitAudio(this);
return 1; /* good to go. */ return 1; /* good to go. */
} }
static int static int
MINTXBIOS_Init(SDL_AudioDriverImpl *impl) MINTXBIOS_Init(SDL_AudioDriverImpl * impl)
{ {
unsigned long dummy = 0; unsigned long dummy = 0;
/*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); */ /*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); */
......
...@@ -63,7 +63,7 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -63,7 +63,7 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -78,7 +78,7 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -78,7 +78,7 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture)
return 0; return 0;
} }
SDL_memset(this->hidden->shm, '\0', sizeof (*this->hidden->shm)); SDL_memset(this->hidden->shm, '\0', sizeof(*this->hidden->shm));
this->hidden->shm->sound = 0; this->hidden->shm->sound = 0;
this->hidden->shm->wFmt.wf.wFormatTag = WAVE_FORMAT_PCM; this->hidden->shm->wFmt.wf.wFormatTag = WAVE_FORMAT_PCM;
...@@ -88,13 +88,13 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -88,13 +88,13 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture)
!valid_format && test_format;) { !valid_format && test_format;) {
valid_format = 1; valid_format = 1;
switch (test_format) { switch (test_format) {
case AUDIO_U8: case AUDIO_U8:
case AUDIO_S16: case AUDIO_S16:
case AUDIO_S32: case AUDIO_S32:
break; break;
default: default:
valid_format = 0; valid_format = 0;
test_format = SDL_NextAudioFormat(); test_format = SDL_NextAudioFormat();
} }
} }
...@@ -111,11 +111,11 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -111,11 +111,11 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture)
this->hidden->shm->wFmt.wf.nChannels = this->spec.channels; this->hidden->shm->wFmt.wf.nChannels = this->spec.channels;
this->hidden->shm->wFmt.wf.nSamplesPerSec = this->spec.freq; this->hidden->shm->wFmt.wf.nSamplesPerSec = this->spec.freq;
this->hidden->shm->wFmt.wf.nBlockAlign = this->hidden->shm->wFmt.wf.nBlockAlign =
this->hidden->shm->wFmt.wf.nChannels * this->hidden->shm->wFmt.wf.nChannels *
this->hidden->shm->wFmt.wBitsPerSample / 8; this->hidden->shm->wFmt.wBitsPerSample / 8;
this->hidden->shm->wFmt.wf.nAvgBytesPerSec = this->hidden->shm->wFmt.wf.nAvgBytesPerSec =
this->hidden->shm->wFmt.wf.nSamplesPerSec * this->hidden->shm->wFmt.wf.nSamplesPerSec *
this->hidden->shm->wFmt.wf.nBlockAlign; this->hidden->shm->wFmt.wf.nBlockAlign;
/* Check the buffer size -- minimum of 1/4 second (word aligned) */ /* Check the buffer size -- minimum of 1/4 second (word aligned) */
if (this->spec.samples < (this->spec.freq / 4)) if (this->spec.samples < (this->spec.freq / 4))
...@@ -150,8 +150,8 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -150,8 +150,8 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture)
this->hidden->shm->wHdr[i].dwBufferLength = this->spec.size; this->hidden->shm->wHdr[i].dwBufferLength = this->spec.size;
this->hidden->shm->wHdr[i].dwFlags = 0; this->hidden->shm->wHdr[i].dwFlags = 0;
this->hidden->shm->wHdr[i].dwUser = i; this->hidden->shm->wHdr[i].dwUser = i;
this->hidden->shm->wHdr[i].dwLoops = 0; /* loop control counter */ this->hidden->shm->wHdr[i].dwLoops = 0; /* loop control counter */
this->hidden->shm->wHdr[i].lpNext = NULL; /* reserved for driver */ this->hidden->shm->wHdr[i].lpNext = NULL; /* reserved for driver */
this->hidden->shm->wHdr[i].reserved = 0; this->hidden->shm->wHdr[i].reserved = 0;
inUse[i] = FALSE; inUse[i] = FALSE;
} }
...@@ -183,7 +183,7 @@ MME_PlayDevice(_THIS) ...@@ -183,7 +183,7 @@ MME_PlayDevice(_THIS)
/* Queue it up */ /* Queue it up */
waveOutWrite(this->hidden->shm->sound, waveOutWrite(this->hidden->shm->sound,
&(this->hidden->shm->wHdr[this->hidden->next_buffer]), &(this->hidden->shm->wHdr[this->hidden->next_buffer]),
sizeof (WAVEHDR)); sizeof(WAVEHDR));
this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS; this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS;
} }
...@@ -238,7 +238,7 @@ MME_CloseDevice(_THIS) ...@@ -238,7 +238,7 @@ MME_CloseDevice(_THIS)
} }
static int static int
MME_Init(SDL_AudioDriverImpl *impl) MME_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = MME_OpenDevice; impl->OpenDevice = MME_OpenDevice;
......
...@@ -43,19 +43,19 @@ ...@@ -43,19 +43,19 @@
static struct SDL_PrivateAudioData *this2 = NULL; static struct SDL_PrivateAudioData *this2 = NULL;
static void (*NAS_AuCloseServer)(AuServer *); static void (*NAS_AuCloseServer) (AuServer *);
static void (*NAS_AuNextEvent)(AuServer *, AuBool, AuEvent *); static void (*NAS_AuNextEvent) (AuServer *, AuBool, AuEvent *);
static AuBool (*NAS_AuDispatchEvent)(AuServer *, AuEvent *); static AuBool(*NAS_AuDispatchEvent) (AuServer *, AuEvent *);
static AuFlowID (*NAS_AuCreateFlow)(AuServer *, AuStatus *); static AuFlowID(*NAS_AuCreateFlow) (AuServer *, AuStatus *);
static void (*NAS_AuStartFlow)(AuServer *, AuFlowID, AuStatus *); static void (*NAS_AuStartFlow) (AuServer *, AuFlowID, AuStatus *);
static void (*NAS_AuSetElements) static void (*NAS_AuSetElements)
(AuServer *, AuFlowID, AuBool, int, AuElement *, AuStatus *); (AuServer *, AuFlowID, AuBool, int, AuElement *, AuStatus *);
static void (*NAS_AuWriteElement) static void (*NAS_AuWriteElement)
(AuServer *, AuFlowID, int, AuUint32, AuPointer, AuBool, AuStatus *); (AuServer *, AuFlowID, int, AuUint32, AuPointer, AuBool, AuStatus *);
static AuServer *(*NAS_AuOpenServer) static AuServer *(*NAS_AuOpenServer)
(_AuConst char *, int, _AuConst char *, int, _AuConst char *, char **); (_AuConst char *, int, _AuConst char *, int, _AuConst char *, char **);
static AuEventHandlerRec *(*NAS_AuRegisterEventHandler) static AuEventHandlerRec *(*NAS_AuRegisterEventHandler)
(AuServer *, AuMask, int, AuID, AuEventHandlerCallback, AuPointer); (AuServer *, AuMask, int, AuID, AuEventHandlerCallback, AuPointer);
#ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC #ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC
...@@ -80,7 +80,8 @@ load_nas_sym(const char *fn, void **addr) ...@@ -80,7 +80,8 @@ load_nas_sym(const char *fn, void **addr)
#define SDL_NAS_SYM(x) NAS_##x = x #define SDL_NAS_SYM(x) NAS_##x = x
#endif #endif
static int load_nas_syms(void) static int
load_nas_syms(void)
{ {
SDL_NAS_SYM(AuCloseServer); SDL_NAS_SYM(AuCloseServer);
SDL_NAS_SYM(AuNextEvent); SDL_NAS_SYM(AuNextEvent);
...@@ -93,6 +94,7 @@ static int load_nas_syms(void) ...@@ -93,6 +94,7 @@ static int load_nas_syms(void)
SDL_NAS_SYM(AuRegisterEventHandler); SDL_NAS_SYM(AuRegisterEventHandler);
return 0; return 0;
} }
#undef SDL_NAS_SYM #undef SDL_NAS_SYM
#ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC #ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC
...@@ -120,7 +122,7 @@ LoadNASLibrary(void) ...@@ -120,7 +122,7 @@ LoadNASLibrary(void)
SDL_strlcpy(err, origerr, len); SDL_strlcpy(err, origerr, len);
retval = -1; retval = -1;
SDL_SetError("NAS: SDL_LoadObject('%s') failed: %s\n", SDL_SetError("NAS: SDL_LoadObject('%s') failed: %s\n",
nas_library, err); nas_library, err);
} else { } else {
retval = load_nas_syms(); retval = load_nas_syms();
if (retval < 0) { if (retval < 0) {
...@@ -175,7 +177,8 @@ NAS_PlayDevice(_THIS) ...@@ -175,7 +177,8 @@ NAS_PlayDevice(_THIS)
/* Write the audio data */ /* Write the audio data */
NAS_AuWriteElement(this->hidden->aud, this->hidden->flow, 0, NAS_AuWriteElement(this->hidden->aud, this->hidden->flow, 0,
this->hidden->mixlen, this->hidden->mixbuf, AuFalse, NULL); this->hidden->mixlen, this->hidden->mixbuf, AuFalse,
NULL);
this->hidden->written += this->hidden->mixlen; this->hidden->written += this->hidden->mixlen;
...@@ -289,7 +292,7 @@ NAS_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -289,7 +292,7 @@ NAS_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -339,12 +342,13 @@ NAS_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -339,12 +342,13 @@ NAS_OpenDevice(_THIS, const char *devname, int iscapture)
this2 = this->hidden; this2 = this->hidden;
AuMakeElementImportClient(elms,this->spec.freq,format,this->spec.channels, AuMakeElementImportClient(elms, this->spec.freq, format,
AuTrue, buffer_size, buffer_size / 4, 0, NULL); this->spec.channels, AuTrue, buffer_size,
buffer_size / 4, 0, NULL);
AuMakeElementExportDevice(elms + 1, 0, this->hidden->dev, this->spec.freq, AuMakeElementExportDevice(elms + 1, 0, this->hidden->dev, this->spec.freq,
AuUnlimitedSamples, 0, NULL); AuUnlimitedSamples, 0, NULL);
NAS_AuSetElements(this->hidden->aud, this->hidden->flow, NAS_AuSetElements(this->hidden->aud, this->hidden->flow, AuTrue, 2, elms,
AuTrue, 2, elms, NULL); NULL);
NAS_AuRegisterEventHandler(this->hidden->aud, AuEventHandlerIDMask, 0, NAS_AuRegisterEventHandler(this->hidden->aud, AuEventHandlerIDMask, 0,
this->hidden->flow, event_handler, this->hidden->flow, event_handler,
(AuPointer) NULL); (AuPointer) NULL);
...@@ -372,7 +376,7 @@ NAS_Deinitialize(void) ...@@ -372,7 +376,7 @@ NAS_Deinitialize(void)
} }
static int static int
NAS_Init(SDL_AudioDriverImpl *impl) NAS_Init(SDL_AudioDriverImpl * impl)
{ {
if (LoadNASLibrary() < 0) { if (LoadNASLibrary() < 0) {
return 0; return 0;
...@@ -392,7 +396,7 @@ NAS_Init(SDL_AudioDriverImpl *impl) ...@@ -392,7 +396,7 @@ NAS_Init(SDL_AudioDriverImpl *impl)
impl->GetDeviceBuf = NAS_GetDeviceBuf; impl->GetDeviceBuf = NAS_GetDeviceBuf;
impl->CloseDevice = NAS_CloseDevice; impl->CloseDevice = NAS_CloseDevice;
impl->Deinitialize = NAS_Deinitialize; impl->Deinitialize = NAS_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this true? */ impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this true? */
return 1; return 1;
} }
......
...@@ -141,7 +141,8 @@ NTO_WaitDevice(_THIS) ...@@ -141,7 +141,8 @@ NTO_WaitDevice(_THIS)
FD_SET(this->hidden->audio_fd, &wfds); FD_SET(this->hidden->audio_fd, &wfds);
do { do {
selectret = select(this->hidden->audio_fd+1, NULL, &wfds, NULL, NULL); selectret =
select(this->hidden->audio_fd + 1, NULL, &wfds, NULL, NULL);
switch (selectret) { switch (selectret) {
case -1: case -1:
case 0: case 0:
...@@ -185,7 +186,7 @@ NTO_PlayDevice(_THIS) ...@@ -185,7 +186,7 @@ NTO_PlayDevice(_THIS)
pcmbuffer += written * this->spec.channels; pcmbuffer += written * this->spec.channels;
continue; continue;
} else if ((errno == EINVAL) || (errno == EIO)) { } else if ((errno == EINVAL) || (errno == EIO)) {
SDL_memset(&cstatus, 0, sizeof (cstatus)); SDL_memset(&cstatus, 0, sizeof(cstatus));
cstatus.channel = SND_PCM_CHANNEL_PLAYBACK; cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
rval = snd_pcm_plugin_status(this->hidden->audio_handle, rval = snd_pcm_plugin_status(this->hidden->audio_handle,
&cstatus); &cstatus);
...@@ -194,10 +195,10 @@ NTO_PlayDevice(_THIS) ...@@ -194,10 +195,10 @@ NTO_PlayDevice(_THIS)
return; return;
} }
if ( (cstatus.status == SND_PCM_STATUS_UNDERRUN) || if ((cstatus.status == SND_PCM_STATUS_UNDERRUN) ||
(cstatus.status == SND_PCM_STATUS_READY)) { (cstatus.status == SND_PCM_STATUS_READY)) {
rval = snd_pcm_plugin_prepare(this->hidden->audio_handle, rval = snd_pcm_plugin_prepare(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK); SND_PCM_CHANNEL_PLAYBACK);
if (rval < 0) { if (rval < 0) {
NTO_SetError("snd_pcm_plugin_prepare", rval); NTO_SetError("snd_pcm_plugin_prepare", rval);
return; return;
...@@ -258,7 +259,7 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -258,7 +259,7 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -374,7 +375,7 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -374,7 +375,7 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture)
} }
/* Make sure channel is setup right one last time */ /* Make sure channel is setup right one last time */
SDL_memset(&csetup, '\0', sizeof (csetup)); SDL_memset(&csetup, '\0', sizeof(csetup));
csetup.channel = SND_PCM_CHANNEL_PLAYBACK; csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
if (snd_pcm_plugin_setup(this->hidden->audio_handle, &csetup) < 0) { if (snd_pcm_plugin_setup(this->hidden->audio_handle, &csetup) < 0) {
NTO_CloseDevice(this); NTO_CloseDevice(this);
...@@ -398,17 +399,20 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -398,17 +399,20 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture)
* (Note that buffer size must be a multiple of fragment size, so find * (Note that buffer size must be a multiple of fragment size, so find
* closest multiple) * closest multiple)
*/ */
this->hidden->pcm_buf = (Uint8 *) SDL_AllocAudioMem(this->hidden->pcm_len); this->hidden->pcm_buf =
(Uint8 *) SDL_AllocAudioMem(this->hidden->pcm_len);
if (this->hidden->pcm_buf == NULL) { if (this->hidden->pcm_buf == NULL) {
NTO_CloseDevice(this); NTO_CloseDevice(this);
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
} }
SDL_memset(this->hidden->pcm_buf,this->spec.silence,this->hidden->pcm_len); SDL_memset(this->hidden->pcm_buf, this->spec.silence,
this->hidden->pcm_len);
/* get the file descriptor */ /* get the file descriptor */
this->hidden->audio_fd = snd_pcm_file_descriptor(this->hidden->audio_handle, this->hidden->audio_fd =
SND_PCM_CHANNEL_PLAYBACK); snd_pcm_file_descriptor(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
if (this->hidden->audio_fd < 0) { if (this->hidden->audio_fd < 0) {
NTO_CloseDevice(this); NTO_CloseDevice(this);
NTO_SetError("snd_pcm_file_descriptor", rval); NTO_SetError("snd_pcm_file_descriptor", rval);
...@@ -430,7 +434,7 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -430,7 +434,7 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture)
static int static int
NTO_Init(SDL_AudioDriverImpl *impl) NTO_Init(SDL_AudioDriverImpl * impl)
{ {
/* See if we can open a nonblocking channel. */ /* See if we can open a nonblocking channel. */
snd_pcm_t *handle = NULL; snd_pcm_t *handle = NULL;
...@@ -451,7 +455,7 @@ NTO_Init(SDL_AudioDriverImpl *impl) ...@@ -451,7 +455,7 @@ NTO_Init(SDL_AudioDriverImpl *impl)
impl->PlayDevice = NTO_PlayDevice; impl->PlayDevice = NTO_PlayDevice;
impl->GetDeviceBuf = NTO_GetDeviceBuf; impl->GetDeviceBuf = NTO_GetDeviceBuf;
impl->CloseDevice = NTO_CloseDevice; impl->CloseDevice = NTO_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */ impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */
return 1; return 1;
} }
......
...@@ -137,7 +137,9 @@ PAUDIO_WaitDevice(_THIS) ...@@ -137,7 +137,9 @@ PAUDIO_WaitDevice(_THIS)
/* Use timer for general audio synchronization */ /* Use timer for general audio synchronization */
Sint32 ticks; Sint32 ticks;
ticks = ((Sint32)(this->hidden->next_frame-SDL_GetTicks()))-FUDGE_TICKS; ticks =
((Sint32) (this->hidden->next_frame - SDL_GetTicks())) -
FUDGE_TICKS;
if (ticks > 0) { if (ticks > 0) {
SDL_Delay(ticks); SDL_Delay(ticks);
} }
...@@ -170,7 +172,8 @@ PAUDIO_WaitDevice(_THIS) ...@@ -170,7 +172,8 @@ PAUDIO_WaitDevice(_THIS)
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
fprintf(stderr, "Waiting for audio to get ready\n"); fprintf(stderr, "Waiting for audio to get ready\n");
#endif #endif
if (select(this->hidden->audio_fd+1,NULL,&fdset,NULL,&timeout) <= 0) { if (select(this->hidden->audio_fd + 1, NULL, &fdset, NULL, &timeout)
<= 0) {
const char *message = const char *message =
"Audio timeout - buggy audio driver? (disabled)"; "Audio timeout - buggy audio driver? (disabled)";
/* /*
...@@ -264,7 +267,7 @@ PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -264,7 +267,7 @@ PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -515,7 +518,7 @@ PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -515,7 +518,7 @@ PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Check to see if we need to use select() workaround */ /* Check to see if we need to use select() workaround */
if (workaround != NULL) { if (workaround != NULL) {
this->hidden->frame_ticks = (float) (this->spec.samples * 1000) / this->hidden->frame_ticks = (float) (this->spec.samples * 1000) /
this->spec.freq; this->spec.freq;
this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks; this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks;
} }
...@@ -524,7 +527,7 @@ PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -524,7 +527,7 @@ PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
} }
static int static int
PAUDIO_Init(SDL_AudioDriverImpl *impl) PAUDIO_Init(SDL_AudioDriverImpl * impl)
{ {
int fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0); int fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
if (fd < 0) { if (fd < 0) {
...@@ -539,7 +542,7 @@ PAUDIO_Init(SDL_AudioDriverImpl *impl) ...@@ -539,7 +542,7 @@ PAUDIO_Init(SDL_AudioDriverImpl *impl)
impl->PlayDevice = DSP_WaitDevice; impl->PlayDevice = DSP_WaitDevice;
impl->GetDeviceBuf = DSP_GetDeviceBuf; impl->GetDeviceBuf = DSP_GetDeviceBuf;
impl->CloseDevice = DSP_CloseDevice; impl->CloseDevice = DSP_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */ impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */
return 1; return 1;
} }
......
...@@ -107,7 +107,8 @@ WINWAVEOUT_WaitDevice(_THIS) ...@@ -107,7 +107,8 @@ WINWAVEOUT_WaitDevice(_THIS)
Uint8 * Uint8 *
WINWAVEOUT_GetDeviceBuf(_THIS) WINWAVEOUT_GetDeviceBuf(_THIS)
{ {
return (Uint8 *) (this->hidden->wavebuf[this->hidden->next_buffer].lpData); return (Uint8 *) (this->hidden->wavebuf[this->hidden->next_buffer].
lpData);
} }
void void
...@@ -116,7 +117,7 @@ WINWAVEOUT_PlayDevice(_THIS) ...@@ -116,7 +117,7 @@ WINWAVEOUT_PlayDevice(_THIS)
/* Queue it up */ /* Queue it up */
waveOutWrite(this->hidden->sound, waveOutWrite(this->hidden->sound,
&this->hidden->wavebuf[this->hidden->next_buffer], &this->hidden->wavebuf[this->hidden->next_buffer],
sizeof (this->hidden->wavebuf[0])); sizeof(this->hidden->wavebuf[0]));
this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS; this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS;
} }
...@@ -165,7 +166,7 @@ WINWAVEOUT_CloseDevice(_THIS) ...@@ -165,7 +166,7 @@ WINWAVEOUT_CloseDevice(_THIS)
if (this->hidden->wavebuf[i].dwUser != 0xFFFF) { if (this->hidden->wavebuf[i].dwUser != 0xFFFF) {
waveOutUnprepareHeader(this->hidden->sound, waveOutUnprepareHeader(this->hidden->sound,
&this->hidden->wavebuf[i], &this->hidden->wavebuf[i],
sizeof (this->hidden->wavebuf[i])); sizeof(this->hidden->wavebuf[i]));
this->hidden->wavebuf[i].dwUser = 0xFFFF; this->hidden->wavebuf[i].dwUser = 0xFFFF;
} }
} }
...@@ -192,7 +193,7 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -192,7 +193,7 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -207,15 +208,15 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -207,15 +208,15 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
valid_datatype = 1; valid_datatype = 1;
this->spec.format = test_format; this->spec.format = test_format;
switch (test_format) { switch (test_format) {
case AUDIO_U8: case AUDIO_U8:
case AUDIO_S16: case AUDIO_S16:
case AUDIO_S32: case AUDIO_S32:
break; /* valid. */ break; /* valid. */
default: default:
valid_datatype = 0; valid_datatype = 0;
test_format = SDL_NextAudioFormat(); test_format = SDL_NextAudioFormat();
break; break;
} }
} }
...@@ -226,12 +227,12 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -226,12 +227,12 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
} }
/* Set basic WAVE format parameters */ /* Set basic WAVE format parameters */
SDL_memset(&waveformat, '\0', sizeof (waveformat)); SDL_memset(&waveformat, '\0', sizeof(waveformat));
waveformat.wFormatTag = WAVE_FORMAT_PCM; waveformat.wFormatTag = WAVE_FORMAT_PCM;
waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format); waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
if (this->spec.channels > 2) if (this->spec.channels > 2)
this->spec.channels = 2; /* !!! FIXME: is this right? */ this->spec.channels = 2; /* !!! FIXME: is this right? */
waveformat.nChannels = this->spec.channels; waveformat.nChannels = this->spec.channels;
waveformat.nSamplesPerSec = this->spec.freq; waveformat.nSamplesPerSec = this->spec.freq;
...@@ -273,11 +274,11 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -273,11 +274,11 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
#endif #endif
/* Create the audio buffer semaphore */ /* Create the audio buffer semaphore */
this->hidden->audio_sem = this->hidden->audio_sem =
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300) #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
CreateSemaphoreCE(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL); CreateSemaphoreCE(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
#else #else
CreateSemaphore(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL); CreateSemaphore(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
#endif #endif
if (this->hidden->audio_sem == NULL) { if (this->hidden->audio_sem == NULL) {
WINWAVEOUT_CloseDevice(this); WINWAVEOUT_CloseDevice(this);
...@@ -286,7 +287,8 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -286,7 +287,8 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
} }
/* Create the sound buffers */ /* Create the sound buffers */
this->hidden->mixbuf = (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size); this->hidden->mixbuf =
(Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size);
if (this->hidden->mixbuf == NULL) { if (this->hidden->mixbuf == NULL) {
WINWAVEOUT_CloseDevice(this); WINWAVEOUT_CloseDevice(this);
SDL_OutOfMemory(); SDL_OutOfMemory();
...@@ -294,14 +296,14 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -294,14 +296,14 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
} }
for (i = 0; i < NUM_BUFFERS; ++i) { for (i = 0; i < NUM_BUFFERS; ++i) {
SDL_memset(&this->hidden->wavebuf[i], '\0', SDL_memset(&this->hidden->wavebuf[i], '\0',
sizeof (this->hidden->wavebuf[i])); sizeof(this->hidden->wavebuf[i]));
this->hidden->wavebuf[i].dwBufferLength = this->spec.size; this->hidden->wavebuf[i].dwBufferLength = this->spec.size;
this->hidden->wavebuf[i].dwFlags = WHDR_DONE; this->hidden->wavebuf[i].dwFlags = WHDR_DONE;
this->hidden->wavebuf[i].lpData = this->hidden->wavebuf[i].lpData =
(LPSTR) &this->hidden->mixbuf[i * this->spec.size]; (LPSTR) & this->hidden->mixbuf[i * this->spec.size];
result = waveOutPrepareHeader(this->hidden->sound, result = waveOutPrepareHeader(this->hidden->sound,
&this->hidden->wavebuf[i], &this->hidden->wavebuf[i],
sizeof (this->hidden->wavebuf[i])); sizeof(this->hidden->wavebuf[i]));
if (result != MMSYSERR_NOERROR) { if (result != MMSYSERR_NOERROR) {
WINWAVEOUT_CloseDevice(this); WINWAVEOUT_CloseDevice(this);
SetMMerror("waveOutPrepareHeader()", result); SetMMerror("waveOutPrepareHeader()", result);
...@@ -309,12 +311,12 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -309,12 +311,12 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
} }
} }
return 1; /* Ready to go! */ return 1; /* Ready to go! */
} }
static int static int
WINWAVEOUT_Init(SDL_AudioDriverImpl *impl) WINWAVEOUT_Init(SDL_AudioDriverImpl * impl)
{ {
/* Set the function pointers */ /* Set the function pointers */
impl->OpenDevice = WINWAVEOUT_OpenDevice; impl->OpenDevice = WINWAVEOUT_OpenDevice;
...@@ -324,7 +326,7 @@ WINWAVEOUT_Init(SDL_AudioDriverImpl *impl) ...@@ -324,7 +326,7 @@ WINWAVEOUT_Init(SDL_AudioDriverImpl *impl)
impl->WaitDone = WINWAVEOUT_WaitDone; impl->WaitDone = WINWAVEOUT_WaitDone;
impl->GetDeviceBuf = WINWAVEOUT_GetDeviceBuf; impl->GetDeviceBuf = WINWAVEOUT_GetDeviceBuf;
impl->CloseDevice = WINWAVEOUT_CloseDevice; impl->CloseDevice = WINWAVEOUT_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Is this true? */ impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Is this true? */
return 1; return 1;
} }
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
/* DirectX function pointers for audio */ /* DirectX function pointers for audio */
static HINSTANCE DSoundDLL = NULL; static HINSTANCE DSoundDLL = NULL;
static HRESULT (WINAPI *DSoundCreate)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN) = NULL; static HRESULT(WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN) =
NULL;
static void static void
DSOUND_Unload(void) DSOUND_Unload(void)
...@@ -70,7 +71,7 @@ DSOUND_Load(void) ...@@ -70,7 +71,7 @@ DSOUND_Load(void)
SDL_SetError("DirectSound: System doesn't appear to have DX5."); SDL_SetError("DirectSound: System doesn't appear to have DX5.");
} else { } else {
DSoundCreate = (void *) GetProcAddress(DSoundDLL, DSoundCreate = (void *) GetProcAddress(DSoundDLL,
TEXT("DirectSoundCreate")); TEXT("DirectSoundCreate"));
} }
if (!DSoundCreate) { if (!DSoundCreate) {
...@@ -271,14 +272,14 @@ DSOUND_GetDeviceBuf(_THIS) ...@@ -271,14 +272,14 @@ DSOUND_GetDeviceBuf(_THIS)
/* Lock the audio buffer */ /* Lock the audio buffer */
result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor, result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
this->hidden->mixlen, this->hidden->mixlen,
(LPVOID *) &this->hidden->locked_buf, (LPVOID *) & this->hidden->locked_buf,
&rawlen, NULL, &junk, 0); &rawlen, NULL, &junk, 0);
if (result == DSERR_BUFFERLOST) { if (result == DSERR_BUFFERLOST) {
IDirectSoundBuffer_Restore(this->hidden->mixbuf); IDirectSoundBuffer_Restore(this->hidden->mixbuf);
result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor, result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
this->hidden->mixlen, this->hidden->mixlen,
(LPVOID *) &this->hidden->locked_buf, (LPVOID *) & this->hidden->
&rawlen, NULL, &junk, 0); locked_buf, &rawlen, NULL, &junk, 0);
} }
if (result != DS_OK) { if (result != DS_OK) {
SetDSerror("DirectSound Lock", result); SetDSerror("DirectSound Lock", result);
...@@ -326,7 +327,7 @@ DSOUND_CloseDevice(_THIS) ...@@ -326,7 +327,7 @@ DSOUND_CloseDevice(_THIS)
number of audio chunks available in the created buffer. number of audio chunks available in the created buffer.
*/ */
static int static int
CreateSecondary(_THIS, HWND focus, WAVEFORMATEX *wavefmt) CreateSecondary(_THIS, HWND focus, WAVEFORMATEX * wavefmt)
{ {
LPDIRECTSOUND sndObj = this->hidden->sound; LPDIRECTSOUND sndObj = this->hidden->sound;
LPDIRECTSOUNDBUFFER *sndbuf = &this->hidden->mixbuf; LPDIRECTSOUNDBUFFER *sndbuf = &this->hidden->mixbuf;
...@@ -405,7 +406,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -405,7 +406,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) { if (this->hidden == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return 0; return 0;
...@@ -414,12 +415,12 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -414,12 +415,12 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
while ((!valid_format) && (test_format)) { while ((!valid_format) && (test_format)) {
switch (test_format) { switch (test_format) {
case AUDIO_U8: case AUDIO_U8:
case AUDIO_S16: case AUDIO_S16:
case AUDIO_S32: case AUDIO_S32:
this->spec.format = test_format; this->spec.format = test_format;
valid_format = 1; valid_format = 1;
break; break;
} }
test_format = SDL_NextAudioFormat(); test_format = SDL_NextAudioFormat();
} }
...@@ -461,7 +462,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -461,7 +462,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
/* The buffer will auto-start playing in DSOUND_WaitDevice() */ /* The buffer will auto-start playing in DSOUND_WaitDevice() */
this->hidden->mixlen = this->spec.size; this->hidden->mixlen = this->spec.size;
return 1; /* good to go. */ return 1; /* good to go. */
} }
...@@ -473,7 +474,7 @@ DSOUND_Deinitialize(void) ...@@ -473,7 +474,7 @@ DSOUND_Deinitialize(void)
static int static int
DSOUND_Init(SDL_AudioDriverImpl *impl) DSOUND_Init(SDL_AudioDriverImpl * impl)
{ {
OSVERSIONINFO ver; OSVERSIONINFO ver;
...@@ -482,12 +483,12 @@ DSOUND_Init(SDL_AudioDriverImpl *impl) ...@@ -482,12 +483,12 @@ DSOUND_Init(SDL_AudioDriverImpl *impl)
* audio buffers used by many SDL applications, so there are gaps in the * audio buffers used by many SDL applications, so there are gaps in the
* audio - it sounds terrible. Punt for now. * audio - it sounds terrible. Punt for now.
*/ */
SDL_memset(&ver, '\0', sizeof (OSVERSIONINFO)); SDL_memset(&ver, '\0', sizeof(OSVERSIONINFO));
ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&ver); GetVersionEx(&ver);
if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) { if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
if (ver.dwMajorVersion <= 4) { if (ver.dwMajorVersion <= 4) {
return 0; /* NT4.0 or earlier. Disable dsound support. */ return 0; /* NT4.0 or earlier. Disable dsound support. */
} }
} }
...@@ -504,7 +505,7 @@ DSOUND_Init(SDL_AudioDriverImpl *impl) ...@@ -504,7 +505,7 @@ DSOUND_Init(SDL_AudioDriverImpl *impl)
impl->GetDeviceBuf = DSOUND_GetDeviceBuf; impl->GetDeviceBuf = DSOUND_GetDeviceBuf;
impl->CloseDevice = DSOUND_CloseDevice; impl->CloseDevice = DSOUND_CloseDevice;
impl->Deinitialize = DSOUND_Deinitialize; impl->Deinitialize = DSOUND_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME */ impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME */
return 1; return 1;
} }
......
...@@ -64,6 +64,7 @@ SDL_GetTicks(void) ...@@ -64,6 +64,7 @@ SDL_GetTicks(void)
hires_now /= hires_ticks_per_second; hires_now /= hires_ticks_per_second;
*/ */
/* inline asm to avoid runtime inclusion */ /* inline asm to avoid runtime inclusion */
/* *INDENT-OFF* */
_asm { _asm {
push edx push edx
push eax push eax
...@@ -87,6 +88,7 @@ SDL_GetTicks(void) ...@@ -87,6 +88,7 @@ SDL_GetTicks(void)
pop edx pop edx
pop eax pop eax
} }
/* *INDENT-ON* */
return ticks; return ticks;
......
#include "SDL.h" #include "SDL.h"
static void print_devices(int iscapture) static void
print_devices(int iscapture)
{ {
const char *typestr = ((iscapture) ? "capture" : "output"); const char *typestr = ((iscapture) ? "capture" : "output");
int n = SDL_GetNumAudioDevices(iscapture); int n = SDL_GetNumAudioDevices(iscapture);
...@@ -11,8 +12,7 @@ static void print_devices(int iscapture) ...@@ -11,8 +12,7 @@ static void print_devices(int iscapture)
printf(" Driver can't detect specific devices.\n\n", typestr); printf(" Driver can't detect specific devices.\n\n", typestr);
else if (n == 0) else if (n == 0)
printf(" No %s devices found.\n\n", typestr); printf(" No %s devices found.\n\n", typestr);
else else {
{
int i; int i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
printf(" %s\n", SDL_GetAudioDeviceName(i, iscapture)); printf(" %s\n", SDL_GetAudioDeviceName(i, iscapture));
...@@ -21,7 +21,8 @@ static void print_devices(int iscapture) ...@@ -21,7 +21,8 @@ static void print_devices(int iscapture)
} }
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
/* Print available audio drivers */ /* Print available audio drivers */
int n = SDL_GetNumAudioDrivers(); int n = SDL_GetNumAudioDrivers();
...@@ -50,4 +51,3 @@ int main(int argc, char **argv) ...@@ -50,4 +51,3 @@ int main(int argc, char **argv)
SDL_Quit(); SDL_Quit();
return 0; return 0;
} }
#include "SDL.h" #include "SDL.h"
static SDL_AudioSpec spec; static SDL_AudioSpec spec;
static Uint8 *sound = NULL; /* Pointer to wave data */ static Uint8 *sound = NULL; /* Pointer to wave data */
static Uint32 soundlen = 0; /* Length of wave data */ static Uint32 soundlen = 0; /* Length of wave data */
typedef struct typedef struct
{ {
...@@ -11,7 +11,8 @@ typedef struct ...@@ -11,7 +11,8 @@ typedef struct
volatile int done; volatile int done;
} callback_data; } callback_data;
void SDLCALL play_through_once(void *arg, Uint8 * stream, int len) void SDLCALL
play_through_once(void *arg, Uint8 * stream, int len)
{ {
callback_data *cbd = (callback_data *) arg; callback_data *cbd = (callback_data *) arg;
Uint8 *waveptr = sound + cbd->soundpos; Uint8 *waveptr = sound + cbd->soundpos;
...@@ -30,14 +31,16 @@ void SDLCALL play_through_once(void *arg, Uint8 * stream, int len) ...@@ -30,14 +31,16 @@ void SDLCALL play_through_once(void *arg, Uint8 * stream, int len)
} }
} }
static void test_multi_audio(int devcount) static void
test_multi_audio(int devcount)
{ {
callback_data cbd[64]; callback_data cbd[64];
int keep_going = 1; int keep_going = 1;
int i; int i;
if (devcount > 64) { if (devcount > 64) {
fprintf(stderr, "Too many devices (%d), clamping to 64...\n", devcount); fprintf(stderr, "Too many devices (%d), clamping to 64...\n",
devcount);
devcount = 64; devcount = 64;
} }
...@@ -48,7 +51,7 @@ static void test_multi_audio(int devcount) ...@@ -48,7 +51,7 @@ static void test_multi_audio(int devcount)
printf("playing on device #%d: ('%s')...", i, devname); printf("playing on device #%d: ('%s')...", i, devname);
fflush(stdout); fflush(stdout);
memset(&cbd[0], '\0', sizeof (callback_data)); memset(&cbd[0], '\0', sizeof(callback_data));
spec.userdata = &cbd[0]; spec.userdata = &cbd[0];
cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL); cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL);
if (cbd[0].dev == 0) { if (cbd[0].dev == 0) {
...@@ -63,7 +66,7 @@ static void test_multi_audio(int devcount) ...@@ -63,7 +66,7 @@ static void test_multi_audio(int devcount)
} }
} }
memset(cbd, '\0', sizeof (cbd)); memset(cbd, '\0', sizeof(cbd));
printf("playing on all devices...\n"); printf("playing on all devices...\n");
for (i = 0; i < devcount; i++) { for (i = 0; i < devcount; i++) {
...@@ -102,7 +105,8 @@ static void test_multi_audio(int devcount) ...@@ -102,7 +105,8 @@ static void test_multi_audio(int devcount)
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
int devcount = 0; int devcount = 0;
...@@ -124,7 +128,8 @@ int main(int argc, char **argv) ...@@ -124,7 +128,8 @@ int main(int argc, char **argv)
/* Load the wave file into memory */ /* Load the wave file into memory */
if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) { if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) {
fprintf(stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError()); fprintf(stderr, "Couldn't load %s: %s\n", argv[1],
SDL_GetError());
} else { } else {
test_multi_audio(devcount); test_multi_audio(devcount);
SDL_FreeWAV(sound); SDL_FreeWAV(sound);
......
...@@ -276,7 +276,7 @@ int ...@@ -276,7 +276,7 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
SDL_Event event; SDL_Event event;
char *title; const char *title;
SDL_Surface *icon; SDL_Surface *icon;
Uint8 *icon_mask; Uint8 *icon_mask;
int parsed; int parsed;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment