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

View file

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

View file

@ -68,7 +68,7 @@
"OSS" : { "OSS" : {
"Device" : "/dev/dsp" "Device" : "/dev/dsp"
}, },
"Player" : "portaudio", "Player" : "",
"Plays When Stepping Video" : false, "Plays When Stepping Video" : false,
"Provider" : "ffmpegsource", "Provider" : "ffmpegsource",
"Renderer" : { "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)); cb->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, IntCBUpdater(opt_name, parent));
break; break;
} }
case agi::OptionValue::Type_String: case agi::OptionValue::Type_String: {
cb->SetValue(lagi_wxString(opt->GetString())); 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)); cb->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, StringUpdater(opt_name, parent));
break; break;
}
default: default:
throw PreferenceNotSupported("Unsupported type"); throw PreferenceNotSupported("Unsupported type");