Commit 4ee147ea authored by Max Kellermann's avatar Max Kellermann

DecoderAPI: stop decoder on MPD error

This commit adds the basic infrastructure for reporting bugs from DecoderAPI.cxx via DecoderThread.cxx to DecoderControl.
parent f1ca61d7
...@@ -134,6 +134,10 @@ gcc_pure ...@@ -134,6 +134,10 @@ gcc_pure
static DecoderCommand static DecoderCommand
decoder_get_virtual_command(Decoder &decoder) decoder_get_virtual_command(Decoder &decoder)
{ {
if (decoder.error.IsDefined())
/* an error has occurred: stop the decoder plugin */
return DecoderCommand::STOP;
const DecoderControl &dc = decoder.dc; const DecoderControl &dc = decoder.dc;
assert(dc.pipe != nullptr); assert(dc.pipe != nullptr);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "DecoderCommand.hxx" #include "DecoderCommand.hxx"
#include "ReplayGainInfo.hxx" #include "ReplayGainInfo.hxx"
#include "util/Error.hxx"
class PcmConvert; class PcmConvert;
struct DecoderControl; struct DecoderControl;
...@@ -87,6 +88,12 @@ struct Decoder { ...@@ -87,6 +88,12 @@ struct Decoder {
*/ */
unsigned replay_gain_serial; unsigned replay_gain_serial;
/**
* An error has occurred (in DecoderAPI.cxx), and the plugin
* will be asked to stop.
*/
Error error;
Decoder(DecoderControl &_dc, bool _initial_seek_pending, Tag *_tag) Decoder(DecoderControl &_dc, bool _initial_seek_pending, Tag *_tag)
:dc(_dc), :dc(_dc),
convert(nullptr), convert(nullptr),
......
...@@ -360,7 +360,12 @@ decoder_run_song(DecoderControl &dc, ...@@ -360,7 +360,12 @@ decoder_run_song(DecoderControl &dc,
dc.Lock(); dc.Lock();
if (ret) if (decoder.error.IsDefined()) {
/* copy the Error from sruct Decoder to
DecoderControl */
dc.state = DecoderState::ERROR;
dc.error = std::move(decoder.error);
} else if (ret)
dc.state = DecoderState::STOP; dc.state = DecoderState::STOP;
else { else {
dc.state = DecoderState::ERROR; dc.state = DecoderState::ERROR;
......
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