moved variable "dc" to decode.h
Now that "dc" is available here, we don't have to pass it to decoder_is_idle() and decoder_is_starting() anymore.
This commit is contained in:
parent
9521c92f66
commit
1c03c721ea
26
src/decode.h
26
src/decode.h
@ -44,7 +44,7 @@ enum decoder_command {
|
|||||||
#define DECODE_ERROR_UNKTYPE 10
|
#define DECODE_ERROR_UNKTYPE 10
|
||||||
#define DECODE_ERROR_FILE 20
|
#define DECODE_ERROR_FILE 20
|
||||||
|
|
||||||
typedef struct _DecoderControl {
|
struct decoder_control {
|
||||||
Notify notify;
|
Notify notify;
|
||||||
|
|
||||||
volatile enum decoder_state state;
|
volatile enum decoder_state state;
|
||||||
@ -57,29 +57,31 @@ typedef struct _DecoderControl {
|
|||||||
Song *current_song;
|
Song *current_song;
|
||||||
Song *volatile next_song;
|
Song *volatile next_song;
|
||||||
volatile float totalTime;
|
volatile float totalTime;
|
||||||
} DecoderControl;
|
};
|
||||||
|
|
||||||
|
extern struct decoder_control dc;
|
||||||
|
|
||||||
void decoderInit(void);
|
void decoderInit(void);
|
||||||
|
|
||||||
static inline int decoder_is_idle(DecoderControl *dc)
|
static inline int decoder_is_idle(void)
|
||||||
{
|
{
|
||||||
return dc->state == DECODE_STATE_STOP &&
|
return dc.state == DECODE_STATE_STOP &&
|
||||||
dc->command != DECODE_COMMAND_START;
|
dc.command != DECODE_COMMAND_START;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int decoder_is_starting(DecoderControl *dc)
|
static inline int decoder_is_starting(void)
|
||||||
{
|
{
|
||||||
return dc->command == DECODE_COMMAND_START ||
|
return dc.command == DECODE_COMMAND_START ||
|
||||||
dc->state == DECODE_STATE_START;
|
dc.state == DECODE_STATE_START;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Song *decoder_current_song(DecoderControl *dc)
|
static inline Song *decoder_current_song(void)
|
||||||
{
|
{
|
||||||
if (dc->state == DECODE_STATE_STOP ||
|
if (dc.state == DECODE_STATE_STOP ||
|
||||||
dc->error != DECODE_ERROR_NOERROR)
|
dc.error != DECODE_ERROR_NOERROR)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return dc->current_song;
|
return dc.current_song;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dc_command_wait(Notify *notify);
|
void dc_command_wait(Notify *notify);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "decoder_internal.h"
|
#include "decoder_internal.h"
|
||||||
#include "decoder_list.h"
|
#include "decoder_list.h"
|
||||||
|
#include "decode.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "replayGain.h"
|
#include "replayGain.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "playerData.h"
|
#include "playerData.h"
|
||||||
|
#include "decode.h"
|
||||||
|
|
||||||
|
|
||||||
/* valid values for streamTypes in the InputPlugin struct: */
|
/* valid values for streamTypes in the InputPlugin struct: */
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "decode.h"
|
#include "decode.h"
|
||||||
#include "playerData.h"
|
|
||||||
|
struct decoder_control dc;
|
||||||
|
|
||||||
void dc_command_wait(Notify *notify)
|
void dc_command_wait(Notify *notify)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "playerData.h"
|
#include "playerData.h"
|
||||||
|
#include "decode.h"
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
#include "sig_handlers.h"
|
#include "sig_handlers.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "playerData.h"
|
#include "playerData.h"
|
||||||
|
#include "decode.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@ -26,7 +27,6 @@
|
|||||||
|
|
||||||
unsigned int buffered_before_play;
|
unsigned int buffered_before_play;
|
||||||
PlayerControl pc;
|
PlayerControl pc;
|
||||||
DecoderControl dc;
|
|
||||||
OutputBuffer ob;
|
OutputBuffer ob;
|
||||||
|
|
||||||
void initPlayerData(void)
|
void initPlayerData(void)
|
||||||
|
@ -20,12 +20,10 @@
|
|||||||
#define PLAYER_DATA_H
|
#define PLAYER_DATA_H
|
||||||
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "decode.h"
|
|
||||||
#include "outputBuffer.h"
|
#include "outputBuffer.h"
|
||||||
|
|
||||||
extern unsigned int buffered_before_play;
|
extern unsigned int buffered_before_play;
|
||||||
extern PlayerControl pc;
|
extern PlayerControl pc;
|
||||||
extern DecoderControl dc;
|
|
||||||
extern OutputBuffer ob;
|
extern OutputBuffer ob;
|
||||||
|
|
||||||
void initPlayerData(void);
|
void initPlayerData(void);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "player_thread.h"
|
#include "player_thread.h"
|
||||||
#include "playerData.h"
|
#include "playerData.h"
|
||||||
|
#include "decode.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "pcm_utils.h"
|
#include "pcm_utils.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
@ -65,7 +66,7 @@ static int decodeSeek(int *decodeWaitedOn, int *next)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
double where;
|
double where;
|
||||||
|
|
||||||
if (decoder_current_song(&dc) != pc.next_song) {
|
if (decoder_current_song() != pc.next_song) {
|
||||||
dc_stop(&pc.notify);
|
dc_stop(&pc.notify);
|
||||||
*next = -1;
|
*next = -1;
|
||||||
ob_clear();
|
ob_clear();
|
||||||
@ -224,7 +225,7 @@ static void do_play(void)
|
|||||||
pc.error = PLAYER_ERROR_FILE;
|
pc.error = PLAYER_ERROR_FILE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (!decoder_is_starting(&dc)) {
|
else if (!decoder_is_starting()) {
|
||||||
/* the decoder is ready and ok */
|
/* the decoder is ready and ok */
|
||||||
decodeWaitedOn = 0;
|
decodeWaitedOn = 0;
|
||||||
if(openAudioDevice(&(ob.audioFormat))<0) {
|
if(openAudioDevice(&(ob.audioFormat))<0) {
|
||||||
@ -256,7 +257,7 @@ static void do_play(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decoder_is_idle(&dc) &&
|
if (decoder_is_idle() &&
|
||||||
pc.queueState == PLAYER_QUEUE_FULL &&
|
pc.queueState == PLAYER_QUEUE_FULL &&
|
||||||
pc.queueLockState == PLAYER_QUEUE_UNLOCKED) {
|
pc.queueLockState == PLAYER_QUEUE_UNLOCKED) {
|
||||||
/* the decoder has finished the current song;
|
/* the decoder has finished the current song;
|
||||||
@ -267,7 +268,7 @@ static void do_play(void)
|
|||||||
wakeup_main_task();
|
wakeup_main_task();
|
||||||
}
|
}
|
||||||
if (next >= 0 && do_xfade == XFADE_UNKNOWN &&
|
if (next >= 0 && do_xfade == XFADE_UNKNOWN &&
|
||||||
!decoder_is_starting(&dc)) {
|
!decoder_is_starting()) {
|
||||||
/* enable cross fading in this song? if yes,
|
/* enable cross fading in this song? if yes,
|
||||||
calculate how many chunks will be required
|
calculate how many chunks will be required
|
||||||
for it */
|
for it */
|
||||||
@ -313,7 +314,7 @@ static void do_play(void)
|
|||||||
} else {
|
} else {
|
||||||
/* there are not enough
|
/* there are not enough
|
||||||
decoded chunks yet */
|
decoded chunks yet */
|
||||||
if (decoder_is_idle(&dc)) {
|
if (decoder_is_idle()) {
|
||||||
/* the decoder isn't
|
/* the decoder isn't
|
||||||
running, abort
|
running, abort
|
||||||
cross fading */
|
cross fading */
|
||||||
@ -361,7 +362,7 @@ static void do_play(void)
|
|||||||
|
|
||||||
pc.queueState = PLAYER_QUEUE_EMPTY;
|
pc.queueState = PLAYER_QUEUE_EMPTY;
|
||||||
wakeup_main_task();
|
wakeup_main_task();
|
||||||
} else if (decoder_is_idle(&dc)) {
|
} else if (decoder_is_idle()) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
/*DEBUG("waiting for decoded audio, play silence\n");*/
|
/*DEBUG("waiting for decoded audio, play silence\n");*/
|
||||||
|
Loading…
Reference in New Issue
Block a user