diff options
-rw-r--r-- | src/decoder_control.c | 8 | ||||
-rw-r--r-- | src/decoder_control.h | 2 | ||||
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/playerData.c | 22 | ||||
-rw-r--r-- | src/playerData.h | 1 | ||||
-rw-r--r-- | src/player_control.c | 13 | ||||
-rw-r--r-- | src/player_control.h | 4 | ||||
-rw-r--r-- | src/player_thread.c | 5 |
8 files changed, 37 insertions, 24 deletions
diff --git a/src/decoder_control.c b/src/decoder_control.c index 49842b445..a0e3b6143 100644 --- a/src/decoder_control.c +++ b/src/decoder_control.c @@ -20,6 +20,14 @@ struct decoder_control dc; +void dc_init(void) +{ + notify_init(&dc.notify); + dc.state = DECODE_STATE_STOP; + dc.command = DECODE_COMMAND_NONE; + dc.error = DECODE_ERROR_NOERROR; +} + void dc_command_wait(Notify *notify) { while (dc.command != DECODE_COMMAND_NONE) { diff --git a/src/decoder_control.h b/src/decoder_control.h index f492b6aba..e3fe53da7 100644 --- a/src/decoder_control.h +++ b/src/decoder_control.h @@ -56,6 +56,8 @@ struct decoder_control { extern struct decoder_control dc; +void dc_init(void); + static inline int decoder_is_idle(void) { return dc.state == DECODE_STATE_STOP && diff --git a/src/main.c b/src/main.c index 4e0079a85..54c2548b1 100644 --- a/src/main.c +++ b/src/main.c @@ -25,7 +25,9 @@ #include "conf.h" #include "path.h" #include "playerData.h" +#include "outputBuffer.h" #include "decoder_thread.h" +#include "decoder_control.h" #include "player_control.h" #include "stats.h" #include "sig_handlers.h" @@ -415,6 +417,9 @@ int main(int argc, char *argv[]) initCommands(); initPlayerData(); + pc_init(buffered_before_play); + ob_init(buffered_chunks, &pc.notify); + dc_init(); initAudioConfig(); initAudioDriver(); initVolume(); @@ -464,6 +469,7 @@ int main(int argc, char *argv[]) finishPermissions(); finishCommands(); decoder_plugin_deinit_all(); + ob_free(); cleanUpPidFile(); finishConf(); diff --git a/src/playerData.c b/src/playerData.c index 593a1dbd1..948c59570 100644 --- a/src/playerData.c +++ b/src/playerData.c @@ -18,7 +18,6 @@ #include "playerData.h" #include "player_control.h" -#include "decoder_control.h" #include "outputBuffer.h" #include "conf.h" #include "log.h" @@ -27,15 +26,14 @@ #define DEFAULT_BUFFER_SIZE 2048 #define DEFAULT_BUFFER_BEFORE_PLAY 10 +unsigned int buffered_chunks; unsigned int buffered_before_play; void initPlayerData(void) { float perc = DEFAULT_BUFFER_BEFORE_PLAY; char *test; - int crossfade = 0; size_t bufferSize = DEFAULT_BUFFER_SIZE; - unsigned int buffered_chunks; ConfigParam *param; param = getConfigParam(CONF_AUDIO_BUFFER_SIZE); @@ -71,22 +69,4 @@ void initPlayerData(void) if (buffered_before_play > buffered_chunks) { buffered_before_play = buffered_chunks; } - - ob_init(buffered_chunks, &pc.notify); - - notify_init(&pc.notify); - pc.command = PLAYER_COMMAND_NONE; - pc.error = PLAYER_ERROR_NOERROR; - pc.state = PLAYER_STATE_STOP; - pc.queueState = PLAYER_QUEUE_BLANK; - pc.queueLockState = PLAYER_QUEUE_UNLOCKED; - pc.crossFade = crossfade; - pc.softwareVolume = 1000; - - notify_init(&dc.notify); - dc.state = DECODE_STATE_STOP; - dc.command = DECODE_COMMAND_NONE; - dc.error = DECODE_ERROR_NOERROR; } - - diff --git a/src/playerData.h b/src/playerData.h index 9d2918c8d..48d0c09c0 100644 --- a/src/playerData.h +++ b/src/playerData.h @@ -19,6 +19,7 @@ #ifndef PLAYER_DATA_H #define PLAYER_DATA_H +extern unsigned int buffered_chunks; extern unsigned int buffered_before_play; void initPlayerData(void); diff --git a/src/player_control.c b/src/player_control.c index 93dd407e8..13310a6c5 100644 --- a/src/player_control.c +++ b/src/player_control.c @@ -25,6 +25,19 @@ struct player_control pc; +void pc_init(unsigned int buffered_before_play) +{ + pc.buffered_before_play = buffered_before_play; + notify_init(&pc.notify); + pc.command = PLAYER_COMMAND_NONE; + pc.error = PLAYER_ERROR_NOERROR; + pc.state = PLAYER_STATE_STOP; + pc.queueState = PLAYER_QUEUE_BLANK; + pc.queueLockState = PLAYER_QUEUE_UNLOCKED; + pc.crossFade = 0; + pc.softwareVolume = 1000; +} + static void set_current_song(Song *song) { assert(song != NULL); diff --git a/src/player_control.h b/src/player_control.h index fcdbb000f..633d16dcd 100644 --- a/src/player_control.h +++ b/src/player_control.h @@ -80,6 +80,8 @@ enum player_queue_state { #define PLAYER_QUEUE_LOCKED 1 struct player_control { + unsigned int buffered_before_play; + Notify notify; volatile enum player_command command; volatile enum player_state state; @@ -103,6 +105,8 @@ struct player_control { extern struct player_control pc; +void pc_init(unsigned int buffered_before_play); + void player_command_finished(void); void playerPlay(Song * song); diff --git a/src/player_thread.c b/src/player_thread.c index 110705443..eecc351c6 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -18,7 +18,6 @@ #include "player_thread.h" #include "player_control.h" -#include "playerData.h" #include "decoder_control.h" #include "audio.h" #include "pcm_utils.h" @@ -171,7 +170,7 @@ static void do_play(void) { int do_pause = 0; int buffering = 1; - unsigned int bbp = buffered_before_play; + unsigned int bbp = pc.buffered_before_play; enum xfade_state do_xfade = XFADE_UNKNOWN; unsigned int crossFadeChunks = 0; /** the position of the next cross-faded chunk in the next @@ -277,7 +276,7 @@ static void do_play(void) cross_fade_calc(pc.crossFade, dc.totalTime, &(ob.audioFormat), ob.size - - buffered_before_play); + pc.buffered_before_play); if (crossFadeChunks > 0) { do_xfade = XFADE_ENABLED; nextChunk = -1; |