diff options
author | Max Kellermann <max@duempel.org> | 2015-12-31 13:06:31 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-12-31 13:06:31 +0100 |
commit | 650799397291b6f5e4d892e33d33ed461caa8f87 (patch) | |
tree | 1c8a8c2d15d8a331234a298a6bce673c3c2e3bd0 | |
parent | f081696f620b6e2f2c18056412c7bf2c2832d401 (diff) |
decoder/Thread: move decoder_command_finished_locked() to DecoderControl
-rw-r--r-- | src/decoder/DecoderControl.hxx | 14 | ||||
-rw-r--r-- | src/decoder/DecoderThread.cxx | 23 |
2 files changed, 17 insertions, 20 deletions
diff --git a/src/decoder/DecoderControl.hxx b/src/decoder/DecoderControl.hxx index 4147f5acc..35bd6828e 100644 --- a/src/decoder/DecoderControl.hxx +++ b/src/decoder/DecoderControl.hxx @@ -351,6 +351,20 @@ private: public: /** + * Marks the current command as "finished" and notifies the + * client (= player thread). + * + * To be called from the decoder thread. Caller must lock the + * mutex. + */ + void CommandFinishedLocked() { + assert(command != DecoderCommand::NONE); + + command = DecoderCommand::NONE; + client_cond.signal(); + } + + /** * Start the decoder. * * @param song the song to be decoded; the given instance will be diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx index 6e48ab3d2..67e785d4e 100644 --- a/src/decoder/DecoderThread.cxx +++ b/src/decoder/DecoderThread.cxx @@ -45,22 +45,6 @@ static constexpr Domain decoder_thread_domain("decoder_thread"); /** - * Marks the current decoder command as "finished" and notifies the - * player thread. - * - * @param dc the #DecoderControl object; must be locked - */ -static void -decoder_command_finished_locked(DecoderControl &dc) -{ - assert(dc.command != DecoderCommand::NONE); - - dc.command = DecoderCommand::NONE; - - dc.client_cond.signal(); -} - -/** * Opens the input stream with InputStream::Open(), and waits until * the stream gets ready. If a decoder STOP command is received * during that, it cancels the operation (but does not close the @@ -382,8 +366,7 @@ decoder_run_song(DecoderControl &dc, song.IsFile() ? new Tag(song.GetTag()) : nullptr); dc.state = DecoderState::START; - - decoder_command_finished_locked(dc); + dc.CommandFinishedLocked(); bool success; { @@ -441,7 +424,7 @@ decoder_run(DecoderControl &dc) path_buffer = AllocatedPath::FromUTF8(uri_utf8, dc.error); if (path_buffer.IsNull()) { dc.state = DecoderState::ERROR; - decoder_command_finished_locked(dc); + dc.CommandFinishedLocked(); return; } @@ -487,7 +470,7 @@ decoder_task(void *arg) break; case DecoderCommand::STOP: - decoder_command_finished_locked(dc); + dc.CommandFinishedLocked(); break; case DecoderCommand::NONE: |