From cb75c42f04b3c8005165aacbeabaad248c474204 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 2 May 2012 00:31:38 +0000 Subject: [PATCH] Leave the old audio open when opening new audio fails for any reason Originally committed to SVN as r6738. --- aegisub/src/audio_controller.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/aegisub/src/audio_controller.cpp b/aegisub/src/audio_controller.cpp index 8a68a8d77..6322e90c9 100644 --- a/aegisub/src/audio_controller.cpp +++ b/aegisub/src/audio_controller.cpp @@ -150,13 +150,13 @@ void AudioController::OnAudioProviderChanged() void AudioController::OpenAudio(const wxString &url) { - CloseAudio(); - if (!url) throw agi::InternalError("AudioController::OpenAudio() was passed an empty string. This must not happen.", 0); wxString path_part; + AudioProvider *new_provider = 0; + if (url.StartsWith("dummy-audio:", &path_part)) { /* @@ -179,7 +179,7 @@ void AudioController::OpenAudio(const wxString &url) * in every channel even if one would be LFE. * "ln", length of signal in samples. ln/sr gives signal length in seconds. */ - provider = new DummyAudioProvider(5*30*60*1000, path_part.StartsWith("noise")); + new_provider = new DummyAudioProvider(5*30*60*1000, path_part.StartsWith("noise")); } else if (url.StartsWith("video-audio:", &path_part)) { @@ -215,7 +215,7 @@ void AudioController::OpenAudio(const wxString &url) * Assume it's not a URI but instead a filename in the platform's native format. */ try { - provider = AudioProviderFactory::GetProvider(url); + new_provider = AudioProviderFactory::GetProvider(url); StandardPaths::SetPathValue("?audio", wxFileName(url).GetPath()); } catch (agi::UserCancelException const&) { @@ -227,6 +227,9 @@ void AudioController::OpenAudio(const wxString &url) } } + CloseAudio(); + provider = new_provider; + try { player = AudioPlayerFactory::GetAudioPlayer();