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, ...@@ -77,7 +77,7 @@ decoder_initialized(Decoder &decoder,
if (!decoder.convert->Open(dc.in_audio_format, if (!decoder.convert->Open(dc.in_audio_format,
dc.out_audio_format, dc.out_audio_format,
error)) error))
decoder.error = std::move(error); decoder.error = std::make_exception_ptr(std::move(error));
} }
const ScopeLock protect(dc.mutex); const ScopeLock protect(dc.mutex);
...@@ -140,7 +140,7 @@ gcc_pure ...@@ -140,7 +140,7 @@ gcc_pure
static DecoderCommand static DecoderCommand
decoder_get_virtual_command(Decoder &decoder) decoder_get_virtual_command(Decoder &decoder)
{ {
if (decoder.error.IsDefined()) if (decoder.error)
/* an error has occurred: stop the decoder plugin */ /* an error has occurred: stop the decoder plugin */
return DecoderCommand::STOP; return DecoderCommand::STOP;
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
#define MPD_DECODER_INTERNAL_HXX #define MPD_DECODER_INTERNAL_HXX
#include "ReplayGainInfo.hxx" #include "ReplayGainInfo.hxx"
#include "util/Error.hxx"
#include <exception>
class PcmConvert; class PcmConvert;
struct MusicChunk; struct MusicChunk;
...@@ -91,7 +92,7 @@ struct Decoder { ...@@ -91,7 +92,7 @@ struct Decoder {
* An error has occurred (in DecoderAPI.cxx), and the plugin * An error has occurred (in DecoderAPI.cxx), and the plugin
* will be asked to stop. * will be asked to stop.
*/ */
Error error; std::exception_ptr error;
Decoder(DecoderControl &_dc, bool _initial_seek_pending, Tag *_tag) Decoder(DecoderControl &_dc, bool _initial_seek_pending, Tag *_tag)
:dc(_dc), :dc(_dc),
......
...@@ -211,7 +211,7 @@ decoder_run_stream_plugin(Decoder &decoder, InputStream &is, ...@@ -211,7 +211,7 @@ decoder_run_stream_plugin(Decoder &decoder, InputStream &is,
if (!decoder_check_plugin(plugin, is, suffix)) if (!decoder_check_plugin(plugin, is, suffix))
return false; return false;
decoder.error.Clear(); decoder.error = std::exception_ptr();
tried_r = true; tried_r = true;
return decoder_stream_decode(plugin, decoder, is); return decoder_stream_decode(plugin, decoder, is);
...@@ -300,7 +300,7 @@ TryDecoderFile(Decoder &decoder, Path path_fs, const char *suffix, ...@@ -300,7 +300,7 @@ TryDecoderFile(Decoder &decoder, Path path_fs, const char *suffix,
if (!plugin.SupportsSuffix(suffix)) if (!plugin.SupportsSuffix(suffix))
return false; return false;
decoder.error.Clear(); decoder.error = std::exception_ptr();
DecoderControl &dc = decoder.dc; DecoderControl &dc = decoder.dc;
...@@ -398,10 +398,10 @@ decoder_run_song(DecoderControl &dc, ...@@ -398,10 +398,10 @@ decoder_run_song(DecoderControl &dc,
} }
if (decoder.error.IsDefined()) { if (decoder.error) {
/* copy the Error from struct Decoder to /* copy the Error from struct Decoder to
DecoderControl */ DecoderControl */
throw std::move(decoder.error); std::rethrow_exception(decoder.error);
} else if (success) } else if (success)
dc.state = DecoderState::STOP; dc.state = DecoderState::STOP;
else { 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