mirror of https://github.com/odrling/Aegisub
Reload audio when the player or provider is changed
Originally committed to SVN as r5892.
This commit is contained in:
parent
43d41def4f
commit
236ea4261d
|
@ -151,6 +151,9 @@ AudioController::AudioController(agi::Context *context)
|
|||
Bind(wxEVT_POWER_SUSPENDED, &AudioController::OnComputerSuspending, this);
|
||||
Bind(wxEVT_POWER_RESUME, &AudioController::OnComputerResuming, this);
|
||||
#endif
|
||||
|
||||
OPT_SUB("Audio/Player", &AudioController::OnAudioPlayerChanged, this);
|
||||
OPT_SUB("Audio/Provider", &AudioController::OnAudioProviderChanged, this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -193,6 +196,34 @@ void AudioController::OnComputerResuming(wxPowerEvent &event)
|
|||
}
|
||||
#endif
|
||||
|
||||
void AudioController::OnAudioPlayerChanged()
|
||||
{
|
||||
if (!IsAudioOpen()) return;
|
||||
|
||||
Stop();
|
||||
|
||||
delete player;
|
||||
|
||||
try
|
||||
{
|
||||
player = AudioPlayerFactory::GetAudioPlayer();
|
||||
player->SetProvider(provider);
|
||||
player->OpenStream();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
CloseAudio();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioController::OnAudioProviderChanged()
|
||||
{
|
||||
if (IsAudioOpen())
|
||||
// url is cloned because CloseAudio clears it and OpenAudio takes a const reference
|
||||
OpenAudio(audio_url.Clone());
|
||||
}
|
||||
|
||||
|
||||
void AudioController::OpenAudio(const wxString &url)
|
||||
{
|
||||
|
|
|
@ -248,6 +248,12 @@ class AudioController : public wxEvtHandler, public AudioMarkerProvider, public
|
|||
/// Subtitles save slot which adds the audio uri to the subtitles
|
||||
void OnSubtitlesSave();
|
||||
|
||||
/// Handler for the current audio player changing
|
||||
void OnAudioPlayerChanged();
|
||||
|
||||
/// Handler for the current audio provider changing
|
||||
void OnAudioProviderChanged();
|
||||
|
||||
#ifdef wxHAS_POWER_EVENTS
|
||||
/// Handle computer going into suspend mode by stopping audio and closing device
|
||||
void OnComputerSuspending(wxPowerEvent &event);
|
||||
|
|
Loading…
Reference in New Issue