Use common module prefix.

This commit is contained in:
Johns 2012-01-20 19:56:06 +01:00
parent 0422b6aa5a
commit 5ba88bb822

37
audio.c
View File

@ -99,7 +99,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
/** /**
** Audio output module typedef. ** Audio output module structure and typedef.
*/ */
typedef struct _audio_module_ typedef struct _audio_module_
{ {
@ -117,12 +117,16 @@ typedef struct _audio_module_
void (*Exit) (void); ///< cleanup audio output module void (*Exit) (void); ///< cleanup audio output module
} AudioModule; } AudioModule;
static const AudioModule NoopModule; ///< forward definition of noop module
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Variables // Variables
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static const char *AudioModuleName; ///< which audio module to use static const char *AudioModuleName; ///< which audio module to use
static const AudioModule *UsedAudioModule; ///< Selected audio module.
/// Selected audio module.
static const AudioModule *AudioUsedModule = &NoopModule;
static const char *AudioPCMDevice; ///< alsa/OSS PCM device name static const char *AudioPCMDevice; ///< alsa/OSS PCM device name
static const char *AudioMixerDevice; ///< alsa/OSS mixer device name static const char *AudioMixerDevice; ///< alsa/OSS mixer device name
static const char *AudioMixerChannel; ///< alsa/OSS mixer channel name static const char *AudioMixerChannel; ///< alsa/OSS mixer channel name
@ -1863,7 +1867,7 @@ static void *AudioPlayHandlerThread(void *dummy)
#endif #endif
Debug(3, "audio: play start\n"); Debug(3, "audio: play start\n");
UsedAudioModule->Thread(); AudioUsedModule->Thread();
} }
return dummy; return dummy;
@ -1928,7 +1932,7 @@ static const AudioModule *AudioModules[] = {
*/ */
void AudioEnqueue(const void *samples, int count) void AudioEnqueue(const void *samples, int count)
{ {
UsedAudioModule->Enqueue(samples, count); AudioUsedModule->Enqueue(samples, count);
} }
/** /**
@ -1936,7 +1940,7 @@ void AudioEnqueue(const void *samples, int count)
*/ */
void AudioFlushBuffers(void) void AudioFlushBuffers(void)
{ {
UsedAudioModule->FlushBuffers(); AudioUsedModule->FlushBuffers();
} }
/** /**
@ -1944,7 +1948,7 @@ void AudioFlushBuffers(void)
*/ */
void AudioPoller(void) void AudioPoller(void)
{ {
UsedAudioModule->Poller(); AudioUsedModule->Poller();
} }
/** /**
@ -1952,7 +1956,7 @@ void AudioPoller(void)
*/ */
int AudioFreeBytes(void) int AudioFreeBytes(void)
{ {
return UsedAudioModule->FreeBytes(); return AudioUsedModule->FreeBytes();
} }
/** /**
@ -1962,7 +1966,7 @@ int AudioFreeBytes(void)
*/ */
uint64_t AudioGetDelay(void) uint64_t AudioGetDelay(void)
{ {
return UsedAudioModule->GetDelay(); return AudioUsedModule->GetDelay();
} }
/** /**
@ -2041,7 +2045,7 @@ int AudioSetup(int *freq, int *channels)
// FIXME: need to store possible combination and report this // FIXME: need to store possible combination and report this
return AudioRingAdd(*freq, *channels); return AudioRingAdd(*freq, *channels);
#endif #endif
return UsedAudioModule->Setup(freq, channels); return AudioUsedModule->Setup(freq, channels);
} }
/** /**
@ -2089,27 +2093,27 @@ void AudioInit(void)
// //
for (u = 0; u < sizeof(AudioModules) / sizeof(*AudioModules); ++u) { for (u = 0; u < sizeof(AudioModules) / sizeof(*AudioModules); ++u) {
if (!strcasecmp(name, AudioModules[u]->Name)) { if (!strcasecmp(name, AudioModules[u]->Name)) {
UsedAudioModule = AudioModules[u]; AudioUsedModule = AudioModules[u];
Info(_("audio: '%s' output module used\n"), UsedAudioModule->Name); Info(_("audio: '%s' output module used\n"), AudioUsedModule->Name);
goto found; goto found;
} }
} }
Error(_("audio: '%s' output module isn't supported\n"), name); Error(_("audio: '%s' output module isn't supported\n"), name);
UsedAudioModule = &NoopModule; AudioUsedModule = &NoopModule;
return; return;
found: found:
#ifdef USE_AUDIORING #ifdef USE_AUDIORING
AudioRingInit(); AudioRingInit();
#endif #endif
UsedAudioModule->Init(); AudioUsedModule->Init();
freq = 48000; freq = 48000;
chan = 2; chan = 2;
if (AudioSetup(&freq, &chan)) { // set default parameters if (AudioSetup(&freq, &chan)) { // set default parameters
Error(_("audio: can't do initial setup\n")); Error(_("audio: can't do initial setup\n"));
} }
#ifdef USE_AUDIO_THREAD #ifdef USE_AUDIO_THREAD
if (UsedAudioModule->Thread) { // supports threads if (AudioUsedModule->Thread) { // supports threads
AudioInitThread(); AudioInitThread();
} }
#endif #endif
@ -2125,9 +2129,8 @@ void AudioExit(void)
#ifdef USE_AUDIO_THREAD #ifdef USE_AUDIO_THREAD
AudioExitThread(); AudioExitThread();
#endif #endif
if (UsedAudioModule) { AudioUsedModule->Exit();
UsedAudioModule->Exit(); AudioUsedModule = &NoopModule;
}
#ifdef USE_AUDIORING #ifdef USE_AUDIORING
AudioRingExit(); AudioRingExit();
#endif #endif