mirror of https://github.com/odrling/Aegisub
Fix and de-wxify audio_manager.cpp
Originally committed to SVN as r5326.
This commit is contained in:
parent
185721837b
commit
ae7d00a57e
|
@ -25,6 +25,7 @@ endif
|
||||||
|
|
||||||
SRC = \
|
SRC = \
|
||||||
common/video_frame.cpp \
|
common/video_frame.cpp \
|
||||||
|
common/audio_manager.cpp \
|
||||||
audio/downmix.cpp \
|
audio/downmix.cpp \
|
||||||
audio/convert.cpp \
|
audio/convert.cpp \
|
||||||
audio/dummy_audio.cpp \
|
audio/dummy_audio.cpp \
|
||||||
|
|
|
@ -38,21 +38,24 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
#include <wx/thread.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_AVISYNTH
|
#ifdef WITH_AVISYNTH
|
||||||
#include "audio_provider_avs.h"
|
#include "../audio/avs_audio.h"
|
||||||
#endif
|
#endif
|
||||||
#include "audio_provider_convert.h"
|
#include "../audio/convert.h"
|
||||||
#ifdef WITH_FFMPEGSOURCE
|
#ifdef WITH_FFMPEGSOURCE
|
||||||
#include "audio_provider_ffmpegsource.h"
|
#include "../audio/ffms_audio.h"
|
||||||
#endif
|
#endif
|
||||||
#include "audio_provider_hd.h"
|
#include "../cache/audio_hd.h"
|
||||||
#include "audio_provider_pcm.h"
|
#include "../cache/audio_ram.h"
|
||||||
#include "audio_provider_ram.h"
|
#include "../audio/pcm.h"
|
||||||
#include "compat.h"
|
|
||||||
#include "main.h"
|
|
||||||
|
//#include "compat.h"
|
||||||
|
//#include "main.h"
|
||||||
|
|
||||||
|
namespace media {
|
||||||
|
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
///
|
///
|
||||||
|
@ -105,12 +108,13 @@ void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count,
|
||||||
/// @param cache
|
/// @param cache
|
||||||
/// @return
|
/// @return
|
||||||
///
|
///
|
||||||
AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) {
|
AudioProvider *AudioProviderFactory::GetProvider(std::string filename, int cache) {
|
||||||
AudioProvider *provider = NULL;
|
AudioProvider *provider = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
std::string msg;
|
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 a PCM provider first
|
||||||
try {
|
try {
|
||||||
provider = CreatePCMAudioProvider(filename);
|
provider = CreatePCMAudioProvider(filename);
|
||||||
|
@ -124,7 +128,9 @@ AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
std::vector<std::string> list = GetClasses(OPT_GET("Audio/Provider")->GetString());
|
//XXX std::vector<std::string> list = GetClasses(OPT_GET("Audio/Provider")->GetString());
|
||||||
|
std::vector<std::string> list = GetClasses("ffmpegsource");
|
||||||
|
|
||||||
if (list.empty()) throw AudioOpenError("No audio providers are available.");
|
if (list.empty()) throw AudioOpenError("No audio providers are available.");
|
||||||
|
|
||||||
for (unsigned int i=0;i<list.size();i++) {
|
for (unsigned int i=0;i<list.size();i++) {
|
||||||
|
@ -146,7 +152,7 @@ AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) {
|
||||||
throw AudioOpenError(msg);
|
throw AudioOpenError(msg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw agi::FileNotFoundError(STD_STR(filename));
|
throw agi::FileNotFoundError(filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool needsCache = provider->NeedsCache();
|
bool needsCache = provider->NeedsCache();
|
||||||
|
@ -156,7 +162,8 @@ AudioProvider *AudioProviderFactory::GetProvider(wxString filename, int cache) {
|
||||||
provider = CreateConvertAudioProvider(provider);
|
provider = CreateConvertAudioProvider(provider);
|
||||||
|
|
||||||
// Change provider to RAM/HD cache if needed
|
// 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) {
|
if (!cache || !needsCache) {
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
@ -177,8 +184,10 @@ void AudioProviderFactory::RegisterProviders() {
|
||||||
Register<AvisynthAudioProvider>("Avisynth");
|
Register<AvisynthAudioProvider>("Avisynth");
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_FFMPEGSOURCE
|
#ifdef WITH_FFMPEGSOURCE
|
||||||
Register<FFmpegSourceAudioProvider>("FFmpegSource");
|
Register<ffms::FFmpegSourceAudioProvider>("FFmpegSource");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> AudioProviderFactory::map *FactoryBase<AudioProvider *(*)(wxString)>::classes = NULL;
|
template<> AudioProviderFactory::map *FactoryBase<AudioProvider *(*)(std::string)>::classes = NULL;
|
||||||
|
|
||||||
|
} // namespace media
|
||||||
|
|
|
@ -74,6 +74,14 @@ public:
|
||||||
virtual bool WantsCaching() const { return false; }
|
virtual bool WantsCaching() const { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class VideoProviderFactory : public Factory1<VideoProvider, wxString> {
|
||||||
|
public:
|
||||||
|
static VideoProvider *GetProvider(wxString video);
|
||||||
|
static void RegisterProviders();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
DEFINE_BASE_EXCEPTION_NOINNER(VideoProviderError, agi::Exception);
|
DEFINE_BASE_EXCEPTION_NOINNER(VideoProviderError, agi::Exception);
|
||||||
/// File could be opened, but is not a supported format
|
/// File could be opened, but is not a supported format
|
||||||
DEFINE_SIMPLE_EXCEPTION_NOINNER(VideoNotSupported, VideoProviderError, "video/open/notsupported");
|
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
|
/// Error of some sort occurred while decoding a frame
|
||||||
DEFINE_SIMPLE_EXCEPTION_NOINNER(VideoDecodeError, VideoProviderError, "video/error");
|
DEFINE_SIMPLE_EXCEPTION_NOINNER(VideoDecodeError, VideoProviderError, "video/error");
|
||||||
|
|
||||||
|
|
||||||
} // namespace media
|
} // namespace media
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue