hide DecoderControl accesses in inline functions

Unfortunately, we have to pass the DecoderControl pointer to these
inline functions, because the global variable "dc" may not be
available here.  This will be fixed later.
This commit is contained in:
Max Kellermann 2008-08-26 08:29:35 +02:00
parent a1ce999978
commit 70904adf18
2 changed files with 27 additions and 10 deletions

View File

@ -61,6 +61,27 @@ typedef struct _DecoderControl {
void decoderInit(void);
static inline int decoder_is_idle(DecoderControl *dc)
{
return dc->state == DECODE_STATE_STOP &&
dc->command != DECODE_COMMAND_START;
}
static inline int decoder_is_starting(DecoderControl *dc)
{
return dc->command == DECODE_COMMAND_START ||
dc->state == DECODE_STATE_START;
}
static inline Song *decoder_current_song(DecoderControl *dc)
{
if (dc->state == DECODE_STATE_STOP ||
dc->error != DECODE_ERROR_NOERROR)
return NULL;
return dc->current_song;
}
void dc_command_wait(Notify *notify);
void dc_start(Notify *notify, Song *song);

View File

@ -65,9 +65,7 @@ static int decodeSeek(int *decodeWaitedOn, int *next)
int ret = -1;
double where;
if (dc.state == DECODE_STATE_STOP ||
dc.error != DECODE_ERROR_NOERROR ||
dc.current_song != pc.next_song) {
if (decoder_current_song(&dc) != pc.next_song) {
dc_stop(&pc.notify);
*next = -1;
ob_clear();
@ -224,7 +222,7 @@ static void decodeParent(void)
pc.error = PLAYER_ERROR_FILE;
break;
}
else if (dc.state != DECODE_STATE_START) {
else if (!decoder_is_starting(&dc)) {
/* the decoder is ready and ok */
decodeWaitedOn = 0;
if(openAudioDevice(&(ob.audioFormat))<0) {
@ -256,7 +254,7 @@ static void decodeParent(void)
}
}
if (dc.state == DECODE_STATE_STOP &&
if (decoder_is_idle(&dc) &&
pc.queueState == PLAYER_QUEUE_FULL &&
pc.queueLockState == PLAYER_QUEUE_UNLOCKED) {
/* the decoder has finished the current song;
@ -267,8 +265,7 @@ static void decodeParent(void)
wakeup_main_task();
}
if (next >= 0 && do_xfade == XFADE_UNKNOWN &&
dc.command != DECODE_COMMAND_START &&
dc.state != DECODE_STATE_START) {
!decoder_is_starting(&dc)) {
/* enable cross fading in this song? if yes,
calculate how many chunks will be required
for it */
@ -314,7 +311,7 @@ static void decodeParent(void)
} else {
/* there are not enough
decoded chunks yet */
if (dc.state == DECODE_STATE_STOP) {
if (decoder_is_idle(&dc)) {
/* the decoder isn't
running, abort
cross fading */
@ -362,8 +359,7 @@ static void decodeParent(void)
pc.queueState = PLAYER_QUEUE_EMPTY;
wakeup_main_task();
} else if (dc.state == DECODE_STATE_STOP &&
dc.command != DECODE_COMMAND_START) {
} else if (decoder_is_idle(&dc)) {
break;
} else {
/*DEBUG("waiting for decoded audio, play silence\n");*/