pcm/PcmConvert: eliminate Open() and Close()

Let the constructor and destructor do this.  This means that all users
have to be converted to allocate PcmConvert dynamically.
This commit is contained in:
Max Kellermann
2019-04-04 20:55:39 +02:00
parent 00b04468dc
commit e78d825059
9 changed files with 53 additions and 99 deletions

@@ -37,15 +37,16 @@
#include <string.h>
#include <math.h>
DecoderBridge::DecoderBridge(DecoderControl &_dc, bool _initial_seek_pending,
std::unique_ptr<Tag> _tag) noexcept
:dc(_dc),
initial_seek_pending(_initial_seek_pending),
song_tag(std::move(_tag)) {}
DecoderBridge::~DecoderBridge()
{
/* caller must flush the chunk */
assert(current_chunk == nullptr);
if (convert != nullptr) {
convert->Close();
delete convert;
}
}
bool
@@ -255,11 +256,9 @@ DecoderBridge::Ready(const AudioFormat audio_format,
FormatDebug(decoder_domain, "converting to %s",
ToString(dc.out_audio_format).c_str());
convert = new PcmConvert();
try {
convert->Open(dc.in_audio_format,
dc.out_audio_format);
convert = std::make_unique<PcmConvert>(dc.in_audio_format,
dc.out_audio_format);
} catch (...) {
error = std::current_exception();
}