moved code to pc_init(), dc_init()
This commit is contained in:
parent
5e51fa020d
commit
e2c8b960de
@ -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) {
|
||||
|
@ -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 &&
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user