From ae7d00a57e352d207dc84c80ac6c2a24b6dfe66d Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Wed, 9 Feb 2011 02:28:43 +0000 Subject: [PATCH] Fix and de-wxify audio_manager.cpp Originally committed to SVN as r5326. --- aegisub/libmedia/Makefile | 1 + aegisub/libmedia/common/audio_manager.cpp | 41 ++++++++++++++--------- aegisub/libmedia/include/libmedia/video.h | 9 +++++ 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/aegisub/libmedia/Makefile b/aegisub/libmedia/Makefile index c61528c91..7a6bb5f70 100644 --- a/aegisub/libmedia/Makefile +++ b/aegisub/libmedia/Makefile @@ -25,6 +25,7 @@ endif SRC = \ common/video_frame.cpp \ + common/audio_manager.cpp \ audio/downmix.cpp \ audio/convert.cpp \ audio/dummy_audio.cpp \ diff --git a/aegisub/libmedia/common/audio_manager.cpp b/aegisub/libmedia/common/audio_manager.cpp index 4c230293c..dcb27275c 100644 --- a/aegisub/libmedia/common/audio_manager.cpp +++ b/aegisub/libmedia/common/audio_manager.cpp @@ -38,21 +38,24 @@ #include "config.h" #ifndef AGI_PRE -#include #endif #ifdef WITH_AVISYNTH -#include "audio_provider_avs.h" +#include "../audio/avs_audio.h" #endif -#include "audio_provider_convert.h" +#include "../audio/convert.h" #ifdef WITH_FFMPEGSOURCE -#include "audio_provider_ffmpegsource.h" +#include "../audio/ffms_audio.h" #endif -#include "audio_provider_hd.h" -#include "audio_provider_pcm.h" -#include "audio_provider_ram.h" -#include "compat.h" -#include "main.h" +#include "../cache/audio_hd.h" +#include "../cache/audio_ram.h" +#include "../audio/pcm.h" + + +//#include "compat.h" +//#include "main.h" + +namespace media { /// @brief Constructor /// @@ -105,12 +108,13 @@ void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count, /// @param cache /// @return /// -AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) { +AudioProvider *AudioProviderFactory::GetProvider(std::string filename, int cache) { AudioProvider *provider = NULL; bool found = false; std::string msg; - if (!OPT_GET("Provider/Audio/PCM/Disable")->GetBool()) { +//XXX if (!OPT_GET("Provider/Audio/PCM/Disable")->GetBool()) { + if (1) { // Try a PCM provider first try { provider = CreatePCMAudioProvider(filename); @@ -124,7 +128,9 @@ AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) { } } if (!provider) { - std::vector list = GetClasses(OPT_GET("Audio/Provider")->GetString()); +//XXX std::vector list = GetClasses(OPT_GET("Audio/Provider")->GetString()); + std::vector list = GetClasses("ffmpegsource"); + if (list.empty()) throw AudioOpenError("No audio providers are available."); for (unsigned int i=0;iNeedsCache(); @@ -156,7 +162,8 @@ AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) { provider = CreateConvertAudioProvider(provider); // Change provider to RAM/HD cache if needed - if (cache == -1) cache = OPT_GET("Audio/Cache/Type")->GetInt(); +//XXX if (cache == -1) cache = OPT_GET("Audio/Cache/Type")->GetInt(); + if (cache == -1) cache = 1; if (!cache || !needsCache) { return provider; } @@ -177,8 +184,10 @@ void AudioProviderFactory::RegisterProviders() { Register("Avisynth"); #endif #ifdef WITH_FFMPEGSOURCE - Register("FFmpegSource"); + Register("FFmpegSource"); #endif } -template<> AudioProviderFactory::map *FactoryBase::classes = NULL; +template<> AudioProviderFactory::map *FactoryBase::classes = NULL; + +} // namespace media diff --git a/aegisub/libmedia/include/libmedia/video.h b/aegisub/libmedia/include/libmedia/video.h index 8eae8c272..f5351905f 100644 --- a/aegisub/libmedia/include/libmedia/video.h +++ b/aegisub/libmedia/include/libmedia/video.h @@ -74,6 +74,14 @@ public: virtual bool WantsCaching() const { return false; } }; + +class VideoProviderFactory : public Factory1 { +public: + static VideoProvider *GetProvider(wxString video); + static void RegisterProviders(); +}; + + DEFINE_BASE_EXCEPTION_NOINNER(VideoProviderError, agi::Exception); /// File could be opened, but is not a supported format DEFINE_SIMPLE_EXCEPTION_NOINNER(VideoNotSupported, VideoProviderError, "video/open/notsupported"); @@ -83,5 +91,6 @@ DEFINE_SIMPLE_EXCEPTION_NOINNER(VideoOpenError, VideoProviderError, "video/open/ /// Error of some sort occurred while decoding a frame DEFINE_SIMPLE_EXCEPTION_NOINNER(VideoDecodeError, VideoProviderError, "video/error"); + } // namespace media