From b63c2ea27c14f28ecfe6b6df9d62651bc496d67d Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Wed, 15 Apr 2009 11:26:43 +0000 Subject: [PATCH] Add hidden option 'Audio PortAudio Device' to set the default portaudio output device. Originally committed to SVN as r2797. --- aegisub/src/audio_player_portaudio2.cpp | 16 +++++++++++++--- aegisub/src/options.cpp | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/aegisub/src/audio_player_portaudio2.cpp b/aegisub/src/audio_player_portaudio2.cpp index 8153f98fe..a150b266f 100644 --- a/aegisub/src/audio_player_portaudio2.cpp +++ b/aegisub/src/audio_player_portaudio2.cpp @@ -43,6 +43,7 @@ // Headers #include "audio_player_portaudio2.h" #include "audio_provider_manager.h" +#include "options.h" #include "utils.h" @@ -192,7 +193,16 @@ void PortAudioPlayer::OpenStream() { // Open stream PaStreamParameters pa_output_p; - PaDeviceIndex pa_device = Pa_GetDefaultOutputDevice(); + int pa_config_default = Options.AsInt(_T("Audio PortAudio Device")); + PaDeviceIndex pa_device; + + if (pa_config_default < 0) { + pa_device = Pa_GetDefaultOutputDevice(); + wxLogDebug(_T("PortAudioPlayer::OpenStream Using Default Output Device: %d"), pa_device); + } else { + pa_device = pa_config_default; + wxLogDebug(_T("PortAudioPlayer::OpenStream Using Config Device: %d"), pa_device); + } pa_output_p.device = pa_device; pa_output_p.channelCount = provider->GetChannels(); @@ -200,8 +210,8 @@ void PortAudioPlayer::OpenStream() { pa_output_p.suggestedLatency = Pa_GetDeviceInfo(pa_device)->defaultLowOutputLatency; pa_output_p.hostApiSpecificStreamInfo = NULL; - wxLogDebug(_T("PortAudioPlayer::OpenStream Output Device: %d, Output channels: %d, Latency: %f Sample Rate: %ld\n"), - pa_device, pa_output_p.channelCount, pa_output_p.suggestedLatency, pa_output_p.sampleFormat); + wxLogDebug(_T("PortAudioPlayer::OpenStream Output channels: %d, Latency: %f Sample Rate: %ld\n"), + pa_output_p.channelCount, pa_output_p.suggestedLatency, pa_output_p.sampleFormat); PaError err = Pa_OpenStream(&stream, NULL, &pa_output_p, provider->GetSampleRate(), 256, paNoFlag, paCallback, this); diff --git a/aegisub/src/options.cpp b/aegisub/src/options.cpp index 113e64055..2f209c5cb 100644 --- a/aegisub/src/options.cpp +++ b/aegisub/src/options.cpp @@ -213,6 +213,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults,bool doOverride) { #endif SetText(_T("Audio Downmixer"),_T("ConvertToMono"),1700); SetText(_T("Audio Alsa Device"), _T("default")); + SetInt(_T("Audio PortAudio Device"), -1); SetText(_T("Audio HD Cache Location"),_T("default"),1700); SetText(_T("Audio HD Cache Name"),_T("audio%02i.tmp"),1700); SetBool(_T("Audio Disable PCM Provider"), false);