diff options
author | Max Kellermann <max@duempel.org> | 2013-09-27 09:18:03 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-09-27 09:18:03 +0200 |
commit | ef663810a2128eb26e701f4962f6683e2c28c052 (patch) | |
tree | 8f2b54e8fc7c283161f45b3eb41178bf31499088 /src/DecoderControl.hxx | |
parent | ada67a6a4ff53bef4d874eafea83272eac8e18f1 (diff) | |
download | mpd-ef663810a2128eb26e701f4962f6683e2c28c052.tar.gz mpd-ef663810a2128eb26e701f4962f6683e2c28c052.tar.xz mpd-ef663810a2128eb26e701f4962f6683e2c28c052.zip |
DecoderControl: convert functions to methods
Diffstat (limited to 'src/DecoderControl.hxx')
-rw-r--r-- | src/DecoderControl.hxx | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/DecoderControl.hxx b/src/DecoderControl.hxx index 00fddecc6..b9c58dcf2 100644 --- a/src/DecoderControl.hxx +++ b/src/DecoderControl.hxx @@ -278,6 +278,53 @@ struct decoder_control { return result; } +private: + /** + * Wait for the command to be finished by the decoder thread. + * + * To be called from the client thread. Caller must lock the + * object. + */ + void WaitCommandLocked() { + while (command != DECODE_COMMAND_NONE) + WaitForDecoder(); + } + + /** + * Send a command to the decoder thread and synchronously wait + * for it to finish. + * + * To be called from the client thread. Caller must lock the + * object. + */ + void SynchronousCommandLocked(decoder_command cmd) { + command = cmd; + Signal(); + WaitCommandLocked(); + } + + /** + * Send a command to the decoder thread and synchronously wait + * for it to finish. + * + * To be called from the client thread. This method locks the + * object. + */ + void LockSynchronousCommand(decoder_command cmd) { + Lock(); + ClearError(); + SynchronousCommandLocked(cmd); + Unlock(); + } + + void LockAsynchronousCommand(decoder_command cmd) { + Lock(); + command = cmd; + Signal(); + Unlock(); + } + +public: /** * Start the decoder. * |