Audio volume slider support for OS X.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6720 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2011-01-02 02:49:30 +00:00
parent 26a3a9400b
commit c729b86c00
6 changed files with 29 additions and 24 deletions

View File

@ -22,9 +22,7 @@
#include "XAudio2Stream.h" #include "XAudio2Stream.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"
@ -49,10 +47,8 @@ namespace AudioCommon
soundStream = new AOSound(mixer); soundStream = new AOSound(mixer);
else if (backend == BACKEND_ALSA && AlsaSound::isValid()) else if (backend == BACKEND_ALSA && AlsaSound::isValid())
soundStream = new AlsaSound(mixer); soundStream = new AlsaSound(mixer);
#ifdef __APPLE__
else if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid()) else if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid())
soundStream = new CoreAudioSound(mixer); soundStream = new CoreAudioSound(mixer);
#endif
else if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid()) else if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid())
soundStream = new PulseAudio(mixer); soundStream = new PulseAudio(mixer);
@ -109,10 +105,8 @@ namespace AudioCommon
backends.push_back(BACKEND_AOSOUND); backends.push_back(BACKEND_AOSOUND);
if (AlsaSound::isValid()) if (AlsaSound::isValid())
backends.push_back(BACKEND_ALSA); backends.push_back(BACKEND_ALSA);
#ifdef __APPLE__
if (CoreAudioSound::isValid()) if (CoreAudioSound::isValid())
backends.push_back(BACKEND_COREAUDIO); backends.push_back(BACKEND_COREAUDIO);
#endif
if (PulseAudio::isValid()) if (PulseAudio::isValid())
backends.push_back(BACKEND_PULSEAUDIO); backends.push_back(BACKEND_PULSEAUDIO);

View File

@ -34,7 +34,7 @@
struct AudioCommonConfig struct AudioCommonConfig
{ {
bool m_EnableDTKMusic; bool m_EnableDTKMusic;
bool m_EnableThrottle; bool m_EnableThrottle;
bool m_EnableJIT; bool m_EnableJIT;
int m_Volume; int m_Volume;
#ifdef __APPLE__ #ifdef __APPLE__

View File

@ -112,6 +112,18 @@ bool CoreAudioSound::Start()
return true; return true;
} }
void CoreAudioSound::SetVolume(int volume)
{
OSStatus err;
err = AudioUnitSetParameter(audioUnit,
kHALOutputParam_Volume,
kAudioUnitParameterFlag_Output, 0,
volume / 100., 0);
if (err != noErr)
ERROR_LOG(AUDIO, "error setting volume");
}
void CoreAudioSound::SoundLoop() void CoreAudioSound::SoundLoop()
{ {
} }
@ -121,22 +133,16 @@ void CoreAudioSound::Stop()
OSStatus err; OSStatus err;
err = AudioOutputUnitStop(audioUnit); err = AudioOutputUnitStop(audioUnit);
if (err != noErr) { if (err != noErr)
ERROR_LOG(AUDIO, "error stopping audiounit"); ERROR_LOG(AUDIO, "error stopping audiounit");
return;
}
err = AudioUnitUninitialize(audioUnit); err = AudioUnitUninitialize(audioUnit);
if (err != noErr) { if (err != noErr)
ERROR_LOG(AUDIO, "error uninitializing audiounit"); ERROR_LOG(AUDIO, "error uninitializing audiounit");
return;
}
err = CloseComponent(audioUnit); err = CloseComponent(audioUnit);
if (err != noErr) { if (err != noErr)
ERROR_LOG(AUDIO, "error closing audio component"); ERROR_LOG(AUDIO, "error closing audio component");
return;
}
} }
void CoreAudioSound::Update() void CoreAudioSound::Update()

View File

