decoder/flac: migrate from class Error to C++ exceptions

This commit is contained in:
Max Kellermann
2016-11-10 12:19:33 +01:00
parent 42a696873b
commit 4e16ea0f0a
4 changed files with 18 additions and 19 deletions

View File

@@ -24,10 +24,11 @@
#include "config.h"
#include "FlacCommon.hxx"
#include "FlacMetadata.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "Log.hxx"
#include <stdexcept>
bool
FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample,
unsigned channels, FLAC__uint64 total_frames)
@@ -35,10 +36,11 @@ FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample,
assert(!initialized);
assert(!unsupported);
::Error error;
if (!pcm_import.Open(sample_rate, bits_per_sample,
channels, error)) {
LogError(error);
try {
pcm_import.Open(sample_rate, bits_per_sample,
channels);
} catch (const std::runtime_error &e) {
LogError(e);
unsupported = true;
return false;
}