removed playerData.c

Fetch the configuration variables buffered_chunks and
buffered_before_play just when they are needed.
This commit is contained in:
Max Kellermann
2009-01-18 17:32:43 +01:00
parent 90b34f8e6f
commit a3f03f3ccd
5 changed files with 55 additions and 107 deletions

View File

@@ -30,7 +30,6 @@
#include "conf.h"
#include "path.h"
#include "mapper.h"
#include "playerData.h"
#include "pipe.h"
#include "decoder_thread.h"
#include "decoder_control.h"
@@ -70,6 +69,11 @@
#include <locale.h>
#endif
enum {
DEFAULT_BUFFER_SIZE = 2048,
DEFAULT_BUFFER_BEFORE_PLAY = 10,
};
GThread *main_task;
GMainLoop *main_loop;
@@ -111,6 +115,55 @@ static void openDB(Options * options, char *argv0)
}
}
/**
* Initialize the decoder and player core, including the music pipe.
*/
static void
initialize_decoder_and_player(void)
{
struct config_param *param;
char *test;
size_t buffer_size;
float perc;
unsigned buffered_chunks;
unsigned buffered_before_play;
param = config_get_param(CONF_AUDIO_BUFFER_SIZE);
if (param != NULL) {
buffer_size = strtol(param->value, &test, 10);
if (*test != '\0' || buffer_size <= 0)
g_error("buffer size \"%s\" is not a positive integer, "
"line %i\n", param->value, param->line);
} else
buffer_size = DEFAULT_BUFFER_SIZE;
buffer_size *= 1024;
buffered_chunks = buffer_size / CHUNK_SIZE;
if (buffered_chunks >= 1 << 15)
g_error("buffer size \"%li\" is too big\n", (long)buffer_size);
param = config_get_param(CONF_BUFFER_BEFORE_PLAY);
if (param != NULL) {
perc = strtod(param->value, &test);
if (*test != '%' || perc < 0 || perc > 100) {
FATAL("buffered before play \"%s\" is not a positive "
"percentage and less than 100 percent, line %i"
"\n", param->value, param->line);
}
} else
perc = DEFAULT_BUFFER_BEFORE_PLAY;
buffered_before_play = (perc / 100) * buffered_chunks;
if (buffered_before_play > buffered_chunks)
buffered_before_play = buffered_chunks;
pc_init(buffered_before_play);
music_pipe_init(buffered_chunks, &pc.notify);
dc_init();
}
static gboolean
timer_save_state_file(G_GNUC_UNUSED gpointer data)
{
@@ -189,10 +242,7 @@ int main(int argc, char *argv[])
openDB(&options, argv[0]);
command_init();
initPlayerData();
pc_init(buffered_before_play);
music_pipe_init(buffered_chunks, &pc.notify);
dc_init();
initialize_decoder_and_player();
initAudioConfig();
initAudioDriver();
volume_init();