@ -18,23 +18,24 @@
#ifndef _COREAUDIO_SOUND_STREAM_H #ifndef _COREAUDIO_SOUND_STREAM_H
#define _COREAUDIO_SOUND_STREAM_H #define _COREAUDIO_SOUND_STREAM_H
#include <CoreAudio/AudioHardware.h> #ifdef __APPLE__
#include <AudioUnit/AudioUnit.h> #include <AudioUnit/AudioUnit.h>
#include <CoreServices/CoreServices.h> #endif
#include "Common.h"
#include "SoundStream.h" #include "SoundStream.h"
class CoreAudioSound : public SoundStream class CoreAudioSound : public SoundStream
{ {
ComponentDescription desc; #ifdef __APPLE__
AudioUnit audioUnit; ComponentDescription desc;
AudioUnit audioUnit;
public: public:
CoreAudioSound(CMixer *mixer); CoreAudioSound(CMixer *mixer);
virtual ~CoreAudioSound(); virtual ~CoreAudioSound();
virtual bool Start(); virtual bool Start();
virtual void SetVolume(int volume);
virtual void SoundLoop(); virtual void SoundLoop();
virtual void Stop(); virtual void Stop();
@ -48,6 +49,10 @@ 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

View File

@ -78,7 +78,6 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id,
SetToolTip(wxT("Changing this will have no effect while the emulator is running!")); SetToolTip(wxT("Changing this will have no effect while the emulator is running!"));
m_BackendSelection-> m_BackendSelection->
SetToolTip(wxT("Changing this will have no effect while the emulator is running!")); SetToolTip(wxT("Changing this will have no effect while the emulator is running!"));
m_volumeSlider->SetToolTip(wxT("This setting only affects DSound, OpenAL, XAudio2, and PulseAudio."));
// Create sizer and add items to dialog // Create sizer and add items to dialog
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL); wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
@ -182,6 +181,7 @@ bool DSPConfigDialogHLE::SupportsVolumeChanges(std::string backend)
// but getting the backend from string etc. is probably // but getting the backend from string etc. is probably
// too much just to enable/disable a stupid slider... // too much just to enable/disable a stupid slider...
return (backend == BACKEND_DIRECTSOUND || return (backend == BACKEND_DIRECTSOUND ||
backend == BACKEND_COREAUDIO ||
backend == BACKEND_OPENAL || backend == BACKEND_OPENAL ||
backend == BACKEND_XAUDIO2 || backend == BACKEND_XAUDIO2 ||
backend == BACKEND_PULSEAUDIO); backend == BACKEND_PULSEAUDIO);

View File

@ -64,7 +64,6 @@ DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wx
m_buttonEnableJIT->SetToolTip(wxT("Enables dynamic recompilation of DSP code.\n") m_buttonEnableJIT->SetToolTip(wxT("Enables dynamic recompilation of DSP code.\n")
wxT("Changing this will have no effect while the emulator is running!")); wxT("Changing this will have no effect while the emulator is running!"));
m_BackendSelection->SetToolTip(wxT("Changing this will have no effect while the emulator is running!")); m_BackendSelection->SetToolTip(wxT("Changing this will have no effect while the emulator is running!"));
m_volumeSlider->SetToolTip(wxT("This setting only affects DSound, OpenAL, and PulseAudio."));
// Create sizer and add items to dialog // Create sizer and add items to dialog
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL); wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
@ -151,7 +150,8 @@ bool DSPConfigDialogLLE::SupportsVolumeChanges(std::string backend)
// but getting the backend from string etc. is probably // but getting the backend from string etc. is probably
// too much just to enable/disable a stupid slider... // too much just to enable/disable a stupid slider...
return (backend == BACKEND_DIRECTSOUND || return (backend == BACKEND_DIRECTSOUND ||
backend == BACKEND_OPENAL || backend == BACKEND_COREAUDIO ||
backend == BACKEND_OPENAL ||
backend == BACKEND_XAUDIO2 || backend == BACKEND_XAUDIO2 ||
backend == BACKEND_PULSEAUDIO); backend == BACKEND_PULSEAUDIO);
} }