summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/Src/PulseAudioStream.cpp
diff options
context:
space:
mode:
authorGlenn Rice <glennricster@gmail.com>2010-06-06 04:02:16 +0000
committerGlenn Rice <glennricster@gmail.com>2010-06-06 04:02:16 +0000
commit9c3c7c544324f91b6ffbeab8daa56070e3929d10 (patch)
tree091c23e5550da3f92bbac289cb22ed2b40842127 /Source/Core/AudioCommon/Src/PulseAudioStream.cpp
parent5341bbad3acb3f52d0151083c243913f00061e7c (diff)
Implement pulseaudio output. It is rather crude but seems to work.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5626 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/AudioCommon/Src/PulseAudioStream.cpp')
-rw-r--r--Source/Core/AudioCommon/Src/PulseAudioStream.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/Source/Core/AudioCommon/Src/PulseAudioStream.cpp b/Source/Core/AudioCommon/Src/PulseAudioStream.cpp
index 96d0157dca..321c502b9b 100644
--- a/Source/Core/AudioCommon/Src/PulseAudioStream.cpp
+++ b/Source/Core/AudioCommon/Src/PulseAudioStream.cpp
@@ -61,11 +61,19 @@ void PulseAudio::Update()
// Called on audio thread.
void PulseAudio::SoundLoop()
{
- PulseInit();
+ if (!PulseInit()) {
+ thread_data = 2;
+ return;
+ }
while (!thread_data)
{
+ int err;
int frames_to_deliver = 512;
m_mixer->Mix(reinterpret_cast<short *>(mix_buffer), frames_to_deliver);
+ if (pa_simple_write(handle, mix_buffer, frames_to_deliver * 2 * 2, &err) < 0)
+ {
+ ERROR_LOG(AUDIO, "pa_simple_write fail: %s", pa_strerror(err));
+ }
}
PulseShutdown();
thread_data = 2;
@@ -73,6 +81,22 @@ void PulseAudio::SoundLoop()
bool PulseAudio::PulseInit()
{
+ // The Sample format to use
+ static const pa_sample_spec ss = {
+ PA_SAMPLE_S16LE,
+ m_mixer->GetSampleRate(),
+ 2
+ };
+
+ int err;
+
+ if (!(handle = pa_simple_new(NULL, "dolphin-emu", PA_STREAM_PLAYBACK, NULL,
+ "emulator", &ss, NULL, NULL, &err)))
+ {
+ ERROR_LOG(AUDIO, "PulseAudio open error: %s\n", pa_strerror(err));
+ return false;
+ }
+
NOTICE_LOG(AUDIO, "Pulse successfully initialized.\n");
return true;
}
@@ -81,7 +105,7 @@ void PulseAudio::PulseShutdown()
{
if (handle != NULL)
{
-
+ pa_simple_free(handle);
handle = NULL;
}
}