Originally committed to SVN as r1945.

This commit is contained in:
Rodrigo Braz Monteiro 2008-03-07 00:47:57 +00:00
parent e65fdf1fcf
commit 6bdee2a765
11 changed files with 147 additions and 31 deletions

View File

@ -231,6 +231,7 @@ aegisub_SOURCES = \
mkv_wrap.cpp \
mythes.cxx \
options.cpp \
plugin_manager.cpp \
scintilla_text_ctrl.cpp \
spellchecker.cpp \
spline.cpp \

View File

@ -127,12 +127,6 @@ void AudioPlayer::OnStopAudio(wxCommandEvent &event) {
//////////////
// Get player
AudioPlayer* AudioPlayerFactory::GetAudioPlayer() {
// Register factories
// HACK: fix me
static bool init = false;
if (!init) RegisterFactories();
init = true;
// List of providers
wxArrayString list = GetFactoryList(Options.AsText(_T("Audio player")));
@ -158,7 +152,7 @@ AudioPlayer* AudioPlayerFactory::GetAudioPlayer() {
//////////////////////////
// Register all factories
void AudioPlayerFactory::RegisterFactories() {
void AudioPlayerFactory::RegisterProviders() {
#ifdef WITH_ALSA
new AlsaPlayerFactory();
#endif

View File

@ -104,7 +104,7 @@ protected:
public:
virtual ~AudioPlayerFactory() {}
static AudioPlayer *GetAudioPlayer();
static void RegisterFactories();
static void RegisterProviders();
};

View File

@ -192,12 +192,6 @@ void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count,
////////////////
// Get provider
AudioProvider *AudioProviderFactory::GetAudioProvider(wxString filename, int cache) {
// Initialize providers
// HACK: fixme
static bool init = false;
if (!init) RegisterProviders();
init = true;
// Prepare provider
AudioProvider *provider = NULL;

View File

@ -65,6 +65,7 @@
#include "auto4_base.h"
#endif
#include "version.h"
#include "plugin_manager.h"
///////////////////
@ -156,11 +157,9 @@ bool AegisubApp::OnInit() {
locale.Init(wxLANGUAGE_DEFAULT);
#endif
// Set association
#ifndef _DEBUG
StartupLog(_T("Install file type associations"));
RegistryAssociate();
#endif
// Load plugins
plugins = new PluginManager();
plugins->RegisterBuiltInPlugins();
// Load Automation scripts
#ifdef WITH_AUTOMATION
@ -172,6 +171,12 @@ bool AegisubApp::OnInit() {
StartupLog(_T("Prepare export filters"));
AssExportFilterChain::PrepareFilters();
// Set association
#ifndef _DEBUG
StartupLog(_T("Install file type associations"));
RegistryAssociate();
#endif
// Get parameter subs
StartupLog(_T("Parse command line"));
wxArrayString subs;
@ -205,6 +210,7 @@ bool AegisubApp::OnInit() {
int AegisubApp::OnExit() {
SubtitleFormat::DestroyFormats();
VideoContext::Clear();
delete plugins;
Options.Clear();
#ifdef WITH_AUTOMATION
delete global_scripts;

View File

@ -51,6 +51,7 @@
//////////////
// Prototypes
class FrameMain;
class PluginManager;
namespace Automation4 { class AutoloadScriptManager; }
@ -58,6 +59,8 @@ namespace Automation4 { class AutoloadScriptManager; }
// Application class definition
class AegisubApp: public wxApp {
private:
PluginManager *plugins;
void OnMouseWheel(wxMouseEvent &event);
void OnKey(wxKeyEvent &key);

View File

@ -0,0 +1,71 @@
// Copyright (c) 2008, 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
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
///////////
// Headers
#include "plugin_manager.h"
#include "video_provider.h"
#include "audio_provider.h"
#include "audio_player.h"
#include "subtitles_provider.h"
///////////////
// Constructor
PluginManager::PluginManager() {
init = false;
}
//////////////
// Destructor
PluginManager::~PluginManager() {
}
//////////////////////////////////
// Registers all built-in plugins
void PluginManager::RegisterBuiltInPlugins() {
if (!init) {
VideoProviderFactory::RegisterProviders();
AudioProviderFactory::RegisterProviders();
AudioPlayerFactory::RegisterProviders();
SubtitlesProviderFactory::RegisterProviders();
}
// Done
init = true;
}

51
aegisub/plugin_manager.h Normal file
View File

@ -0,0 +1,51 @@
// Copyright (c) 2008, 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
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
#pragma once
////////////////////////
// Plugin manager class
class PluginManager {
private:
bool init;
public:
PluginManager();
~PluginManager();
void RegisterBuiltInPlugins();
};

View File

@ -66,12 +66,6 @@ bool SubtitlesProviderFactory::ProviderAvailable() {
////////////////
// Get provider
SubtitlesProvider* SubtitlesProviderFactory::GetProvider() {
// Register them
// HACK: fix me
static bool init = false;
if (!init) RegisterProviders();
init = true;
// List of providers
wxArrayString list = GetFactoryList(Options.AsText(_T("Subtitles provider")));

View File

@ -61,12 +61,6 @@ VideoProvider *VideoProviderFactory::GetProvider(wxString video,double fps) {
return new DummyVideoProvider(video, fps);
}
// Register the first time
// HACK: move this into program initialization later
static bool init = false;
if (!init) RegisterProviders();
init = true;
// List of providers
wxArrayString list = GetFactoryList(Options.AsText(_T("Video provider")));

View File

@ -1444,6 +1444,14 @@
RelativePath="..\..\aegisub\options.h"
>
</File>
<File
RelativePath="..\..\aegisub\plugin_manager.cpp"
>
</File>
<File
RelativePath="..\..\aegisub\plugin_manager.h"
>
</File>
<File
RelativePath="..\..\aegisub\setup.cpp"
>