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,
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
#endif
extern DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int (SDLCALL * f) (void *),
void *data,
pfnSDL_CurrentBeginThread
pfnBeginThread,
pfnSDL_CurrentEndThread
pfnEndThread);
extern DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThread(int (SDLCALL * f) (void *), void *data,
pfnSDL_CurrentBeginThread pfnBeginThread,
pfnSDL_CurrentEndThread pfnEndThread);
#ifdef __OS2__
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
......
......@@ -144,10 +144,11 @@ static AudioBootStrap *bootstrap[] = {
NULL
};
static SDL_AudioDevice *get_audio_device(SDL_AudioDeviceID id)
static SDL_AudioDevice *
get_audio_device(SDL_AudioDeviceID id)
{
id--;
if ( (id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL) ) {
if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) {
SDL_SetError("Invalid audio device ID");
return NULL;
}
......@@ -157,14 +158,40 @@ static SDL_AudioDevice *get_audio_device(SDL_AudioDeviceID id)
/* stubs for audio drivers that don't need a specific entry point... */
static int SDL_AudioDetectDevices_Default(int iscapture) { return -1; }
static void SDL_AudioThreadInit_Default(_THIS) { /* no-op. */ }
static void SDL_AudioWaitDevice_Default(_THIS) { /* no-op. */ }
static void SDL_AudioPlayDevice_Default(_THIS) { /* no-op. */ }
static Uint8 *SDL_AudioGetDeviceBuf_Default(_THIS) { return NULL; }
static void SDL_AudioWaitDone_Default(_THIS) { /* no-op. */ }
static void SDL_AudioCloseDevice_Default(_THIS) { /* no-op. */ }
static void SDL_AudioDeinitialize_Default(void) { /* no-op. */ }
static int
SDL_AudioDetectDevices_Default(int iscapture)
{
return -1;
}
static void
SDL_AudioThreadInit_Default(_THIS)
{ /* no-op. */
}
static void
SDL_AudioWaitDevice_Default(_THIS)
{ /* no-op. */
}
static void
SDL_AudioPlayDevice_Default(_THIS)
{ /* no-op. */
}
static Uint8 *
SDL_AudioGetDeviceBuf_Default(_THIS)
{
return NULL;
}
static void
SDL_AudioWaitDone_Default(_THIS)
{ /* no-op. */
}
static void
SDL_AudioCloseDevice_Default(_THIS)
{ /* no-op. */
}
static void
SDL_AudioDeinitialize_Default(void)
{ /* no-op. */
}
static int
SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture)
......@@ -172,7 +199,8 @@ SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture)
return 0;
}
static const char *SDL_AudioGetDeviceName_Default(int index, int iscapture)
static const char *
SDL_AudioGetDeviceName_Default(int index, int iscapture)
{
SDL_SetError("No such device");
return NULL;
......@@ -197,14 +225,15 @@ SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device)
}
static void finalize_audio_entry_points(void)
static void
finalize_audio_entry_points(void)
{
/*
* Fill in stub functions for unused driver entry points. This lets us
* blindly call them without having to check for validity first.
*/
#define FILL_STUB(x) \
#define FILL_STUB(x) \
if (current_audio.impl.x == NULL) { \
current_audio.impl.x = SDL_Audio##x##_Default; \
}
......@@ -220,7 +249,7 @@ static void finalize_audio_entry_points(void)
FILL_STUB(LockDevice);
FILL_STUB(UnlockDevice);
FILL_STUB(Deinitialize);
#undef FILL_STUB
#undef FILL_STUB
}
......@@ -317,7 +346,7 @@ SDL_RunAudio(void *devicep)
static SDL_AudioFormat
SDL_ParseAudioFormat(const char *string)
{
#define CHECK_FMT_STRING(x) if (strcmp(string, #x) == 0) return AUDIO_##x
#define CHECK_FMT_STRING(x) if (strcmp(string, #x) == 0) return AUDIO_##x
CHECK_FMT_STRING(U8);
CHECK_FMT_STRING(S8);
CHECK_FMT_STRING(U16LSB);
......@@ -336,7 +365,7 @@ SDL_ParseAudioFormat(const char *string)
CHECK_FMT_STRING(F32MSB);
CHECK_FMT_STRING(F32SYS);
CHECK_FMT_STRING(F32);
#undef CHECK_FMT_STRING
#undef CHECK_FMT_STRING
return 0;
}
......@@ -363,11 +392,11 @@ SDL_AudioInit(const char *driver_name)
int tried_to_init = 0;
if (SDL_WasInit(SDL_INIT_AUDIO)) {
SDL_AudioQuit(); /* shutdown driver if already running. */
SDL_AudioQuit(); /* shutdown driver if already running. */
}
SDL_memset(&current_audio, '\0', sizeof (current_audio));
SDL_memset(open_devices, '\0', sizeof (open_devices));
SDL_memset(&current_audio, '\0', sizeof(current_audio));
SDL_memset(open_devices, '\0', sizeof(open_devices));
/* Select the proper audio driver */
if (driver_name == NULL) {
......@@ -377,13 +406,13 @@ SDL_AudioInit(const char *driver_name)
for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
/* make sure we should even try this driver before doing so... */
const AudioBootStrap *backend = bootstrap[i];
if ( ((driver_name) && (SDL_strcasecmp(backend->name, driver_name))) ||
((!driver_name) && (backend->demand_only)) ) {
if (((driver_name) && (SDL_strcasecmp(backend->name, driver_name))) ||
((!driver_name) && (backend->demand_only))) {
continue;
}
tried_to_init = 1;
SDL_memset(&current_audio, 0, sizeof (current_audio));
SDL_memset(&current_audio, 0, sizeof(current_audio));
current_audio.name = backend->name;
current_audio.desc = backend->desc;
initialized = backend->init(&current_audio.impl);
......@@ -399,8 +428,8 @@ SDL_AudioInit(const char *driver_name)
}
}
SDL_memset(&current_audio, 0, sizeof (current_audio));
return (-1); /* No driver was available, so fail. */
SDL_memset(&current_audio, 0, sizeof(current_audio));
return (-1); /* No driver was available, so fail. */
}
finalize_audio_entry_points();
......@@ -471,7 +500,7 @@ SDL_GetAudioDeviceName(int index, int iscapture)
static void
close_audio_device(SDL_AudioDevice *device)
close_audio_device(SDL_AudioDevice * device)
{
device->enabled = 0;
if (device->thread != NULL) {
......@@ -500,9 +529,9 @@ close_audio_device(SDL_AudioDevice *device)
* Returns non-zero if okay, zero on fatal parameters in (orig).
*/
static int
prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared)
{
SDL_memcpy(prepared, orig, sizeof (SDL_AudioSpec));
SDL_memcpy(prepared, orig, sizeof(SDL_AudioSpec));
if (orig->callback == NULL) {
SDL_SetError("SDL_OpenAudio() passed a NULL callback");
......@@ -511,26 +540,26 @@ prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
if (orig->freq == 0) {
const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY");
if ( (!env) || ((prepared->freq = SDL_atoi(env)) == 0) ) {
prepared->freq = 22050; /* a reasonable default */
if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) {
prepared->freq = 22050; /* a reasonable default */
}
}
if (orig->format == 0) {
const char *env = SDL_getenv("SDL_AUDIO_FORMAT");
if ((!env) || ((prepared->format = SDL_ParseAudioFormat(env)) == 0)) {
prepared->format = AUDIO_S16; /* a reasonable default */
prepared->format = AUDIO_S16; /* a reasonable default */
}
}
switch (orig->channels) {
case 0: {
const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
if ( (!env) || ((prepared->channels = SDL_atoi(env)) == 0) ) {
prepared->channels = 2; /* a reasonable default */
case 0:{
const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
if ((!env) || ((prepared->channels = SDL_atoi(env)) == 0)) {
prepared->channels = 2; /* a reasonable default */
}
break;
}
break;
}
case 1: /* Mono */
case 2: /* Stereo */
case 4: /* surround */
......@@ -543,7 +572,7 @@ prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
if (orig->samples == 0) {
const char *env = SDL_getenv("SDL_AUDIO_SAMPLES");
if ( (!env) || ((prepared->samples = (Uint16) SDL_atoi(env)) == 0) ) {
if ((!env) || ((prepared->samples = (Uint16) SDL_atoi(env)) == 0)) {
/* Pick a default of ~46 ms at desired frequency */
/* !!! FIXME: remove this when the non-Po2 resampling is in. */
const int samples = (prepared->freq / 1000) * 46;
......@@ -564,8 +593,8 @@ prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
static SDL_AudioDeviceID
open_audio_device(const char *devname, int iscapture,
const SDL_AudioSpec *_desired, SDL_AudioSpec *obtained,
int min_id)
const SDL_AudioSpec * _desired, SDL_AudioSpec * obtained,
int min_id)
{
SDL_AudioDeviceID id = 0;
SDL_AudioSpec desired;
......@@ -631,13 +660,13 @@ open_audio_device(const char *devname, int iscapture,
}
}
device = (SDL_AudioDevice *) SDL_AllocAudioMem(sizeof (SDL_AudioDevice));
device = (SDL_AudioDevice *) SDL_AllocAudioMem(sizeof(SDL_AudioDevice));
if (device == NULL) {
SDL_OutOfMemory();
return 0;
}
SDL_memset(device, '\0', sizeof (SDL_AudioDevice));
SDL_memcpy(&device->spec, &desired, sizeof (SDL_AudioSpec));
SDL_memset(device, '\0', sizeof(SDL_AudioDevice));
SDL_memcpy(&device->spec, &desired, sizeof(SDL_AudioSpec));
device->enabled = 1;
device->paused = 1;
device->iscapture = iscapture;
......@@ -688,8 +717,8 @@ open_audio_device(const char *devname, int iscapture,
return 0;
}
if (device->convert.needed) {
device->convert.len = (int) ( ((double) desired.size) /
device->convert.len_ratio );
device->convert.len = (int) (((double) desired.size) /
device->convert.len_ratio);
device->convert.buf =
(Uint8 *) SDL_AllocAudioMem(device->convert.len *
......@@ -703,7 +732,7 @@ open_audio_device(const char *devname, int iscapture,
}
/* Find an available device ID and store the structure... */
for (id = min_id-1; id < SDL_arraysize(open_devices); id++) {
for (id = min_id - 1; id < SDL_arraysize(open_devices); id++) {
if (open_devices[id] == NULL) {
open_devices[id] = device;
break;
......@@ -727,13 +756,13 @@ open_audio_device(const char *devname, int iscapture,
device->thread = SDL_CreateThread(SDL_RunAudio, device);
#endif
if (device->thread == NULL) {
SDL_CloseAudioDevice(id+1);
SDL_CloseAudioDevice(id + 1);
SDL_SetError("Couldn't create audio thread");
return 0;
}
}
return id+1;
return id + 1;
}
......@@ -756,9 +785,9 @@ SDL_OpenAudio(const SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
}
id = open_audio_device(NULL, 0, desired, obtained, 1);
if (id > 1) { /* this should never happen in theory... */
if (id > 1) { /* this should never happen in theory... */
SDL_CloseAudioDevice(id);
SDL_SetError("Internal error"); /* MUST be Device ID #1! */
SDL_SetError("Internal error"); /* MUST be Device ID #1! */
return (-1);
}
......@@ -767,7 +796,7 @@ SDL_OpenAudio(const SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
SDL_AudioDeviceID
SDL_OpenAudioDevice(const char *device, int iscapture,
const SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
const SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
{
return open_audio_device(device, iscapture, desired, obtained, 2);
}
......@@ -848,7 +877,7 @@ SDL_CloseAudioDevice(SDL_AudioDeviceID devid)
SDL_AudioDevice *device = get_audio_device(devid);
if (device) {
close_audio_device(device);
open_devices[devid-1] = NULL;
open_devices[devid - 1] = NULL;
}
}
......@@ -868,8 +897,8 @@ SDL_AudioQuit(void)
/* Free the driver data */
current_audio.impl.Deinitialize();
SDL_memset(&current_audio, '\0', sizeof (current_audio));
SDL_memset(open_devices, '\0', sizeof (open_devices));
SDL_memset(&current_audio, '\0', sizeof(current_audio));
SDL_memset(open_devices, '\0', sizeof(open_devices));
}
#define NUM_FORMATS 10
......
......@@ -47,14 +47,15 @@
#endif
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)
{
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);
if ( (audio_fd >= 0) && (test(audio_fd)) ) {
void *p = SDL_realloc(*devices, ((*devCount)+1) * sizeof (char *));
if ((audio_fd >= 0) && (test(audio_fd))) {
void *p =
SDL_realloc(*devices, ((*devCount) + 1) * sizeof(char *));
if (p != NULL) {
size_t len = strlen(fname) + 1;
char *str = (char *) SDL_malloc(len);
......@@ -75,7 +76,7 @@ SDL_FreeUnixAudioDevices(char ***devices, int *devCount)
int i = *devCount;
if ((i > 0) && (*devices != NULL)) {
while (i--) {
SDL_free( (*devices)[*devCount] );
SDL_free((*devices)[*devCount]);
}
}
......@@ -94,7 +95,7 @@ test_stub(int fd)
}
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)
{
const char *audiodev;
......
......@@ -21,7 +21,7 @@
*/
#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);
void SDL_FreeUnixAudioDevices(char ***devices, int *devCount);
......
......@@ -33,8 +33,8 @@ typedef struct SDL_AudioDevice SDL_AudioDevice;
typedef struct SDL_AudioDriverImpl
{
int (*DetectDevices)(int iscapture);
const char *(*GetDeviceName)(int index, int iscapture);
int (*DetectDevices) (int iscapture);
const char *(*GetDeviceName) (int index, int iscapture);
int (*OpenDevice) (_THIS, const char *devname, int iscapture);
void (*ThreadInit) (_THIS); /* Called by audio thread at start */
void (*WaitDevice) (_THIS);
......@@ -107,8 +107,8 @@ typedef struct AudioBootStrap
{
const char *name;
const char *desc;
int (*init) (SDL_AudioDriverImpl *impl);
int demand_only:1; /* 1==request explicitly, or it won't be available. */
int (*init) (SDL_AudioDriverImpl * impl);
int demand_only:1; /* 1==request explicitly, or it won't be available. */
} AudioBootStrap;
#endif /* _SDL_sysaudio_h */
......
......@@ -43,41 +43,43 @@
#define DEFAULT_DEVICE "default"
static int (*ALSA_snd_pcm_open)
(snd_pcm_t **, const char *, snd_pcm_stream_t, int);
static int (*ALSA_snd_pcm_close)(snd_pcm_t * pcm);
(snd_pcm_t **, const char *, snd_pcm_stream_t, int);
static int (*ALSA_snd_pcm_close) (snd_pcm_t * pcm);
static snd_pcm_sframes_t(*ALSA_snd_pcm_writei)
(snd_pcm_t *,const void *, snd_pcm_uframes_t);
static int (*ALSA_snd_pcm_resume)(snd_pcm_t *);
static int (*ALSA_snd_pcm_prepare)(snd_pcm_t *);
static int (*ALSA_snd_pcm_drain)(snd_pcm_t *);
static const char *(*ALSA_snd_strerror)(int);
static size_t(*ALSA_snd_pcm_hw_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 *);
(snd_pcm_t *, const void *, snd_pcm_uframes_t);
static int (*ALSA_snd_pcm_resume) (snd_pcm_t *);
static int (*ALSA_snd_pcm_prepare) (snd_pcm_t *);
static int (*ALSA_snd_pcm_drain) (snd_pcm_t *);
static const char *(*ALSA_snd_strerror) (int);
static size_t(*ALSA_snd_pcm_hw_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_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)
(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)
(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 *);
(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 unsigned int (*ALSA_snd_pcm_hw_params_set_rate_near)
(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)
(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)
(const snd_pcm_hw_params_t *);
(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)
(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)
(const snd_pcm_hw_params_t *);
static unsigned int (*ALSA_snd_pcm_hw_params_set_periods_near)
(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)(snd_pcm_t *, snd_pcm_hw_params_t *);
static int (*ALSA_snd_pcm_sw_params_current)(snd_pcm_t*, snd_pcm_sw_params_t*);
(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) (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_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)
(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_nonblock)(snd_pcm_t *, int);
(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_nonblock) (snd_pcm_t *, int);
#define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_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)
#define SDL_ALSA_SYM(x) ALSA_##x = x
#endif
static int load_alsa_syms(void)
static int
load_alsa_syms(void)
{
SDL_ALSA_SYM(snd_pcm_open);
SDL_ALSA_SYM(snd_pcm_close);
......@@ -147,6 +150,7 @@ static int load_alsa_syms(void)
SDL_ALSA_SYM(snd_pcm_nonblock);
return 0;
}
#undef SDL_ALSA_SYM
#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
......@@ -169,7 +173,7 @@ LoadALSALibrary(void)
if (alsa_handle == NULL) {
retval = -1;
SDL_SetError("ALSA: dlopen('%s') failed: %s\n",
alsa_library, strerror(errno));
alsa_library, strerror(errno));
} else {
retval = load_alsa_syms();
if (retval < 0) {
......@@ -376,7 +380,7 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -422,7 +426,7 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
status = -1;
for (test_format = SDL_FirstAudioFormat(this->spec.format);
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) {
case AUDIO_U8:
format = SND_PCM_FORMAT_U8;
......@@ -512,15 +516,15 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
ALSA_snd_strerror(status));
return 0;
}
#if AUDIO_DEBUG
{
snd_pcm_sframes_t bufsize;
int fragments;
bufsize = ALSA_snd_pcm_hw_params_get_period_size(hwparams);
fragments = ALSA_snd_pcm_hw_params_get_periods(hwparams);
fprintf(stderr,"ALSA: bufsize = %ld, fragments = %d\n",bufsize,fragments);
}
{
snd_pcm_sframes_t bufsize;
int fragments;
bufsize = ALSA_snd_pcm_hw_params_get_period_size(hwparams);
fragments = ALSA_snd_pcm_hw_params_get_periods(hwparams);
fprintf(stderr, "ALSA: bufsize = %ld, fragments = %d\n", bufsize,
fragments);
}
#endif
/* Set the software parameters */
......@@ -532,14 +536,16 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
ALSA_snd_strerror(status));
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) {
ALSA_CloseDevice(this);
SDL_SetError("ALSA: Couldn't set start threshold: %s",
ALSA_snd_strerror(status));
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) {
ALSA_CloseDevice(this);
SDL_SetError("Couldn't set avail min: %s", ALSA_snd_strerror(status));
......@@ -583,7 +589,7 @@ ALSA_Deinitialize(void)
}
static int
ALSA_Init(SDL_AudioDriverImpl *impl)
ALSA_Init(SDL_AudioDriverImpl * impl)
{
if (LoadALSALibrary() < 0) {
return 0;
......@@ -596,7 +602,7 @@ ALSA_Init(SDL_AudioDriverImpl *impl)
impl->PlayDevice = ALSA_PlayDevice;
impl->CloseDevice = ALSA_CloseDevice;
impl->Deinitialize = ALSA_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Add device enum! */
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Add device enum! */
return 1;
}
......
......@@ -66,15 +66,13 @@ static struct
const char *name;
void **func;
} arts_functions[] = {
SDL_ARTS_SYM(arts_init),
SDL_ARTS_SYM(arts_free),
SDL_ARTS_SYM(arts_play_stream),
SDL_ARTS_SYM(arts_stream_set),
SDL_ARTS_SYM(arts_stream_get),
SDL_ARTS_SYM(arts_write),
SDL_ARTS_SYM(arts_close_stream),
SDL_ARTS_SYM(arts_error_text),
};
SDL_ARTS_SYM(arts_init),
SDL_ARTS_SYM(arts_free),
SDL_ARTS_SYM(arts_play_stream),
SDL_ARTS_SYM(arts_stream_set),
SDL_ARTS_SYM(arts_stream_get),
SDL_ARTS_SYM(arts_write),
SDL_ARTS_SYM(arts_close_stream), SDL_ARTS_SYM(arts_error_text),};
#undef SDL_ARTS_SYM
static void
......@@ -147,7 +145,8 @@ ARTS_WaitDevice(_THIS)
}
/* 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) {
SDL_Delay(ticks);
}
......@@ -157,10 +156,9 @@ static void
ARTS_PlayDevice(_THIS)
{
/* Write the audio data */
int written = SDL_NAME(arts_write) (
this->hidden->stream,
this->hidden->mixbuf,
this->hidden->mixlen);
int written = SDL_NAME(arts_write) (this->hidden->stream,
this->hidden->mixbuf,
this->hidden->mixlen);
/* If timer synchronization is enabled, set the next write frame */
if (this->hidden->frame_ticks) {
......@@ -218,7 +216,7 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -257,14 +255,14 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
if ((rc = SDL_NAME(arts_init) ()) != 0) {
ARTS_CloseDevice(this);
SDL_SetError( "Unable to initialize ARTS: %s",
SDL_NAME(arts_error_text)(rc) );
SDL_SetError("Unable to initialize ARTS: %s",
SDL_NAME(arts_error_text) (rc));
return 0;
}
this->hidden->stream = SDL_NAME(arts_play_stream) (
this->spec.freq,
bits, this->spec.channels,
"SDL");
this->hidden->stream = SDL_NAME(arts_play_stream) (this->spec.freq,
bits,
this->spec.channels,
"SDL");
/* Calculate the final parameters for this audio specification */
SDL_CalculateAudioSpec(&this->spec);
......@@ -280,7 +278,7 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
#ifdef ARTS_P_PACKET_SETTINGS
SDL_NAME(arts_stream_set) (this->hidden->stream,
ARTS_P_PACKET_SETTINGS, frag_spec);
ARTS_P_PACKET_SETTINGS, frag_spec);
#else
SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_SIZE,
frag_spec & 0xffff);
......@@ -316,7 +314,7 @@ ARTS_Deinitialize(void)
static int
ARTS_Init(SDL_AudioDriverImpl *impl)
ARTS_Init(SDL_AudioDriverImpl * impl)
{
if (LoadARTSLibrary() < 0) {
return 0;
......
......@@ -58,15 +58,15 @@ FillSound(void *device, void *stream, size_t len,
if (audio->convert.needed) {
SDL_mutexP(audio->mixer_lock);
(*audio->spec.callback) (audio->spec.userdata,
(Uint8 *) audio->convert.buf,
audio->convert.len);
(Uint8 *) audio->convert.buf,
audio->convert.len);
SDL_mutexV(audio->mixer_lock);
SDL_ConvertAudio(&audio->convert);
SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt);
} else {
SDL_mutexP(audio->mixer_lock);
(*audio->spec.callback) (audio->spec.userdata,
(Uint8 *) stream, len);
(Uint8 *) stream, len);
SDL_mutexV(audio->mixer_lock);
}
}
......@@ -106,56 +106,56 @@ BEOSAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
SDL_memset(&format, '\0', sizeof(media_raw_audio_format));
format.byte_order = B_MEDIA_LITTLE_ENDIAN;
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)) {
valid_datatype = 1;
_this->spec.format = test_format;
switch (test_format) {
case AUDIO_S8:
format.format = media_raw_audio_format::B_AUDIO_CHAR;
break;
case AUDIO_U8:
format.format = media_raw_audio_format::B_AUDIO_UCHAR;
break;
case AUDIO_S16LSB:
format.format = media_raw_audio_format::B_AUDIO_SHORT;
break;
case AUDIO_S16MSB:
format.format = media_raw_audio_format::B_AUDIO_SHORT;
format.byte_order = B_MEDIA_BIG_ENDIAN;
break;
case AUDIO_S32LSB:
format.format = media_raw_audio_format::B_AUDIO_INT;
break;
case AUDIO_S32MSB:
format.format = media_raw_audio_format::B_AUDIO_INT;
format.byte_order = B_MEDIA_BIG_ENDIAN;
break;
case AUDIO_F32LSB:
format.format = media_raw_audio_format::B_AUDIO_FLOAT;
break;
case AUDIO_F32MSB:
format.format = media_raw_audio_format::B_AUDIO_FLOAT;
format.byte_order = B_MEDIA_BIG_ENDIAN;
break;
default:
valid_datatype = 0;
test_format = SDL_NextAudioFormat();
break;
case AUDIO_S8:
format.format = media_raw_audio_format::B_AUDIO_CHAR;
break;
case AUDIO_U8:
format.format = media_raw_audio_format::B_AUDIO_UCHAR;
break;
case AUDIO_S16LSB:
format.format = media_raw_audio_format::B_AUDIO_SHORT;
break;
case AUDIO_S16MSB:
format.format = media_raw_audio_format::B_AUDIO_SHORT;
format.byte_order = B_MEDIA_BIG_ENDIAN;
break;
case AUDIO_S32LSB:
format.format = media_raw_audio_format::B_AUDIO_INT;
break;
case AUDIO_S32MSB:
format.format = media_raw_audio_format::B_AUDIO_INT;
format.byte_order = B_MEDIA_BIG_ENDIAN;
break;
case AUDIO_F32LSB:
format.format = media_raw_audio_format::B_AUDIO_FLOAT;
break;
case AUDIO_F32MSB:
format.format = media_raw_audio_format::B_AUDIO_FLOAT;
format.byte_order = B_MEDIA_BIG_ENDIAN;
break;
default:
valid_datatype = 0;
test_format = SDL_NextAudioFormat();
break;
}
}
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);
SDL_SetError("Unsupported audio format");
return 0;
......@@ -190,7 +190,7 @@ BEOSAUDIO_Deinitialize(void)
}
static int
BEOSAUDIO_Init(SDL_AudioDriverImpl *impl)
BEOSAUDIO_Init(SDL_AudioDriverImpl * impl)
{
/* Initialize the Be Application, if it's not already started */
if (SDL_InitBeApp() < 0) {
......@@ -207,10 +207,12 @@ BEOSAUDIO_Init(SDL_AudioDriverImpl *impl)
return 1;
}
extern "C" { extern AudioBootStrap BEOSAUDIO_bootstrap; }
extern "C"
{
extern AudioBootStrap BEOSAUDIO_bootstrap;
}
AudioBootStrap BEOSAUDIO_bootstrap = {
"baudio", "BeOS BSoundPlayer", BEOSAUDIO_Init, 0
};
/* vi: set ts=4 sw=4 expandtab: */
......@@ -122,7 +122,7 @@ BSDAUDIO_DetectDevices(int iscapture)
return outputDeviceCount;
}
return 0; /* shouldn't ever hit this. */
return 0; /* shouldn't ever hit this. */
}
static const char *
......@@ -149,7 +149,7 @@ BSDAUDIO_Status(_THIS)
fprintf(stderr, "AUDIO_GETINFO failed.\n");
return;
}
/* *INDENT-OFF* */
fprintf(stderr, "\n"
"[play/record info]\n"
"buffer size : %d bytes\n"
......@@ -177,7 +177,9 @@ BSDAUDIO_Status(_THIS)
info.play.error ? "yes" : "no",
info.play.waiting ? "yes" : "no",
info.play.active ? "yes" : "no");
/* *INDENT-ON* */
/* *INDENT-OFF* */
fprintf(stderr, "\n"
"[audio info]\n"
"monitor_gain : %i\n"
......@@ -192,6 +194,7 @@ BSDAUDIO_Status(_THIS)
(info.mode == AUMODE_PLAY) ? "PLAY"
: (info.mode = AUMODE_RECORD) ? "RECORD"
: (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" : "?"));
/* *INDENT-ON* */
#endif /* DEBUG_AUDIO */
}
......@@ -206,7 +209,9 @@ BSDAUDIO_WaitDevice(_THIS)
/* Use timer for general audio synchronization */
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) {
SDL_Delay(ticks);
}
......@@ -222,7 +227,8 @@ BSDAUDIO_WaitDevice(_THIS)
#ifdef DEBUG_AUDIO
fprintf(stderr, "Waiting for audio to get ready\n");
#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 =
"Audio timeout - buggy audio driver? (disabled)";
/* In general we should never print to the screen,
......@@ -252,8 +258,7 @@ BSDAUDIO_PlayDevice(_THIS)
/* Write the audio data, checking for EAGAIN on broken audio drivers */
do {
written = write(this->hidden->audio_fd,
&this->hidden->mixbuf[p],
this->hidden->mixlen - p);
&this->hidden->mixbuf[p], this->hidden->mixlen - p);
if (written > 0)
p += written;
......@@ -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. */
/* ...but default to first name in the list... */
if (devname == NULL) {
if ( ((iscapture) && (inputDeviceCount == 0)) ||
((!iscapture) && (outputDeviceCount == 0)) ) {
if (((iscapture) && (inputDeviceCount == 0)) ||
((!iscapture) && (outputDeviceCount == 0))) {
SDL_SetError("No such audio device");
return 0;
}
......@@ -327,7 +332,7 @@ BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -429,7 +434,7 @@ BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
}
static int
BSDAUDIO_Init(SDL_AudioDriverImpl *impl)
BSDAUDIO_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->DetectDevices = BSDAUDIO_DetectDevices;
......
......@@ -90,7 +90,7 @@ DART_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
_this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *_this->hidden));
SDL_malloc((sizeof *_this->hidden));
if (_this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -108,12 +108,11 @@ DART_OpenDevice(_THIS, const char *devname, int iscapture)
iOpenMode |= MCI_OPEN_SHAREABLE;
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);
SDL_SetError("DART: Couldn't open audio device.");
return 0;
}
// Save the device ID we got from DART!
// We will use this in the next calls!
_this->hidden->iCurrDeviceOrd = iDeviceOrd = AmpOpenParms.usDeviceID;
......@@ -361,7 +360,7 @@ DART_WaitDone(_THIS)
APIRET rc = NO_ERROR;
pBufDesc = (pMixBufferDesc)
_this->hidden->pMixBuffers[_this->hidden->iLastPlayedBuf].ulUserParm;
_this->hidden->pMixBuffers[_this->hidden->iLastPlayedBuf].ulUserParm;
while ((pBufDesc->iBufferUsage != BUFFER_EMPTY) && (rc == NO_ERROR)) {
DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount);
......@@ -388,13 +387,11 @@ DART_CloseDevice(_THIS)
}
#endif
}
// Close event semaphore
if (_this->hidden->hevAudioBufferPlayed) {
DosCloseEventSem(_this->hidden->hevAudioBufferPlayed);
_this->hidden->hevAudioBufferPlayed = 0;
}
// Free memory of buffer descriptions
for (i = 0; i < _this->hidden->iCurrNumBufs; i++) {
SDL_free((void *) (_this->hidden->pMixBuffers[i].ulUserParm));
......@@ -408,13 +405,11 @@ DART_CloseDevice(_THIS)
MCI_WAIT | MCI_DEALLOCATE_MEMORY,
&(_this->hidden->BufferParms), 0);
}
// Free bufferlist
if (_this->hidden->pMixBuffers != NULL) {
SDL_free(_this->hidden->pMixBuffers);
_this->hidden->pMixBuffers = NULL;
}
// Close dart
if (_this->hidden->iCurrDeviceOrd) {
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE,
......@@ -429,7 +424,7 @@ DART_CloseDevice(_THIS)
static int
DART_Init(SDL_AudioDriverImpl *impl)
DART_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->OpenDevice = DART_OpenDevice;
......@@ -439,7 +434,7 @@ DART_Init(SDL_AudioDriverImpl *impl)
impl->PlayDevice = DART_PlayDevice;
impl->WaitDone = DART_WaitDone;
impl->CloseDevice = DART_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this right? */
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this right? */
return 1;
}
......
......@@ -170,7 +170,7 @@ DCAUD_OpenDevice(_THIS, SDL_AudioSpec * spec)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -225,7 +225,7 @@ DCAUD_OpenDevice(_THIS, SDL_AudioSpec * spec)
}
static int
DCAUD_Init(SDL_AudioDriverImpl *impl)
DCAUD_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->OpenDevice = DCAUD_OpenDevice;
......
......@@ -112,12 +112,12 @@ DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
const char *fname = DISKAUD_GetOutputFilename(devname);
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof (*this->hidden));
SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
}
SDL_memset(this->hidden, 0, sizeof (*this->hidden));
SDL_memset(this->hidden, 0, sizeof(*this->hidden));
/* Open the audio device */
this->hidden->output = SDL_RWFromFile(fname, "wb");
......@@ -149,7 +149,7 @@ DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
}
static int
DISKAUD_Init(SDL_AudioDriverImpl *impl)
DISKAUD_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->OpenDevice = DISKAUD_OpenDevice;
......
......@@ -74,8 +74,7 @@ test_for_mmap(int fd)
struct audio_buf_info info;
if ((ioctl(fd, SNDCTL_DSP_GETCAPS, &caps) == 0) &&
(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;
Uint8 *buf = (Uint8 *) mmap(NULL, len, PROT_WRITE, MAP_SHARED, fd, 0);
if (buf != MAP_FAILED) {
......@@ -117,7 +116,8 @@ free_device_lists(void)
}
static void DMA_Deinitialize(void)
static void
DMA_Deinitialize(void)
{
free_device_lists();
}
......@@ -133,7 +133,7 @@ DMA_DetectDevices(int iscapture)
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)
/* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */
if (devname == NULL) {
if ( ((iscapture) && (inputDeviceCount == 0)) ||
((!iscapture) && (outputDeviceCount == 0)) ) {
if (((iscapture) && (inputDeviceCount == 0)) ||
((!iscapture) && (outputDeviceCount == 0))) {
SDL_SetError("No such audio device");
return 0;
}
......@@ -250,7 +250,7 @@ DMA_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -380,7 +380,8 @@ DMA_OpenDevice(_THIS, const char *devname, int iscapture)
char *workaround;
workaround = SDL_getenv("SDL_DSP_NOSELECT");
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;
}
}
......@@ -511,7 +512,7 @@ DMA_GetDeviceBuf(_THIS)
static int
DMA_Init(SDL_AudioDriverImpl *impl)
DMA_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->DetectDevices = DMA_DetectDevices;
......
......@@ -104,7 +104,7 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -160,15 +160,17 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
valid = 0;
if (audio_config) {
if (alSetChannels(audio_config, this->spec.channels) < 0) {
if (this->spec.channels > 2) { /* can't handle > stereo? */
this->spec.channels = 2; /* try again below. */
if (this->spec.channels > 2) { /* can't handle > stereo? */
this->spec.channels = 2; /* try again below. */
}
}
if ((alSetSampFmt(audio_config, fmt) >= 0) &&
((!width) || (alSetWidth(audio_config, width) >= 0)) &&
(alSetQueueSize(audio_config,this->spec.samples*2) >= 0) &&
(alSetChannels(audio_config, this->spec.channels) >= 0)) {
(alSetQueueSize(audio_config, this->spec.samples * 2) >=
0)
&& (alSetChannels(audio_config, this->spec.channels) >=
0)) {
this->hidden->audio_port = alOpenPort("SDL audio", "w",
audio_config);
......@@ -178,8 +180,8 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
if (err == AL_BAD_CHANNELS) {
this->spec.channels = 2;
alSetChannels(audio_config, this->spec.channels);
this->hidden->audio_port = alOpenPort("SDL audio", "w",
audio_config);
this->hidden->audio_port =
alOpenPort("SDL audio", "w", audio_config);
}
}
......@@ -216,7 +218,7 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
}
static int
IRIXAUDIO_Init(SDL_AudioDriverImpl *impl)
IRIXAUDIO_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->OpenDevice = DSP_OpenDevice;
......@@ -224,7 +226,7 @@ IRIXAUDIO_Init(SDL_AudioDriverImpl *impl)
impl->WaitDevice = DSP_WaitDevice;
impl->GetDeviceBuf = DSP_GetDeviceBuf;
impl->CloseDevice = DSP_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: not true, I think. */
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: not true, I think. */
return 1;
}
......
......@@ -33,8 +33,8 @@
struct SDL_PrivateAudioData
{
ALport audio_port; /* The handle for the audio device */
Uint8 *mixbuf; /* The app mixing buffer */
ALport audio_port; /* The handle for the audio device */
Uint8 *mixbuf; /* The app mixing buffer */
};
#endif /* _SDL_irixaudio_h */
......
......@@ -111,7 +111,7 @@ DSP_DetectDevices(int iscapture)
return outputDeviceCount;
}
return 0; /* shouldn't ever hit this. */
return 0; /* shouldn't ever hit this. */
}
static const char *
......@@ -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. */
/* ...but default to first name in the list... */
if (devname == NULL) {
if ( ((iscapture) && (inputDeviceCount == 0)) ||
((!iscapture) && (outputDeviceCount == 0)) ) {
if (((iscapture) && (inputDeviceCount == 0)) ||
((!iscapture) && (outputDeviceCount == 0))) {
SDL_SetError("No such audio device");
return 0;
}
......@@ -168,7 +168,7 @@ DSP_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -265,8 +265,8 @@ DSP_OpenDevice(_THIS, const char *devname, int iscapture)
/* Set the audio format */
value = format;
if ( (ioctl(this->hidden->audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
(value != format) ) {
if ((ioctl(this->hidden->audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
(value != format)) {
perror("SNDCTL_DSP_SETFMT");
DSP_CloseDevice(this);
SDL_SetError("Couldn't set audio format");
......@@ -360,7 +360,7 @@ DSP_GetDeviceBuf(_THIS)
}
static int
DSP_Init(SDL_AudioDriverImpl *impl)
DSP_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->DetectDevices = DSP_DetectDevices;
......
......@@ -32,11 +32,11 @@
static int
DUMMYAUD_OpenDevice(_THIS, const char *devname, int iscapture)
{
return 1; /* always succeeds. */
return 1; /* always succeeds. */
}
static int
DUMMYAUD_Init(SDL_AudioDriverImpl *impl)
DUMMYAUD_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->OpenDevice = DUMMYAUD_OpenDevice;
......
......@@ -61,10 +61,8 @@ static struct
const char *name;
void **func;
} esd_functions[] = {
SDL_ESD_SYM(esd_open_sound),
SDL_ESD_SYM(esd_close),
SDL_ESD_SYM(esd_play_stream),
};
SDL_ESD_SYM(esd_open_sound),
SDL_ESD_SYM(esd_close), SDL_ESD_SYM(esd_play_stream),};
#undef SDL_ESD_SYM
static void
......@@ -137,7 +135,8 @@ ESD_WaitDevice(_THIS)
}
/* 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) {
SDL_Delay(ticks);
}
......@@ -151,8 +150,7 @@ ESD_PlayDevice(_THIS)
/* Write the audio data, checking for EAGAIN on broken audio drivers */
do {
written = write(this->hidden->audio_fd,
this->hidden->mixbuf,
this->hidden->mixlen);
this->hidden->mixbuf, this->hidden->mixlen);
if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) {
SDL_Delay(1); /* Let a little CPU time go by */
}
......@@ -229,7 +227,7 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -246,15 +244,15 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture)
#endif
found = 1;
switch (test_format) {
case AUDIO_U8:
format |= ESD_BITS8;
break;
case AUDIO_S16SYS:
format |= ESD_BITS16;
break;
default:
found = 0;
break;
case AUDIO_U8:
format |= ESD_BITS8;
break;
case AUDIO_S16SYS:
format |= ESD_BITS16;
break;
default:
found = 0;
break;
}
}
......@@ -270,12 +268,13 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture)
format |= ESD_STEREO;
}
#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
/* Open a connection to the ESD audio server */
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) {
ESD_CloseDevice(this);
......@@ -285,7 +284,8 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture)
/* Calculate the final parameters for this audio specification */
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;
/* Allocate mixing buffer */
......@@ -312,7 +312,7 @@ ESD_Deinitialize(void)
}
static int
ESD_Init(SDL_AudioDriverImpl *impl)
ESD_Init(SDL_AudioDriverImpl * impl)
{
if (LoadESDLibrary() < 0) {
return 0;
......
......@@ -43,7 +43,7 @@ static COREAUDIO_DeviceList *outputDevices = NULL;
static int outputDeviceCount = 0;
static void
free_device_list(COREAUDIO_DeviceList **devices, int *devCount)
free_device_list(COREAUDIO_DeviceList ** devices, int *devCount)
{
if (*devices) {
int i = *devCount;
......@@ -57,7 +57,8 @@ free_device_list(COREAUDIO_DeviceList **devices, int *devCount)
static void
build_device_list(int iscapture, COREAUDIO_DeviceList **devices, int *devCount)
build_device_list(int iscapture, COREAUDIO_DeviceList ** devices,
int *devCount)
{
Boolean outWritable = 0;
OSStatus result = noErr;
......@@ -69,7 +70,7 @@ build_device_list(int iscapture, COREAUDIO_DeviceList **devices, int *devCount)
free_device_list(devices, devCount);
result = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices,
&size, &outWritable);
&size, &outWritable);
if (result != kAudioHardwareNoError)
return;
......@@ -78,13 +79,13 @@ build_device_list(int iscapture, COREAUDIO_DeviceList **devices, int *devCount)
if (devs == NULL)
return;
max = size / sizeof (AudioDeviceID);
*devices = (COREAUDIO_DeviceList *) SDL_malloc(max * sizeof (**devices));
max = size / sizeof(AudioDeviceID);
*devices = (COREAUDIO_DeviceList *) SDL_malloc(max * sizeof(**devices));
if (*devices == NULL)
return;
result = AudioHardwareGetProperty(kAudioHardwarePropertyDevices,
&size, devs);
&size, devs);
if (result != kAudioHardwareNoError)
return;
......@@ -97,8 +98,8 @@ build_device_list(int iscapture, COREAUDIO_DeviceList **devices, int *devCount)
CFIndex len = 0;
result = AudioDeviceGetPropertyInfo(dev, 0, iscapture,
kAudioDevicePropertyStreamConfiguration,
&size, &outWritable);
kAudioDevicePropertyStreamConfiguration,
&size, &outWritable);
if (result != noErr)
continue;
......@@ -107,8 +108,8 @@ build_device_list(int iscapture, COREAUDIO_DeviceList **devices, int *devCount)
continue;
result = AudioDeviceGetProperty(dev, 0, iscapture,
kAudioDevicePropertyStreamConfiguration,
&size, buflist);
kAudioDevicePropertyStreamConfiguration,
&size, buflist);
if (result == noErr) {
UInt32 j;
......@@ -125,7 +126,7 @@ build_device_list(int iscapture, COREAUDIO_DeviceList **devices, int *devCount)
if (!usable)
continue;
size = sizeof (CFStringRef);
size = sizeof(CFStringRef);
result = AudioDeviceGetProperty(dev, 0, iscapture,
kAudioObjectPropertyName,
&size, &cfstr);
......@@ -137,15 +138,16 @@ build_device_list(int iscapture, COREAUDIO_DeviceList **devices, int *devCount)
kCFStringEncodingUTF8);
ptr = (char *) SDL_malloc(len + 1);
usable = ( (ptr != NULL) &&
(CFStringGetCString(cfstr,ptr,len+1,kCFStringEncodingUTF8)) );
usable = ((ptr != NULL) &&
(CFStringGetCString
(cfstr, ptr, len + 1, kCFStringEncodingUTF8)));
CFRelease(cfstr);
if (usable) {
len = strlen(ptr);
/* Some devices have whitespace at the end...trim it. */
while ((len > 0) && (ptr[len-1] == ' ')) {
while ((len > 0) && (ptr[len - 1] == ' ')) {
len--;
}
usable = (len > 0);
......@@ -156,11 +158,11 @@ build_device_list(int iscapture, COREAUDIO_DeviceList **devices, int *devCount)
} else {
ptr[len] = '\0';
#if DEBUG_COREAUDIO
#if DEBUG_COREAUDIO
printf("COREAUDIO: Found %s device #%d: '%s' (devid %d)\n",
((iscapture) ? "capture" : "output"),
(int) *devCount, ptr, (int) dev);
#endif
((iscapture) ? "capture" : "output"),
(int) *devCount, ptr, (int) dev);
#endif
(*devices)[*devCount].id = dev;
(*devices)[*devCount].name = ptr;
......@@ -186,7 +188,7 @@ free_device_lists(void)
static int
find_device_id(const char *devname, int iscapture, AudioDeviceID *id)
find_device_id(const char *devname, int iscapture, AudioDeviceID * id)
{
int i = ((iscapture) ? inputDeviceCount : outputDeviceCount);
COREAUDIO_DeviceList *devs = ((iscapture) ? inputDevices : outputDevices);
......@@ -213,7 +215,7 @@ COREAUDIO_DetectDevices(int iscapture)
return outputDeviceCount;
}
return 0; /* shouldn't ever hit this. */
return 0; /* shouldn't ever hit this. */
}
......@@ -241,10 +243,10 @@ COREAUDIO_Deinitialize(void)
/* The CoreAudio callback */
static OSStatus
outputCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp * inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioDataList)
AudioUnitRenderActionFlags * ioActionFlags,
const AudioTimeStamp * inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList * ioDataList)
{
SDL_AudioDevice *this = (SDL_AudioDevice *) inRefCon;
AudioBuffer *ioData = &ioDataList->mBuffers[0];
......@@ -288,8 +290,8 @@ outputCallback(void *inRefCon,
if (len > remaining)
len = remaining;
SDL_memcpy(ptr,
(char *) this->hidden->buffer + this->hidden->bufferOffset,
len);
(char *) this->hidden->buffer + this->hidden->bufferOffset,
len);
ptr = (char *) ptr + len;
remaining -= len;
this->hidden->bufferOffset += len;
......@@ -300,10 +302,10 @@ outputCallback(void *inRefCon,
static OSStatus
inputCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
AudioUnitRenderActionFlags * ioActionFlags,
const AudioTimeStamp * inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData)
AudioBufferList * ioData)
{
//err = AudioUnitRender(afr->fAudioUnit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, afr->fAudioBuffer);
// !!! FIXME: write me!
......@@ -321,19 +323,21 @@ COREAUDIO_CloseDevice(_THIS)
const AudioUnitElement output_bus = 0;
const AudioUnitElement input_bus = 1;
const int iscapture = this->iscapture;
const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus);
const AudioUnitScope scope = ((iscapture) ? kAudioUnitScope_Output :
kAudioUnitScope_Input);
const AudioUnitElement bus =
((iscapture) ? input_bus : output_bus);
const AudioUnitScope scope =
((iscapture) ? kAudioUnitScope_Output :
kAudioUnitScope_Input);
/* stop processing the audio unit */
result = AudioOutputUnitStop(this->hidden->audioUnit);
/* Remove the input callback */
SDL_memset(&callback, '\0', sizeof (AURenderCallbackStruct));
SDL_memset(&callback, '\0', sizeof(AURenderCallbackStruct));
result = AudioUnitSetProperty(this->hidden->audioUnit,
kAudioUnitProperty_SetRenderCallback,
scope, bus, &callback,
sizeof (callback));
sizeof(callback));
CloseComponent(this->hidden->audioUnit);
this->hidden->audioUnitOpened = 0;
......@@ -362,10 +366,10 @@ find_device_by_name(_THIS, const char *devname, int iscapture)
pid_t pid = 0;
if (devname == NULL) {
size = sizeof (AudioDeviceID);
size = sizeof(AudioDeviceID);
const AudioHardwarePropertyID propid =
((iscapture) ? kAudioHardwarePropertyDefaultInputDevice :
kAudioHardwarePropertyDefaultOutputDevice);
((iscapture) ? kAudioHardwarePropertyDefaultInputDevice :
kAudioHardwarePropertyDefaultOutputDevice);
result = AudioHardwareGetProperty(propid, &size, &devid);
CHECK_RESULT("AudioHardwareGetProperty (default device)");
......@@ -376,18 +380,19 @@ find_device_by_name(_THIS, const char *devname, int iscapture)
}
}
size = sizeof (alive);
size = sizeof(alive);
result = AudioDeviceGetProperty(devid, 0, iscapture,
kAudioDevicePropertyDeviceIsAlive,
&size, &alive);
CHECK_RESULT("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
CHECK_RESULT
("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
if (!alive) {
SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
return 0;
}
size = sizeof (pid);
size = sizeof(pid);
result = AudioDeviceGetProperty(devid, 0, iscapture,
kAudioDevicePropertyHogMode, &size, &pid);
......@@ -404,7 +409,7 @@ find_device_by_name(_THIS, const char *devname, int iscapture)
static int
prepare_audiounit(_THIS, const char *devname, int iscapture,
const AudioStreamBasicDescription *strdesc)
const AudioStreamBasicDescription * strdesc)
{
OSStatus result = noErr;
AURenderCallbackStruct callback;
......@@ -416,7 +421,7 @@ prepare_audiounit(_THIS, const char *devname, int iscapture,
const AudioUnitElement input_bus = 1;
const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus);
const AudioUnitScope scope = ((iscapture) ? kAudioUnitScope_Output :
kAudioUnitScope_Input);
kAudioUnitScope_Input);
if (!find_device_by_name(this, devname, iscapture)) {
SDL_SetError("Couldn't find requested CoreAudio device");
......@@ -445,7 +450,7 @@ prepare_audiounit(_THIS, const char *devname, int iscapture,
result = AudioUnitSetProperty(this->hidden->audioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input, input_bus,
&enableIO, sizeof (enableIO));
&enableIO, sizeof(enableIO));
CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_EnableIO input)");
// !!! FIXME: this is wrong?
......@@ -453,30 +458,32 @@ prepare_audiounit(_THIS, const char *devname, int iscapture,
result = AudioUnitSetProperty(this->hidden->audioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Output, output_bus,
&enableIO, sizeof (enableIO));
&enableIO, sizeof(enableIO));
CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_EnableIO output)");
result = AudioUnitSetProperty(this->hidden->audioUnit,
kAudioOutputUnitProperty_CurrentDevice,
kAudioUnitScope_Global, 0,
&this->hidden->deviceID,
sizeof (AudioDeviceID));
CHECK_RESULT("AudioUnitSetProperty (kAudioOutputUnitProperty_CurrentDevice)");
sizeof(AudioDeviceID));
CHECK_RESULT
("AudioUnitSetProperty (kAudioOutputUnitProperty_CurrentDevice)");
/* Set the data format of the audio unit. */
result = AudioUnitSetProperty(this->hidden->audioUnit,
kAudioUnitProperty_StreamFormat,
scope, bus, strdesc, sizeof (*strdesc));
scope, bus, strdesc, sizeof(*strdesc));
CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)");
/* Set the audio callback */
SDL_memset(&callback, '\0', sizeof (AURenderCallbackStruct));
SDL_memset(&callback, '\0', sizeof(AURenderCallbackStruct));
callback.inputProc = ((iscapture) ? inputCallback : outputCallback);
callback.inputProcRefCon = this;
result = AudioUnitSetProperty(this->hidden->audioUnit,
kAudioUnitProperty_SetRenderCallback,
scope, bus, &callback, sizeof (callback));
CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)");
scope, bus, &callback, sizeof(callback));
CHECK_RESULT
("AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)");
/* Calculate the final parameters for this audio specification */
SDL_CalculateAudioSpec(&this->spec);
......@@ -506,7 +513,7 @@ COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return (0);
......@@ -561,14 +568,14 @@ COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
if (!prepare_audiounit(this, devname, iscapture, &strdesc)) {
COREAUDIO_CloseDevice(this);
return 0; /* prepare_audiounit() will call SDL_SetError()... */
return 0; /* prepare_audiounit() will call SDL_SetError()... */
}
return 1; /* good to go. */
return 1; /* good to go. */
}
static int
COREAUDIO_Init(SDL_AudioDriverImpl *impl)
COREAUDIO_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->DetectDevices = COREAUDIO_DetectDevices;
......@@ -578,7 +585,7 @@ COREAUDIO_Init(SDL_AudioDriverImpl *impl)
impl->Deinitialize = COREAUDIO_Deinitialize;
impl->ProvidesOwnCallbackThread = 1;
build_device_lists(); /* do an initial check for devices... */
build_device_lists(); /* do an initial check for devices... */
return 1;
}
......
......@@ -190,7 +190,7 @@ SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -292,7 +292,7 @@ SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture)
}
static int
SNDMGR_Init(SDL_AudioDriverImpl *impl)
SNDMGR_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->OpenDevice = SNDMGR_OpenDevice;
......
......@@ -101,7 +101,8 @@ MINTDMA8_CloseDevice(_THIS)
DEBUG_PRINT((DEBUG_NAME "closeaudio: interrupt disabled\n"));
/* 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"));
......@@ -127,12 +128,13 @@ MINTDMA8_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(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(("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(("freq=%d\n", this->spec.freq));
if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */
this->spec.channels = 2; /* no more than stereo! */
}
/* Check formats available */
......@@ -184,7 +186,8 @@ MINTDMA8_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(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(("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(("freq=%d\n", this->spec.freq));
......@@ -255,7 +258,7 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -267,7 +270,8 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture)
/* Allocate memory for audio buffers in DMA-able RAM */
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) {
SDL_free(this->hidden);
this->hidden = NULL;
......@@ -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_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_mutex = 0;
......@@ -290,11 +295,11 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture)
/* Setup audio hardware */
MINTDMA8_InitAudio(this);
return 1; /* good to go. */
return 1; /* good to go. */
}
static int
MINTDMA8_Init(SDL_AudioDriverImpl *impl)
MINTDMA8_Init(SDL_AudioDriverImpl * impl)
{
/* Cookie _MCH present ? if not, assume ST machine */
if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
......
......@@ -94,7 +94,8 @@ MINTGSXB_CloseDevice(_THIS)
}
/* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {}
while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) {
......@@ -130,7 +131,7 @@ MINTGSXB_CheckAudio(_THIS)
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
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)) {
......@@ -141,37 +142,37 @@ MINTGSXB_CheckAudio(_THIS)
format_signed = SDL_AUDIO_ISSIGNED(this->spec.format);
format_bigendian = SDL_AUDIO_ISBIGENDIAN(this->spec.format);
switch (test_format) {
case AUDIO_U8:
case AUDIO_S8:
if (snd_format & SND_FORMAT8) {
valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY8BIT);
}
break;
case AUDIO_U16LSB:
case AUDIO_S16LSB:
case AUDIO_U16MSB:
case AUDIO_S16MSB:
if (snd_format & SND_FORMAT16) {
valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY16BIT);
}
break;
case AUDIO_S32LSB:
case AUDIO_S32MSB:
if (snd_format & SND_FORMAT32) {
valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY32BIT);
}
break;
case AUDIO_U8:
case AUDIO_S8:
if (snd_format & SND_FORMAT8) {
valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY8BIT);
}
break;
case AUDIO_U16LSB:
case AUDIO_S16LSB:
case AUDIO_U16MSB:
case AUDIO_S16MSB:
if (snd_format & SND_FORMAT16) {
valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY16BIT);
}
break;
case AUDIO_S32LSB:
case AUDIO_S32MSB:
if (snd_format & SND_FORMAT32) {
valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY32BIT);
}
break;
/* no float support... */
default:
test_format = SDL_NextAudioFormat();
break;
default:
test_format = SDL_NextAudioFormat();
break;
}
}
......@@ -238,7 +239,8 @@ MINTGSXB_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(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(("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(("freq=%d\n", this->spec.freq));
......@@ -326,7 +328,7 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -338,7 +340,8 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture)
/* Allocate memory for audio buffers in DMA-able RAM */
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) {
SDL_free(this->hidden);
this->hidden = NULL;
......@@ -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_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_mutex = 0;
......@@ -361,7 +365,7 @@ MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture)
/* Setup audio hardware */
MINTGSXB_InitAudio(this);
return 1; /* good to go. */
return 1; /* good to go. */
}
static void
......@@ -388,7 +392,7 @@ MINTGSXB_GsxbNullInterrupt(void)
}
static int
MINTGSXB_Init(SDL_AudioDriverImpl *impl)
MINTGSXB_Init(SDL_AudioDriverImpl * impl)
{
/* Cookie _SND present ? if not, assume ST machine */
if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
......
......@@ -93,7 +93,8 @@ MINTMCSN_CloseDevice(_THIS)
}
/* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {}
while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) {
......@@ -119,12 +120,13 @@ MINTMCSN_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(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(("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(("freq=%d\n", this->spec.freq));
if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */
this->spec.channels = 2; /* no more than stereo! */
}
/* Check formats available */
......@@ -132,7 +134,7 @@ MINTMCSN_CheckAudio(_THIS)
switch (cookie_mcsn->play) {
case MCSN_ST:
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);
break;
case MCSN_TT: /* Also STE, Mega STE */
......@@ -170,10 +172,10 @@ MINTMCSN_CheckAudio(_THIS)
(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) {
this->spec.format |= SDL_AUDIO_MASK_ENDIAN; /* Audio is always big endian */
this->spec.channels = 2; /* 16 bits always stereo */
this->spec.format |= SDL_AUDIO_MASK_ENDIAN; /* Audio is always big endian */
this->spec.channels = 2; /* 16 bits always stereo */
}
break;
}
......@@ -194,7 +196,8 @@ MINTMCSN_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(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(("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(("freq=%d\n", this->spec.freq));
......@@ -288,7 +291,7 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -300,7 +303,8 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture)
/* Allocate memory for audio buffers in DMA-able RAM */
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) {
SDL_free(this->hidden);
this->hidden = NULL;
......@@ -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_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_mutex = 0;
......@@ -323,11 +328,11 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture)
/* Setup audio hardware */
MINTMCSN_InitAudio(this);
return 1; /* good to go. */
return 1; /* good to go. */
}
static int
MINTMCSN_Init(SDL_AudioDriverImpl *impl)
MINTMCSN_Init(SDL_AudioDriverImpl * impl)
{
unsigned long dummy = 0;
......
......@@ -98,7 +98,8 @@ MINTSTFA_CloseDevice(_THIS)
Super(oldpile);
/* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {}
while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) {
......@@ -120,16 +121,17 @@ MINTSTFA_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(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(("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(("freq=%d\n", this->spec.freq));
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) {
this->spec.channels = 2; /* no more than stereo! */
this->spec.channels = 2; /* no more than stereo! */
}
/* Check formats available */
......@@ -154,7 +156,8 @@ MINTSTFA_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(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(("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(("freq=%d\n", this->spec.freq));
......@@ -221,7 +224,7 @@ MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -233,16 +236,18 @@ MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture)
/* Allocate memory for audio buffers in DMA-able RAM */
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) {
SDL_OutOfMemory()
SDL_free(this->hidden);
SDL_free(this->hidden);
this->hidden = NULL;
return 0;
}
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
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_mutex = 0;
......@@ -256,12 +261,12 @@ MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture)
/* Setup audio hardware */
MINTSTFA_InitAudio(this);
return 1; /* good to go. */
return 1; /* good to go. */
}
static int
MINTSTFA_Init(SDL_AudioDriverImpl *impl)
MINTSTFA_Init(SDL_AudioDriverImpl * impl)
{
/* Cookie _MCH present ? if not, assume ST machine */
if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
......
......@@ -90,7 +90,8 @@ MINTXBIOS_CloseDevice(_THIS)
}
/* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {}
while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) {
......@@ -267,18 +268,19 @@ MINTXBIOS_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(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(("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(("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 */
if (SDL_AUDIO_BITSIZE(this->spec.format) >= 16) {
this->spec.format = AUDIO_S16MSB; /* Audio is always big endian */
this->spec.channels = 2; /* 16 bits always stereo */
this->spec.format = AUDIO_S16MSB; /* Audio is always big endian */
this->spec.channels = 2; /* 16 bits always stereo */
} 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;
......@@ -314,7 +316,8 @@ MINTXBIOS_CheckAudio(_THIS)
SDL_AUDIO_BITSIZE(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(("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(("freq=%d\n", this->spec.freq));
......@@ -405,7 +408,7 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -417,7 +420,8 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture)
/* Allocate memory for audio buffers in DMA-able RAM */
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) {
SDL_free(this->hidden);
this->hidden = NULL;
......@@ -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_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_mutex = 0;
......@@ -440,11 +445,11 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture)
/* Setup audio hardware */
MINTXBIOS_InitAudio(this);
return 1; /* good to go. */
return 1; /* good to go. */
}
static int
MINTXBIOS_Init(SDL_AudioDriverImpl *impl)
MINTXBIOS_Init(SDL_AudioDriverImpl * impl)
{
unsigned long dummy = 0;
/*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); */
......
......@@ -63,7 +63,7 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -78,7 +78,7 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture)
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->wFmt.wf.wFormatTag = WAVE_FORMAT_PCM;
......@@ -88,13 +88,13 @@ MME_OpenDevice(_THIS, const char *devname, int iscapture)
!valid_format && test_format;) {
valid_format = 1;
switch (test_format) {
case AUDIO_U8:
case AUDIO_S16:
case AUDIO_S32:
break;
default:
valid_format = 0;
test_format = SDL_NextAudioFormat();
case AUDIO_U8:
case AUDIO_S16:
case AUDIO_S32:
break;
default:
valid_format = 0;
test_format = SDL_NextAudioFormat();
}
}
......@@ -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.nSamplesPerSec = this->spec.freq;
this->hidden->shm->wFmt.wf.nBlockAlign =
this->hidden->shm->wFmt.wf.nChannels *
this->hidden->shm->wFmt.wBitsPerSample / 8;
this->hidden->shm->wFmt.wf.nChannels *
this->hidden->shm->wFmt.wBitsPerSample / 8;
this->hidden->shm->wFmt.wf.nAvgBytesPerSec =
this->hidden->shm->wFmt.wf.nSamplesPerSec *
this->hidden->shm->wFmt.wf.nBlockAlign;
this->hidden->shm->wFmt.wf.nSamplesPerSec *
this->hidden->shm->wFmt.wf.nBlockAlign;
/* Check the buffer size -- minimum of 1/4 second (word aligned) */
if (this->spec.samples < (this->spec.freq / 4))
......@@ -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].dwFlags = 0;
this->hidden->shm->wHdr[i].dwUser = i;
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].dwLoops = 0; /* loop control counter */
this->hidden->shm->wHdr[i].lpNext = NULL; /* reserved for driver */
this->hidden->shm->wHdr[i].reserved = 0;
inUse[i] = FALSE;
}
......@@ -183,7 +183,7 @@ MME_PlayDevice(_THIS)
/* Queue it up */
waveOutWrite(this->hidden->shm->sound,
&(this->hidden->shm->wHdr[this->hidden->next_buffer]),
sizeof (WAVEHDR));
sizeof(WAVEHDR));
this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS;
}
......@@ -238,7 +238,7 @@ MME_CloseDevice(_THIS)
}
static int
MME_Init(SDL_AudioDriverImpl *impl)
MME_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->OpenDevice = MME_OpenDevice;
......
......@@ -43,19 +43,19 @@
static struct SDL_PrivateAudioData *this2 = NULL;
static void (*NAS_AuCloseServer)(AuServer *);
static void (*NAS_AuNextEvent)(AuServer *, AuBool, AuEvent *);
static AuBool (*NAS_AuDispatchEvent)(AuServer *, AuEvent *);
static AuFlowID (*NAS_AuCreateFlow)(AuServer *, AuStatus *);
static void (*NAS_AuStartFlow)(AuServer *, AuFlowID, AuStatus *);
static void (*NAS_AuCloseServer) (AuServer *);
static void (*NAS_AuNextEvent) (AuServer *, AuBool, AuEvent *);
static AuBool(*NAS_AuDispatchEvent) (AuServer *, AuEvent *);
static AuFlowID(*NAS_AuCreateFlow) (AuServer *, AuStatus *);
static void (*NAS_AuStartFlow) (AuServer *, AuFlowID, AuStatus *);
static void (*NAS_AuSetElements)
(AuServer *, AuFlowID, AuBool, int, AuElement *, AuStatus *);
(AuServer *, AuFlowID, AuBool, int, AuElement *, AuStatus *);
static void (*NAS_AuWriteElement)
(AuServer *, AuFlowID, int, AuUint32, AuPointer, AuBool, AuStatus *);
(AuServer *, AuFlowID, int, AuUint32, AuPointer, AuBool, AuStatus *);
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)
(AuServer *, AuMask, int, AuID, AuEventHandlerCallback, AuPointer);
(AuServer *, AuMask, int, AuID, AuEventHandlerCallback, AuPointer);
#ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC
......@@ -80,7 +80,8 @@ load_nas_sym(const char *fn, void **addr)
#define SDL_NAS_SYM(x) NAS_##x = x
#endif
static int load_nas_syms(void)
static int
load_nas_syms(void)
{
SDL_NAS_SYM(AuCloseServer);
SDL_NAS_SYM(AuNextEvent);
......@@ -93,6 +94,7 @@ static int load_nas_syms(void)
SDL_NAS_SYM(AuRegisterEventHandler);
return 0;
}
#undef SDL_NAS_SYM
#ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC
......@@ -120,7 +122,7 @@ LoadNASLibrary(void)
SDL_strlcpy(err, origerr, len);
retval = -1;
SDL_SetError("NAS: SDL_LoadObject('%s') failed: %s\n",
nas_library, err);
nas_library, err);
} else {
retval = load_nas_syms();
if (retval < 0) {
......@@ -175,7 +177,8 @@ NAS_PlayDevice(_THIS)
/* Write the audio data */
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;
......@@ -289,7 +292,7 @@ NAS_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -339,12 +342,13 @@ NAS_OpenDevice(_THIS, const char *devname, int iscapture)
this2 = this->hidden;
AuMakeElementImportClient(elms,this->spec.freq,format,this->spec.channels,
AuTrue, buffer_size, buffer_size / 4, 0, NULL);
AuMakeElementImportClient(elms, this->spec.freq, format,
this->spec.channels, AuTrue, buffer_size,
buffer_size / 4, 0, NULL);
AuMakeElementExportDevice(elms + 1, 0, this->hidden->dev, this->spec.freq,
AuUnlimitedSamples, 0, NULL);
NAS_AuSetElements(this->hidden->aud, this->hidden->flow,
AuTrue, 2, elms, NULL);
NAS_AuSetElements(this->hidden->aud, this->hidden->flow, AuTrue, 2, elms,
NULL);
NAS_AuRegisterEventHandler(this->hidden->aud, AuEventHandlerIDMask, 0,
this->hidden->flow, event_handler,
(AuPointer) NULL);
......@@ -372,7 +376,7 @@ NAS_Deinitialize(void)
}
static int
NAS_Init(SDL_AudioDriverImpl *impl)
NAS_Init(SDL_AudioDriverImpl * impl)
{
if (LoadNASLibrary() < 0) {
return 0;
......@@ -392,7 +396,7 @@ NAS_Init(SDL_AudioDriverImpl *impl)
impl->GetDeviceBuf = NAS_GetDeviceBuf;
impl->CloseDevice = NAS_CloseDevice;
impl->Deinitialize = NAS_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this true? */
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this true? */
return 1;
}
......
......@@ -141,7 +141,8 @@ NTO_WaitDevice(_THIS)
FD_SET(this->hidden->audio_fd, &wfds);
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) {
case -1:
case 0:
......@@ -185,7 +186,7 @@ NTO_PlayDevice(_THIS)
pcmbuffer += written * this->spec.channels;
continue;
} else if ((errno == EINVAL) || (errno == EIO)) {
SDL_memset(&cstatus, 0, sizeof (cstatus));
SDL_memset(&cstatus, 0, sizeof(cstatus));
cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
rval = snd_pcm_plugin_status(this->hidden->audio_handle,
&cstatus);
......@@ -194,10 +195,10 @@ NTO_PlayDevice(_THIS)
return;
}
if ( (cstatus.status == SND_PCM_STATUS_UNDERRUN) ||
(cstatus.status == SND_PCM_STATUS_READY)) {
if ((cstatus.status == SND_PCM_STATUS_UNDERRUN) ||
(cstatus.status == SND_PCM_STATUS_READY)) {
rval = snd_pcm_plugin_prepare(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
SND_PCM_CHANNEL_PLAYBACK);
if (rval < 0) {
NTO_SetError("snd_pcm_plugin_prepare", rval);
return;
......@@ -258,7 +259,7 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -374,7 +375,7 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture)
}
/* 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;
if (snd_pcm_plugin_setup(this->hidden->audio_handle, &csetup) < 0) {
NTO_CloseDevice(this);
......@@ -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
* 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) {
NTO_CloseDevice(this);
SDL_OutOfMemory();
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 */
this->hidden->audio_fd = snd_pcm_file_descriptor(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
this->hidden->audio_fd =
snd_pcm_file_descriptor(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
if (this->hidden->audio_fd < 0) {
NTO_CloseDevice(this);
NTO_SetError("snd_pcm_file_descriptor", rval);
......@@ -430,7 +434,7 @@ NTO_OpenDevice(_THIS, const char *devname, int iscapture)
static int
NTO_Init(SDL_AudioDriverImpl *impl)
NTO_Init(SDL_AudioDriverImpl * impl)
{
/* See if we can open a nonblocking channel. */
snd_pcm_t *handle = NULL;
......@@ -451,7 +455,7 @@ NTO_Init(SDL_AudioDriverImpl *impl)
impl->PlayDevice = NTO_PlayDevice;
impl->GetDeviceBuf = NTO_GetDeviceBuf;
impl->CloseDevice = NTO_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */
return 1;
}
......
......@@ -137,7 +137,9 @@ PAUDIO_WaitDevice(_THIS)
/* Use timer for general audio synchronization */
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) {
SDL_Delay(ticks);
}
......@@ -170,7 +172,8 @@ PAUDIO_WaitDevice(_THIS)
#ifdef DEBUG_AUDIO
fprintf(stderr, "Waiting for audio to get ready\n");
#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 =
"Audio timeout - buggy audio driver? (disabled)";
/*
......@@ -264,7 +267,7 @@ PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -515,7 +518,7 @@ PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
/* Check to see if we need to use select() workaround */
if (workaround != NULL) {
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;
}
......@@ -524,7 +527,7 @@ PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
}
static int
PAUDIO_Init(SDL_AudioDriverImpl *impl)
PAUDIO_Init(SDL_AudioDriverImpl * impl)
{
int fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
if (fd < 0) {
......@@ -539,7 +542,7 @@ PAUDIO_Init(SDL_AudioDriverImpl *impl)
impl->PlayDevice = DSP_WaitDevice;
impl->GetDeviceBuf = DSP_GetDeviceBuf;
impl->CloseDevice = DSP_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */
return 1;
}
......
......@@ -107,7 +107,8 @@ WINWAVEOUT_WaitDevice(_THIS)
Uint8 *
WINWAVEOUT_GetDeviceBuf(_THIS)
{
return (Uint8 *) (this->hidden->wavebuf[this->hidden->next_buffer].lpData);
return (Uint8 *) (this->hidden->wavebuf[this->hidden->next_buffer].
lpData);
}
void
......@@ -116,7 +117,7 @@ WINWAVEOUT_PlayDevice(_THIS)
/* Queue it up */
waveOutWrite(this->hidden->sound,
&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;
}
......@@ -165,7 +166,7 @@ WINWAVEOUT_CloseDevice(_THIS)
if (this->hidden->wavebuf[i].dwUser != 0xFFFF) {
waveOutUnprepareHeader(this->hidden->sound,
&this->hidden->wavebuf[i],
sizeof (this->hidden->wavebuf[i]));
sizeof(this->hidden->wavebuf[i]));
this->hidden->wavebuf[i].dwUser = 0xFFFF;
}
}
......@@ -192,7 +193,7 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -207,15 +208,15 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
valid_datatype = 1;
this->spec.format = test_format;
switch (test_format) {
case AUDIO_U8:
case AUDIO_S16:
case AUDIO_S32:
break; /* valid. */
default:
valid_datatype = 0;
test_format = SDL_NextAudioFormat();
break;
case AUDIO_U8:
case AUDIO_S16:
case AUDIO_S32:
break; /* valid. */
default:
valid_datatype = 0;
test_format = SDL_NextAudioFormat();
break;
}
}
......@@ -226,12 +227,12 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
}
/* Set basic WAVE format parameters */
SDL_memset(&waveformat, '\0', sizeof (waveformat));
SDL_memset(&waveformat, '\0', sizeof(waveformat));
waveformat.wFormatTag = WAVE_FORMAT_PCM;
waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
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.nSamplesPerSec = this->spec.freq;
......@@ -273,11 +274,11 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
#endif
/* Create the audio buffer semaphore */
this->hidden->audio_sem =
this->hidden->audio_sem =
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
CreateSemaphoreCE(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
CreateSemaphoreCE(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
#else
CreateSemaphore(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
CreateSemaphore(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
#endif
if (this->hidden->audio_sem == NULL) {
WINWAVEOUT_CloseDevice(this);
......@@ -286,7 +287,8 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
}
/* 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) {
WINWAVEOUT_CloseDevice(this);
SDL_OutOfMemory();
......@@ -294,14 +296,14 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
}
for (i = 0; i < NUM_BUFFERS; ++i) {
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].dwFlags = WHDR_DONE;
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,
&this->hidden->wavebuf[i],
sizeof (this->hidden->wavebuf[i]));
sizeof(this->hidden->wavebuf[i]));
if (result != MMSYSERR_NOERROR) {
WINWAVEOUT_CloseDevice(this);
SetMMerror("waveOutPrepareHeader()", result);
......@@ -309,12 +311,12 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
}
}
return 1; /* Ready to go! */
return 1; /* Ready to go! */
}
static int
WINWAVEOUT_Init(SDL_AudioDriverImpl *impl)
WINWAVEOUT_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->OpenDevice = WINWAVEOUT_OpenDevice;
......@@ -324,7 +326,7 @@ WINWAVEOUT_Init(SDL_AudioDriverImpl *impl)
impl->WaitDone = WINWAVEOUT_WaitDone;
impl->GetDeviceBuf = WINWAVEOUT_GetDeviceBuf;
impl->CloseDevice = WINWAVEOUT_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Is this true? */
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Is this true? */
return 1;
}
......
......@@ -39,7 +39,8 @@
/* DirectX function pointers for audio */
static HINSTANCE DSoundDLL = NULL;
static HRESULT (WINAPI *DSoundCreate)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN) = NULL;
static HRESULT(WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN) =
NULL;
static void
DSOUND_Unload(void)
......@@ -70,7 +71,7 @@ DSOUND_Load(void)
SDL_SetError("DirectSound: System doesn't appear to have DX5.");
} else {
DSoundCreate = (void *) GetProcAddress(DSoundDLL,
TEXT("DirectSoundCreate"));
TEXT("DirectSoundCreate"));
}
if (!DSoundCreate) {
......@@ -271,14 +272,14 @@ DSOUND_GetDeviceBuf(_THIS)
/* Lock the audio buffer */
result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
this->hidden->mixlen,
(LPVOID *) &this->hidden->locked_buf,
(LPVOID *) & this->hidden->locked_buf,
&rawlen, NULL, &junk, 0);
if (result == DSERR_BUFFERLOST) {
IDirectSoundBuffer_Restore(this->hidden->mixbuf);
result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
this->hidden->mixlen,
(LPVOID *) &this->hidden->locked_buf,
&rawlen, NULL, &junk, 0);
(LPVOID *) & this->hidden->
locked_buf, &rawlen, NULL, &junk, 0);
}
if (result != DS_OK) {
SetDSerror("DirectSound Lock", result);
......@@ -326,7 +327,7 @@ DSOUND_CloseDevice(_THIS)
number of audio chunks available in the created buffer.
*/
static int
CreateSecondary(_THIS, HWND focus, WAVEFORMATEX *wavefmt)
CreateSecondary(_THIS, HWND focus, WAVEFORMATEX * wavefmt)
{
LPDIRECTSOUND sndObj = this->hidden->sound;
LPDIRECTSOUNDBUFFER *sndbuf = &this->hidden->mixbuf;
......@@ -405,7 +406,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
......@@ -414,12 +415,12 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
while ((!valid_format) && (test_format)) {
switch (test_format) {
case AUDIO_U8:
case AUDIO_S16:
case AUDIO_S32:
this->spec.format = test_format;
valid_format = 1;
break;
case AUDIO_U8:
case AUDIO_S16:
case AUDIO_S32:
this->spec.format = test_format;
valid_format = 1;
break;
}
test_format = SDL_NextAudioFormat();
}
......@@ -461,7 +462,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
/* The buffer will auto-start playing in DSOUND_WaitDevice() */
this->hidden->mixlen = this->spec.size;
return 1; /* good to go. */
return 1; /* good to go. */
}
......@@ -473,7 +474,7 @@ DSOUND_Deinitialize(void)
static int
DSOUND_Init(SDL_AudioDriverImpl *impl)
DSOUND_Init(SDL_AudioDriverImpl * impl)
{
OSVERSIONINFO ver;
......@@ -482,12 +483,12 @@ DSOUND_Init(SDL_AudioDriverImpl *impl)
* audio buffers used by many SDL applications, so there are gaps in the
* audio - it sounds terrible. Punt for now.
*/
SDL_memset(&ver, '\0', sizeof (OSVERSIONINFO));
SDL_memset(&ver, '\0', sizeof(OSVERSIONINFO));
ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&ver);
if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
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)
impl->GetDeviceBuf = DSOUND_GetDeviceBuf;
impl->CloseDevice = DSOUND_CloseDevice;
impl->Deinitialize = DSOUND_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME */
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME */
return 1;
}
......
......@@ -64,6 +64,7 @@ SDL_GetTicks(void)
hires_now /= hires_ticks_per_second;
*/
/* inline asm to avoid runtime inclusion */
/* *INDENT-OFF* */
_asm {
push edx
push eax
......@@ -87,6 +88,7 @@ SDL_GetTicks(void)
pop edx
pop eax
}
/* *INDENT-ON* */
return ticks;
......
#include "SDL.h"
static void print_devices(int iscapture)
static void
print_devices(int iscapture)
{
const char *typestr = ((iscapture) ? "capture" : "output");
int n = SDL_GetNumAudioDevices(iscapture);
......@@ -11,8 +12,7 @@ static void print_devices(int iscapture)
printf(" Driver can't detect specific devices.\n\n", typestr);
else if (n == 0)
printf(" No %s devices found.\n\n", typestr);
else
{
else {
int i;
for (i = 0; i < n; i++) {
printf(" %s\n", SDL_GetAudioDeviceName(i, 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 */
int n = SDL_GetNumAudioDrivers();
......@@ -50,4 +51,3 @@ int main(int argc, char **argv)
SDL_Quit();
return 0;
}
#include "SDL.h"
static SDL_AudioSpec spec;
static Uint8 *sound = NULL; /* Pointer to wave data */
static Uint32 soundlen = 0; /* Length of wave data */
static Uint8 *sound = NULL; /* Pointer to wave data */
static Uint32 soundlen = 0; /* Length of wave data */
typedef struct
{
......@@ -11,7 +11,8 @@ typedef struct
volatile int done;
} 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;
Uint8 *waveptr = sound + cbd->soundpos;
......@@ -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];
int keep_going = 1;
int i;
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;
}
......@@ -48,7 +51,7 @@ static void test_multi_audio(int devcount)
printf("playing on device #%d: ('%s')...", i, devname);
fflush(stdout);
memset(&cbd[0], '\0', sizeof (callback_data));
memset(&cbd[0], '\0', sizeof(callback_data));
spec.userdata = &cbd[0];
cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL);
if (cbd[0].dev == 0) {
......@@ -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");
for (i = 0; i < devcount; i++) {
......@@ -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;
......@@ -124,7 +128,8 @@ int main(int argc, char **argv)
/* Load the wave file into memory */
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 {
test_multi_audio(devcount);
SDL_FreeWAV(sound);
......
......@@ -276,7 +276,7 @@ int
main(int argc, char *argv[])
{
SDL_Event event;
char *title;
const char *title;
SDL_Surface *icon;
Uint8 *icon_mask;
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