Log more stuff when creating audio providers

This commit is contained in:
Thomas Goyne 2012-12-27 08:42:10 -08:00
parent 572a58cd90
commit 9955a2c39d
2 changed files with 14 additions and 3 deletions

View File

@ -126,13 +126,16 @@ struct provider_creator {
return provider; return provider;
} }
catch (agi::FileNotFoundError const& err) { catch (agi::FileNotFoundError const& err) {
LOG_D("audio_provider") << err.GetChainedMessage();
msg += name + ": " + err.GetMessage() + " not found.\n"; msg += name + ": " + err.GetMessage() + " not found.\n";
} }
catch (agi::AudioDataNotFoundError const& err) { catch (agi::AudioDataNotFoundError const& err) {
LOG_D("audio_provider") << err.GetChainedMessage();
found_file = true; found_file = true;
msg += name + ": " + err.GetChainedMessage() + "\n"; msg += name + ": " + err.GetChainedMessage() + "\n";
} }
catch (agi::AudioOpenError const& err) { catch (agi::AudioOpenError const& err) {
LOG_D("audio_provider") << err.GetChainedMessage();
found_audio = true; found_audio = true;
found_file = true; found_file = true;
msg += name + ": " + err.GetChainedMessage() + "\n"; msg += name + ": " + err.GetChainedMessage() + "\n";

View File

@ -28,6 +28,7 @@
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
#include <libaegisub/scoped_ptr.h> #include <libaegisub/scoped_ptr.h>
#include <libaegisub/log.h>
#include <limits> #include <limits>
@ -214,21 +215,28 @@ AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider) {
// Ensure 16-bit audio with proper endianness // Ensure 16-bit audio with proper endianness
if (provider->AreSamplesFloat()) { if (provider->AreSamplesFloat()) {
LOG_D("audio_provider") << "Converting float to S16";
if (provider->GetBytesPerSample() == sizeof(float)) if (provider->GetBytesPerSample() == sizeof(float))
provider = new FloatConvertAudioProvider<float, int16_t>(provider); provider = new FloatConvertAudioProvider<float, int16_t>(provider);
else else
provider = new FloatConvertAudioProvider<double, int16_t>(provider); provider = new FloatConvertAudioProvider<double, int16_t>(provider);
} }
if (provider->GetBytesPerSample() != 2 || !provider->AreSamplesNativeEndian()) if (provider->GetBytesPerSample() != 2 || !provider->AreSamplesNativeEndian()) {
LOG_D("audio_provider") << "Converting " << provider->GetBytesPerSample() << " bytes per sample or wrong endian to S16";
provider = new BitdepthConvertAudioProvider<int16_t>(provider); provider = new BitdepthConvertAudioProvider<int16_t>(provider);
}
// We currently only support mono audio // We currently only support mono audio
if (provider->GetChannels() != 1) if (provider->GetChannels() != 1) {
LOG_D("audio_provider") << "Downmixing to mono from " << provider->GetChannels() << " channels";
provider = new DownmixAudioProvider(provider); provider = new DownmixAudioProvider(provider);
}
// Some players don't like low sample rate audio // Some players don't like low sample rate audio
while (provider->GetSampleRate() < 32000) while (provider->GetSampleRate() < 32000) {
LOG_D("audio_provider") << "Doubling sample rate";
provider = new SampleDoublingAudioProvider(provider); provider = new SampleDoublingAudioProvider(provider);
}
return provider; return provider;
} }