Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific cra…

…p out of

 the core and into the drivers where it belongs, and push generic
 responsibilities out of the drivers and into the core where they belong.
  • Loading branch information
icculus committed Oct 4, 2006
1 parent 9da9dd9 commit 5c6e38b8b23912a5b809dbe5444aff309ef7987c

Large diffs are not rendered by default.

@@ -45,6 +45,13 @@ typedef struct SDL_AudioDriverImpl
void (*LockDevice) (_THIS);
void (*UnlockDevice) (_THIS);
void (*Deinitialize) (void);

/* Some flags to push duplicate code into the core and reduce #ifdefs. */
int ProvidesOwnCallbackThread:1;
int SkipMixerLock:1;
int HasCaptureSupport:1;
int OnlyHasDefaultOutputDevice:1;
int OnlyHasDefaultInputDevice:1;
} SDL_AudioDriverImpl;


@@ -65,10 +72,6 @@ typedef struct SDL_AudioDriver
/* Define the SDL audio driver structure */
struct SDL_AudioDevice
{
/* * * */
/* Lowlevel audio implementation */
const SDL_AudioDriver *driver;

/* * * */
/* Data common to all devices */

@@ -79,6 +82,7 @@ struct SDL_AudioDevice
SDL_AudioCVT convert;

/* Current state flags */
int iscapture;
int enabled;
int paused;
int opened;
@@ -96,10 +100,6 @@ struct SDL_AudioDevice
/* * * */
/* Data private to this driver */
struct SDL_PrivateAudioData *hidden;

/* * * */
/* The function used to dispose of this structure */
void (*free) (_THIS);
};
#undef _THIS

@@ -111,77 +111,5 @@ typedef struct AudioBootStrap
int (*init) (SDL_AudioDriverImpl *impl);
} AudioBootStrap;

#if SDL_AUDIO_DRIVER_BSD
extern AudioBootStrap BSD_AUDIO_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_OSS
extern AudioBootStrap DSP_bootstrap;
extern AudioBootStrap DMA_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_ALSA
extern AudioBootStrap ALSA_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_QNXNTO
extern AudioBootStrap QNXNTOAUDIO_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_SUNAUDIO
extern AudioBootStrap SUNAUDIO_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_DMEDIA
extern AudioBootStrap DMEDIA_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_ARTS
extern AudioBootStrap ARTS_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_ESD
extern AudioBootStrap ESD_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_NAS
extern AudioBootStrap NAS_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_DSOUND
extern AudioBootStrap DSOUND_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_WAVEOUT
extern AudioBootStrap WAVEOUT_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_PAUD
extern AudioBootStrap Paud_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_BAUDIO
extern AudioBootStrap BAUDIO_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_COREAUDIO
extern AudioBootStrap COREAUDIO_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_SNDMGR
extern AudioBootStrap SNDMGR_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_AHI
extern AudioBootStrap AHI_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_MINT
extern AudioBootStrap MINTAUDIO_GSXB_bootstrap;
extern AudioBootStrap MINTAUDIO_MCSN_bootstrap;
extern AudioBootStrap MINTAUDIO_STFA_bootstrap;
extern AudioBootStrap MINTAUDIO_XBIOS_bootstrap;
extern AudioBootStrap MINTAUDIO_DMA8_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_DISK
extern AudioBootStrap DISKAUD_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_DUMMY
extern AudioBootStrap DUMMYAUD_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_DC
extern AudioBootStrap DCAUD_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_MMEAUDIO
extern AudioBootStrap MMEAUDIO_bootstrap;
#endif
#if SDL_AUDIO_DRIVER_DART
extern AudioBootStrap DART_bootstrap;
#endif

#endif /* _SDL_sysaudio_h */
/* vi: set ts=4 sw=4 expandtab: */
@@ -285,7 +285,25 @@ DART_OpenAudio(_THIS, SDL_AudioSpec * spec)
void
DART_ThreadInit(_THIS)
{
return;
/* Increase the priority of this thread to make sure that
the audio will be continuous all the time! */
#ifdef USE_DOSSETPRIORITY
if (SDL_getenv("SDL_USE_TIMECRITICAL_AUDIO")) {
#ifdef DEBUG_BUILD
printf
("[SDL_RunAudio] : Setting priority to TimeCritical+0! (TID%d)\n",
SDL_ThreadID());
#endif
DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
} else {
#ifdef DEBUG_BUILD
printf
("[SDL_RunAudio] : Setting priority to ForegroundServer+0! (TID%d)\n",
SDL_ThreadID());
#endif
DosSetPriority(PRTYS_THREAD, PRTYC_FOREGROUNDSERVER, 0, 0);
}
#endif
}

/* This function waits until it is possible to write a full sound buffer */
@@ -65,6 +65,7 @@ DUMMYAUD_Init(SDL_AudioDriverImpl *impl)
impl->PlayDevice = DUMMYAUD_PlayDevice;
impl->GetDeviceBuf = DUMMYAUD_GetDeviceBuf;
impl->CloseDevice = DUMMYAUD_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1;

return 1;
}
@@ -233,7 +233,7 @@ COREAUDIO_Init(SDL_AudioDriverImpl *impl)
impl->GetDeviceBuf = COREAUDIO_GetDeviceBuf;
impl->CloseDevice = COREAUDIO_CloseDevice;
impl->Deinitialize = COREAUDIO_Deinitialize;

