Commit 845901ab authored by Max Kellermann's avatar Max Kellermann

decoder/Internal: convert error from Error to std::exception_ptr

parent 25f73602
......@@ -77,7 +77,7 @@ decoder_initialized(Decoder &decoder,
if (!decoder.convert->Open(dc.in_audio_format,
dc.out_audio_format,
error))
decoder.error = std::move(error);
decoder.error = std::make_exception_ptr(std::move(error));
}
const ScopeLock protect(dc.mutex);
......@@ -140,7 +140,7 @@ gcc_pure
static DecoderCommand
decoder_get_virtual_command(Decoder &decoder)
{
if (decoder.error.IsDefined())
if (decoder.error)
/* an error has occurred: stop the decoder plugin */
return DecoderCommand::STOP;
......
......@@ -21,7 +21,8 @@
#define MPD_DECODER_INTERNAL_HXX
#include "ReplayGainInfo.hxx"
#include "util/Error.hxx"
#include <exception>
class PcmConvert;
struct MusicChunk;
......@@ -91,7 +92,7 @@ struct Decoder {
* An error has occurred (in DecoderAPI.cxx), and the plugin
* will be asked to stop.
*/
Error error;
std::exception_ptr error;
Decoder(DecoderControl &_dc, bool _initial_seek_pending, Tag *_tag)
:dc(_dc),
......
......@@ -211,7 +211,7 @@ decoder_run_stream_plugin(Decoder &decoder, InputStream &is,
if (!decoder_check_plugin(plugin, is, suffix))
return false;
decoder.error.Clear();
decoder.error = std::exception_ptr();
tried_r = true;
return decoder_stream_decode(plugin, decoder, is);
......@@ -300,7 +300,7 @@ TryDecoderFile(Decoder &decoder, Path path_fs, const char *suffix,
if (!plugin.SupportsSuffix(suffix))
return false;
decoder.error.Clear();
decoder.error = std::exception_ptr();
DecoderControl &dc = decoder.dc;
......@@ -398,10 +398,10 @@ decoder_run_song(DecoderControl &dc,
}
if (decoder.error.IsDefined()) {
if (decoder.error) {
/* copy the Error from struct Decoder to
DecoderControl */
throw std::move(decoder.error);
std::rethrow_exception(decoder.error);
} else if (success)
dc.state = DecoderState::STOP;
else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment