decoder/flac: throw exception on FLAC__stream_decoder_new() failure

This commit is contained in:
Max Kellermann 2016-07-10 21:43:23 +02:00
parent 74740ca50b
commit 3b031c6ba5
2 changed files with 5 additions and 7 deletions

View File

@ -120,12 +120,6 @@ static FlacStreamDecoder
flac_decoder_new(void)
{
FlacStreamDecoder sd;
if (!sd) {
LogError(flac_domain,
"FLAC__stream_decoder_new() failed");
return sd;
}
if(!FLAC__stream_decoder_set_metadata_respond(sd.get(), FLAC__METADATA_TYPE_VORBIS_COMMENT))
LogDebug(flac_domain,
"FLAC__stream_decoder_set_metadata_respond() has failed");

View File

@ -25,6 +25,7 @@
#include <FLAC/stream_decoder.h>
#include <utility>
#include <stdexcept>
#include <assert.h>
@ -36,7 +37,10 @@ class FlacStreamDecoder {
public:
FlacStreamDecoder()
:decoder(FLAC__stream_decoder_new()) {}
:decoder(FLAC__stream_decoder_new()) {
if (decoder == nullptr)
throw std::runtime_error("FLAC__stream_decoder_new() failed");
}
FlacStreamDecoder(FlacStreamDecoder &&src)
:decoder(src.decoder) {