Now that Core Audio works, reduce the number of build permutations a bit
by not linking in other Unix audio modules. Use kAudioUnitSubType_DefaultOutput instead of kAudioUnitSubType_HALOutput so that a runtime switch to another audio device is automatically handled. Use ERROR_LOG for audio errors. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5562 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
f7494e6b2b
commit
9d7b569ccb
24
SConstruct
24
SConstruct
|
@ -288,29 +288,25 @@ env['HAVE_SDL'] = conf.CheckSDL('1.0.0')
|
||||||
env['HAVE_BLUEZ'] = conf.CheckPKG('bluez')
|
env['HAVE_BLUEZ'] = conf.CheckPKG('bluez')
|
||||||
|
|
||||||
# needed for sound
|
# needed for sound
|
||||||
env['HAVE_AO'] = 0
|
|
||||||
if not env['noao']:
|
|
||||||
env['HAVE_AO'] = conf.CheckPKG('ao')
|
|
||||||
|
|
||||||
env['HAVE_OPENAL'] = 0
|
|
||||||
if env['openal']:
|
|
||||||
env['HAVE_OPENAL'] = conf.CheckPKG('openal')
|
|
||||||
|
|
||||||
env['HAVE_ALSA'] = conf.CheckPKG('alsa')
|
env['HAVE_ALSA'] = conf.CheckPKG('alsa')
|
||||||
|
|
||||||
|
env['HAVE_AO'] = 0
|
||||||
|
env['HAVE_OPENAL'] = 0
|
||||||
|
env['HAVE_PORTAUDIO'] = 0
|
||||||
env['HAVE_PULSEAUDIO'] = 0
|
env['HAVE_PULSEAUDIO'] = 0
|
||||||
#env['HAVE_PULSEAUDIO'] = conf.CheckPKG('libpulse')
|
if sys.platform != 'darwin':
|
||||||
|
if not env['noao']:
|
||||||
|
env['HAVE_AO'] = conf.CheckPKG('ao')
|
||||||
|
if env['openal']:
|
||||||
|
env['HAVE_OPENAL'] = conf.CheckPKG('openal')
|
||||||
|
env['HAVE_PORTAUDIO'] = conf.CheckPortaudio(1890)
|
||||||
|
#env['HAVE_PULSEAUDIO'] = conf.CheckPKG('libpulse')
|
||||||
|
|
||||||
# OpenCL
|
# OpenCL
|
||||||
env['HAVE_OPENCL'] = 0
|
env['HAVE_OPENCL'] = 0
|
||||||
if env['opencl']:
|
if env['opencl']:
|
||||||
env['HAVE_OPENCL'] = conf.CheckPKG('OpenCL')
|
env['HAVE_OPENCL'] = conf.CheckPKG('OpenCL')
|
||||||
|
|
||||||
env['HAVE_PORTAUDIO'] = 0
|
|
||||||
if sys.platform != 'darwin':
|
|
||||||
# needed for mic
|
|
||||||
env['HAVE_PORTAUDIO'] = conf.CheckPortaudio(1890)
|
|
||||||
|
|
||||||
# SOIL
|
# SOIL
|
||||||
env['SHARED_SOIL'] = 0;
|
env['SHARED_SOIL'] = 0;
|
||||||
if env['shared_soil']:
|
if env['shared_soil']:
|
||||||
|
|
|
@ -29,11 +29,7 @@ void AOSound::SoundLoop()
|
||||||
default_driver = ao_default_driver_id();
|
default_driver = ao_default_driver_id();
|
||||||
format.bits = 16;
|
format.bits = 16;
|
||||||
format.channels = 2;
|
format.channels = 2;
|
||||||
#ifdef __APPLE__
|
|
||||||
format.rate = 44100; // libao for osx only supports 44.1kHz...
|
|
||||||
#else
|
|
||||||
format.rate = m_mixer->GetSampleRate();
|
format.rate = m_mixer->GetSampleRate();
|
||||||
#endif
|
|
||||||
format.byte_format = AO_FMT_LITTLE;
|
format.byte_format = AO_FMT_LITTLE;
|
||||||
|
|
||||||
device = ao_open_live(default_driver, &format, NULL /* no options */);
|
device = ao_open_live(default_driver, &format, NULL /* no options */);
|
||||||
|
|
|
@ -20,7 +20,9 @@
|
||||||
#include "DSoundStream.h"
|
#include "DSoundStream.h"
|
||||||
#include "AOSoundStream.h"
|
#include "AOSoundStream.h"
|
||||||
#include "AlsaSoundStream.h"
|
#include "AlsaSoundStream.h"
|
||||||
|
#ifdef __APPLE__
|
||||||
#include "CoreAudioSoundStream.h"
|
#include "CoreAudioSoundStream.h"
|
||||||
|
#endif
|
||||||
#include "OpenALStream.h"
|
#include "OpenALStream.h"
|
||||||
#include "PulseAudioStream.h"
|
#include "PulseAudioStream.h"
|
||||||
|
|
||||||
|
|
|
@ -52,20 +52,20 @@ bool CoreAudioSound::Start()
|
||||||
AudioStreamBasicDescription format;
|
AudioStreamBasicDescription format;
|
||||||
|
|
||||||
desc.componentType = kAudioUnitType_Output;
|
desc.componentType = kAudioUnitType_Output;
|
||||||
desc.componentSubType = kAudioUnitSubType_HALOutput;
|
desc.componentSubType = kAudioUnitSubType_DefaultOutput;
|
||||||
desc.componentFlags = 0;
|
desc.componentFlags = 0;
|
||||||
desc.componentFlagsMask = 0;
|
desc.componentFlagsMask = 0;
|
||||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||||
|
|
||||||
Component component = FindNextComponent(NULL, &desc);
|
Component component = FindNextComponent(NULL, &desc);
|
||||||
if (component == NULL) {
|
if (component == NULL) {
|
||||||
printf("error finding audio component\n");
|
ERROR_LOG(AUDIO, "error finding audio component");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = OpenAComponent(component, &audioUnit);
|
err = OpenAComponent(component, &audioUnit);
|
||||||
if (err != noErr) {
|
if (err != noErr) {
|
||||||
printf("error opening audio component\n");
|
ERROR_LOG(AUDIO, "error opening audio component");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ bool CoreAudioSound::Start()
|
||||||
kAudioUnitScope_Input, 0, &format,
|
kAudioUnitScope_Input, 0, &format,
|
||||||
sizeof(AudioStreamBasicDescription));
|
sizeof(AudioStreamBasicDescription));
|
||||||
if (err != noErr) {
|
if (err != noErr) {
|
||||||
printf("error setting audio format\n");
|
ERROR_LOG(AUDIO, "error setting audio format");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,19 +93,19 @@ bool CoreAudioSound::Start()
|
||||||
kAudioUnitScope_Input, 0, &callback_struct,
|
kAudioUnitScope_Input, 0, &callback_struct,
|
||||||
sizeof callback_struct);
|
sizeof callback_struct);
|
||||||
if (err != noErr) {
|
if (err != noErr) {
|
||||||
printf("error setting audio callback\n");
|
ERROR_LOG(AUDIO, "error setting audio callback");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = AudioUnitInitialize(audioUnit);
|
err = AudioUnitInitialize(audioUnit);
|
||||||
if (err != noErr) {
|
if (err != noErr) {
|
||||||
printf("error initializing audiounit\n");
|
ERROR_LOG(AUDIO, "error initializing audiounit");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = AudioOutputUnitStart(audioUnit);
|
err = AudioOutputUnitStart(audioUnit);
|
||||||
if (err != noErr) {
|
if (err != noErr) {
|
||||||
printf("error starting audiounit\n");
|
ERROR_LOG(AUDIO, "error starting audiounit");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,19 +122,19 @@ void CoreAudioSound::Stop()
|
||||||
|
|
||||||
err = AudioOutputUnitStop(audioUnit);
|
err = AudioOutputUnitStop(audioUnit);
|
||||||
if (err != noErr) {
|
if (err != noErr) {
|
||||||
printf("error stopping audiounit\n");
|
ERROR_LOG(AUDIO, "error stopping audiounit");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = AudioUnitUninitialize(audioUnit);
|
err = AudioUnitUninitialize(audioUnit);
|
||||||
if (err != noErr) {
|
if (err != noErr) {
|
||||||
printf("error uninitializing audiounit\n");
|
ERROR_LOG(AUDIO, "error uninitializing audiounit");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = CloseComponent(audioUnit);
|
err = CloseComponent(audioUnit);
|
||||||
if (err != noErr) {
|
if (err != noErr) {
|
||||||
printf("error while closing audio component\n");
|
ERROR_LOG(AUDIO, "error closing audio component");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,23 +18,15 @@
|
||||||
#ifndef _COREAUDIO_SOUND_STREAM_H
|
#ifndef _COREAUDIO_SOUND_STREAM_H
|
||||||
#define _COREAUDIO_SOUND_STREAM_H
|
#define _COREAUDIO_SOUND_STREAM_H
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include "SoundStream.h"
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
#include <CoreAudio/AudioHardware.h>
|
#include <CoreAudio/AudioHardware.h>
|
||||||
#include <AudioUnit/AudioUnit.h>
|
#include <AudioUnit/AudioUnit.h>
|
||||||
#include <CoreServices/CoreServices.h>
|
#include <CoreServices/CoreServices.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Thread.h"
|
#include "Common.h"
|
||||||
|
#include "SoundStream.h"
|
||||||
|
|
||||||
class CoreAudioSound : public SoundStream
|
class CoreAudioSound : public SoundStream
|
||||||
{
|
{
|
||||||
#if defined(__APPLE__)
|
|
||||||
Common::Thread *thread;
|
|
||||||
Common::Event soundSyncEvent;
|
|
||||||
Common::CriticalSection soundCriticalSection;
|
|
||||||
|
|
||||||
ComponentDescription desc;
|
ComponentDescription desc;
|
||||||
AudioUnit audioUnit;
|
AudioUnit audioUnit;
|
||||||
|
|
||||||
|
@ -56,10 +48,6 @@ public:
|
||||||
virtual void Update();
|
virtual void Update();
|
||||||
|
|
||||||
void RenderSamples(void *target, UInt32 size);
|
void RenderSamples(void *target, UInt32 size);
|
||||||
#else
|
|
||||||
public:
|
|
||||||
CoreAudioSound(CMixer *mixer) : SoundStream(mixer) {}
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,10 +26,6 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "../../../../Externals/OpenAL/include/al.h"
|
#include "../../../../Externals/OpenAL/include/al.h"
|
||||||
#include "../../../../Externals/OpenAL/include/alc.h"
|
#include "../../../../Externals/OpenAL/include/alc.h"
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#include "openal/al.h"
|
|
||||||
#include "openal/alc.h"
|
|
||||||
#else
|
|
||||||
#include <AL/al.h>
|
#include <AL/al.h>
|
||||||
#include <AL/alc.h>
|
#include <AL/alc.h>
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
|
@ -27,10 +27,6 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "../../../../Externals/OpenAL/include/al.h"
|
#include "../../../../Externals/OpenAL/include/al.h"
|
||||||
#include "../../../../Externals/OpenAL/include/alc.h"
|
#include "../../../../Externals/OpenAL/include/alc.h"
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#include "openal/al.h"
|
|
||||||
#include "openal/alc.h"
|
|
||||||
#else
|
|
||||||
#include <AL/al.h>
|
#include <AL/al.h>
|
||||||
#include <AL/alc.h>
|
#include <AL/alc.h>
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
Loading…
Reference in New Issue