aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-18 17:32:43 +0100
committerMax Kellermann <max@duempel.org>2009-01-18 17:32:43 +0100
commita3f03f3ccdefc8704d112405dca5db10a2f6cf94 (patch)
treee26e045a9694b32eb0292bde5407e1014ecdeac1
parent90b34f8e6feb4dabc8da0d782cf5146318cfc02a (diff)
downloadmpd-a3f03f3ccdefc8704d112405dca5db10a2f6cf94.tar.gz
mpd-a3f03f3ccdefc8704d112405dca5db10a2f6cf94.tar.xz
mpd-a3f03f3ccdefc8704d112405dca5db10a2f6cf94.zip
removed playerData.c
Fetch the configuration variables buffered_chunks and buffered_before_play just when they are needed.
Diffstat (limited to '')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/decoder_api.h1
-rw-r--r--src/main.c60
-rw-r--r--src/playerData.c72
-rw-r--r--src/playerData.h27
5 files changed, 55 insertions, 107 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d92b40ff1..c4cde6952 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -90,7 +90,6 @@ mpd_headers = \
permission.h \
player_thread.h \
player_control.h \
- playerData.h \
playlist.h \
playlist_save.h \
replay_gain.h \
@@ -172,7 +171,6 @@ mpd_SOURCES = \
permission.c \
player_thread.c \
player_control.c \
- playerData.c \
playlist.c \
playlist_save.c \
replay_gain.c \
diff --git a/src/decoder_api.h b/src/decoder_api.h
index 11ee86e42..6e3332d52 100644
--- a/src/decoder_api.h
+++ b/src/decoder_api.h
@@ -30,7 +30,6 @@
#include "replay_gain.h"
#include "tag.h"
#include "audio_format.h"
-#include "playerData.h"
#include <stdbool.h>
diff --git a/src/main.c b/src/main.c
index bfe89ae2a..9b1203a92 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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();
diff --git a/src/playerData.c b/src/playerData.c
deleted file mode 100644
index a2e12562d..000000000
--- a/src/playerData.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* the Music Player Daemon (MPD)
- * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
- * This project's homepage is: http://www.musicpd.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "playerData.h"
-#include "pipe.h"
-#include "conf.h"
-#include "log.h"
-
-#include <stdlib.h>
-
-#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;
- size_t bufferSize = DEFAULT_BUFFER_SIZE;
- struct config_param *param;
-
- param = config_get_param(CONF_AUDIO_BUFFER_SIZE);
-
- if (param) {
- bufferSize = strtol(param->value, &test, 10);
- if (*test != '\0' || bufferSize <= 0) {
- FATAL("buffer size \"%s\" is not a positive integer, "
- "line %i\n", param->value, param->line);
- }
- }
-
- bufferSize *= 1024;
-
- buffered_chunks = bufferSize / CHUNK_SIZE;
-
- if (buffered_chunks >= 1 << 15) {
- FATAL("buffer size \"%li\" is too big\n", (long)bufferSize);
- }
-
- param = config_get_param(CONF_BUFFER_BEFORE_PLAY);
-
- if (param) {
- 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);
- }
- }
-
- buffered_before_play = (perc / 100) * buffered_chunks;
- if (buffered_before_play > buffered_chunks) {
- buffered_before_play = buffered_chunks;
- }
-}
diff --git a/src/playerData.h b/src/playerData.h
deleted file mode 100644
index 45f523852..000000000
--- a/src/playerData.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* the Music Player Daemon (MPD)
- * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
- * This project's homepage is: http://www.musicpd.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef MPD_PLAYER_DATA_H
-#define MPD_PLAYER_DATA_H
-
-extern unsigned int buffered_chunks;
-extern unsigned int buffered_before_play;
-
-void initPlayerData(void);
-
-#endif