impl->ProvidesOwnCallbackThread = 1;
return 1;
}

@@ -382,7 +382,7 @@ COREAUDIO_CloseDevice(_THIS)
AURenderCallbackStruct callback;
const AudioUnitElement output_bus = 0;
const AudioUnitElement input_bus = 1;
const int iscapture = this->hidden->isCapture;
const int iscapture = this->iscapture;
const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus);
const AudioUnitScope scope = ((iscapture) ? kAudioUnitScope_Output :
kAudioUnitScope_Input);
@@ -571,8 +571,6 @@ COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
}
SDL_memset(this->hidden, 0, (sizeof *this->hidden));

this->hidden->isCapture = iscapture;

/* Setup a AudioStreamBasicDescription with the requested format */
memset(&strdesc, '\0', sizeof(AudioStreamBasicDescription));
strdesc.mFormatID = kAudioFormatLinearPCM;
@@ -36,7 +36,6 @@ struct SDL_PrivateAudioData
UInt32 bufferOffset;
UInt32 bufferSize;
AudioDeviceID deviceID;
int isCapture;
};

#endif /* _SDL_coreaudio_h */
@@ -70,14 +70,16 @@ static int
SNDMGR_Init(SDL_AudioDriverImpl *impl)
{
/* Set the function pointers */
impl->DetectDevices = SNDMGR_DetectDevices;
impl->GetDeviceName = SNDMGR_GetDeviceName;
impl->OpenDevice = SNDMGR_OpenDevice;
impl->CloseDevice = SNDMGR_CloseDevice;
impl->ProvidesOwnCallbackThread = 1;
impl->OnlyHasDefaultOutputDevice = 1;

#ifndef __MACOSX__ /* Mac OS X uses threaded audio, so normal thread code is okay */
impl->LockDevice = SNDMGR_LockDevice;
impl->UnlockDevice = SNDMGR_UnlockDevice;

#ifdef __MACOSX__ /* Mac OS X uses threaded audio, so normal thread code is okay */
impl->LockDevice = NULL;
impl->UnlockDevice = NULL;
#endif

return 1;
@@ -90,7 +92,6 @@ AudioBootStrap SNDMGR_bootstrap = {

#pragma options align=power

static volatile int audio_is_opened = 0;
static volatile SInt32 audio_is_locked = 0;
static volatile SInt32 need_to_mix = 0;

@@ -99,6 +100,7 @@ static volatile UInt32 running = 0;
static CmpSoundHeader header;
static volatile Uint32 fill_me = 0;


static void
mix_buffer(SDL_AudioDevice * audio, UInt8 * buffer)
{
@@ -206,18 +208,6 @@ SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture)
int i;
long initOptions;

if (audio_is_opened) {
SDL_SetError("SoundManager driver doesn't support multiple opens");
return 0;
}

if (iscapture) {
SDL_SetError("SoundManager driver doesn't support recording");
return 0;
}

/* !!! FIXME: ignore devname? */

/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
@@ -320,14 +310,12 @@ SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture)
SndDoCommand(channel, &cmd, 0);
}

audio_is_opened = 1;
return 1;
}

static void
SNDMGR_CloseDevice(_THIS)
{

int i;

running = 0;
@@ -345,7 +333,6 @@ SNDMGR_CloseDevice(_THIS)
}
SDL_free(this->hidden);
this->hidden = NULL;
audio_is_opened = 0;
}

/* vi: set ts=4 sw=4 expandtab: */
@@ -150,6 +150,11 @@ Audio_CreateDevice(int devindex)
this->UnlockAudio = Mint_UnlockAudio;
this->free = Audio_DeleteDevice;

/* Uses interrupt driven audio, without thread */
#if SDL_THREADS_DISABLED
this->SkipMixerLock = 1;
#endif

return this;
}

@@ -156,6 +156,11 @@ Audio_CreateDevice(int devindex)
this->UnlockAudio = Mint_UnlockAudio;
this->free = Audio_DeleteDevice;

/* Uses interrupt driven audio, without thread */
#if SDL_THREADS_DISABLED
this->SkipMixerLock = 1;
#endif

return this;
}

@@ -171,6 +171,11 @@ Audio_CreateDevice(int devindex)
this->UnlockAudio = Mint_UnlockAudio;
this->free = Audio_DeleteDevice;

/* Uses interrupt driven audio, without thread */
#if SDL_THREADS_DISABLED
this->SkipMixerLock = 1;
#endif

return this;
}

@@ -150,6 +150,11 @@ Audio_CreateDevice(int devindex)
this->UnlockAudio = Mint_UnlockAudio;
this->free = Audio_DeleteDevice;

/* Uses interrupt driven audio, without thread */
#if SDL_THREADS_DISABLED
this->SkipMixerLock = 1;
#endif

return this;
}

@@ -155,6 +155,11 @@ Audio_CreateDevice(int devindex)
this->UnlockAudio = Mint_UnlockAudio;
this->free = Audio_DeleteDevice;

/* Uses interrupt driven audio, without thread */
#if SDL_THREADS_DISABLED
this->SkipMixerLock = 1;
#endif

return this;
}

0 comments on commit 5c6e38b

Please sign in to comment.