indent is evil
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402208
This commit is contained in:
parent
3d24370c4c
commit
05a29201de
35 changed files with 586 additions and 497 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -366,8 +395,8 @@ SDL_AudioInit(const char *driver_name)
|
|||
SDL_AudioQuit(); /* shutdown driver if already running. */
|
||||
}
|
||||
|
||||
SDL_memset(¤t_audio, '\0', sizeof (current_audio));
|
||||
SDL_memset(open_devices, '\0', sizeof (open_devices));
|
||||
SDL_memset(¤t_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(¤t_audio, 0, sizeof (current_audio));
|
||||
SDL_memset(¤t_audio, 0, sizeof(current_audio));
|
||||
current_audio.name = backend->name;
|
||||
current_audio.desc = backend->desc;
|
||||
initialized = backend->init(¤t_audio.impl);
|
||||
|
@ -399,7 +428,7 @@ SDL_AudioInit(const char *driver_name)
|
|||
}
|
||||
}
|
||||
|
||||
SDL_memset(¤t_audio, 0, sizeof (current_audio));
|
||||
SDL_memset(¤t_audio, 0, sizeof(current_audio));
|
||||
return (-1); /* No driver was available, so fail. */
|
||||
}
|
||||
|
||||
|
@ -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,7 +540,7 @@ 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) ) {
|
||||
if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) {
|
||||
prepared->freq = 22050; /* a reasonable default */
|
||||
}
|
||||
}
|
||||
|
@ -524,9 +553,9 @@ prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
|
|||
}
|
||||
|
||||
switch (orig->channels) {
|
||||
case 0: {
|
||||
case 0:{
|
||||
const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
|
||||
if ( (!env) || ((prepared->channels = SDL_atoi(env)) == 0) ) {
|
||||
if ((!env) || ((prepared->channels = SDL_atoi(env)) == 0)) {
|
||||
prepared->channels = 2; /* a reasonable default */
|
||||
}
|
||||
break;
|
||||
|
@ -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,7 +593,7 @@ 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,
|
||||
const SDL_AudioSpec * _desired, SDL_AudioSpec * obtained,
|
||||
int min_id)
|
||||
{
|
||||
SDL_AudioDeviceID id = 0;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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(¤t_audio, '\0', sizeof (current_audio));
|
||||
SDL_memset(open_devices, '\0', sizeof (open_devices));
|
||||
SDL_memset(¤t_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,7 +107,7 @@ typedef struct AudioBootStrap
|
|||
{
|
||||
const char *name;
|
||||
const char *desc;
|
||||
int (*init) (SDL_AudioDriverImpl *impl);
|
||||
int (*init) (SDL_AudioDriverImpl * impl);
|
||||
int demand_only:1; /* 1==request explicitly, or it won't be available. */
|
||||
} AudioBootStrap;
|
||||
|
||||
|
|
|
@ -44,40 +44,42 @@
|
|||
|
||||
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);
|
||||
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);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_format)
|
||||
(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 *);
|
||||
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)
|
||||
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)
|
||||
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);
|
||||
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);
|
||||
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
|
||||
|
@ -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);
|
||||
}
|
||||
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;
|
||||
|
|
|
@ -66,15 +66,13 @@ static struct
|
|||
const char *name;
|
||||
void **func;
|
||||
} arts_functions[] = {
|
||||
SDL_ARTS_SYM(arts_init),
|
||||
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_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,8 +156,7 @@ static void
|
|||
ARTS_PlayDevice(_THIS)
|
||||
{
|
||||
/* Write the audio data */
|
||||
int written = SDL_NAME(arts_write) (
|
||||
this->hidden->stream,
|
||||
int written = SDL_NAME(arts_write) (this->hidden->stream,
|
||||
this->hidden->mixbuf,
|
||||
this->hidden->mixlen);
|
||||
|
||||
|
@ -257,13 +255,13 @@ 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,
|
||||
this->hidden->stream = SDL_NAME(arts_play_stream) (this->spec.freq,
|
||||
bits,
|
||||
this->spec.channels,
|
||||
"SDL");
|
||||
|
||||
/* Calculate the final parameters for this audio specification */
|
||||
|
@ -316,7 +314,7 @@ ARTS_Deinitialize(void)
|
|||
|
||||
|
||||
static int
|
||||
ARTS_Init(SDL_AudioDriverImpl *impl)
|
||||
ARTS_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
if (LoadARTSLibrary() < 0) {
|
||||
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: */
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -113,7 +113,6 @@ DART_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
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;
|
||||
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -167,8 +167,10 @@ IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -36,7 +36,7 @@ DUMMYAUD_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
}
|
||||
|
||||
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 */
|
||||
}
|
||||
|
@ -275,7 +273,8 @@ ESD_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
|
||||
/* 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;
|
||||
|
@ -78,8 +79,8 @@ 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;
|
||||
|
||||
|
@ -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
|
||||
#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);
|
||||
|
@ -241,10 +243,10 @@ COREAUDIO_Deinitialize(void)
|
|||
/* The CoreAudio callback */
|
||||
static OSStatus
|
||||
outputCallback(void *inRefCon,
|
||||
AudioUnitRenderActionFlags *ioActionFlags,
|
||||
AudioUnitRenderActionFlags * ioActionFlags,
|
||||
const AudioTimeStamp * inTimeStamp,
|
||||
UInt32 inBusNumber, UInt32 inNumberFrames,
|
||||
AudioBufferList *ioDataList)
|
||||
AudioBufferList * ioDataList)
|
||||
{
|
||||
SDL_AudioDevice *this = (SDL_AudioDevice *) inRefCon;
|
||||
AudioBuffer *ioData = &ioDataList->mBuffers[0];
|
||||
|
@ -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 :
|
||||
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,7 +366,7 @@ 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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -568,7 +575,7 @@ COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
}
|
||||
|
||||
static int
|
||||
COREAUDIO_Init(SDL_AudioDriverImpl *impl)
|
||||
COREAUDIO_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
/* Set the function pointers */
|
||||
impl->DetectDevices = COREAUDIO_DetectDevices;
|
||||
|
|
|
@ -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,7 +128,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));
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -294,7 +299,7 @@ MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
}
|
||||
|
||||
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]) {
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,7 +120,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));
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -327,7 +332,7 @@ MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
}
|
||||
|
||||
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,7 +121,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));
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
@ -233,7 +236,8 @@ 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);
|
||||
|
@ -242,7 +246,8 @@ MINTSTFA_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;
|
||||
|
||||
|
@ -261,7 +266,7 @@ MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
|
||||
|
||||
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,7 +268,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));
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -444,7 +449,7 @@ MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
}
|
||||
|
||||
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); */
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -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,11 +43,11 @@
|
|||
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 *);
|
||||
static void (*NAS_AuWriteElement)
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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,7 +195,7 @@ NTO_PlayDevice(_THIS)
|
|||
return;
|
||||
}
|
||||
|
||||
if ( (cstatus.status == SND_PCM_STATUS_UNDERRUN) ||
|
||||
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);
|
||||
|
@ -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,16 +399,19 @@ 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,
|
||||
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);
|
||||
|
@ -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;
|
||||
|
|
|
@ -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)";
|
||||
/*
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +227,7 @@ 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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -314,7 +316,7 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
|
||||
|
||||
static int
|
||||
WINWAVEOUT_Init(SDL_AudioDriverImpl *impl)
|
||||
WINWAVEOUT_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
/* Set the function pointers */
|
||||
impl->OpenDevice = WINWAVEOUT_OpenDevice;
|
||||
|
|
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -473,7 +474,7 @@ DSOUND_Deinitialize(void)
|
|||
|
||||
|
||||
static int
|
||||
DSOUND_Init(SDL_AudioDriverImpl *impl)
|
||||
DSOUND_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
OSVERSIONINFO ver;
|
||||
|
||||
|
@ -482,7 +483,7 @@ 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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue