decoder/Thread: move decoder_command_finished_locked() to DecoderControl
This commit is contained in:
		| @@ -350,6 +350,20 @@ private: | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| public: | 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. | 	 * Start the decoder. | ||||||
| 	 * | 	 * | ||||||
|   | |||||||
| @@ -44,22 +44,6 @@ | |||||||
|  |  | ||||||
| static constexpr Domain decoder_thread_domain("decoder_thread"); | 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 |  * Opens the input stream with InputStream::Open(), and waits until | ||||||
|  * the stream gets ready.  If a decoder STOP command is received |  * the stream gets ready.  If a decoder STOP command is received | ||||||
| @@ -382,8 +366,7 @@ decoder_run_song(DecoderControl &dc, | |||||||
| 			song.IsFile() ? new Tag(song.GetTag()) : nullptr); | 			song.IsFile() ? new Tag(song.GetTag()) : nullptr); | ||||||
|  |  | ||||||
| 	dc.state = DecoderState::START; | 	dc.state = DecoderState::START; | ||||||
|  | 	dc.CommandFinishedLocked(); | ||||||
| 	decoder_command_finished_locked(dc); |  | ||||||
|  |  | ||||||
| 	bool success; | 	bool success; | ||||||
| 	{ | 	{ | ||||||
| @@ -441,7 +424,7 @@ decoder_run(DecoderControl &dc) | |||||||
| 		path_buffer = AllocatedPath::FromUTF8(uri_utf8, dc.error); | 		path_buffer = AllocatedPath::FromUTF8(uri_utf8, dc.error); | ||||||
| 		if (path_buffer.IsNull()) { | 		if (path_buffer.IsNull()) { | ||||||
| 			dc.state = DecoderState::ERROR; | 			dc.state = DecoderState::ERROR; | ||||||
| 			decoder_command_finished_locked(dc); | 			dc.CommandFinishedLocked(); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -487,7 +470,7 @@ decoder_task(void *arg) | |||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		case DecoderCommand::STOP: | 		case DecoderCommand::STOP: | ||||||
| 			decoder_command_finished_locked(dc); | 			dc.CommandFinishedLocked(); | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		case DecoderCommand::NONE: | 		case DecoderCommand::NONE: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann