decoder_control: add function _is_current_song()
Replaces _current_song().
This commit is contained in:
parent
784d666a8e
commit
b5fde6dfa5
@ -97,6 +97,27 @@ dc_command_async(struct decoder_control *dc, enum decoder_command cmd)
|
|||||||
decoder_unlock(dc);
|
decoder_unlock(dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
decoder_is_current_song(const struct decoder_control *dc,
|
||||||
|
const struct song *song)
|
||||||
|
{
|
||||||
|
assert(dc != NULL);
|
||||||
|
assert(song != NULL);
|
||||||
|
|
||||||
|
switch (dc->state) {
|
||||||
|
case DECODE_STATE_STOP:
|
||||||
|
case DECODE_STATE_ERROR:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case DECODE_STATE_START:
|
||||||
|
case DECODE_STATE_DECODE:
|
||||||
|
return dc->song == song;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dc_start(struct decoder_control *dc, struct song *song,
|
dc_start(struct decoder_control *dc, struct song *song,
|
||||||
unsigned start_ms, unsigned end_ms,
|
unsigned start_ms, unsigned end_ms,
|
||||||
|
@ -276,21 +276,27 @@ decoder_lock_has_failed(struct decoder_control *dc)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const struct song *
|
/**
|
||||||
decoder_current_song(const struct decoder_control *dc)
|
* Check if the specified song is currently being decoded. If the
|
||||||
|
* decoder is not running currently (or being started), then this
|
||||||
|
* function returns false in any case.
|
||||||
|
*
|
||||||
|
* Caller must lock the object.
|
||||||
|
*/
|
||||||
|
gcc_pure
|
||||||
|
bool
|
||||||
|
decoder_is_current_song(const struct decoder_control *dc,
|
||||||
|
const struct song *song);
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
static inline bool
|
||||||
|
decoder_lock_is_current_song(struct decoder_control *dc,
|
||||||
|
const struct song *song)
|
||||||
{
|
{
|
||||||
switch (dc->state) {
|
decoder_lock(dc);
|
||||||
case DECODE_STATE_STOP:
|
const bool result = decoder_is_current_song(dc, song);
|
||||||
case DECODE_STATE_ERROR:
|
decoder_unlock(dc);
|
||||||
return NULL;
|
return result;
|
||||||
|
|
||||||
case DECODE_STATE_START:
|
|
||||||
case DECODE_STATE_DECODE:
|
|
||||||
return dc->song;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(false);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,7 +458,7 @@ static bool player_seek_decoder(struct player *player)
|
|||||||
|
|
||||||
assert(pc->next_song != NULL);
|
assert(pc->next_song != NULL);
|
||||||
|
|
||||||
if (decoder_current_song(dc) != song) {
|
if (!decoder_lock_is_current_song(dc, song)) {
|
||||||
/* the decoder is already decoding the "next" song -
|
/* the decoder is already decoding the "next" song -
|
||||||
stop it and start the previous song again */
|
stop it and start the previous song again */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user