decoder/Bridge: make many attributes private
This commit is contained in:
parent
6be3c99876
commit
a19eee78c6
@ -40,6 +40,7 @@ class DecoderBridge final : public DecoderClient {
|
|||||||
public:
|
public:
|
||||||
DecoderControl &dc;
|
DecoderControl &dc;
|
||||||
|
|
||||||
|
private:
|
||||||
/**
|
/**
|
||||||
* For converting input data to the configured audio format.
|
* For converting input data to the configured audio format.
|
||||||
* nullptr means no conversion necessary.
|
* nullptr means no conversion necessary.
|
||||||
@ -83,12 +84,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::unique_ptr<Tag> song_tag;
|
std::unique_ptr<Tag> song_tag;
|
||||||
|
|
||||||
|
public:
|
||||||
/** the last tag received from the stream */
|
/** the last tag received from the stream */
|
||||||
std::unique_ptr<Tag> stream_tag;
|
std::unique_ptr<Tag> stream_tag;
|
||||||
|
|
||||||
/** the last tag received from the decoder plugin */
|
/** the last tag received from the decoder plugin */
|
||||||
std::unique_ptr<Tag> decoder_tag;
|
std::unique_ptr<Tag> decoder_tag;
|
||||||
|
|
||||||
|
private:
|
||||||
/** the chunk currently being written to */
|
/** the chunk currently being written to */
|
||||||
MusicChunkPtr current_chunk;
|
MusicChunkPtr current_chunk;
|
||||||
|
|
||||||
@ -106,11 +109,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::exception_ptr error;
|
std::exception_ptr error;
|
||||||
|
|
||||||
|
public:
|
||||||
DecoderBridge(DecoderControl &_dc, bool _initial_seek_pending,
|
DecoderBridge(DecoderControl &_dc, bool _initial_seek_pending,
|
||||||
std::unique_ptr<Tag> _tag) noexcept;
|
std::unique_ptr<Tag> _tag) noexcept;
|
||||||
|
|
||||||
~DecoderBridge() noexcept;
|
~DecoderBridge() noexcept;
|
||||||
|
|
||||||
|
void Reset() noexcept {
|
||||||
|
error = {};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be read operation be cancelled? That is the case when the
|
* Should be read operation be cancelled? That is the case when the
|
||||||
* player thread has sent a command such as "STOP".
|
* player thread has sent a command such as "STOP".
|
||||||
@ -135,6 +143,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
void FlushChunk() noexcept;
|
void FlushChunk() noexcept;
|
||||||
|
|
||||||
|
void CheckFlushChunk() {
|
||||||
|
if (current_chunk != nullptr)
|
||||||
|
FlushChunk();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckRethrowError() {
|
||||||
|
if (error)
|
||||||
|
std::rethrow_exception(error);
|
||||||
|
}
|
||||||
|
|
||||||
/* virtual methods from DecoderClient */
|
/* virtual methods from DecoderClient */
|
||||||
void Ready(AudioFormat audio_format,
|
void Ready(AudioFormat audio_format,
|
||||||
bool seekable, SignedSongTime duration) override;
|
bool seekable, SignedSongTime duration) override;
|
||||||
|
@ -210,7 +210,7 @@ decoder_run_stream_plugin(DecoderBridge &bridge, InputStream &is,
|
|||||||
if (!decoder_check_plugin(plugin, is, suffix))
|
if (!decoder_check_plugin(plugin, is, suffix))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bridge.error = std::exception_ptr();
|
bridge.Reset();
|
||||||
|
|
||||||
tried_r = true;
|
tried_r = true;
|
||||||
return decoder_stream_decode(plugin, bridge, is);
|
return decoder_stream_decode(plugin, bridge, is);
|
||||||
@ -316,7 +316,7 @@ TryDecoderFile(DecoderBridge &bridge, Path path_fs, const char *suffix,
|
|||||||
if (!plugin.SupportsSuffix(suffix))
|
if (!plugin.SupportsSuffix(suffix))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bridge.error = std::exception_ptr();
|
bridge.Reset();
|
||||||
|
|
||||||
DecoderControl &dc = bridge.dc;
|
DecoderControl &dc = bridge.dc;
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ TryContainerDecoder(DecoderBridge &bridge, Path path_fs, const char *suffix,
|
|||||||
!plugin.SupportsSuffix(suffix))
|
!plugin.SupportsSuffix(suffix))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bridge.error = nullptr;
|
bridge.Reset();
|
||||||
|
|
||||||
DecoderControl &dc = bridge.dc;
|
DecoderControl &dc = bridge.dc;
|
||||||
const std::lock_guard<Mutex> protect(dc.mutex);
|
const std::lock_guard<Mutex> protect(dc.mutex);
|
||||||
@ -472,19 +472,16 @@ decoder_run_song(DecoderControl &dc,
|
|||||||
|
|
||||||
AtScopeExit(&bridge) {
|
AtScopeExit(&bridge) {
|
||||||
/* flush the last chunk */
|
/* flush the last chunk */
|
||||||
if (bridge.current_chunk != nullptr)
|
bridge.CheckFlushChunk();
|
||||||
bridge.FlushChunk();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
success = DecoderUnlockedRunUri(bridge, uri, path_fs);
|
success = DecoderUnlockedRunUri(bridge, uri, path_fs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bridge.error) {
|
bridge.CheckRethrowError();
|
||||||
/* copy the Error from struct Decoder to
|
|
||||||
DecoderControl */
|
if (success)
|
||||||
std::rethrow_exception(bridge.error);
|
|
||||||
} else if (success)
|
|
||||||
dc.state = DecoderState::STOP;
|
dc.state = DecoderState::STOP;
|
||||||
else {
|
else {
|
||||||
const char *error_uri = song.GetURI();
|
const char *error_uri = song.GetURI();
|
||||||
|
Loading…
Reference in New Issue
Block a user