Add CoreAudio Backend, still needs a bit of work. Will cleanup AudioCommon.cpp, and finish off CoreAudioStream.cpp if I ever get running games working in Snow Leopard. Interpreter seems to run in to a spinlock, dunno why yet, and Jit just crashes out. Core problems is probably something I won't be able to fix
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4316 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
578fc8d54a
commit
804b9e99f8
|
@ -21,6 +21,7 @@
|
||||||
#include "AOSoundStream.h"
|
#include "AOSoundStream.h"
|
||||||
#include "AlsaSoundStream.h"
|
#include "AlsaSoundStream.h"
|
||||||
#include "NullSoundStream.h"
|
#include "NullSoundStream.h"
|
||||||
|
#include "CoreAudioSoundStream.h"
|
||||||
#include "OpenALStream.h"
|
#include "OpenALStream.h"
|
||||||
|
|
||||||
namespace AudioCommon
|
namespace AudioCommon
|
||||||
|
@ -32,6 +33,7 @@ namespace AudioCommon
|
||||||
mixer = new CMixer();
|
mixer = new CMixer();
|
||||||
|
|
||||||
std::string backend = ac_Config.sBackend;
|
std::string backend = ac_Config.sBackend;
|
||||||
|
if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid()) soundStream = new CoreAudioSound(mixer);
|
||||||
if (backend == BACKEND_DIRECTSOUND && DSound::isValid()) soundStream = new DSound(mixer, g_dspInitialize.hWnd);
|
if (backend == BACKEND_DIRECTSOUND && DSound::isValid()) soundStream = new DSound(mixer, g_dspInitialize.hWnd);
|
||||||
if (backend == BACKEND_AOSOUND && AOSound::isValid()) soundStream = new AOSound(mixer);
|
if (backend == BACKEND_AOSOUND && AOSound::isValid()) soundStream = new AOSound(mixer);
|
||||||
if (backend == BACKEND_OPENAL && OpenALStream::isValid()) soundStream = new OpenALStream(mixer);
|
if (backend == BACKEND_OPENAL && OpenALStream::isValid()) soundStream = new OpenALStream(mixer);
|
||||||
|
@ -83,6 +85,7 @@ namespace AudioCommon
|
||||||
{
|
{
|
||||||
std::vector<std::string> backends;
|
std::vector<std::string> backends;
|
||||||
|
|
||||||
|
if (CoreAudioSound::isValid()) backends.push_back(BACKEND_COREAUDIO);
|
||||||
if (DSound::isValid()) backends.push_back(BACKEND_DIRECTSOUND);
|
if (DSound::isValid()) backends.push_back(BACKEND_DIRECTSOUND);
|
||||||
if (AOSound::isValid()) backends.push_back(BACKEND_AOSOUND);
|
if (AOSound::isValid()) backends.push_back(BACKEND_AOSOUND);
|
||||||
if (OpenALStream::isValid()) backends.push_back(BACKEND_OPENAL);
|
if (OpenALStream::isValid()) backends.push_back(BACKEND_OPENAL);
|
||||||
|
|
|
@ -27,7 +27,7 @@ void AudioCommonConfig::Load(IniFile &file) {
|
||||||
file.Get("Config", "Backend", &sBackend, "DSound");
|
file.Get("Config", "Backend", &sBackend, "DSound");
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
std::string temp;
|
std::string temp;
|
||||||
file.Get("Config", "Backend", &temp, "AOSound");
|
file.Get("Config", "Backend", &temp, "CoreAudio");
|
||||||
strncpy(sBackend, temp.c_str(), 128);
|
strncpy(sBackend, temp.c_str(), 128);
|
||||||
#else
|
#else
|
||||||
file.Get("Config", "Backend", &sBackend, "AOSound");
|
file.Get("Config", "Backend", &sBackend, "AOSound");
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
|
|
||||||
// Backend Types
|
// Backend Types
|
||||||
|
#define BACKEND_COREAUDIO "CoreAudio"
|
||||||
#define BACKEND_DIRECTSOUND "DSound"
|
#define BACKEND_DIRECTSOUND "DSound"
|
||||||
#define BACKEND_AOSOUND "AOSound"
|
#define BACKEND_AOSOUND "AOSound"
|
||||||
#define BACKEND_OPENAL "OpenAL"
|
#define BACKEND_OPENAL "OpenAL"
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official SVN repository and contact information can be found at
|
||||||
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
|
#include "CoreAudioSoundStream.h"
|
||||||
|
|
||||||
|
|
||||||
|
AudioDeviceID outputDeviceId;
|
||||||
|
AudioStreamBasicDescription outputStreamBasicDescription;
|
||||||
|
AudioDeviceIOProcID outputProcId;
|
||||||
|
UInt32 outputBufferByteCount;
|
||||||
|
|
||||||
|
static OSStatus outputIoProc(AudioDeviceID inDevice, const AudioTimeStamp *inNow,const AudioBufferList *inInputData, const AudioTimeStamp *inInputTime, AudioBufferList *outOutputData, const AudioTimeStamp *inOutputTime, void *inClientData)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoreAudioSound::SoundLoop()
|
||||||
|
{
|
||||||
|
CoreAudioInit();
|
||||||
|
|
||||||
|
}
|
||||||
|
CoreAudioSound::CoreAudioSound(CMixer *mixer) : SoundStream(mixer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CoreAudioSound::~CoreAudioSound()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
bool CoreAudioSound::CoreAudioInit()
|
||||||
|
{
|
||||||
|
|
||||||
|
OSStatus status;
|
||||||
|
UInt32 size;
|
||||||
|
size = sizeof(outputDeviceId);
|
||||||
|
status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &outputDeviceId);
|
||||||
|
if (outputDeviceId == kAudioDeviceUnknown) {
|
||||||
|
printf("CoreAudioDevice Unknown\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = sizeof(outputStreamBasicDescription);
|
||||||
|
status = AudioDeviceGetProperty(outputDeviceId, 0, false, kAudioDevicePropertyStreamFormat, &size, &outputStreamBasicDescription);
|
||||||
|
|
||||||
|
size = sizeof(outputBufferByteCount);
|
||||||
|
|
||||||
|
outputBufferByteCount = 8192;
|
||||||
|
status = AudioDeviceSetProperty(outputDeviceId, 0, 0, false, kAudioDevicePropertyBufferSize, size, &outputBufferByteCount);
|
||||||
|
|
||||||
|
status = AudioDeviceGetProperty(outputDeviceId, 0, false, kAudioDevicePropertyBufferSize, &size, &outputBufferByteCount);
|
||||||
|
|
||||||
|
|
||||||
|
status = AudioDeviceCreateIOProcID( outputDeviceId, outputIoProc, NULL, &outputProcId );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CoreAudioSound::Start()
|
||||||
|
{
|
||||||
|
AudioDeviceStart(outputDeviceId,outputProcId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CoreAudioSound::Stop()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
void CoreAudioSound::Update()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official SVN repository and contact information can be found at
|
||||||
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
|
#ifndef _COREAUDIO_SOUND_STREAM_H
|
||||||
|
#define _COREAUDIO_SOUND_STREAM_H
|
||||||
|
|
||||||
|
#include "Common.h"
|
||||||
|
#include "SoundStream.h"
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <CoreAudio/AudioHardware.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Thread.h"
|
||||||
|
|
||||||
|
class CoreAudioSound : public SoundStream
|
||||||
|
{
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
public:
|
||||||
|
CoreAudioSound(CMixer *mixer);
|
||||||
|
virtual ~CoreAudioSound();
|
||||||
|
|
||||||
|
virtual bool Start();
|
||||||
|
virtual void SoundLoop();
|
||||||
|
virtual void Stop();
|
||||||
|
|
||||||
|
static bool isValid() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual bool usesMixer() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Update();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool CoreAudioInit();
|
||||||
|
#else
|
||||||
|
public:
|
||||||
|
CoreAudioSound(CMixer *mixer) : SoundStream(mixer) {}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# -*- python -*-
|
# -*- python -*-
|
||||||
|
|
||||||
Import('env')
|
Import('env')
|
||||||
|
import sys
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
'AudioCommonConfig.cpp',
|
'AudioCommonConfig.cpp',
|
||||||
|
@ -21,5 +22,8 @@ if acenv['HAVE_AO']:
|
||||||
|
|
||||||
if acenv['HAVE_ALSA']:
|
if acenv['HAVE_ALSA']:
|
||||||
files += [ 'AlsaSoundStream.cpp' ]
|
files += [ 'AlsaSoundStream.cpp' ]
|
||||||
|
if sys.platform == 'darwin':
|
||||||
|
files += [ 'CoreAudioSoundStream.cpp' ]
|
||||||
|
acenv['FRAMEWORKS'] = [ 'CoreAudio' ]
|
||||||
|
|
||||||
acenv.StaticLibrary(env['local_libs'] + 'audiocommon', files)
|
acenv.StaticLibrary(env['local_libs'] + 'audiocommon', files)
|
||||||
|
|
|
@ -42,5 +42,7 @@ dspenv.Append(
|
||||||
CXXFLAGS = [ '-fPIC' ],
|
CXXFLAGS = [ '-fPIC' ],
|
||||||
LIBS = [ 'common', 'audiocommon' ],
|
LIBS = [ 'common', 'audiocommon' ],
|
||||||
)
|
)
|
||||||
|
if sys.platform == 'darwin':
|
||||||
|
dspenv['FRAMEWORKS'] = [ 'CoreAudio' ]
|
||||||
|
|
||||||
dspenv.SharedLibrary(env['plugin_dir']+name, files)
|
dspenv.SharedLibrary(env['plugin_dir']+name, files)
|
||||||
|
|
|
@ -42,5 +42,5 @@ else:
|
||||||
LIBS = [ 'dspcore', 'audiocommon', 'common' ],
|
LIBS = [ 'dspcore', 'audiocommon', 'common' ],
|
||||||
)
|
)
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
lleenv['FRAMEWORKS'] = ['CoreFoundation', 'System']
|
lleenv['FRAMEWORKS'] = ['CoreFoundation', 'System', 'CoreAudio']
|
||||||
lleenv.SharedLibrary(env['plugin_dir']+name, files)
|
lleenv.SharedLibrary(env['plugin_dir']+name, files)
|
||||||
|
|
Loading…
Reference in New Issue