mirror of https://github.com/odrling/Aegisub
Rework most of the various factories to not need an explicit helper class for each class constructable via a factory.
Originally committed to SVN as r4716.
This commit is contained in:
parent
f0aa85dfbb
commit
71fb04cd29
|
@ -495,10 +495,6 @@
|
|||
RelativePath="..\..\src\audio_provider_hd.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\audio_provider_manager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\audio_provider_pcm.cpp"
|
||||
>
|
||||
|
@ -1443,10 +1439,6 @@
|
|||
RelativePath="..\..\src\spellchecker_hunspell.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\spellchecker_manager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\thesaurus.cpp"
|
||||
>
|
||||
|
@ -1571,10 +1563,6 @@
|
|||
RelativePath="..\..\src\subtitles_provider_libass.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\subtitles_provider_manager.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Visual Tools"
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
/// @ingroup audio_ui
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
#ifndef AGI_PRE
|
||||
|
@ -55,6 +52,7 @@
|
|||
#include "audio_karaoke.h"
|
||||
#include "frame_main.h"
|
||||
#include "hotkeys.h"
|
||||
#include "include/aegisub/audio_player.h"
|
||||
#include "libresrc/libresrc.h"
|
||||
#include "main.h"
|
||||
#include "toggle_bitmap.h"
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
#include "compat.h"
|
||||
#include "fft.h"
|
||||
#include "hotkeys.h"
|
||||
#include "include/aegisub/audio_player.h"
|
||||
#include "include/aegisub/audio_provider.h"
|
||||
#include "main.h"
|
||||
#include "standard_paths.h"
|
||||
#include "subs_edit_box.h"
|
||||
|
@ -895,14 +897,14 @@ void AudioDisplay::SetFile(wxString file) {
|
|||
is_dummy = true;
|
||||
provider = new DummyAudioProvider(150*60*1000, true); // 150 minutes noise
|
||||
} else {
|
||||
provider = AudioProviderFactoryManager::GetAudioProvider(file);
|
||||
provider = AudioProviderFactory::GetProvider(file);
|
||||
}
|
||||
#else
|
||||
provider = AudioProviderFactoryManager::GetAudioProvider(file);
|
||||
provider = AudioProviderFactory::GetProvider(file);
|
||||
#endif
|
||||
|
||||
// Get player
|
||||
player = AudioPlayerFactoryManager::GetAudioPlayer();
|
||||
player = AudioPlayerFactory::GetAudioPlayer();
|
||||
player->SetDisplayTimer(&UpdateTimer);
|
||||
player->SetProvider(provider);
|
||||
player->OpenStream();
|
||||
|
|
|
@ -44,10 +44,10 @@
|
|||
#include <wx/window.h>
|
||||
#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;
|
||||
|
|
|
@ -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<std::string> 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;i<list.Count();i++) {
|
||||
for (unsigned int i=0;i<list.size();i++) {
|
||||
try {
|
||||
AudioPlayer *player = GetFactory(list[i])->CreatePlayer();
|
||||
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<AlsaPlayer>("ALSA");
|
||||
#endif
|
||||
#ifdef WITH_DIRECTSOUND
|
||||
RegisterFactory(new DirectSoundPlayerFactory(),_T("DirectSound-old"));
|
||||
RegisterFactory(new DirectSoundPlayer2Factory(),_T("DirectSound"));
|
||||
Register<DirectSoundPlayer>("DirectSound-old");
|
||||
Register<DirectSoundPlayer2>("DirectSound");
|
||||
#endif
|
||||
#ifdef WITH_OPENAL
|
||||
RegisterFactory(new OpenALPlayerFactory(),_T("OpenAL"));
|
||||
Register<OpenALPlayer>("OpenAL");
|
||||
#endif
|
||||
#ifdef WITH_PORTAUDIO
|
||||
RegisterFactory(new PortAudioPlayerFactory(),_T("PortAudio"));
|
||||
Register<PortAudioPlayer>("PortAudio");
|
||||
#endif
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
RegisterFactory(new PulseAudioPlayerFactory(),_T("PulseAudio"));
|
||||
Register<PulseAudioPlayer>("PulseAudio");
|
||||
#endif
|
||||
#ifdef WITH_OSS
|
||||
RegisterFactory(new OSSPlayerFactory(),_T("OSS"));
|
||||
Register<OSSPlayer>("OSS");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Clear all factories
|
||||
///
|
||||
void AudioPlayerFactoryManager::ClearProviders() {
|
||||
ClearFactories();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
template <class AudioPlayerFactory> std::map<wxString,AudioPlayerFactory*>* FactoryManager<AudioPlayerFactory>::factories=NULL;
|
||||
|
||||
|
||||
|
||||
template<> AudioPlayerFactory::map *FactoryBase<AudioPlayer *(*)()>::classes = NULL;
|
||||
|
|
|
@ -40,14 +40,9 @@
|
|||
|
||||
#ifdef WITH_ALSA
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include <libaegisub/log.h>
|
||||
|
||||
#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
|
||||
|
||||
|
||||
|
|
|
@ -37,9 +37,6 @@
|
|||
|
||||
#ifdef WITH_ALSA
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
#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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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 <stdint.h>
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/thread.h>
|
||||
#include <wx/timer.h>
|
||||
#endif
|
||||
|
||||
#include "factory_manager.h"
|
||||
#include "include/aegisub/audio_player.h"
|
||||
|
||||
|
||||
//////////////
|
||||
// Prototypes
|
||||
class AudioProvider;
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class AudioPlayerFactoryManager
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class AudioPlayerFactoryManager : public FactoryManager<AudioPlayerFactory> {
|
||||
public:
|
||||
static AudioPlayer *GetAudioPlayer();
|
||||
static void RegisterProviders();
|
||||
static void ClearProviders();
|
||||
};
|
||||
|
||||
|
||||
|
||||
/////////
|
||||
// Event
|
||||
DECLARE_EVENT_TYPE(wxEVT_STOP_AUDIO, -1)
|
||||
|
||||
|
||||
|
||||
|
|
@ -34,19 +34,13 @@
|
|||
/// @ingroup audio_output
|
||||
///
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef WITH_OPENAL
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include <libaegisub/log.h>
|
||||
|
||||
#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 <AL/alc.h>
|
||||
#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
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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 <AL/alc.h>
|
||||
#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
|
||||
|
||||
|
||||
|
|
|
@ -37,13 +37,9 @@
|
|||
|
||||
#ifdef WITH_OSS
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include <libaegisub/log.h>
|
||||
|
||||
#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"
|
||||
|
|
|
@ -37,10 +37,6 @@
|
|||
#include "config.h"
|
||||
|
||||
#ifdef WITH_OSS
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifndef AGI_PRE
|
||||
#include <sys/ioctl.h>
|
||||
#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
|
||||
|
|
|
@ -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 <portaudio.h>
|
||||
}
|
||||
|
||||
|
||||
/// @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
|
||||
|
|
|
@ -34,20 +34,15 @@
|
|||
/// @ingroup audio_output
|
||||
///
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifndef AGI_PRE
|
||||
#include <stdio.h>
|
||||
#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
|
||||
|
||||
|
||||
|
|
|
@ -34,12 +34,7 @@
|
|||
/// @ingroup audio_output
|
||||
///
|
||||
|
||||
|
||||
#ifdef WITH_PULSEAUDIO
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifndef AGI_PRE
|
||||
#include <stdio.h>
|
||||
#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
|
||||
|
||||
|
||||
|
|
|
@ -35,15 +35,12 @@
|
|||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/thread.h>
|
||||
#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<std::string> 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;i<list.Count();i++) {
|
||||
for (unsigned int i=0;i<list.size();i++) {
|
||||
try {
|
||||
AudioProvider *prov = GetFactory(list[i])->CreateProvider(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<AvisynthAudioProvider>("Avisynth");
|
||||
#endif
|
||||
#ifdef WITH_FFMPEGSOURCE
|
||||
RegisterFactory(new FFmpegSourceAudioProviderFactory(),_T("FFmpegSource"));
|
||||
Register<FFmpegSourceAudioProvider>("FFmpegSource");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Clear all providers
|
||||
///
|
||||
void AudioProviderFactoryManager::ClearProviders() {
|
||||
ClearFactories();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
template <class AudioProviderFactory> std::map<wxString,AudioProviderFactory*>* FactoryManager<AudioProviderFactory>::factories=NULL;
|
||||
|
||||
|
||||
template<> AudioProviderFactory::map *FactoryBase<AudioProvider *(*)(wxString)>::classes = NULL;
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
/// @ingroup audio_input
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifdef WITH_AVISYNTH
|
||||
#include <Mmreg.h>
|
||||
#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
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
/// @ingroup audio_input
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/file.h>
|
||||
#include <wx/thread.h>
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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 <stdint.h>
|
||||
#endif
|
||||
|
||||
#include "include/aegisub/audio_provider.h"
|
||||
#include "factory_manager.h"
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class AudioProviderFactoryManager
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class AudioProviderFactoryManager : public FactoryManager<AudioProviderFactory> {
|
||||
public:
|
||||
static void RegisterProviders();
|
||||
static AudioProvider *GetAudioProvider(wxString filename, int cache=-1);
|
||||
static void ClearProviders();
|
||||
};
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
/// @ingroup audio_input
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifndef AGI_PRE
|
||||
#include <vector>
|
||||
|
||||
|
@ -116,7 +113,3 @@ public:
|
|||
|
||||
// Construct the right PCM audio provider (if any) for the file
|
||||
AudioProvider *CreatePCMAudioProvider(const wxString &filename);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
|
||||
#include <libaegisub/log.h>
|
||||
|
||||
#include "include/aegisub/audio_provider.h"
|
||||
#include "audio_renderer_spectrum.h"
|
||||
#include "colorspace.h"
|
||||
#include "fft.h"
|
||||
|
|
|
@ -36,15 +36,11 @@
|
|||
///
|
||||
/// Calculate and render a frequency-power spectrum for PCM audio data.
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include "audio_provider_manager.h"
|
||||
|
||||
class AudioProvider;
|
||||
|
||||
// Specified and implemented in cpp file, interface is private to spectrum code
|
||||
class AudioSpectrumCacheManager;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -34,17 +34,12 @@
|
|||
/// @ingroup secondary_ui
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/stattext.h>
|
||||
#endif
|
||||
|
||||
#include "audio_box.h"
|
||||
#include "audio_provider_manager.h"
|
||||
#include "dialog_video_details.h"
|
||||
#include "utils.h"
|
||||
#include "video_context.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2007-2008, Rodrigo Braz Monteiro
|
||||
// Copyright (c) 2010, Thomas Goyne <plorkyeran@aegisub.org>
|
||||
// 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 <cctype>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <wx/arrstr.h>
|
||||
#include <wx/string.h>
|
||||
#endif
|
||||
|
||||
|
||||
/////////////////
|
||||
// Factory class
|
||||
template <class T>
|
||||
|
||||
/// DOCME
|
||||
/// @class FactoryManager
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class FactoryManager {
|
||||
template <class func>
|
||||
class FactoryBase {
|
||||
protected:
|
||||
typedef std::map<std::string, std::pair<bool, func> > map;
|
||||
typedef typename map::iterator iterator;
|
||||
|
||||
/// DOCME
|
||||
static std::map<wxString,T*> *factories;
|
||||
static map *classes;
|
||||
|
||||
static void DoRegister(func function, std::string name, bool hide, std::vector<std::string> &subtypes) {
|
||||
if (!classes) classes = new map;
|
||||
|
||||
/// @brief DOCME
|
||||
///
|
||||
static void ClearFactories() {
|
||||
if (factories && !factories->empty()) {
|
||||
typename std::map<wxString,T*>::iterator iter;
|
||||
for (iter = factories->begin(); iter != factories->end(); iter++) {
|
||||
delete iter->second;
|
||||
if (subtypes.empty()) {
|
||||
classes->insert(std::make_pair(name, std::make_pair(hide, function)));
|
||||
}
|
||||
factories->clear();
|
||||
}
|
||||
delete factories;
|
||||
}
|
||||
|
||||
|
||||
/// @brief // Register one factory type (with possible subtypes)
|
||||
/// @param factory
|
||||
/// @param name
|
||||
/// @param subTypes
|
||||
///
|
||||
static void RegisterFactory(T* factory,wxString name, wxArrayString subTypes=wxArrayString()) {
|
||||
// Create factories if it doesn't exist
|
||||
if (factories == NULL) factories = new std::map<wxString,T*>;
|
||||
|
||||
// Prepare subtypes
|
||||
if (subTypes.GetCount() == 0) subTypes.Add(_T(""));
|
||||
else {
|
||||
for (unsigned int i=0;i<subTypes.GetCount();i++) {
|
||||
subTypes[i] = _T("/") + subTypes[i];
|
||||
for (size_t i = 0; i < subtypes.size(); i++) {
|
||||
classes->insert(std::make_pair(name + '/' + subtypes[i], std::make_pair(hide, function)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert each subtype
|
||||
for (unsigned int i=0;i<subTypes.GetCount();i++) {
|
||||
factories->insert(std::make_pair(name.Lower() + subTypes[i],factory));
|
||||
}
|
||||
}
|
||||
static func Find(std::string name) {
|
||||
if (!classes) return NULL;
|
||||
|
||||
|
||||
/// @brief // Get a factory with name
|
||||
/// @param name
|
||||
/// @return
|
||||
///
|
||||
static T *GetFactory(wxString name) {
|
||||
// No factories
|
||||
if (factories == NULL) {
|
||||
factories = new std::map<wxString,T*>;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Search for factory that matches
|
||||
typename std::map<wxString,T*>::iterator cur;
|
||||
for (cur = factories->begin();cur != factories->end();cur++) {
|
||||
if (cur->first.StartsWith(name)) return cur->second;
|
||||
}
|
||||
|
||||
// None found
|
||||
iterator factory = classes->find(name);
|
||||
if (factory != classes->end()) return factory->second.second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/// @brief // Virtual destructor
|
||||
///
|
||||
virtual ~FactoryManager() {
|
||||
ClearFactories();
|
||||
};
|
||||
|
||||
|
||||
/// @brief // Get list of all factories, with favourite as first
|
||||
/// @param favourite
|
||||
///
|
||||
static wxArrayString GetFactoryList(wxString favourite=_T("")) {
|
||||
if (factories == NULL) factories = new std::map<wxString,T*>;
|
||||
wxArrayString list;
|
||||
favourite = favourite.Lower();
|
||||
for (typename std::map<wxString,T*>::iterator cur=factories->begin();cur!=factories->end();cur++) {
|
||||
if (cur->first == favourite) list.Insert(cur->first,0);
|
||||
else list.Add(cur->first);
|
||||
static void Clear() {
|
||||
delete classes;
|
||||
}
|
||||
static std::vector<std::string> GetClasses(std::string favourite="") {
|
||||
std::vector<std::string> list;
|
||||
if (!classes) return list;
|
||||
std::string cmp;
|
||||
std::transform(favourite.begin(), favourite.end(), favourite.begin(), ::tolower);
|
||||
for (iterator cur=classes->begin();cur!=classes->end();cur++) {
|
||||
cmp.clear();
|
||||
std::transform(cur->first.begin(), cur->first.end(), std::back_inserter(cmp), ::tolower);
|
||||
if (cmp == favourite) list.insert(list.begin(), cur->first);
|
||||
else if (!cur->second.first) list.push_back(cur->first);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
virtual ~FactoryBase() {
|
||||
delete classes;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Base>
|
||||
class Factory0 : public FactoryBase<Base *(*)()> {
|
||||
typedef Base *(*func)();
|
||||
template<class T>
|
||||
static Base* create() {
|
||||
return new T;
|
||||
}
|
||||
public:
|
||||
static Base* Create(std::string name) {
|
||||
func factory = FactoryBase<func>::Find(name);
|
||||
if (factory) {
|
||||
return factory();
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static void Register(std::string name, bool hide = false, std::vector<std::string> subTypes = std::vector<std::string>()) {
|
||||
DoRegister(&Factory0<Base>::create<T>, name, hide, subTypes);
|
||||
}
|
||||
};
|
||||
|
||||
template<class Base, class Arg1>
|
||||
class Factory1 : public FactoryBase<Base *(*)(Arg1)> {
|
||||
typedef Base *(*func)(Arg1);
|
||||
template<class T>
|
||||
static Base* create(Arg1 a1) {
|
||||
return new T(a1);
|
||||
}
|
||||
public:
|
||||
static Base* Create(std::string name, Arg1 a1) {
|
||||
func factory = FactoryBase<func>::Find(name);
|
||||
if (factory) {
|
||||
return factory(a1);
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static void Register(std::string name, bool hide = false, std::vector<std::string> subTypes = std::vector<std::string>()) {
|
||||
DoRegister(&Factory1<Base, Arg1>::create<T>, name, hide, subTypes);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
/// @ingroup main_ui
|
||||
|
||||
|
||||
////////////////// Include headers
|
||||
#include "config.h"
|
||||
|
||||
#ifndef AGI_PRE
|
||||
|
@ -79,6 +78,7 @@
|
|||
#include "dialog_video_details.h"
|
||||
#include "frame_main.h"
|
||||
#include "hotkeys.h"
|
||||
#include "include/aegisub/audio_player.h"
|
||||
#include "keyframe.h"
|
||||
#include "libresrc/libresrc.h"
|
||||
#include "main.h"
|
||||
|
|
|
@ -34,37 +34,26 @@
|
|||
/// @ingroup main_headers audio_output
|
||||
///
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/event.h>
|
||||
#include <wx/thread.h>
|
||||
#include <wx/timer.h>
|
||||
#endif
|
||||
|
||||
#include "aegisub.h"
|
||||
#include "factory_manager.h"
|
||||
|
||||
|
||||
//////////////
|
||||
// Prototypes
|
||||
class AudioProvider;
|
||||
|
||||
|
||||
|
||||
/// @class AudioPlayer
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class AudioPlayer : public wxEvtHandler {
|
||||
private:
|
||||
void OnStopAudio(wxCommandEvent &event);
|
||||
|
||||
protected:
|
||||
|
||||
/// DOCME
|
||||
AudioProvider *provider;
|
||||
|
||||
|
@ -98,27 +87,20 @@ public:
|
|||
virtual void SetEndPosition(int64_t pos)=0;
|
||||
virtual void SetCurrentPosition(int64_t pos)=0;
|
||||
|
||||
virtual wxMutex *GetMutex();
|
||||
virtual wxMutex *GetMutex() { return NULL; }
|
||||
|
||||
virtual void SetProvider(AudioProvider *provider);
|
||||
AudioProvider *GetProvider();
|
||||
virtual void SetProvider(AudioProvider *new_provider) { provider = new_provider; }
|
||||
AudioProvider *GetProvider() const { return provider; }
|
||||
|
||||
void SetDisplayTimer(wxTimer *timer);
|
||||
void SetDisplayTimer(wxTimer *timer) { displayTimer = timer; }
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// @class AudioPlayerFactory
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class AudioPlayerFactory {
|
||||
class AudioPlayerFactory : public Factory0<AudioPlayer> {
|
||||
public:
|
||||
|
||||
/// @brief DOCME
|
||||
///
|
||||
virtual ~AudioPlayerFactory() {}
|
||||
virtual AudioPlayer *CreatePlayer()=0;
|
||||
static void RegisterProviders();
|
||||
static AudioPlayer *GetAudioPlayer();
|
||||
};
|
||||
|
||||
DECLARE_EVENT_TYPE(wxEVT_STOP_AUDIO, -1)
|
||||
|
|
|
@ -34,24 +34,13 @@
|
|||
/// @ingroup main_headers audio_input
|
||||
///
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/string.h>
|
||||
#endif
|
||||
|
||||
#include "aegisub.h"
|
||||
|
||||
|
||||
//////////////
|
||||
// Prototypes
|
||||
class VideoProvider;
|
||||
|
||||
|
||||
#include "factory_manager.h"
|
||||
|
||||
/// @class AudioProvider
|
||||
/// @brief DOCME
|
||||
|
@ -88,30 +77,26 @@ public:
|
|||
AudioProvider();
|
||||
virtual ~AudioProvider();
|
||||
|
||||
virtual wxString GetFilename();
|
||||
virtual wxString GetFilename() const { return filename; };
|
||||
virtual void GetAudio(void *buf, int64_t start, int64_t count)=0;
|
||||
void GetAudioWithVolume(void *buf, int64_t start, int64_t count, double volume);
|
||||
|
||||
int64_t GetNumSamples();
|
||||
int GetSampleRate();
|
||||
int GetBytesPerSample();
|
||||
int GetChannels();
|
||||
virtual bool AreSamplesNativeEndian() = 0;
|
||||
int64_t GetNumSamples() const { return num_samples; }
|
||||
int GetSampleRate() const { return sample_rate; }
|
||||
int GetBytesPerSample() const { return bytes_per_sample; }
|
||||
int GetChannels() const { return channels; }
|
||||
virtual bool AreSamplesNativeEndian() const = 0;
|
||||
|
||||
void GetWaveForm(int *min,int *peak,int64_t start,int w,int h,int samples,float scale);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class AudioProviderFactory
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class AudioProviderFactory {
|
||||
class AudioProviderFactory : public Factory1<AudioProvider, wxString> {
|
||||
public:
|
||||
|
||||
/// @brief DOCME
|
||||
///
|
||||
virtual ~AudioProviderFactory() {}
|
||||
virtual AudioProvider *CreateProvider(wxString filename)=0;
|
||||
static void RegisterProviders();
|
||||
static AudioProvider *GetProvider(wxString filename, int cache=-1);
|
||||
};
|
||||
|
|
|
@ -34,19 +34,14 @@
|
|||
/// @ingroup main_headers spelling
|
||||
///
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/arrstr.h>
|
||||
#include <wx/string.h>
|
||||
#endif
|
||||
|
||||
#include "aegisub.h"
|
||||
|
||||
#include "factory_manager.h"
|
||||
|
||||
/// @class SpellChecker
|
||||
/// @brief DOCME
|
||||
|
@ -54,16 +49,10 @@
|
|||
/// DOCME
|
||||
class SpellChecker {
|
||||
public:
|
||||
|
||||
/// @brief DOCME
|
||||
///
|
||||
SpellChecker() {}
|
||||
|
||||
/// @brief DOCME
|
||||
///
|
||||
virtual ~SpellChecker() {}
|
||||
|
||||
|
||||
/// @brief DOCME
|
||||
/// @param word
|
||||
/// @return
|
||||
|
@ -83,19 +72,13 @@ public:
|
|||
virtual void SetLanguage(wxString language)=0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// @class SpellCheckerFactory
|
||||
/// DOCME
|
||||
/// @class SpellCheckerFactoryManager
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class SpellCheckerFactory {
|
||||
class SpellCheckerFactory : public Factory0<SpellChecker> {
|
||||
public:
|
||||
|
||||
/// @brief DOCME
|
||||
///
|
||||
virtual ~SpellCheckerFactory() {}
|
||||
virtual SpellChecker *CreateSpellChecker()=0;
|
||||
static SpellChecker *GetSpellChecker();
|
||||
static void RegisterProviders();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -34,20 +34,12 @@
|
|||
/// @ingroup main_headers subtitle_rendering
|
||||
///
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "aegisub.h"
|
||||
#include "video_frame.h"
|
||||
#include "factory_manager.h"
|
||||
|
||||
|
||||
//////////////
|
||||
// Prototypes
|
||||
class AssFile;
|
||||
|
||||
|
||||
class AegiVideoFrame;
|
||||
|
||||
/// @class SubtitlesProvider
|
||||
/// @brief DOCME
|
||||
|
@ -55,7 +47,7 @@ class AssFile;
|
|||
/// DOCME
|
||||
class SubtitlesProvider {
|
||||
public:
|
||||
virtual ~SubtitlesProvider();
|
||||
virtual ~SubtitlesProvider() { };
|
||||
|
||||
virtual void LoadSubtitles(AssFile *subs)=0;
|
||||
|
||||
|
@ -63,22 +55,16 @@ public:
|
|||
/// @param dst
|
||||
/// @param time
|
||||
///
|
||||
virtual void DrawSubtitles(AegiVideoFrame &dst,double time) {}
|
||||
virtual void DrawSubtitles(AegiVideoFrame &dst,double time)=0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// @class SubtitlesProviderFactory
|
||||
/// DOCME
|
||||
/// @class SubtitlesProviderFactoryManager
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class SubtitlesProviderFactory {
|
||||
class SubtitlesProviderFactory : public Factory1<SubtitlesProvider, std::string> {
|
||||
public:
|
||||
|
||||
/// @brief DOCME
|
||||
///
|
||||
virtual ~SubtitlesProviderFactory() {}
|
||||
virtual SubtitlesProvider *CreateProvider(wxString subType=_T(""))=0;
|
||||
static SubtitlesProvider *GetProvider();
|
||||
static void RegisterProviders();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -69,16 +69,3 @@ public:
|
|||
/// @return Returns true if caching is desired, false otherwise.
|
||||
virtual bool WantsCaching() const { return false; }
|
||||
};
|
||||
|
||||
/// @class VideoProviderFactory
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class VideoProviderFactory {
|
||||
public:
|
||||
|
||||
/// @brief DOCME
|
||||
///
|
||||
virtual ~VideoProviderFactory() {}
|
||||
virtual VideoProvider *CreateProvider(wxString video)=0;
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
ghost@aladdin.com
|
||||
|
||||
*/
|
||||
/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
|
||||
/* $Id$ */
|
||||
/*
|
||||
Independent implementation of MD5 (RFC 1321).
|
||||
|
||||
|
|
|
@ -34,16 +34,13 @@
|
|||
/// @ingroup main
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
#include "audio_player_manager.h"
|
||||
#include "audio_provider_manager.h"
|
||||
#include "include/aegisub/audio_player.h"
|
||||
#include "include/aegisub/audio_provider.h"
|
||||
#include "include/aegisub/spellchecker.h"
|
||||
#include "include/aegisub/subtitles_provider.h"
|
||||
#include "plugin_manager.h"
|
||||
#include "spellchecker_manager.h"
|
||||
#include "subtitles_provider_manager.h"
|
||||
#include "video_provider_manager.h"
|
||||
|
||||
|
||||
|
@ -59,15 +56,14 @@ PluginManager::PluginManager() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Destructor
|
||||
///
|
||||
PluginManager::~PluginManager() {
|
||||
VideoProviderFactoryManager::ClearProviders();
|
||||
AudioProviderFactoryManager::ClearProviders();
|
||||
AudioPlayerFactoryManager::ClearProviders();
|
||||
SubtitlesProviderFactoryManager::ClearProviders();
|
||||
SpellCheckerFactoryManager::ClearProviders();
|
||||
VideoProviderFactory::Clear();
|
||||
AudioProviderFactory::Clear();
|
||||
AudioPlayerFactory::Clear();
|
||||
SubtitlesProviderFactory::Clear();
|
||||
SpellCheckerFactory::Clear();
|
||||
|
||||
#ifdef WITH_AUTO4_LUA
|
||||
if (lua) {
|
||||
|
@ -85,11 +81,11 @@ PluginManager::~PluginManager() {
|
|||
void PluginManager::RegisterBuiltInPlugins() {
|
||||
if (!init) {
|
||||
// Managers
|
||||
VideoProviderFactoryManager::RegisterProviders();
|
||||
AudioProviderFactoryManager::RegisterProviders();
|
||||
AudioPlayerFactoryManager::RegisterProviders();
|
||||
SubtitlesProviderFactoryManager::RegisterProviders();
|
||||
SpellCheckerFactoryManager::RegisterProviders();
|
||||
VideoProviderFactory::RegisterProviders();
|
||||
AudioProviderFactory::RegisterProviders();
|
||||
AudioPlayerFactory::RegisterProviders();
|
||||
SubtitlesProviderFactory::RegisterProviders();
|
||||
SpellCheckerFactory::RegisterProviders();
|
||||
|
||||
// Automation languages
|
||||
#ifdef WITH_AUTO4_LUA
|
||||
|
@ -101,5 +97,3 @@ void PluginManager::RegisterBuiltInPlugins() {
|
|||
// Done
|
||||
init = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <iterator>
|
||||
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/combobox.h>
|
||||
#include <wx/filefn.h>
|
||||
|
@ -37,10 +39,10 @@
|
|||
#include "libresrc/libresrc.h"
|
||||
#include "preferences.h"
|
||||
#include "main.h"
|
||||
#include "subtitles_provider_manager.h"
|
||||
#include "include/aegisub/audio_player.h"
|
||||
#include "include/aegisub/audio_provider.h"
|
||||
#include "include/aegisub/subtitles_provider.h"
|
||||
#include "video_provider_manager.h"
|
||||
#include "audio_player_manager.h"
|
||||
#include "audio_provider_manager.h"
|
||||
|
||||
/// Define make all platform-specific options visible in a single view.
|
||||
#define SHOW_ALL 1
|
||||
|
@ -296,15 +298,20 @@ Advanced_Interface::Advanced_Interface(wxTreebook *book): OptionPage(book, _("Ba
|
|||
SetSizerAndFit(sizer);
|
||||
}
|
||||
|
||||
static wxArrayString vec_to_arrstr(std::vector<std::string> const& vec) {
|
||||
wxArrayString arrstr;
|
||||
std::copy(vec.begin(), vec.end(), std::back_inserter(arrstr));
|
||||
return arrstr;
|
||||
}
|
||||
|
||||
/// Advanced Audio preferences subpage
|
||||
Advanced_Audio::Advanced_Audio(wxTreebook *book): OptionPage(book, _("Audio"), PAGE_SUB) {
|
||||
wxFlexGridSizer *expert = PageSizer(_("Expert"));
|
||||
|
||||
wxArrayString ap_choice = AudioProviderFactoryManager::GetFactoryList();
|
||||
wxArrayString ap_choice = vec_to_arrstr(AudioProviderFactory::GetClasses());
|
||||
OptionChoice(expert, _("Audio provider"), ap_choice, "Audio/Provider");
|
||||
|
||||
wxArrayString apl_choice = AudioPlayerFactoryManager::GetFactoryList();
|
||||
wxArrayString apl_choice = vec_to_arrstr(AudioPlayerFactory::GetClasses());
|
||||
OptionChoice(expert, _("Audio player"), apl_choice, "Audio/Player");
|
||||
|
||||
wxFlexGridSizer *cache = PageSizer(_("Cache"));
|
||||
|
@ -340,10 +347,10 @@ Advanced_Audio::Advanced_Audio(wxTreebook *book): OptionPage(book, _("Audio"), P
|
|||
Advanced_Video::Advanced_Video(wxTreebook *book): OptionPage(book, _("Video")) {
|
||||
wxFlexGridSizer *expert = PageSizer(_("Expert"));
|
||||
|
||||
wxArrayString vp_choice = VideoProviderFactoryManager::GetFactoryList();
|
||||
wxArrayString vp_choice = vec_to_arrstr(VideoProviderFactory::GetClasses());
|
||||
OptionChoice(expert, _("Video provider"), vp_choice, "Video/Provider");
|
||||
|
||||
wxArrayString sp_choice = SubtitlesProviderFactoryManager::GetFactoryList();
|
||||
wxArrayString sp_choice = vec_to_arrstr(SubtitlesProviderFactory::GetClasses());
|
||||
OptionChoice(expert, _("Subtitle provider"), sp_choice, "Subtitle/Provider");
|
||||
|
||||
|
||||
|
|
|
@ -37,10 +37,9 @@
|
|||
#include "libresrc/libresrc.h"
|
||||
#include "preferences.h"
|
||||
#include "main.h"
|
||||
#include "subtitles_provider_manager.h"
|
||||
#include "include/aegisub/audio_player.h"
|
||||
#include "include/aegisub/audio_provider.h"
|
||||
#include "video_provider_manager.h"
|
||||
#include "audio_player_manager.h"
|
||||
#include "audio_provider_manager.h"
|
||||
|
||||
#include "preferences_base.h"
|
||||
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
/// @ingroup spelling
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
#ifdef WITH_HUNSPELL
|
||||
|
@ -44,26 +41,22 @@
|
|||
#endif
|
||||
|
||||
#include "compat.h"
|
||||
#include "include/aegisub/spellchecker.h"
|
||||
#include "main.h"
|
||||
#include "spellchecker_manager.h"
|
||||
|
||||
|
||||
|
||||
/// @brief Get spell checker
|
||||
/// @return
|
||||
///
|
||||
SpellChecker *SpellCheckerFactoryManager::GetSpellChecker() {
|
||||
SpellChecker *SpellCheckerFactory::GetSpellChecker() {
|
||||
// List of providers
|
||||
wxArrayString list = GetFactoryList(lagi_wxString(OPT_GET("Tool/Spell Checker/Backend")->GetString()));
|
||||
|
||||
// None available
|
||||
if (list.Count() == 0) return 0; //throw _T("No spell checkers are available.");
|
||||
std::vector<std::string> list = GetClasses(OPT_GET("Tool/Spell Checker/Backend")->GetString());
|
||||
if (list.empty()) return NULL;
|
||||
|
||||
// Get provider
|
||||
wxString error;
|
||||
for (unsigned int i=0;i<list.Count();i++) {
|
||||
for (unsigned int i=0;i<list.size();i++) {
|
||||
try {
|
||||
SpellChecker *checker = GetFactory(list[i])->CreateSpellChecker();
|
||||
SpellChecker *checker = Create(list[i]);
|
||||
if (checker) return checker;
|
||||
}
|
||||
catch (wxString err) { error += list[i] + _T(" factory: ") + err + _T("\n"); }
|
||||
|
@ -75,27 +68,12 @@ SpellChecker *SpellCheckerFactoryManager::GetSpellChecker() {
|
|||
throw error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Register all providers
|
||||
///
|
||||
void SpellCheckerFactoryManager::RegisterProviders() {
|
||||
void SpellCheckerFactory::RegisterProviders() {
|
||||
#ifdef WITH_HUNSPELL
|
||||
RegisterFactory(new HunspellSpellCheckerFactory(),_T("Hunspell"));
|
||||
Register<HunspellSpellChecker>("Hunspell");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Clear all providers
|
||||
///
|
||||
void SpellCheckerFactoryManager::ClearProviders() {
|
||||
ClearFactories();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
template <class SpellCheckerFactory> std::map<wxString,SpellCheckerFactory*>* FactoryManager<SpellCheckerFactory>::factories=NULL;
|
||||
|
||||
|
||||
template<> SpellCheckerFactory::map *FactoryBase<SpellChecker *(*)()>::classes = NULL;
|
||||
|
|
|
@ -49,7 +49,6 @@ namespace agi {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// @class HunspellSpellChecker
|
||||
/// @brief Hunspell spell checker
|
||||
///
|
||||
|
@ -88,19 +87,4 @@ public:
|
|||
void SetLanguage(wxString language);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// @class HunspellSpellCheckerFactory
|
||||
/// @brief Hunspell SpellChecker Factory
|
||||
///
|
||||
class HunspellSpellCheckerFactory : public SpellCheckerFactory {
|
||||
public:
|
||||
|
||||
/// @brief Create new Hunspell Spell checker.
|
||||
///
|
||||
SpellChecker *CreateSpellChecker() { return new HunspellSpellChecker(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -1,59 +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 spellchecker_manager.h
|
||||
/// @brief Factory class for spell checkers
|
||||
/// @ingroup spelling
|
||||
///
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "factory_manager.h"
|
||||
#include "include/aegisub/spellchecker.h"
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class SpellCheckerFactoryManager
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class SpellCheckerFactoryManager : public FactoryManager<SpellCheckerFactory> {
|
||||
public:
|
||||
static SpellChecker *GetSpellChecker();
|
||||
static void RegisterProviders();
|
||||
static void ClearProviders();
|
||||
};
|
||||
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
#include "ass_dialogue.h"
|
||||
#include "compat.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"
|
||||
|
@ -88,7 +88,7 @@ enum {
|
|||
///
|
||||
SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, SubtitlesGrid *grid)
|
||||
: ScintillaTextCtrl(parent, wxID_ANY, "", wxDefaultPosition, wsize, style)
|
||||
, spellchecker(SpellCheckerFactoryManager::GetSpellChecker())
|
||||
, spellchecker(SpellCheckerFactory::GetSpellChecker())
|
||||
, thesaurus(Thesaurus::GetThesaurus())
|
||||
, grid(grid)
|
||||
{
|
||||
|
|
|
@ -45,10 +45,13 @@
|
|||
#include <wx/tokenzr.h>
|
||||
#endif
|
||||
|
||||
#include "include/aegisub/audio_provider.h"
|
||||
#include "ass_file.h"
|
||||
#include "ass_karaoke.h"
|
||||
#include "ass_override.h"
|
||||
#include "ass_style.h"
|
||||
#include "audio_box.h"
|
||||
#include "audio_display.h"
|
||||
#include "charset_conv.h"
|
||||
#include "dialog_paste_over.h"
|
||||
#include "frame_main.h"
|
||||
|
|
|
@ -44,9 +44,6 @@
|
|||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include "audio_box.h"
|
||||
#include "audio_display.h"
|
||||
#include "audio_provider_manager.h"
|
||||
#include "base_grid.h"
|
||||
|
||||
class AssFile;
|
||||
|
@ -54,7 +51,6 @@ class AssEntry;
|
|||
class AssDialogue;
|
||||
class SubsEditBox;
|
||||
class FrameMain;
|
||||
class AudioDisplay;
|
||||
|
||||
typedef std::list<AssEntry*>::iterator entryIter;
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include "ass_file.h"
|
||||
#include "ass_style.h"
|
||||
#include "subs_preview.h"
|
||||
#include "subtitles_provider_manager.h"
|
||||
#include "include/aegisub/subtitles_provider.h"
|
||||
#include "video_provider_dummy.h"
|
||||
|
||||
|
||||
|
@ -139,7 +139,7 @@ void SubtitlesPreview::OnSize(wxSizeEvent &evt) {
|
|||
bmp.reset(new wxBitmap(w, h, -1));
|
||||
vid.reset(new DummyVideoProvider(0.0, 10, w, h, backColour, true));
|
||||
try {
|
||||
provider.reset(SubtitlesProviderFactoryManager::GetProvider());
|
||||
provider.reset(SubtitlesProviderFactory::GetProvider());
|
||||
}
|
||||
catch (...) {
|
||||
wxMessageBox(
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
#include "subtitle_format_dvd.h"
|
||||
#include "subtitles_provider_manager.h"
|
||||
#include "include/aegisub/subtitles_provider.h"
|
||||
#include "video_provider_dummy.h"
|
||||
|
||||
|
||||
|
@ -115,7 +115,7 @@ void DVDSubtitleFormat::GetSubPictureList(std::vector<SubPicture> &pics) {
|
|||
pics.resize(count);
|
||||
|
||||
SubtitlesProvider *provider = NULL;
|
||||
provider = SubtitlesProviderFactoryManager::GetProvider();
|
||||
provider = SubtitlesProviderFactory::GetProvider();
|
||||
provider->LoadSubtitles(GetAssFile());
|
||||
//TessDllAPI tess;
|
||||
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
/// @ingroup subtitle_rendering
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
@ -47,47 +44,22 @@
|
|||
#ifdef WITH_LIBASS
|
||||
#include "subtitles_provider_libass.h"
|
||||
#endif
|
||||
#include "subtitles_provider_manager.h"
|
||||
|
||||
|
||||
/// @brief Destructor
|
||||
///
|
||||
SubtitlesProvider::~SubtitlesProvider() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Check if provider available (doesn't verify provider works!)
|
||||
/// @return
|
||||
///
|
||||
bool SubtitlesProviderFactoryManager::ProviderAvailable() {
|
||||
// List of providers
|
||||
wxArrayString list = GetFactoryList(lagi_wxString(OPT_GET("Subtitle/Provider")->GetString()));
|
||||
|
||||
// None available
|
||||
return (list.Count() > 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Get provider
|
||||
/// @return
|
||||
///
|
||||
SubtitlesProvider* SubtitlesProviderFactoryManager::GetProvider() {
|
||||
// List of providers
|
||||
wxArrayString list = GetFactoryList(lagi_wxString(OPT_GET("Subtitle/Provider")->GetString()));
|
||||
|
||||
// None available
|
||||
if (list.Count() == 0) throw _T("No subtitle providers are available.");
|
||||
SubtitlesProvider* SubtitlesProviderFactory::GetProvider() {
|
||||
std::vector<std::string> list = GetClasses(OPT_GET("Subtitle/Provider")->GetString());
|
||||
if (list.empty()) throw _T("No subtitle providers are available.");
|
||||
|
||||
// Get provider
|
||||
wxString error;
|
||||
for (unsigned int i=0;i<list.Count();i++) {
|
||||
for (unsigned int i=0;i<list.size();i++) {
|
||||
try {
|
||||
size_t pos = list[i].Find(_T('/'));
|
||||
wxString name = list[i].Left(pos);
|
||||
wxString subType = list[i].Mid(pos+1);
|
||||
SubtitlesProvider *provider = GetFactory(list[i])->CreateProvider(subType);
|
||||
size_t pos = list[i].find('/');
|
||||
std::string name = list[i].substr(0, pos);
|
||||
std::string subType = pos < list[i].size() - 1 ? list[i].substr(pos + 1) : "";
|
||||
SubtitlesProvider *provider = Create(list[i], subType);
|
||||
if (provider) return provider;
|
||||
}
|
||||
catch (wxString err) { error += list[i] + _T(" factory: ") + err + _T("\n"); }
|
||||
|
@ -99,31 +71,15 @@ SubtitlesProvider* SubtitlesProviderFactoryManager::GetProvider() {
|
|||
throw error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Register providers
|
||||
///
|
||||
void SubtitlesProviderFactoryManager::RegisterProviders() {
|
||||
void SubtitlesProviderFactory::RegisterProviders() {
|
||||
#ifdef WITH_CSRI
|
||||
CSRISubtitlesProviderFactory *csri = new CSRISubtitlesProviderFactory();
|
||||
RegisterFactory(csri,_T("CSRI"),csri->GetSubTypes());
|
||||
Register<CSRISubtitlesProvider>("CSRI", false, CSRISubtitlesProvider::GetSubTypes());
|
||||
#endif
|
||||
#ifdef WITH_LIBASS
|
||||
RegisterFactory(new LibassSubtitlesProviderFactory(),_T("libass"));
|
||||
Register<LibassSubtitlesProvider>("libass");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Clear providers
|
||||
///
|
||||
void SubtitlesProviderFactoryManager::ClearProviders() {
|
||||
ClearFactories();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
template <class SubtitlesProviderFactory> std::map<wxString,SubtitlesProviderFactory*>* FactoryManager<SubtitlesProviderFactory>::factories=NULL;
|
||||
|
||||
|
||||
template<> SubtitlesProviderFactory::map *FactoryBase<SubtitlesProvider *(*)(std::string)>::classes = NULL;
|
||||
|
|
|
@ -34,12 +34,8 @@
|
|||
/// @ingroup subtitle_rendering
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#ifdef WITH_CSRI
|
||||
|
||||
#include "ass_file.h"
|
||||
|
@ -50,39 +46,29 @@
|
|||
/// @brief Constructor
|
||||
/// @param type
|
||||
///
|
||||
CSRISubtitlesProvider::CSRISubtitlesProvider(wxString type) {
|
||||
subType = type;
|
||||
instance = NULL;
|
||||
CSRISubtitlesProvider::CSRISubtitlesProvider(std::string type) : subType(type) {
|
||||
}
|
||||
|
||||
/// @brief Destructor
|
||||
///
|
||||
CSRISubtitlesProvider::~CSRISubtitlesProvider() {
|
||||
if (!tempfile.empty()) wxRemoveFile(tempfile);
|
||||
if (instance) csri_close(instance);
|
||||
instance = NULL;
|
||||
}
|
||||
|
||||
/// @brief Load subtitles
|
||||
/// @param subs
|
||||
///
|
||||
void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) {
|
||||
// Close
|
||||
if (instance) csri_close(instance);
|
||||
instance = NULL;
|
||||
|
||||
// CSRI variables
|
||||
csri_rend *cur,*renderer=NULL;
|
||||
csri_info *info;
|
||||
|
||||
// Select renderer
|
||||
bool canOpenMem = true;
|
||||
for (cur = csri_renderer_default();cur;cur=csri_renderer_next(cur)) {
|
||||
info = csri_renderer_info(cur);
|
||||
wxString name(info->name,wxConvUTF8);
|
||||
std::string name(csri_renderer_info(cur)->name);
|
||||
if (name == subType) {
|
||||
renderer = cur;
|
||||
if (name.StartsWith(_T("vsfilter"))) canOpenMem = false;
|
||||
if (name.find("vsfilter") != name.npos) canOpenMem = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +85,7 @@ void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) {
|
|||
if (canOpenMem) {
|
||||
std::vector<char> data;
|
||||
subs->SaveMemory(data,wxSTRING_ENCODING);
|
||||
instance = csri_open_mem(renderer,&data[0],data.size(),NULL);
|
||||
instance.reset(csri_open_mem(renderer,&data[0],data.size(),NULL), &csri_close);
|
||||
}
|
||||
|
||||
// Open from disk
|
||||
|
@ -110,7 +96,7 @@ void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) {
|
|||
tempfile += L".ass";
|
||||
}
|
||||
subs->Save(tempfile,false,false,wxSTRING_ENCODING);
|
||||
instance = csri_open_file(renderer,tempfile.utf8_str(),NULL);
|
||||
instance.reset(csri_open_file(renderer,tempfile.utf8_str(),NULL), &csri_close);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +107,7 @@ void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) {
|
|||
///
|
||||
void CSRISubtitlesProvider::DrawSubtitles(AegiVideoFrame &dst,double time) {
|
||||
// Check if CSRI loaded properly
|
||||
if (!instance) return;
|
||||
if (!instance.get()) return;
|
||||
|
||||
// Load data into frame
|
||||
csri_frame frame;
|
||||
|
@ -146,31 +132,19 @@ void CSRISubtitlesProvider::DrawSubtitles(AegiVideoFrame &dst,double time) {
|
|||
format.width = dst.w;
|
||||
format.height = dst.h;
|
||||
format.pixfmt = frame.pixfmt;
|
||||
int error = csri_request_fmt(instance,&format);
|
||||
int error = csri_request_fmt(instance.get(),&format);
|
||||
if (error) return;
|
||||
|
||||
// Render
|
||||
csri_render(instance,&frame,time);
|
||||
csri_render(instance.get(),&frame,time);
|
||||
}
|
||||
|
||||
/// @brief Get CSRI subtypes
|
||||
///
|
||||
wxArrayString CSRISubtitlesProviderFactory::GetSubTypes() {
|
||||
csri_info *info;
|
||||
wxArrayString final;
|
||||
std::vector<std::string> CSRISubtitlesProvider::GetSubTypes() {
|
||||
std::vector<std::string> final;
|
||||
for (csri_rend *cur = csri_renderer_default();cur;cur = csri_renderer_next(cur)) {
|
||||
// Get renderer name
|
||||
info = csri_renderer_info(cur);
|
||||
const char* buffer = info->name;
|
||||
|
||||
// wxWidgets isn't initialized, so h4x into a wxString
|
||||
int len = strlen(buffer);
|
||||
wxString str;
|
||||
str.Alloc(len+1);
|
||||
for (int i=0;i<len;i++) {
|
||||
str.Append((wxChar)buffer[i]);
|
||||
}
|
||||
final.Add(str);
|
||||
final.push_back(csri_renderer_info(cur)->name);
|
||||
}
|
||||
return final;
|
||||
}
|
||||
|
|
|
@ -36,13 +36,14 @@
|
|||
|
||||
#ifdef WITH_CSRI
|
||||
|
||||
#include "include/aegisub/subtitles_provider.h"
|
||||
#ifdef WIN32
|
||||
/// DOCME
|
||||
#define CSRIAPI
|
||||
#ifndef AGI_PRE
|
||||
#include <tr1/memory>
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#include "include/aegisub/subtitles_provider.h"
|
||||
#ifdef WIN32
|
||||
#define CSRIAPI
|
||||
#include "../../contrib/csri/include/csri/csri.h"
|
||||
#else
|
||||
#include <csri/csri.h>
|
||||
|
@ -55,32 +56,19 @@
|
|||
/// DOCME
|
||||
class CSRISubtitlesProvider : public SubtitlesProvider {
|
||||
/// DOCME
|
||||
wxString subType;
|
||||
std::string subType;
|
||||
|
||||
/// DOCME
|
||||
csri_inst *instance;
|
||||
std::tr1::shared_ptr<csri_inst> instance;
|
||||
|
||||
wxString tempfile;
|
||||
public:
|
||||
CSRISubtitlesProvider(wxString subType);
|
||||
CSRISubtitlesProvider(std::string subType);
|
||||
~CSRISubtitlesProvider();
|
||||
|
||||
void LoadSubtitles(AssFile *subs);
|
||||
void DrawSubtitles(AegiVideoFrame &dst,double time);
|
||||
};
|
||||
|
||||
/// DOCME
|
||||
/// @class CSRISubtitlesProviderFactory
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class CSRISubtitlesProviderFactory : public SubtitlesProviderFactory {
|
||||
public:
|
||||
/// @brief DOCME
|
||||
/// @param subType
|
||||
///
|
||||
SubtitlesProvider *CreateProvider(wxString subType=_T("")) { return new CSRISubtitlesProvider(subType); }
|
||||
wxArrayString GetSubTypes();
|
||||
static std::vector<std::string> GetSubTypes();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,11 +34,8 @@
|
|||
/// @ingroup subtitle_rendering
|
||||
///
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#ifdef WITH_LIBASS
|
||||
|
||||
#ifndef AGI_PRE
|
||||
|
@ -61,7 +58,6 @@ extern "C" {
|
|||
#include "video_context.h"
|
||||
|
||||
|
||||
|
||||
/// @brief Handle libass messages
|
||||
///
|
||||
static void msg_callback(int level, const char *fmt, va_list args, void *data) {
|
||||
|
@ -74,11 +70,9 @@ static void msg_callback(int level, const char *fmt, va_list args, void *data) {
|
|||
LOG_D("subtitle/provider/libass") << buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Constructor
|
||||
///
|
||||
LibassSubtitlesProvider::LibassSubtitlesProvider() {
|
||||
LibassSubtitlesProvider::LibassSubtitlesProvider(std::string) {
|
||||
// Initialize library
|
||||
static bool first = true;
|
||||
if (first) {
|
||||
|
@ -117,15 +111,11 @@ LibassSubtitlesProvider::LibassSubtitlesProvider() {
|
|||
ass_set_fonts(ass_renderer, NULL, "Sans", 1, config_path, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Destructor
|
||||
///
|
||||
LibassSubtitlesProvider::~LibassSubtitlesProvider() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Load subtitles
|
||||
/// @param subs
|
||||
///
|
||||
|
@ -140,8 +130,6 @@ void LibassSubtitlesProvider::LoadSubtitles(AssFile *subs) {
|
|||
if (!ass_track) throw _T("libass failed to load subtitles.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
#define _r(c) ((c)>>24)
|
||||
|
||||
|
@ -210,10 +198,7 @@ void LibassSubtitlesProvider::DrawSubtitles(AegiVideoFrame &frame,double time) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
ASS_Library* LibassSubtitlesProvider::ass_library;
|
||||
|
||||
|
||||
#endif // WITH_LIBASS
|
||||
|
|
|
@ -34,12 +34,9 @@
|
|||
/// @ingroup subtitle_rendering
|
||||
///
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
|
||||
#ifdef WITH_LIBASS
|
||||
|
||||
#include "subtitles_provider_manager.h"
|
||||
#include "include/aegisub/subtitles_provider.h"
|
||||
extern "C" {
|
||||
#ifdef __VISUALC__
|
||||
#include "stdint.h"
|
||||
|
@ -55,8 +52,6 @@ extern "C" {
|
|||
///
|
||||
/// DOCME
|
||||
class LibassSubtitlesProvider : public SubtitlesProvider {
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
static ASS_Library* ass_library;
|
||||
|
||||
|
@ -67,27 +62,10 @@ private:
|
|||
ASS_Track* ass_track;
|
||||
|
||||
public:
|
||||
LibassSubtitlesProvider();
|
||||
LibassSubtitlesProvider(std::string);
|
||||
~LibassSubtitlesProvider();
|
||||
|
||||
void LoadSubtitles(AssFile *subs);
|
||||
void DrawSubtitles(AegiVideoFrame &dst,double time);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class LibassSubtitlesProviderFactory
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class LibassSubtitlesProviderFactory : public SubtitlesProviderFactory {
|
||||
public:
|
||||
|
||||
/// @brief DOCME
|
||||
/// @param subType
|
||||
///
|
||||
SubtitlesProvider *CreateProvider(wxString subType=_T("")) { return new LibassSubtitlesProvider(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
// Copyright (c) 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 subtitles_provider_manager.h
|
||||
/// @brief Keep track of installed subtitle renderers
|
||||
/// @ingroup subtitle_rendering
|
||||
///
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "factory_manager.h"
|
||||
#include "include/aegisub/subtitles_provider.h"
|
||||
#include "video_frame.h"
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class SubtitlesProviderFactoryManager
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class SubtitlesProviderFactoryManager : public FactoryManager<SubtitlesProviderFactory> {
|
||||
public:
|
||||
static SubtitlesProvider *GetProvider();
|
||||
static void RegisterProviders();
|
||||
static void ClearProviders();
|
||||
static bool ProviderAvailable();
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
#include "ass_exporter.h"
|
||||
#include "ass_file.h"
|
||||
#include "compat.h"
|
||||
#include "subtitles_provider_manager.h"
|
||||
#include "include/aegisub/subtitles_provider.h"
|
||||
#include "video_provider_manager.h"
|
||||
|
||||
// Test if a line is a dialogue line which is not visible at the given time
|
||||
|
@ -152,8 +152,8 @@ void *ThreadedFrameSource::Entry() {
|
|||
|
||||
ThreadedFrameSource::ThreadedFrameSource(wxString videoFileName, wxEvtHandler *parent)
|
||||
: wxThread()
|
||||
, provider(SubtitlesProviderFactoryManager::GetProvider())
|
||||
, videoProvider(VideoProviderFactoryManager::GetProvider(videoFileName))
|
||||
, provider(SubtitlesProviderFactory::GetProvider())
|
||||
, videoProvider(VideoProviderFactory::GetProvider(videoFileName))
|
||||
, parent(parent)
|
||||
, nextTime(-1.)
|
||||
, jobReady(jobMutex)
|
||||
|
|
|
@ -59,6 +59,8 @@
|
|||
#include "ass_time.h"
|
||||
#include "audio_display.h"
|
||||
#include "compat.h"
|
||||
#include "include/aegisub/audio_player.h"
|
||||
#include "include/aegisub/audio_provider.h"
|
||||
#include "include/aegisub/video_provider.h"
|
||||
#include "keyframe.h"
|
||||
#include <libaegisub/access.h>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
//
|
||||
// Aegisub Project http://www.aegisub.org/
|
||||
//
|
||||
// $Id: video_out_gl.h 3613 2009-10-05 00:06:11Z plorkyeran $
|
||||
// $Id$
|
||||
|
||||
/// @file video_out_gl.h
|
||||
/// @brief OpenGL based video renderer
|
||||
|
|
|
@ -95,19 +95,4 @@ public:
|
|||
wxString GetWarning() const;
|
||||
wxString GetDecoderName() const { return wxString(L"Avisynth/") + decoderName; }
|
||||
};
|
||||
|
||||
/// DOCME
|
||||
/// @class AvisynthVideoProviderFactory
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class AvisynthVideoProviderFactory : public VideoProviderFactory {
|
||||
public:
|
||||
|
||||
/// @brief DOCME
|
||||
/// @param video
|
||||
///
|
||||
VideoProvider *CreateProvider(wxString video) { return new AvisynthVideoProvider(video); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -86,15 +86,4 @@ public:
|
|||
/// @return Returns true.
|
||||
bool WantsCaching() const { return true; }
|
||||
};
|
||||
|
||||
/// @class FFmpegSourceVideoProviderFactory
|
||||
/// @brief Creates a FFmpegSource video provider.
|
||||
class FFmpegSourceVideoProviderFactory : public VideoProviderFactory {
|
||||
public:
|
||||
/// @brief Creates a FFmpegSource video provider.
|
||||
/// @param video The video filename to open.
|
||||
/// @return Returns the video provider.
|
||||
VideoProvider *CreateProvider(wxString video) { return new FFmpegSourceVideoProvider(video); }
|
||||
};
|
||||
|
||||
#endif /* WITH_FFMPEGSOURCE */
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
/// @param video
|
||||
/// @return
|
||||
///
|
||||
VideoProvider *VideoProviderFactoryManager::GetProvider(wxString video) {
|
||||
VideoProvider *VideoProviderFactory::GetProvider(wxString video) {
|
||||
// First check special case of dummy video
|
||||
if (video.StartsWith(_T("?dummy:"))) {
|
||||
return new DummyVideoProvider(video.wc_str());
|
||||
|
@ -73,21 +73,23 @@ VideoProvider *VideoProviderFactoryManager::GetProvider(wxString video) {
|
|||
LOG_E("manager/video/provider/yuv4mpeg") << "Provider creation failed with reason: "<< temp.c_str() << " trying other providers";
|
||||
}
|
||||
catch (...) {
|
||||
LOG_E("manager/video/provider/yuv4mpeg") << "Provider creation failed (uknown reason) trying other providers";
|
||||
LOG_E("manager/video/provider/yuv4mpeg") << "Provider creation failed (unknown reason) trying other providers";
|
||||
}
|
||||
|
||||
// List of providers
|
||||
wxArrayString list = GetFactoryList(lagi_wxString(OPT_GET("Video/Provider")->GetString()));
|
||||
std::vector<std::string> list = GetClasses(OPT_GET("Video/Provider")->GetString());
|
||||
if (video.StartsWith("?dummy")) list.insert(list.begin(), "Dummy");
|
||||
list.insert(list.begin(), "YUV4MPEG");
|
||||
|
||||
// None available
|
||||
if (list.Count() == 0) throw _T("No video providers are available.");
|
||||
if (list.empty()) throw _T("No video providers are available.");
|
||||
|
||||
// Get provider
|
||||
wxString error;
|
||||
for (unsigned int i=0;i<list.Count();i++) {
|
||||
for (unsigned int i=0;i<list.size();i++) {
|
||||
try {
|
||||
// Create provider
|
||||
VideoProvider *provider = GetFactory(list[i])->CreateProvider(video);
|
||||
VideoProvider *provider = Create(list[i], video);
|
||||
if (provider) {
|
||||
// Cache if necessary
|
||||
if (provider->WantsCaching()) {
|
||||
|
@ -105,30 +107,18 @@ VideoProvider *VideoProviderFactoryManager::GetProvider(wxString video) {
|
|||
throw error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Register all providers
|
||||
///
|
||||
void VideoProviderFactoryManager::RegisterProviders() {
|
||||
void VideoProviderFactory::RegisterProviders() {
|
||||
#ifdef WITH_AVISYNTH
|
||||
RegisterFactory(new AvisynthVideoProviderFactory(),_T("Avisynth"));
|
||||
Register<AvisynthVideoProvider>("Avisynth");
|
||||
#endif
|
||||
#ifdef WITH_FFMPEGSOURCE
|
||||
RegisterFactory(new FFmpegSourceVideoProviderFactory(),_T("FFmpegSource"));
|
||||
Register<FFmpegSourceVideoProvider>("FFmpegSource");
|
||||
#endif
|
||||
Register<DummyVideoProvider>("Dummy", true);
|
||||
Register<YUV4MPEGVideoProvider>("YUV4MPEG", true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Clear all providers
|
||||
///
|
||||
void VideoProviderFactoryManager::ClearProviders() {
|
||||
ClearFactories();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
template <class VideoProviderFactory> std::map<wxString,VideoProviderFactory*>* FactoryManager<VideoProviderFactory>::factories=NULL;
|
||||
|
||||
|
||||
template<> VideoProviderFactory::map *FactoryBase<VideoProvider *(*)(wxString)>::classes = NULL;
|
||||
|
|
|
@ -34,30 +34,11 @@
|
|||
/// @ingroup video_input
|
||||
///
|
||||
|
||||
|
||||
|
||||
|
||||
//////////
|
||||
// Headers
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/intl.h>
|
||||
#endif
|
||||
|
||||
#include "factory_manager.h"
|
||||
#include "include/aegisub/video_provider.h"
|
||||
#include "video_frame.h"
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class VideoProviderFactoryManager
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class VideoProviderFactoryManager : public FactoryManager<VideoProviderFactory> {
|
||||
class VideoProviderFactory : public Factory1<VideoProvider, wxString> {
|
||||
public:
|
||||
static void RegisterProviders();
|
||||
static VideoProvider *GetProvider(wxString video);
|
||||
static void ClearProviders();
|
||||
static void RegisterProviders();
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue