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

@@ -19,9 +19,8 @@
#include "config.h"
#include "FlacPcm.hxx"
#include "FlacDomain.hxx"
#include "CheckAudioFormat.hxx"
#include "util/Error.hxx"
#include "util/RuntimeError.hxx"
#include "util/ConstBuffer.hxx"
#include <assert.h>
@@ -47,19 +46,16 @@ flac_sample_format(unsigned bits_per_sample)
}
}
bool
void
FlacPcmImport::Open(unsigned sample_rate, unsigned bits_per_sample,
unsigned channels, Error &error)
unsigned channels)
{
auto sample_format = flac_sample_format(bits_per_sample);
if (sample_format == SampleFormat::UNDEFINED) {
error.Format(flac_domain, "Unsupported FLAC bit depth: %u",
bits_per_sample);
return false;
}
if (sample_format == SampleFormat::UNDEFINED)
throw FormatRuntimeError("Unsupported FLAC bit depth: %u",
bits_per_sample);
audio_format = CheckAudioFormat(sample_rate, sample_format, channels);
return true;
}
template<typename T>