Use the per-platform default audio player from configure rather than always defaulting to portaudio

Originally committed to SVN as r5738.
This commit is contained in:
Thomas Goyne 2011-10-12 23:08:29 +00:00
parent bb4c10a140
commit 98777eff4e
4 changed files with 21 additions and 18 deletions

View File

@ -58,15 +58,11 @@
#include "compat.h"
#include "main.h"
/// @brief Constructor
///
AudioPlayer::AudioPlayer() {
provider = NULL;
displayTimer = NULL;
}
/// @brief Destructor
///
AudioPlayer::~AudioPlayer() {
if (displayTimer) {
displayTimer->Stop();
@ -75,7 +71,6 @@ AudioPlayer::~AudioPlayer() {
}
/// @brief Ask to stop later
///
void AudioPlayer::RequestStop() {
wxCommandEvent event(wxEVT_STOP_AUDIO, 1000);
event.SetEventObject(this);
@ -88,16 +83,10 @@ BEGIN_EVENT_TABLE(AudioPlayer, wxEvtHandler)
EVT_COMMAND (1000, wxEVT_STOP_AUDIO, AudioPlayer::OnStopAudio)
END_EVENT_TABLE()
/// @brief DOCME
/// @param event
///
void AudioPlayer::OnStopAudio(wxCommandEvent &event) {
Stop(false);
}
/// @brief Get player
/// @return
///
AudioPlayer* AudioPlayerFactory::GetAudioPlayer() {
std::vector<std::string> list = GetClasses(OPT_GET("Audio/Player")->GetString());
if (list.empty()) throw "No audio players are available.";
@ -115,10 +104,6 @@ AudioPlayer* AudioPlayerFactory::GetAudioPlayer() {
throw error;
}
/// @brief Register all factories
///
void AudioPlayerFactory::RegisterProviders() {
#ifdef WITH_ALSA
Register<AlsaPlayer>("ALSA");
@ -141,4 +126,15 @@ void AudioPlayerFactory::RegisterProviders() {
#endif
}
std::string AudioPlayerFactory::GetDefault() {
std::string def = OPT_GET("Audio/Player")->GetString();
if (!def.empty())
return def;
#ifdef DEFAULT_PLAYER_AUDIO
return DEFAULT_PLAYER_AUDIO;
#else
return "DirectSound";
#endif
}
template<> AudioPlayerFactory::map *FactoryBase<AudioPlayer *(*)()>::classes = NULL;

View File

@ -99,6 +99,8 @@ public:
class AudioPlayerFactory : public Factory0<AudioPlayer> {
public:
/// Get the name of the preferred audio play
static std::string GetDefault();
static void RegisterProviders();
static AudioPlayer *GetAudioPlayer();
};

View File

@ -68,7 +68,7 @@
"OSS" : {
"Device" : "/dev/dsp"
},
"Player" : "portaudio",
"Player" : "",
"Plays When Stepping Video" : false,
"Provider" : "ffmpegsource",
"Renderer" : {

View File

@ -189,10 +189,15 @@ void OptionPage::OptionChoice(wxFlexGridSizer *flex, const wxString &name, const
cb->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, IntCBUpdater(opt_name, parent));
break;
}
case agi::OptionValue::Type_String:
cb->SetValue(lagi_wxString(opt->GetString()));
case agi::OptionValue::Type_String: {
wxString val(lagi_wxString(opt->GetString()));
if (cb->FindString(val) != wxNOT_FOUND)
cb->SetStringSelection(val);
else
cb->SetSelection(0);
cb->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, StringUpdater(opt_name, parent));
break;
}
default:
throw PreferenceNotSupported("Unsupported type");