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:
parent
26a3a9400b
commit
c729b86c00
|
@ -22,9 +22,7 @@
|
|||
#include "XAudio2Stream.h"
|
||||
#include "AOSoundStream.h"
|
||||
#include "AlsaSoundStream.h"
|
||||
#ifdef __APPLE__
|
||||
#include "CoreAudioSoundStream.h"
|
||||
#endif
|
||||
#include "OpenALStream.h"
|
||||
#include "PulseAudioStream.h"
|
||||
|
||||
|
@ -49,10 +47,8 @@ namespace AudioCommon
|
|||
soundStream = new AOSound(mixer);
|
||||
else if (backend == BACKEND_ALSA && AlsaSound::isValid())
|
||||
soundStream = new AlsaSound(mixer);
|
||||
#ifdef __APPLE__
|
||||
else if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid())
|
||||
soundStream = new CoreAudioSound(mixer);
|
||||
#endif
|
||||
else if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid())
|
||||
soundStream = new PulseAudio(mixer);
|
||||
|
||||
|
@ -109,10 +105,8 @@ namespace AudioCommon
|
|||
backends.push_back(BACKEND_AOSOUND);
|
||||
if (AlsaSound::isValid())
|
||||
backends.push_back(BACKEND_ALSA);
|
||||
#ifdef __APPLE__
|
||||
if (CoreAudioSound::isValid())
|
||||
backends.push_back(BACKEND_COREAUDIO);
|
||||
#endif
|
||||
if (PulseAudio::isValid())
|
||||
backends.push_back(BACKEND_PULSEAUDIO);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
struct AudioCommonConfig
|
||||
{
|
||||
bool m_EnableDTKMusic;
|
||||
bool m_EnableThrottle;
|
||||
bool m_EnableThrottle;
|
||||
bool m_EnableJIT;
|
||||
int m_Volume;
|
||||
#ifdef __APPLE__
|
||||
|
|
|
@ -112,6 +112,18 @@ bool CoreAudioSound::Start()
|
|||
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()
|
||||
{
|
||||
}
|
||||
|
@ -121,22 +133,16 @@ void CoreAudioSound::Stop()
|
|||
OSStatus err;
|
||||
|
||||
err = AudioOutputUnitStop(audioUnit);
|
||||
if (err != noErr) {
|
||||
if (err != noErr)
|
||||
ERROR_LOG(AUDIO, "error stopping audiounit");
|
||||
return;
|
||||
}
|
||||
|
||||
err = AudioUnitUninitialize(audioUnit);
|
||||
if (err != noErr) {
|
||||
if (err != noErr)
|
||||
ERROR_LOG(AUDIO, "error uninitializing audiounit");
|
||||
return;
|
||||
}
|
||||
|
||||
err = CloseComponent(audioUnit);
|
||||
if (err != noErr) {
|
||||
if (err != noErr)
|
||||
ERROR_LOG(AUDIO, "error closing audio component");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CoreAudioSound::Update()
|
||||
|
|
|
@ -18,23 +18,24 @@
|
|||
#ifndef _COREAUDIO_SOUND_STREAM_H
|
||||
#define _COREAUDIO_SOUND_STREAM_H
|
||||
|
||||
#include <CoreAudio/AudioHardware.h>
|
||||
#ifdef __APPLE__
|
||||
#include <AudioUnit/AudioUnit.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
|
||||
#include "Common.h"
|
||||
#include "SoundStream.h"
|
||||
|
||||
class CoreAudioSound : public SoundStream
|
||||
{
|
||||
ComponentDescription desc;
|
||||
AudioUnit audioUnit;
|
||||
#ifdef __APPLE__
|
||||
ComponentDescription desc;
|
||||
AudioUnit audioUnit;
|
||||
|
||||
public:
|
||||
CoreAudioSound(CMixer *mixer);
|
||||
virtual ~CoreAudioSound();
|
||||
|
||||
virtual bool Start();
|
||||
virtual void SetVolume(int volume);
|
||||
virtual void SoundLoop();
|
||||
virtual void Stop();
|
||||
|
||||
|
@ -48,6 +49,10 @@ public:
|
|||
virtual void Update();
|
||||
|
||||
void RenderSamples(void *target, UInt32 size);
|
||||
#else
|
||||
public:
|
||||
CoreAudioSound(CMixer *mixer) : SoundStream(mixer) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -78,7 +78,6 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id,
|
|||
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, XAudio2, and PulseAudio."));
|
||||
|
||||
// Create sizer and add items to dialog
|
||||
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
|
||||
|
@ -182,6 +181,7 @@ bool DSPConfigDialogHLE::SupportsVolumeChanges(std::string backend)
|
|||
// but getting the backend from string etc. is probably
|
||||
// too much just to enable/disable a stupid slider...
|
||||
return (backend == BACKEND_DIRECTSOUND ||
|
||||
backend == BACKEND_COREAUDIO ||
|
||||
backend == BACKEND_OPENAL ||
|
||||
backend == BACKEND_XAUDIO2 ||
|
||||
backend == BACKEND_PULSEAUDIO);
|
||||
|
|
|
@ -64,7 +64,6 @@ DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wx
|
|||
m_buttonEnableJIT->SetToolTip(wxT("Enables dynamic recompilation of DSP code.\n")
|
||||
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
|
||||
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
|
||||
|
@ -151,7 +150,8 @@ bool DSPConfigDialogLLE::SupportsVolumeChanges(std::string backend)
|
|||
// but getting the backend from string etc. is probably
|
||||
// too much just to enable/disable a stupid slider...
|
||||
return (backend == BACKEND_DIRECTSOUND ||
|
||||
backend == BACKEND_OPENAL ||
|
||||
backend == BACKEND_COREAUDIO ||
|
||||
backend == BACKEND_OPENAL ||
|
||||
backend == BACKEND_XAUDIO2 ||
|
||||
backend == BACKEND_PULSEAUDIO);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue