mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user