decoder/API: add class StopDecoder
This commit is contained in:
@@ -46,6 +46,13 @@
|
|||||||
|
|
||||||
class Error;
|
class Error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throw an instance of this class to stop decoding the current song
|
||||||
|
* (successfully). It can be used to jump out of all of a decoder's
|
||||||
|
* stack frames.
|
||||||
|
*/
|
||||||
|
class StopDecoder {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify the player thread that it has finished initialization and
|
* Notify the player thread that it has finished initialization and
|
||||||
* that it has read the song's meta data.
|
* that it has read the song's meta data.
|
||||||
|
@@ -356,6 +356,8 @@ try {
|
|||||||
return !path_fs.IsNull()
|
return !path_fs.IsNull()
|
||||||
? decoder_run_file(decoder, real_uri, path_fs)
|
? decoder_run_file(decoder, real_uri, path_fs)
|
||||||
: decoder_run_stream(decoder, real_uri);
|
: decoder_run_stream(decoder, real_uri);
|
||||||
|
} catch (StopDecoder) {
|
||||||
|
return true;
|
||||||
} catch (const std::runtime_error &e) {
|
} catch (const std::runtime_error &e) {
|
||||||
/* copy the exception to decoder.error */
|
/* copy the exception to decoder.error */
|
||||||
|
|
||||||
|
@@ -310,7 +310,7 @@ MPDOpusDecoder::HandleEOS()
|
|||||||
return decoder_get_command(decoder);
|
return decoder_get_command(decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DecoderCommand::STOP;
|
throw StopDecoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DecoderCommand
|
inline DecoderCommand
|
||||||
|
Reference in New Issue
Block a user