Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific cra…
Browse files Browse the repository at this point in the history
…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 5c6e38b
Show file tree
Hide file tree
Showing 12 changed files with 264 additions and 211 deletions.
307 changes: 202 additions & 105 deletions src/audio/SDL_audio.c

Large diffs are not rendered by default.

88 changes: 8 additions & 80 deletions src/audio/SDL_sysaudio.h
Expand Up @@ -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;


Expand All @@ -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 */

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

/* Current state flags */
int iscapture;
int enabled;
int paused;
int opened;
Expand All @@ -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

Expand All @@ -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: */
20 changes: 19 additions & 1 deletion src/audio/dart/SDL_dart.c
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/audio/dummy/SDL_dummyaudio.c
Expand Up @@ -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;
}
Expand Down
6 changes: 2 additions & 4 deletions src/audio/macosx/SDL_coreaudio.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/audio/macosx/SDL_coreaudio.h
Expand Up @@ -36,7 +36,6 @@ struct SDL_PrivateAudioData
UInt32 bufferOffset;
UInt32 bufferSize;
AudioDeviceID deviceID;
int isCapture;
};

#endif /* _SDL_coreaudio_h */
Expand Down
27 changes: 7 additions & 20 deletions src/audio/macrom/SDL_romaudio.c
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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)
{
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand All @@ -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: */
5 changes: 5 additions & 0 deletions src/audio/mint/SDL_mintaudio_dma8.c
Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions src/audio/mint/SDL_mintaudio_gsxb.c
Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions src/audio/mint/SDL_mintaudio_mcsn.c
Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions src/audio/mint/SDL_mintaudio_stfa.c
Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions src/audio/mint/SDL_mintaudio_xbios.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit 5c6e38b

Please sign in to comment.