diff --git a/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj b/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj
index 7f4596bb5..2ddc0eb31 100644
--- a/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj
+++ b/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj
@@ -495,10 +495,6 @@
RelativePath="..\..\src\audio_provider_hd.h"
>
-
-
@@ -1443,10 +1439,6 @@
RelativePath="..\..\src\spellchecker_hunspell.h"
>
-
-
@@ -1571,10 +1563,6 @@
RelativePath="..\..\src\subtitles_provider_libass.h"
>
-
-
SetDisplayTimer(&UpdateTimer);
player->SetProvider(provider);
player->OpenStream();
diff --git a/aegisub/src/audio_display.h b/aegisub/src/audio_display.h
index fd971de7b..9b76b9847 100644
--- a/aegisub/src/audio_display.h
+++ b/aegisub/src/audio_display.h
@@ -44,10 +44,10 @@
#include
#endif
-#include "audio_player_manager.h"
-#include "audio_provider_manager.h"
#include "audio_renderer_spectrum.h"
+class AudioPlayer;
+class AudioProvider;
class AssDialogue;
class SubtitlesGrid;
class AudioBox;
diff --git a/aegisub/src/audio_player.cpp b/aegisub/src/audio_player.cpp
index dc01dc053..67e8ec99c 100644
--- a/aegisub/src/audio_player.cpp
+++ b/aegisub/src/audio_player.cpp
@@ -34,9 +34,6 @@
/// @ingroup audio_output
///
-
-///////////
-// Headers
#include "config.h"
#ifdef WITH_ALSA
@@ -46,7 +43,6 @@
#include "audio_player_dsound.h"
#include "audio_player_dsound2.h"
#endif
-#include "audio_player_manager.h"
#ifdef WITH_OPENAL
#include "audio_player_openal.h"
#endif
@@ -62,8 +58,6 @@
#include "compat.h"
#include "main.h"
-
-
/// @brief Constructor
///
AudioPlayer::AudioPlayer() {
@@ -71,8 +65,6 @@ AudioPlayer::AudioPlayer() {
displayTimer = NULL;
}
-
-
/// @brief Destructor
///
AudioPlayer::~AudioPlayer() {
@@ -82,44 +74,6 @@ AudioPlayer::~AudioPlayer() {
CloseStream();
}
-
-
-/// @brief Set provider
-/// @param _provider
-///
-void AudioPlayer::SetProvider(AudioProvider *_provider) {
- provider = _provider;
-}
-
-
-
-/// @brief Get provider
-/// @return
-///
-AudioProvider *AudioPlayer::GetProvider() {
- return provider;
-}
-
-
-
-/// @brief Get mutex
-/// @return
-///
-wxMutex *AudioPlayer::GetMutex() {
- return NULL;
-}
-
-
-
-/// @brief Set timer
-/// @param timer
-///
-void AudioPlayer::SetDisplayTimer(wxTimer *timer) {
- displayTimer = timer;
-}
-
-
-
/// @brief Ask to stop later
///
void AudioPlayer::RequestStop() {
@@ -128,16 +82,12 @@ void AudioPlayer::RequestStop() {
AddPendingEvent(event); // thread safe
}
-
-/////////
-// Event
DEFINE_EVENT_TYPE(wxEVT_STOP_AUDIO)
BEGIN_EVENT_TABLE(AudioPlayer, wxEvtHandler)
EVT_COMMAND (1000, wxEVT_STOP_AUDIO, AudioPlayer::OnStopAudio)
END_EVENT_TABLE()
-
/// @brief DOCME
/// @param event
///
@@ -145,31 +95,23 @@ void AudioPlayer::OnStopAudio(wxCommandEvent &event) {
Stop(false);
}
-
-
/// @brief Get player
/// @return
///
-AudioPlayer* AudioPlayerFactoryManager::GetAudioPlayer() {
- // List of providers
- wxArrayString list = GetFactoryList(lagi_wxString(OPT_GET("Audio/Player")->GetString()));
+AudioPlayer* AudioPlayerFactory::GetAudioPlayer() {
+ std::vector list = GetClasses(OPT_GET("Audio/Player")->GetString());
+ if (list.empty()) throw _T("No audio players are available.");
- // None available
- if (list.Count() == 0) throw _T("No audio players are available.");
-
- // Get provider
wxString error;
- for (unsigned int i=0;iCreatePlayer();
+ AudioPlayer *player = Create(list[i]);
if (player) return player;
}
catch (wxString err) { error += list[i] + _T(" factory: ") + err + _T("\n"); }
catch (const wxChar *err) { error += list[i] + _T(" factory: ") + wxString(err) + _T("\n"); }
catch (...) { error += list[i] + _T(" factory: Unknown error\n"); }
}
-
- // Failed
throw error;
}
@@ -177,40 +119,26 @@ AudioPlayer* AudioPlayerFactoryManager::GetAudioPlayer() {
/// @brief Register all factories
///
-void AudioPlayerFactoryManager::RegisterProviders() {
+void AudioPlayerFactory::RegisterProviders() {
#ifdef WITH_ALSA
- RegisterFactory(new AlsaPlayerFactory(),_T("ALSA"));
+ Register("ALSA");
#endif
#ifdef WITH_DIRECTSOUND
- RegisterFactory(new DirectSoundPlayerFactory(),_T("DirectSound-old"));
- RegisterFactory(new DirectSoundPlayer2Factory(),_T("DirectSound"));
+ Register("DirectSound-old");
+ Register("DirectSound");
#endif
#ifdef WITH_OPENAL
- RegisterFactory(new OpenALPlayerFactory(),_T("OpenAL"));
+ Register("OpenAL");
#endif
#ifdef WITH_PORTAUDIO
- RegisterFactory(new PortAudioPlayerFactory(),_T("PortAudio"));
+ Register("PortAudio");
#endif
#ifdef WITH_PULSEAUDIO
- RegisterFactory(new PulseAudioPlayerFactory(),_T("PulseAudio"));
+ Register("PulseAudio");
#endif
#ifdef WITH_OSS
- RegisterFactory(new OSSPlayerFactory(),_T("OSS"));
+ Register("OSS");
#endif
}
-
-
-/// @brief Clear all factories
-///
-void AudioPlayerFactoryManager::ClearProviders() {
- ClearFactories();
-}
-
-
-
-/// DOCME
-template std::map* FactoryManager::factories=NULL;
-
-
-
+template<> AudioPlayerFactory::map *FactoryBase::classes = NULL;
diff --git a/aegisub/src/audio_player_alsa.cpp b/aegisub/src/audio_player_alsa.cpp
index 1cc3ddf83..64bff84fe 100644
--- a/aegisub/src/audio_player_alsa.cpp
+++ b/aegisub/src/audio_player_alsa.cpp
@@ -40,14 +40,9 @@
#ifdef WITH_ALSA
-
-///////////
-// Headers
#include
#include "audio_player_alsa.h"
-#include "audio_player_manager.h"
-#include "audio_provider_manager.h"
#include "main.h"
#include "compat.h"
#include "frame_main.h"
@@ -65,8 +60,6 @@ AlsaPlayer::AlsaPlayer()
provider = 0;
}
-
-
/// @brief Destructor
///
AlsaPlayer::~AlsaPlayer()
@@ -74,8 +67,6 @@ AlsaPlayer::~AlsaPlayer()
CloseStream();
}
-
-
/// @brief Open stream
///
void AlsaPlayer::OpenStream()
@@ -105,8 +96,6 @@ void AlsaPlayer::OpenStream()
open = true;
}
-
-
/// @brief DOCME
///
void AlsaPlayer::SetUpHardware()
@@ -202,8 +191,6 @@ void AlsaPlayer::SetUpHardware()
snd_pcm_hw_params_free(hwparams);
}
-
-
/// @brief DOCME
///
void AlsaPlayer::SetUpAsync()
@@ -249,8 +236,6 @@ void AlsaPlayer::SetUpAsync()
}
}
-
-
/// @brief Close stream
/// @return
///
@@ -270,8 +255,6 @@ void AlsaPlayer::CloseStream()
open = false;
}
-
-
/// @brief Play
/// @param start
/// @param count
@@ -301,8 +284,6 @@ void AlsaPlayer::Play(int64_t start,int64_t count)
if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15);
}
-
-
/// @brief Stop
/// @param timerToo
/// @return
@@ -326,8 +307,6 @@ void AlsaPlayer::Stop(bool timerToo)
}
}
-
-
/// @brief DOCME
/// @return
///
@@ -336,8 +315,6 @@ bool AlsaPlayer::IsPlaying()
return playing;
}
-
-
/// @brief Set end
/// @param pos
///
@@ -346,8 +323,6 @@ void AlsaPlayer::SetEndPosition(int64_t pos)
end_frame = pos;
}
-
-
/// @brief Set current position
/// @param pos
///
@@ -356,8 +331,6 @@ void AlsaPlayer::SetCurrentPosition(int64_t pos)
cur_frame = pos;
}
-
-
/// @brief DOCME
/// @return
///
@@ -366,8 +339,6 @@ int64_t AlsaPlayer::GetStartPosition()
return start_frame;
}
-
-
/// @brief DOCME
/// @return
///
@@ -376,8 +347,6 @@ int64_t AlsaPlayer::GetEndPosition()
return end_frame;
}
-
-
/// @brief Get current position
/// @return
///
@@ -390,8 +359,6 @@ int64_t AlsaPlayer::GetCurrentPosition()
return cur_frame - delay;
}
-
-
/// @brief DOCME
/// @param pcm_callback
///
@@ -439,7 +406,4 @@ void AlsaPlayer::async_write_handler(snd_async_handler_t *pcm_callback)
free(buf);
}
-
#endif // WITH_ALSA
-
-
diff --git a/aegisub/src/audio_player_alsa.h b/aegisub/src/audio_player_alsa.h
index ab4e28cd9..595473a92 100644
--- a/aegisub/src/audio_player_alsa.h
+++ b/aegisub/src/audio_player_alsa.h
@@ -37,9 +37,6 @@
#ifdef WITH_ALSA
-
-///////////
-// Headers
#include
#include "include/aegisub/audio_player.h"
@@ -148,22 +145,4 @@ public:
double GetVolume() { return volume; }
};
-
-
-
-/// DOCME
-/// @class AlsaPlayerFactory
-/// @brief DOCME
-///
-/// DOCME
-class AlsaPlayerFactory : public AudioPlayerFactory {
-public:
-
- /// @brief DOCME
- ///
- AudioPlayer *CreatePlayer() { return new AlsaPlayer(); }
-};
-
#endif
-
-
diff --git a/aegisub/src/audio_player_dsound.h b/aegisub/src/audio_player_dsound.h
index f10884887..47aec34d1 100644
--- a/aegisub/src/audio_player_dsound.h
+++ b/aegisub/src/audio_player_dsound.h
@@ -183,25 +183,5 @@ public:
/// @return
///
double GetVolume() { return volume; }
-
- //wxMutex *GetMutex() { return &DSMutex; }
};
-
-
-
-/// DOCME
-/// @class DirectSoundPlayerFactory
-/// @brief DOCME
-///
-/// DOCME
-class DirectSoundPlayerFactory : public AudioPlayerFactory {
-public:
-
- /// @brief DOCME
- ///
- AudioPlayer *CreatePlayer() { return new DirectSoundPlayer(); }
-};
-
#endif
-
-
diff --git a/aegisub/src/audio_player_dsound2.h b/aegisub/src/audio_player_dsound2.h
index 9e3bd5842..51c754b5f 100644
--- a/aegisub/src/audio_player_dsound2.h
+++ b/aegisub/src/audio_player_dsound2.h
@@ -34,15 +34,12 @@
/// @ingroup audio_output
///
-
#ifdef WITH_DIRECTSOUND
#include "include/aegisub/audio_player.h"
-
class DirectSoundPlayer2Thread;
-
/// @class DirectSoundPlayer2
/// @brief New implementation of DirectSound-based audio player
///
@@ -50,7 +47,6 @@ class DirectSoundPlayer2Thread;
/// and performs all playback operations, and use the player object as a proxy to
/// send commands to the playback thread.
class DirectSoundPlayer2 : public AudioPlayer {
-
/// The playback thread
DirectSoundPlayer2Thread *thread;
@@ -86,18 +82,4 @@ public:
void SetVolume(double vol);
double GetVolume();
};
-
-
-
-/// @class DirectSoundPlayer2Factory
-/// @brief Factory class for DirectSoundPlayer2
-class DirectSoundPlayer2Factory : public AudioPlayerFactory {
-public:
-
- /// @brief Create a DirectSoundPlayer2 object
- AudioPlayer *CreatePlayer() { return new DirectSoundPlayer2(); }
-};
-
#endif
-
-
diff --git a/aegisub/src/audio_player_manager.h b/aegisub/src/audio_player_manager.h
deleted file mode 100644
index bb1982af4..000000000
--- a/aegisub/src/audio_player_manager.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2005-2007, Rodrigo Braz Monteiro
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of the Aegisub Group nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Aegisub Project http://www.aegisub.org/
-//
-// $Id$
-
-/// @file audio_player_manager.h
-/// @brief Manage available audio output implementations
-/// @ingroup audio_output
-///
-
-
-#pragma once
-
-
-///////////
-// Headers
-#ifndef AGI_PRE
-#include
-
-#include
-#include
-#include
-#endif
-
-#include "factory_manager.h"
-#include "include/aegisub/audio_player.h"
-
-
-//////////////
-// Prototypes
-class AudioProvider;
-
-
-
-/// DOCME
-/// @class AudioPlayerFactoryManager
-/// @brief DOCME
-///
-/// DOCME
-class AudioPlayerFactoryManager : public FactoryManager {
-public:
- static AudioPlayer *GetAudioPlayer();
- static void RegisterProviders();
- static void ClearProviders();
-};
-
-
-
-/////////
-// Event
-DECLARE_EVENT_TYPE(wxEVT_STOP_AUDIO, -1)
-
-
-
-
diff --git a/aegisub/src/audio_player_openal.cpp b/aegisub/src/audio_player_openal.cpp
index f68ed05b1..456c4c38d 100644
--- a/aegisub/src/audio_player_openal.cpp
+++ b/aegisub/src/audio_player_openal.cpp
@@ -34,19 +34,13 @@
/// @ingroup audio_output
///
-
#include "config.h"
#ifdef WITH_OPENAL
-
-///////////
-// Headers
#include
-#include "audio_player_manager.h"
#include "audio_player_openal.h"
-#include "audio_provider_manager.h"
#include "frame_main.h"
#include "utils.h"
@@ -61,14 +55,11 @@
#include
#endif
-
// Auto-link to OpenAL lib for MSVC
#ifdef _MSC_VER
#pragma comment(lib, "openal32.lib")
#endif
-
-
/// @brief Constructor
///
OpenALPlayer::OpenALPlayer()
@@ -80,8 +71,6 @@ OpenALPlayer::OpenALPlayer()
provider = 0;
}
-
-
/// @brief Destructor
///
OpenALPlayer::~OpenALPlayer()
@@ -375,6 +364,3 @@ int64_t OpenALPlayer::GetCurrentPosition()
#endif // WITH_OPENAL
-
-
-
diff --git a/aegisub/src/audio_player_openal.h b/aegisub/src/audio_player_openal.h
index 4c2a1ddd3..be172689c 100644
--- a/aegisub/src/audio_player_openal.h
+++ b/aegisub/src/audio_player_openal.h
@@ -36,11 +36,6 @@
#ifdef WITH_OPENAL
-
-
-///////////
-// Headers
-#include "audio_player_manager.h"
#include "include/aegisub/audio_player.h"
#include "include/aegisub/audio_provider.h"
#include "utils.h"
@@ -56,8 +51,6 @@
#include
#endif
-
-
/// DOCME
/// @class OpenALPlayer
/// @brief DOCME
@@ -164,23 +157,4 @@ public:
///
double GetVolume() { return volume; }
};
-
-
-
-
-/// DOCME
-/// @class OpenALPlayerFactory
-/// @brief DOCME
-///
-/// DOCME
-class OpenALPlayerFactory : public AudioPlayerFactory {
-public:
-
- /// @brief DOCME
- ///
- AudioPlayer *CreatePlayer() { return new OpenALPlayer(); }
-};
-
#endif
-
-
diff --git a/aegisub/src/audio_player_oss.cpp b/aegisub/src/audio_player_oss.cpp
index f28eb430f..5a2b62eca 100644
--- a/aegisub/src/audio_player_oss.cpp
+++ b/aegisub/src/audio_player_oss.cpp
@@ -37,13 +37,9 @@
#ifdef WITH_OSS
-///////////
-// Headers
#include
-#include "audio_player_manager.h"
#include "audio_player_oss.h"
-#include "audio_provider_manager.h"
#include "frame_main.h"
#include "compat.h"
#include "main.h"
diff --git a/aegisub/src/audio_player_oss.h b/aegisub/src/audio_player_oss.h
index 4cb6c9749..b7d6f2b36 100644
--- a/aegisub/src/audio_player_oss.h
+++ b/aegisub/src/audio_player_oss.h
@@ -37,10 +37,6 @@
#include "config.h"
#ifdef WITH_OSS
-
-
-///////////
-// Headers
#ifndef AGI_PRE
#include
#endif
@@ -58,13 +54,8 @@
#include "include/aegisub/audio_provider.h"
#include "utils.h"
-
-//////////////
-// Prototypes
class OSSPlayer;
-
-
/// DOCME
/// @class OSSPlayerThread
/// @brief DOCME
@@ -153,21 +144,4 @@ public:
///
double GetVolume() { return volume; }
};
-
-
-
-
-/// DOCME
-/// @class OSSPlayerFactory
-/// @brief DOCME
-///
-/// DOCME
-class OSSPlayerFactory : public AudioPlayerFactory {
-public:
-
- /// @brief DOCME
- ///
- AudioPlayer *CreatePlayer() { return new OSSPlayer(); }
-};
-
#endif
diff --git a/aegisub/src/audio_player_portaudio.h b/aegisub/src/audio_player_portaudio.h
index 169faa0a2..e22416d7c 100644
--- a/aegisub/src/audio_player_portaudio.h
+++ b/aegisub/src/audio_player_portaudio.h
@@ -37,9 +37,6 @@
#ifdef WITH_PORTAUDIO
-
-///////////
-// Headers
#include "include/aegisub/audio_player.h"
#include "include/aegisub/audio_provider.h"
#include "utils.h"
@@ -47,7 +44,6 @@ extern "C" {
#include
}
-
/// @class PortAudioPlayer
/// @brief PortAudio Player
///
@@ -126,16 +122,4 @@ public:
wxArrayString GetOutputDevices(wxString favorite);
};
-
-
-/// @class PortAudioPlayerFactory
-/// @brief PortAudio Player Factory
-class PortAudioPlayerFactory : public AudioPlayerFactory {
-public:
-
- /// @brief Create player
- /// @return New PortAudio Player
- AudioPlayer *CreatePlayer() { return new PortAudioPlayer(); }
-};
-
#endif //ifdef WITH_PORTAUDIO
diff --git a/aegisub/src/audio_player_pulse.cpp b/aegisub/src/audio_player_pulse.cpp
index d718cbd32..25b7d5420 100644
--- a/aegisub/src/audio_player_pulse.cpp
+++ b/aegisub/src/audio_player_pulse.cpp
@@ -34,20 +34,15 @@
/// @ingroup audio_output
///
-
#include "config.h"
#ifdef WITH_PULSEAUDIO
-
-///////////
-// Headers
#ifndef AGI_PRE
#include
#endif
#include "audio_player_pulse.h"
-#include "audio_provider_manager.h"
#include "utils.h"
@@ -451,7 +446,4 @@ void PulseAudioPlayer::pa_stream_notify(pa_stream *p, PulseAudioPlayer *thread)
thread->stream_notify.Post();
}
-
#endif // WITH_PULSEAUDIO
-
-
diff --git a/aegisub/src/audio_player_pulse.h b/aegisub/src/audio_player_pulse.h
index af0debf5b..01a70b832 100644
--- a/aegisub/src/audio_player_pulse.h
+++ b/aegisub/src/audio_player_pulse.h
@@ -34,12 +34,7 @@
/// @ingroup audio_output
///
-
#ifdef WITH_PULSEAUDIO
-
-
-///////////
-// Headers
#ifndef AGI_PRE
#include
#endif
@@ -50,14 +45,8 @@
#include "include/aegisub/audio_provider.h"
#include "utils.h"
-
-//////////////
-// Prototypes
class PulseAudioPlayer;
-
-
-
/// DOCME
/// @class PulseAudioPlayer
/// @brief DOCME
@@ -170,22 +159,4 @@ public:
double GetVolume() { return volume; }
};
-
-
-
-/// DOCME
-/// @class PulseAudioPlayerFactory
-/// @brief DOCME
-///
-/// DOCME
-class PulseAudioPlayerFactory : public AudioPlayerFactory {
-public:
-
- /// @brief DOCME
- ///
- AudioPlayer *CreatePlayer() { return new PulseAudioPlayer(); }
-};
-
#endif
-
-
diff --git a/aegisub/src/audio_provider.cpp b/aegisub/src/audio_provider.cpp
index 417ad9e87..59e3b7974 100644
--- a/aegisub/src/audio_provider.cpp
+++ b/aegisub/src/audio_provider.cpp
@@ -35,15 +35,12 @@
///
-///////////
-// Headers
#include "config.h"
#ifndef AGI_PRE
#include
#endif
-#include "audio_display.h"
#ifdef WITH_AVISYNTH
#include "audio_provider_avs.h"
#endif
@@ -57,71 +54,17 @@
#include "compat.h"
#include "main.h"
-
-
-
/// @brief Constructor
///
-AudioProvider::AudioProvider() {
- raw = NULL;
+AudioProvider::AudioProvider() : raw(NULL) {
}
-
-
/// @brief Destructor
///
AudioProvider::~AudioProvider() {
- // Clear buffers
delete[] raw;
}
-
-
-/// @brief Get number of channels
-/// @return
-///
-int AudioProvider::GetChannels() {
- return channels;
-}
-
-
-
-/// @brief Get number of samples
-/// @return
-///
-int64_t AudioProvider::GetNumSamples() {
- return num_samples;
-}
-
-
-
-/// @brief Get sample rate
-/// @return
-///
-int AudioProvider::GetSampleRate() {
- return sample_rate;
-}
-
-
-
-/// @brief Get bytes per sample
-/// @return
-///
-int AudioProvider::GetBytesPerSample() {
- return bytes_per_sample;
-}
-
-
-
-/// @brief Get filename
-/// @return
-///
-wxString AudioProvider::GetFilename() {
- return filename;
-}
-
-
-
/// @brief Get waveform
/// @param min
/// @param peak
@@ -193,8 +136,6 @@ void AudioProvider::GetWaveForm(int *min,int *peak,int64_t start,int w,int h,int
}
}
-
-
/// @brief Get audio with volume
/// @param buf
/// @param start
@@ -230,15 +171,12 @@ void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count,
}
}
-
-
/// @brief Get provider
/// @param filename
/// @param cache
/// @return
///
-AudioProvider *AudioProviderFactoryManager::GetAudioProvider(wxString filename, int cache) {
- // Prepare provider
+AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) {
AudioProvider *provider = NULL;
if (!OPT_GET("Provider/Audio/PCM/Disable")->GetBool()) {
@@ -248,27 +186,22 @@ AudioProvider *AudioProviderFactoryManager::GetAudioProvider(wxString filename,
if (provider->GetBytesPerSample() == 2 && provider->GetSampleRate() >= 32000 && provider->GetChannels() == 1)
return provider;
else {
- provider = CreateConvertAudioProvider(provider);
- return provider;
+ return CreateConvertAudioProvider(provider);
}
}
}
// List of providers
- wxArrayString list = GetFactoryList(lagi_wxString(OPT_GET("Audio/Provider")->GetString()));
+ std::vector list = GetClasses(OPT_GET("Audio/Provider")->GetString());
- // None available
- if (list.Count() == 0) throw _T("No audio providers are available.");
+ if (list.empty()) throw _T("No audio providers are available.");
// Get provider
wxString error;
- for (unsigned int i=0;iCreateProvider(filename.wc_str());
- if (prov) {
- provider = prov;
- break;
- }
+ provider = Create(list[i], filename);
+ if (provider) break;
}
catch (wxString err) { error += list[i] + _T(" factory: ") + err + _T("\n"); }
catch (const wxChar *err) { error += list[i] + _T(" factory: ") + wxString(err) + _T("\n"); }
@@ -296,11 +229,10 @@ AudioProvider *AudioProviderFactoryManager::GetAudioProvider(wxString filename,
// Reassign
if (final) {
delete provider;
- provider = final;
+ return final;
}
}
- // Return
return provider;
}
@@ -308,26 +240,13 @@ AudioProvider *AudioProviderFactoryManager::GetAudioProvider(wxString filename,
/// @brief Register all providers
///
-void AudioProviderFactoryManager::RegisterProviders() {
+void AudioProviderFactory::RegisterProviders() {
#ifdef WITH_AVISYNTH
- RegisterFactory(new AvisynthAudioProviderFactory(),_T("Avisynth"));
+ Register("Avisynth");
#endif
#ifdef WITH_FFMPEGSOURCE
- RegisterFactory(new FFmpegSourceAudioProviderFactory(),_T("FFmpegSource"));
+ Register("FFmpegSource");
#endif
}
-
-
-/// @brief Clear all providers
-///
-void AudioProviderFactoryManager::ClearProviders() {
- ClearFactories();
-}
-
-
-
-/// DOCME
-template std::map* FactoryManager::factories=NULL;
-
-
+template<> AudioProviderFactory::map *FactoryBase::classes = NULL;
diff --git a/aegisub/src/audio_provider_avs.h b/aegisub/src/audio_provider_avs.h
index 424d4b8d4..3514eca12 100644
--- a/aegisub/src/audio_provider_avs.h
+++ b/aegisub/src/audio_provider_avs.h
@@ -34,9 +34,6 @@
/// @ingroup audio_input
///
-
-///////////
-// Headers
#ifdef WITH_AVISYNTH
#include
#include "include/aegisub/audio_provider.h"
@@ -69,31 +66,12 @@ public:
wxString GetFilename();
- /// @brief // Only exists for x86 Windows, always delivers machine (little) endian
+ /// @brief Only exists for x86 Windows, always delivers machine (little) endian
/// @return
///
- bool AreSamplesNativeEndian() { return true; }
+ bool AreSamplesNativeEndian() const { return true; }
void GetAudio(void *buf, int64_t start, int64_t count);
void GetWaveForm(int *min,int *peak,int64_t start,int w,int h,int samples,float scale);
};
-
-
-
-/// DOCME
-/// @class AvisynthAudioProviderFactory
-/// @brief DOCME
-///
-/// DOCME
-class AvisynthAudioProviderFactory : public AudioProviderFactory {
-public:
-
- /// @brief DOCME
- /// @param file
- ///
- AudioProvider *CreateProvider(wxString file) { return new AvisynthAudioProvider(file); }
-};
-
#endif
-
-
diff --git a/aegisub/src/audio_provider_convert.h b/aegisub/src/audio_provider_convert.h
index f7daf9965..e335e8ef4 100644
--- a/aegisub/src/audio_provider_convert.h
+++ b/aegisub/src/audio_provider_convert.h
@@ -34,9 +34,6 @@
/// @ingroup audio_input
///
-
-///////////
-// Headers
#include "include/aegisub/audio_provider.h"
@@ -66,7 +63,7 @@ public:
/// @brief // That's one of the points of it! // By its nature, the ConvertAudioProvider always delivers machine endian:
/// @return
///
- bool AreSamplesNativeEndian() { return true; }
+ bool AreSamplesNativeEndian() const { return true; }
void GetAudio(void *buf, int64_t start, int64_t count);
@@ -76,6 +73,3 @@ public:
};
AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider);
-
-
-
diff --git a/aegisub/src/audio_provider_downmix.h b/aegisub/src/audio_provider_downmix.h
index 5412b8a1b..871420aa7 100644
--- a/aegisub/src/audio_provider_downmix.h
+++ b/aegisub/src/audio_provider_downmix.h
@@ -59,11 +59,7 @@ public:
/// @brief // Downmixing requires samples to be native endian beforehand
///
- bool AreSamplesNativeEndian() { return true; }
+ bool AreSamplesNativeEndian() const { return true; }
void GetAudio(void *buf, int64_t start, int64_t count);
-
};
-
-
-
diff --git a/aegisub/src/audio_provider_dummy.h b/aegisub/src/audio_provider_dummy.h
index 4fe744b56..89d7e57fd 100644
--- a/aegisub/src/audio_provider_dummy.h
+++ b/aegisub/src/audio_provider_dummy.h
@@ -34,12 +34,8 @@
/// @ingroup audio_input
///
-
-///////////
-// Headers
#include "include/aegisub/audio_provider.h"
-
/// DOCME
/// @class DummyAudioProvider
/// @brief DOCME
@@ -58,9 +54,7 @@ public:
/// @brief DOCME
///
- bool AreSamplesNativeEndian() { return true; }
+ bool AreSamplesNativeEndian() const { return true; }
void GetAudio(void *buf, int64_t start, int64_t count);
};
-
-
diff --git a/aegisub/src/audio_provider_ffmpegsource.h b/aegisub/src/audio_provider_ffmpegsource.h
index f584c2e2a..d47c0d65f 100644
--- a/aegisub/src/audio_provider_ffmpegsource.h
+++ b/aegisub/src/audio_provider_ffmpegsource.h
@@ -34,8 +34,6 @@
/// @ingroup audio_input ffms
///
-///////////
-// Headers
#ifdef WITH_FFMPEGSOURCE
#include "include/aegisub/audio_provider.h"
#include "ffmpegsource_common.h"
@@ -62,24 +60,8 @@ public:
/// @brief Checks sample endianness
/// @return Returns true.
/// FFMS always delivers native endian samples.
- bool AreSamplesNativeEndian() { return true; }
+ bool AreSamplesNativeEndian() const { return true; }
virtual void GetAudio(void *buf, int64_t start, int64_t count);
};
-
-
-
-/// @class FFmpegSourceAudioProviderFactory
-/// @brief Creates a FFmpegSource audio provider.
-class FFmpegSourceAudioProviderFactory : public AudioProviderFactory {
-public:
- /// @brief Creates a FFmpegSource audio provider.
- /// @param video The audio filename to open.
- /// @return Returns the audio provider.
- AudioProvider *CreateProvider(wxString file) { return new FFmpegSourceAudioProvider(file); }
-};
-
-#endif /* WITH_FFMPEGSOURCE */
-
-
-
+#endif
diff --git a/aegisub/src/audio_provider_hd.h b/aegisub/src/audio_provider_hd.h
index 71cc1e6b4..db39d6792 100644
--- a/aegisub/src/audio_provider_hd.h
+++ b/aegisub/src/audio_provider_hd.h
@@ -34,9 +34,6 @@
/// @ingroup audio_input
///
-
-///////////
-// Headers
#ifndef AGI_PRE
#include
#include
@@ -44,8 +41,6 @@
#include "include/aegisub/audio_provider.h"
-
-
/// DOCME
/// @class HDAudioProvider
/// @brief DOCME
@@ -79,9 +74,7 @@ public:
/// @brief DOCME
///
- bool AreSamplesNativeEndian() { return samples_native_endian; }
+ bool AreSamplesNativeEndian() const { return samples_native_endian; }
void GetAudio(void *buf, int64_t start, int64_t count);
};
-
-
diff --git a/aegisub/src/audio_provider_manager.h b/aegisub/src/audio_provider_manager.h
deleted file mode 100644
index 44f621c58..000000000
--- a/aegisub/src/audio_provider_manager.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2006, Rodrigo Braz Monteiro
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of the Aegisub Group nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Aegisub Project http://www.aegisub.org/
-//
-// $Id$
-
-/// @file audio_provider_manager.h
-/// @brief Manage available audio provider implementations
-/// @ingroup audio_input
-///
-
-
-#pragma once
-
-
-///////////
-// Headers
-#ifndef AGI_PRE
-#include
-#endif
-
-#include "include/aegisub/audio_provider.h"
-#include "factory_manager.h"
-
-
-/// DOCME
-/// @class AudioProviderFactoryManager
-/// @brief DOCME
-///
-/// DOCME
-class AudioProviderFactoryManager : public FactoryManager {
-public:
- static void RegisterProviders();
- static AudioProvider *GetAudioProvider(wxString filename, int cache=-1);
- static void ClearProviders();
-};
-
-
diff --git a/aegisub/src/audio_provider_pcm.cpp b/aegisub/src/audio_provider_pcm.cpp
index 4e3804fab..3491e69be 100644
--- a/aegisub/src/audio_provider_pcm.cpp
+++ b/aegisub/src/audio_provider_pcm.cpp
@@ -436,7 +436,7 @@ public:
/// @brief DOCME
/// @return
///
- bool AreSamplesNativeEndian()
+ bool AreSamplesNativeEndian() const
{
// 8 bit samples don't consider endianness
if (bytes_per_sample < 2) return true;
@@ -657,7 +657,7 @@ public:
/// @brief DOCME
/// @return
///
- bool AreSamplesNativeEndian()
+ bool AreSamplesNativeEndian() const
{
// 8 bit samples don't consider endianness
if (bytes_per_sample < 2) return true;
diff --git a/aegisub/src/audio_provider_pcm.h b/aegisub/src/audio_provider_pcm.h
index 7be8c5717..46425d6a7 100644
--- a/aegisub/src/audio_provider_pcm.h
+++ b/aegisub/src/audio_provider_pcm.h
@@ -34,9 +34,6 @@
/// @ingroup audio_input
///
-
-///////////
-// Headers
#ifndef AGI_PRE
#include
@@ -116,7 +113,3 @@ public:
// Construct the right PCM audio provider (if any) for the file
AudioProvider *CreatePCMAudioProvider(const wxString &filename);
-
-
-
-
diff --git a/aegisub/src/audio_provider_ram.h b/aegisub/src/audio_provider_ram.h
index ed53e55ed..1c5cb9a62 100644
--- a/aegisub/src/audio_provider_ram.h
+++ b/aegisub/src/audio_provider_ram.h
@@ -34,20 +34,14 @@
/// @ingroup audio_input
///
-
-///////////
-// Headers
#include "include/aegisub/audio_provider.h"
-
/// DOCME
/// @class RAMAudioProvider
/// @brief DOCME
///
/// DOCME
class RAMAudioProvider : public AudioProvider {
-private:
-
/// DOCME
char** blockcache;
@@ -63,12 +57,6 @@ public:
RAMAudioProvider(AudioProvider *source);
~RAMAudioProvider();
-
- /// @brief DOCME
- ///
- bool AreSamplesNativeEndian() { return samples_native_endian; }
-
+ bool AreSamplesNativeEndian() const { return samples_native_endian; }
void GetAudio(void *buf, int64_t start, int64_t count);
};
-
-
diff --git a/aegisub/src/audio_renderer_spectrum.cpp b/aegisub/src/audio_renderer_spectrum.cpp
index ce17f7329..de95cedd5 100644
--- a/aegisub/src/audio_renderer_spectrum.cpp
+++ b/aegisub/src/audio_renderer_spectrum.cpp
@@ -53,6 +53,7 @@
#include
+#include "include/aegisub/audio_provider.h"
#include "audio_renderer_spectrum.h"
#include "colorspace.h"
#include "fft.h"
diff --git a/aegisub/src/audio_renderer_spectrum.h b/aegisub/src/audio_renderer_spectrum.h
index 2a3c7db4f..e89cedc96 100644
--- a/aegisub/src/audio_renderer_spectrum.h
+++ b/aegisub/src/audio_renderer_spectrum.h
@@ -36,15 +36,11 @@
///
/// Calculate and render a frequency-power spectrum for PCM audio data.
-
-
-
#ifndef AGI_PRE
#include
#endif
-#include "audio_provider_manager.h"
-
+class AudioProvider;
// Specified and implemented in cpp file, interface is private to spectrum code
class AudioSpectrumCacheManager;
diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp
index 7de4e624c..f27d5be22 100644
--- a/aegisub/src/dialog_spellchecker.cpp
+++ b/aegisub/src/dialog_spellchecker.cpp
@@ -50,7 +50,7 @@
#include "help_button.h"
#include "libresrc/libresrc.h"
#include "main.h"
-#include "spellchecker_manager.h"
+#include "include/aegisub/spellchecker.h"
#include "subs_edit_box.h"
#include "subs_edit_ctrl.h"
#include "subs_grid.h"
@@ -96,7 +96,7 @@ DialogSpellChecker::DialogSpellChecker(wxFrame *parent)
SetIcon(BitmapToIcon(GETIMAGE(spellcheck_toolbutton_24)));
// Get spell checker
- spellchecker = SpellCheckerFactoryManager::GetSpellChecker();
+ spellchecker = SpellCheckerFactory::GetSpellChecker();
if (!spellchecker) {
wxMessageBox(_T("No spellchecker available."),_T("Error"),wxICON_ERROR);
Destroy();
diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp
index b3e48b802..e5b50d6b0 100644
--- a/aegisub/src/dialog_style_editor.cpp
+++ b/aegisub/src/dialog_style_editor.cpp
@@ -57,7 +57,7 @@
#include "main.h"
#include "subs_grid.h"
#include "subs_preview.h"
-#include "subtitles_provider_manager.h"
+#include "include/aegisub/subtitles_provider.h"
#include "utils.h"
#include "validators.h"
@@ -361,7 +361,7 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit
// Preview
SubsPreview = NULL;
PreviewText = NULL;
- if (SubtitlesProviderFactoryManager::ProviderAvailable()) {
+ if (!SubtitlesProviderFactory::GetClasses().empty()) {
PreviewText = new wxTextCtrl(this,TEXT_PREVIEW,lagi_wxString(OPT_GET("Tool/Style Editor/Preview Text")->GetString()));
previewButton = new ColourButton(this,BUTTON_PREVIEW_COLOR,wxSize(45,16),lagi_wxColour(OPT_GET("Colour/Style Editor/Background/Preview")->GetColour()));
SubsPreview = new SubtitlesPreview(this,-1,wxDefaultPosition,wxSize(100,60),wxSUNKEN_BORDER,lagi_wxColour(OPT_GET("Colour/Style Editor/Background/Preview")->GetColour()));
diff --git a/aegisub/src/dialog_video_details.cpp b/aegisub/src/dialog_video_details.cpp
index 59e65dcb7..fadc9b889 100644
--- a/aegisub/src/dialog_video_details.cpp
+++ b/aegisub/src/dialog_video_details.cpp
@@ -34,17 +34,12 @@
/// @ingroup secondary_ui
///
-
-///////////
-// Headers
#include "config.h"
#ifndef AGI_PRE
#include
#endif
-#include "audio_box.h"
-#include "audio_provider_manager.h"
#include "dialog_video_details.h"
#include "utils.h"
#include "video_context.h"
diff --git a/aegisub/src/factory_manager.h b/aegisub/src/factory_manager.h
index bb717809d..57b86bb73 100644
--- a/aegisub/src/factory_manager.h
+++ b/aegisub/src/factory_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2008, Rodrigo Braz Monteiro
+// Copyright (c) 2010, Thomas Goyne
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -34,117 +34,111 @@
/// @ingroup utility
///
-
#pragma once
-
-///////////
-// Headers
#ifndef AGI_PRE
+#include
#include