Commit 2b2d267d authored by Led's avatar Led

Merge commit '0.14-beta2' into alt

parents 29e57c2d dbb32d46
Current Developers Current Developers
------------------ ------------------
Max Kellermann <max@duempel.org>
general
Warren Dukes <warren.dukes@gmail.com> Avuton Olrich <avuton@gmail.com>
general release manager
J. Alexander Treuman <jat@spatialrift.net> Max Kellermann <max@duempel.org>
general, MP3, ID3, PulseAudio, format conversion, stored playlists general
Jos Anarch <anarchsss@gmail.com> Jos Anarch <anarchsss@gmail.com>
JACK plugin JACK plugin
...@@ -18,9 +16,6 @@ Guus Sliepen <guus@sliepen.eu.org> ...@@ -18,9 +16,6 @@ Guus Sliepen <guus@sliepen.eu.org>
Jim Ramsay <i.am@jimramsay.com> Jim Ramsay <i.am@jimramsay.com>
Zerconf/avahi support Zerconf/avahi support
Qball Cow <qballcow@gmail.com>
Playlist commands
Patrik Weiskircher <pat@icore.at> Patrik Weiskircher <pat@icore.at>
Stored playlist commands Stored playlist commands
...@@ -30,23 +25,20 @@ Laszlo Ashin <kodest@gmail.com> ...@@ -30,23 +25,20 @@ Laszlo Ashin <kodest@gmail.com>
Viliam Mateicka <viliam.mateicka@gmail.com> Viliam Mateicka <viliam.mateicka@gmail.com>
FFmpeg support FFmpeg support
Eric Wollesen <encoded@xmtp.net>
encoder API, shout output
Former Developers Former Developers
----------------- -----------------
tw-nym
Nagilum Warren Dukes <warren.dukes@gmail.com>
setuid general
Niklas Hofer Niklas Hofer
'next' and 'previous' patch 'next' and 'previous' patch
mackstann J. Alexander Treuman <jat@spatialrift.net>
command.c and signal handling cleanup general, MP3, ID3, PulseAudio, format conversion, stored playlists
AliasMrJones
replayGain
Eric Wong Eric Wong
mp4ff copyrighted by M. Bakker, Ahead Software AG, http://www.nero.com
compress.[ch] copyrighted by fluffy <fluffy@beesbuzz.biz>
...@@ -91,6 +91,18 @@ libcurl - http://curl.haxx.se/ ...@@ -91,6 +91,18 @@ libcurl - http://curl.haxx.se/
For playing HTTP streams. For playing HTTP streams.
pkg-config
----------
MPD uses pkg-config to locate most external libraries. If you do not
have pkg-config, or if your version of the library does not ship the
".pc" file, you have to provide the library's build options in
environment variables. These variables are documented in "./configure
--help". Example:
FLAC_CFLAGS=-I/usr/include/FLAC FLAC_LIBS=-lFLAC ./configure
Download Download
-------- --------
......
ver 0.14.0 (????/??/??) ver 0.14.0 (????/??/??)
* audio outputs: * audio outputs:
- wait 10 seconds before reopening a failed device
- fifo: new plugin - fifo: new plugin
- null: new plugin - null: new plugin
- shout: block while trying to connect instead of failing - shout: block while trying to connect instead of failing
...@@ -9,6 +10,7 @@ ver 0.14.0 (????/??/??) ...@@ -9,6 +10,7 @@ ver 0.14.0 (????/??/??)
* decoders: * decoders:
- ffmpeg: new plugin - ffmpeg: new plugin
- wavpack: new plugin - wavpack: new plugin
- aac: stream support added
* commands: * commands:
- "addid" takes optional second argument to specify position - "addid" takes optional second argument to specify position
- "idle" notifies the client when a notable change occurs - "idle" notifies the client when a notable change occurs
...@@ -25,6 +27,8 @@ ver 0.14.0 (????/??/??) ...@@ -25,6 +27,8 @@ ver 0.14.0 (????/??/??)
* optimized PCM conversions and dithering * optimized PCM conversions and dithering
* much code has been replaced by using GLib * much code has been replaced by using GLib
* the HTTP client has been replaced with libcurl * the HTTP client has been replaced with libcurl
* symbolic links in the music directory can be disabled; the default
is to ignore symlinks pointing outside the music directory
ver 0.13.0 (2007/5/28) ver 0.13.0 (2007/5/28)
* New JACK audio output * New JACK audio output
......
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.63 for mpd 0.14~beta1. # Generated by GNU Autoconf 2.63 for mpd 0.14~beta2.
# #
# Report bugs to <musicpd-dev-team@lists.sourceforge.net>. # Report bugs to <musicpd-dev-team@lists.sourceforge.net>.
# #
...@@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} ...@@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package. # Identity of this package.
PACKAGE_NAME='mpd' PACKAGE_NAME='mpd'
PACKAGE_TARNAME='mpd' PACKAGE_TARNAME='mpd'
PACKAGE_VERSION='0.14~beta1' PACKAGE_VERSION='0.14~beta2'
PACKAGE_STRING='mpd 0.14~beta1' PACKAGE_STRING='mpd 0.14~beta2'
PACKAGE_BUGREPORT='musicpd-dev-team@lists.sourceforge.net' PACKAGE_BUGREPORT='musicpd-dev-team@lists.sourceforge.net'
ac_unique_file="src/main.c" ac_unique_file="src/main.c"
...@@ -1481,7 +1481,7 @@ if test "$ac_init_help" = "long"; then ...@@ -1481,7 +1481,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures mpd 0.14~beta1 to adapt to many kinds of systems. \`configure' configures mpd 0.14~beta2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
...@@ -1551,7 +1551,7 @@ fi ...@@ -1551,7 +1551,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of mpd 0.14~beta1:";; short | recursive ) echo "Configuration of mpd 0.14~beta2:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
...@@ -1749,7 +1749,7 @@ fi ...@@ -1749,7 +1749,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
mpd configure 0.14~beta1 mpd configure 0.14~beta2
generated by GNU Autoconf 2.63 generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
...@@ -1763,7 +1763,7 @@ cat >config.log <<_ACEOF ...@@ -1763,7 +1763,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by mpd $as_me 0.14~beta1, which was It was created by mpd $as_me 0.14~beta2, which was
generated by GNU Autoconf 2.63. Invocation command line was generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@ $ $0 $@
...@@ -2460,7 +2460,7 @@ fi ...@@ -2460,7 +2460,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='mpd' PACKAGE='mpd'
VERSION='0.14~beta1' VERSION='0.14~beta2'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
...@@ -13076,7 +13076,7 @@ exec 6>&1 ...@@ -13076,7 +13076,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by mpd $as_me 0.14~beta1, which was This file was extended by mpd $as_me 0.14~beta2, which was
generated by GNU Autoconf 2.63. Invocation command line was generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
...@@ -13139,7 +13139,7 @@ Report bugs to <bug-autoconf@gnu.org>." ...@@ -13139,7 +13139,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\ ac_cs_version="\\
mpd config.status 0.14~beta1 mpd config.status 0.14~beta2
configured by $0, generated by GNU Autoconf 2.63, configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
AC_PREREQ(2.60) AC_PREREQ(2.60)
AC_INIT(mpd, 0.14~beta1, musicpd-dev-team@lists.sourceforge.net) AC_INIT(mpd, 0.14~beta2, musicpd-dev-team@lists.sourceforge.net)
AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([foreign 1.9 dist-bzip2]) AM_INIT_AUTOMAKE([foreign 1.9 dist-bzip2])
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
......
...@@ -35,6 +35,17 @@ This specifies the directory where music is located. ...@@ -35,6 +35,17 @@ This specifies the directory where music is located.
.B playlist_directory <directory> .B playlist_directory <directory>
This specifies the directory where saved playlists are stored. This specifies the directory where saved playlists are stored.
.TP .TP
.B follow_outside_symlinks <yes or no>
Control if MPD will follow symbolic links pointing outside the music dir.
You must recreate the database after changing this option.
The default is "no".
.TP
.B follow_inside_symlinks <yes or no>
Control if MPD will follow symbolic links pointing outside the music dir, potentially
adding duplicates to the database.
You must recreate the database after changing this option.
The default is "yes".
.TP
.B db_file <file> .B db_file <file>
This specifies where the db file will be stored. This specifies where the db file will be stored.
.TP .TP
......
...@@ -7,6 +7,8 @@ playlist_directory "~/.mpd/playlists" ...@@ -7,6 +7,8 @@ playlist_directory "~/.mpd/playlists"
db_file "~/.mpd/mpd.db" db_file "~/.mpd/mpd.db"
log_file "~/.mpd/mpd.log" log_file "~/.mpd/mpd.log"
error_file "~/.mpd/mpd.error" error_file "~/.mpd/mpd.error"
#follow_outside_symlinks "no"
#follow_inside_symlinks "yes"
################################################################ ################################################################
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "output_api.h" #include "output_api.h"
#include "output_control.h" #include "output_control.h"
#include "output_internal.h" #include "output_internal.h"
#include "log.h"
#include "path.h" #include "path.h"
#include "client.h" #include "client.h"
#include "idle.h" #include "idle.h"
...@@ -73,21 +72,21 @@ void initAudioDriver(void) ...@@ -73,21 +72,21 @@ void initAudioDriver(void)
if (!audio_output_init(output, param)) { if (!audio_output_init(output, param)) {
if (param) if (param)
{ {
FATAL("problems configuring output device " g_error("problems configuring output device "
"defined at line %i\n", param->line); "defined at line %i\n", param->line);
} }
else else
{ {
FATAL("No audio_output specified and unable to " g_error("No audio_output specified and unable to "
"detect a default audio output device\n"); "detect a default audio output device\n");
} }
} }
/* require output names to be unique: */ /* require output names to be unique: */
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
if (!strcmp(output->name, audioOutputArray[j].name)) { if (!strcmp(output->name, audioOutputArray[j].name)) {
FATAL("output devices with identical " g_error("output devices with identical "
"names: %s\n", output->name); "names: %s\n", output->name);
} }
} }
} }
...@@ -109,8 +108,8 @@ void initAudioConfig(void) ...@@ -109,8 +108,8 @@ void initAudioConfig(void)
return; return;
if (0 != parseAudioConfig(&configured_audio_format, param->value)) { if (0 != parseAudioConfig(&configured_audio_format, param->value)) {
FATAL("error parsing \"%s\" at line %i\n", g_error("error parsing \"%s\" at line %i\n",
CONF_AUDIO_OUTPUT_FORMAT, param->line); CONF_AUDIO_OUTPUT_FORMAT, param->line);
} }
} }
...@@ -123,34 +122,34 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf) ...@@ -123,34 +122,34 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
audioFormat->sample_rate = strtol(conf, &test, 10); audioFormat->sample_rate = strtol(conf, &test, 10);
if (*test != ':') { if (*test != ':') {
ERROR("error parsing audio output format: %s\n", conf); g_warning("error parsing audio output format: %s\n", conf);
return -1; return -1;
} }
if (audioFormat->sample_rate <= 0) { if (audioFormat->sample_rate <= 0) {
ERROR("sample rate %u is not >= 0\n", g_warning("sample rate %u is not >= 0\n",
audioFormat->sample_rate); audioFormat->sample_rate);
return -1; return -1;
} }
audioFormat->bits = (uint8_t)strtoul(test + 1, &test, 10); audioFormat->bits = (uint8_t)strtoul(test + 1, &test, 10);
if (*test != ':') { if (*test != ':') {
ERROR("error parsing audio output format: %s\n", conf); g_warning("error parsing audio output format: %s\n", conf);
return -1; return -1;
} }
if (audioFormat->bits != 16 && audioFormat->bits != 24 && if (audioFormat->bits != 16 && audioFormat->bits != 24 &&
audioFormat->bits != 8) { audioFormat->bits != 8) {
ERROR("bits %u can not be used for audio output\n", g_warning("bits %u can not be used for audio output\n",
audioFormat->bits); audioFormat->bits);
return -1; return -1;
} }
audioFormat->channels = (uint8_t)strtoul(test + 1, &test, 10); audioFormat->channels = (uint8_t)strtoul(test + 1, &test, 10);
if (*test != '\0') { if (*test != '\0') {
ERROR("error parsing audio output format: %s\n", conf); g_warning("error parsing audio output format: %s\n", conf);
return -1; return -1;
} }
...@@ -159,8 +158,8 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf) ...@@ -159,8 +158,8 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
case 2: case 2:
break; break;
default: default:
ERROR("channels %i can not be used for audio output\n", g_warning("channels %u can not be used for audio output\n",
(int)audioFormat->channels); audioFormat->channels);
return -1; return -1;
} }
...@@ -418,7 +417,7 @@ void readAudioDevicesState(FILE *fp) ...@@ -418,7 +417,7 @@ void readAudioDevicesState(FILE *fp)
continue; continue;
errline: errline:
/* nonfatal */ /* nonfatal */
ERROR("invalid line in state_file: %s\n", buffer); g_warning("invalid line in state_file: %s\n", buffer);
} }
} }
...@@ -169,7 +169,7 @@ static void new_cmd_list_ptr(struct client *client, char *s) ...@@ -169,7 +169,7 @@ static void new_cmd_list_ptr(struct client *client, char *s)
} }
static void static void
deferred_buffer_free(gpointer data, mpd_unused gpointer user_data) deferred_buffer_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
{ {
struct deferred_buffer *buffer = data; struct deferred_buffer *buffer = data;
g_free(buffer); g_free(buffer);
...@@ -760,7 +760,7 @@ void client_vprintf(struct client *client, const char *fmt, va_list args) ...@@ -760,7 +760,7 @@ void client_vprintf(struct client *client, const char *fmt, va_list args)
free(buffer); free(buffer);
} }
mpd_fprintf void client_printf(struct client *client, const char *fmt, ...) G_GNUC_PRINTF(2, 3) void client_printf(struct client *client, const char *fmt, ...)
{ {
va_list args; va_list args;
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#ifndef MPD_CLIENT_H #ifndef MPD_CLIENT_H
#define MPD_CLIENT_H #define MPD_CLIENT_H
#include "gcc.h" #include <glib.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -65,7 +64,7 @@ void client_vprintf(struct client *client, const char *fmt, va_list args); ...@@ -65,7 +64,7 @@ void client_vprintf(struct client *client, const char *fmt, va_list args);
/** /**
* Write a printf-like formatted string to the client. * Write a printf-like formatted string to the client.
*/ */
mpd_fprintf void client_printf(struct client *client, const char *fmt, ...); G_GNUC_PRINTF(2, 3) void client_printf(struct client *client, const char *fmt, ...);
/** /**
* Adds the specified idle flags to all clients and immediately sends * Adds the specified idle flags to all clients and immediately sends
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#ifndef MPD_COMMAND_H #ifndef MPD_COMMAND_H
#define MPD_COMMAND_H #define MPD_COMMAND_H
#include "gcc.h"
#include "ack.h" #include "ack.h"
#include <glib.h> #include <glib.h>
...@@ -47,7 +46,7 @@ command_process(struct client *client, char *commandString); ...@@ -47,7 +46,7 @@ command_process(struct client *client, char *commandString);
void command_success(struct client *client); void command_success(struct client *client);
mpd_fprintf_ void command_error(struct client *client, enum ack error, G_GNUC_PRINTF(3, 4) void command_error(struct client *client, enum ack error,
const char *fmt, ...); const char *fmt, ...);
#endif #endif
...@@ -145,6 +145,8 @@ void initConf(void) ...@@ -145,6 +145,8 @@ void initConf(void)
/* registerConfigParam(name, repeatable, block); */ /* registerConfigParam(name, repeatable, block); */
registerConfigParam(CONF_MUSIC_DIR, 0, 0); registerConfigParam(CONF_MUSIC_DIR, 0, 0);
registerConfigParam(CONF_PLAYLIST_DIR, 0, 0); registerConfigParam(CONF_PLAYLIST_DIR, 0, 0);
registerConfigParam(CONF_FOLLOW_INSIDE_SYMLINKS, 0, 0);
registerConfigParam(CONF_FOLLOW_OUTSIDE_SYMLINKS, 0, 0);
registerConfigParam(CONF_DB_FILE, 0, 0); registerConfigParam(CONF_DB_FILE, 0, 0);
registerConfigParam(CONF_LOG_FILE, 0, 0); registerConfigParam(CONF_LOG_FILE, 0, 0);
registerConfigParam(CONF_ERROR_FILE, 0, 0); registerConfigParam(CONF_ERROR_FILE, 0, 0);
...@@ -418,6 +420,16 @@ int getBoolConfigParam(const char *name, int force) ...@@ -418,6 +420,16 @@ int getBoolConfigParam(const char *name, int force)
return ret; return ret;
} }
bool config_get_bool(const char *name, bool default_value)
{
int value = getBoolConfigParam(name, true);
if (value == CONF_BOOL_UNSET)
return default_value;
return value;
}
int getBoolBlockParam(ConfigParam *param, const char *name, int force) int getBoolBlockParam(ConfigParam *param, const char *name, int force)
{ {
int ret; int ret;
......
...@@ -19,8 +19,12 @@ ...@@ -19,8 +19,12 @@
#ifndef MPD_CONF_H #ifndef MPD_CONF_H
#define MPD_CONF_H #define MPD_CONF_H
#include <stdbool.h>
#define CONF_MUSIC_DIR "music_directory" #define CONF_MUSIC_DIR "music_directory"
#define CONF_PLAYLIST_DIR "playlist_directory" #define CONF_PLAYLIST_DIR "playlist_directory"
#define CONF_FOLLOW_INSIDE_SYMLINKS "follow_inside_symlinks"
#define CONF_FOLLOW_OUTSIDE_SYMLINKS "follow_outside_symlinks"
#define CONF_DB_FILE "db_file" #define CONF_DB_FILE "db_file"
#define CONF_LOG_FILE "log_file" #define CONF_LOG_FILE "log_file"
#define CONF_ERROR_FILE "error_file" #define CONF_ERROR_FILE "error_file"
...@@ -97,6 +101,8 @@ ConfigParam *parseConfigFilePath(const char *name, int force); ...@@ -97,6 +101,8 @@ ConfigParam *parseConfigFilePath(const char *name, int force);
int getBoolConfigParam(const char *name, int force); int getBoolConfigParam(const char *name, int force);
bool config_get_bool(const char *name, bool default_value);
int getBoolBlockParam(ConfigParam *param, const char *name, int force); int getBoolBlockParam(ConfigParam *param, const char *name, int force);
#endif #endif
...@@ -70,7 +70,7 @@ printDirectoryInDirectory(struct directory *directory, void *data) ...@@ -70,7 +70,7 @@ printDirectoryInDirectory(struct directory *directory, void *data)
} }
static int static int
printSongInDirectory(struct song *song, mpd_unused void *data) printSongInDirectory(struct song *song, G_GNUC_UNUSED void *data)
{ {
struct client *client = data; struct client *client = data;
song_print_url(client, song); song_print_url(client, song);
...@@ -194,7 +194,7 @@ int printAllIn(struct client *client, const char *name) ...@@ -194,7 +194,7 @@ int printAllIn(struct client *client, const char *name)
} }
static int static int
directoryAddSongToPlaylist(struct song *song, mpd_unused void *data) directoryAddSongToPlaylist(struct song *song, G_GNUC_UNUSED void *data)
{ {
return addSongToPlaylist(song, NULL); return addSongToPlaylist(song, NULL);
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "_flac_common.h" #include "_flac_common.h"
#include <assert.h> #include <assert.h>
#include <unistd.h>
/* this code was based on flac123, from flac-tools */ /* this code was based on flac123, from flac-tools */
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
*/ */
#include "../decoder_api.h" #include "../decoder_api.h"
#include "../log.h"
#include "../conf.h" #include "../conf.h"
#include <assert.h> #include <assert.h>
...@@ -284,7 +283,7 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize, ...@@ -284,7 +283,7 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
} }
if (count != tagsize) { if (count != tagsize) {
DEBUG("mp3_decode: error parsing ID3 tag\n"); g_debug("mp3_decode: error parsing ID3 tag\n");
g_free(allocated); g_free(allocated);
return; return;
} }
...@@ -363,9 +362,9 @@ decode_next_frame_header(struct mp3_data *data, struct tag **tag, ...@@ -363,9 +362,9 @@ decode_next_frame_header(struct mp3_data *data, struct tag **tag,
if ((data->stream).error == MAD_ERROR_BUFLEN) if ((data->stream).error == MAD_ERROR_BUFLEN)
return DECODE_CONT; return DECODE_CONT;
else { else {
ERROR("unrecoverable frame level error " g_warning("unrecoverable frame level error "
"(%s).\n", "(%s).\n",
mad_stream_errorstr(&data->stream)); mad_stream_errorstr(&data->stream));
return DECODE_BREAK; return DECODE_BREAK;
} }
} }
...@@ -415,9 +414,9 @@ decodeNextFrame(struct mp3_data *data) ...@@ -415,9 +414,9 @@ decodeNextFrame(struct mp3_data *data)
if ((data->stream).error == MAD_ERROR_BUFLEN) if ((data->stream).error == MAD_ERROR_BUFLEN)
return DECODE_CONT; return DECODE_CONT;
else { else {
ERROR("unrecoverable frame level error " g_warning("unrecoverable frame level error "
"(%s).\n", "(%s).\n",
mad_stream_errorstr(&data->stream)); mad_stream_errorstr(&data->stream));
return DECODE_BREAK; return DECODE_BREAK;
} }
} }
...@@ -588,8 +587,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) ...@@ -588,8 +587,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
&lame->version.major, &lame->version.minor) != 2) &lame->version.major, &lame->version.minor) != 2)
return false; return false;
DEBUG("detected LAME version %i.%i (\"%s\")\n", g_debug("detected LAME version %i.%i (\"%s\")\n",
lame->version.major, lame->version.minor, lame->encoder); lame->version.major, lame->version.minor, lame->encoder);
/* The reference volume was changed from the 83dB used in the /* The reference volume was changed from the 83dB used in the
* ReplayGain spec to 89dB in lame 3.95.1. Bump the gain for older * ReplayGain spec to 89dB in lame 3.95.1. Bump the gain for older
...@@ -605,7 +604,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) ...@@ -605,7 +604,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
mad_bit_read(ptr, 16); mad_bit_read(ptr, 16);
lame->peak = mad_f_todouble(mad_bit_read(ptr, 32) << 5); /* peak */ lame->peak = mad_f_todouble(mad_bit_read(ptr, 32) << 5); /* peak */
DEBUG("LAME peak found: %f\n", lame->peak); g_debug("LAME peak found: %f\n", lame->peak);
lame->track_gain = 0; lame->track_gain = 0;
name = mad_bit_read(ptr, 3); /* gain name */ name = mad_bit_read(ptr, 3); /* gain name */
...@@ -614,7 +613,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) ...@@ -614,7 +613,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
gain = mad_bit_read(ptr, 9); /* gain*10 */ gain = mad_bit_read(ptr, 9); /* gain*10 */
if (gain && name == 1 && orig != 0) { if (gain && name == 1 && orig != 0) {
lame->track_gain = ((sign ? -gain : gain) / 10.0) + adj; lame->track_gain = ((sign ? -gain : gain) / 10.0) + adj;
DEBUG("LAME track gain found: %f\n", lame->track_gain); g_debug("LAME track gain found: %f\n", lame->track_gain);
} }
/* tmz reports that this isn't currently written by any version of lame /* tmz reports that this isn't currently written by any version of lame
...@@ -629,7 +628,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) ...@@ -629,7 +628,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
gain = mad_bit_read(ptr, 9); /* gain*10 */ gain = mad_bit_read(ptr, 9); /* gain*10 */
if (gain && name == 2 && orig != 0) { if (gain && name == 2 && orig != 0) {
lame->album_gain = ((sign ? -gain : gain) / 10.0) + adj; lame->album_gain = ((sign ? -gain : gain) / 10.0) + adj;
DEBUG("LAME album gain found: %f\n", lame->track_gain); g_debug("LAME album gain found: %f\n", lame->track_gain);
} }
#else #else
mad_bit_read(ptr, 16); mad_bit_read(ptr, 16);
...@@ -640,7 +639,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) ...@@ -640,7 +639,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
lame->encoder_delay = mad_bit_read(ptr, 12); lame->encoder_delay = mad_bit_read(ptr, 12);
lame->encoder_padding = mad_bit_read(ptr, 12); lame->encoder_padding = mad_bit_read(ptr, 12);
DEBUG("encoder delay is %i, encoder padding is %i\n", g_debug("encoder delay is %i, encoder padding is %i\n",
lame->encoder_delay, lame->encoder_padding); lame->encoder_delay, lame->encoder_padding);
mad_bit_read(ptr, 80); mad_bit_read(ptr, 80);
...@@ -771,8 +770,8 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag, ...@@ -771,8 +770,8 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag,
return false; return false;
if (data->max_frames > 8 * 1024 * 1024) { if (data->max_frames > 8 * 1024 * 1024) {
ERROR("mp3 file header indicates too many frames: %lu", g_warning("mp3 file header indicates too many frames: %lu\n",
data->max_frames); data->max_frames);
return false; return false;
} }
...@@ -1067,7 +1066,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream) ...@@ -1067,7 +1066,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
if (!mp3_open(input_stream, &data, decoder, &tag, &replay_gain_info)) { if (!mp3_open(input_stream, &data, decoder, &tag, &replay_gain_info)) {
if (decoder_get_command(decoder) == DECODE_COMMAND_NONE) if (decoder_get_command(decoder) == DECODE_COMMAND_NONE)
ERROR g_warning
("Input does not appear to be a mp3 bit stream.\n"); ("Input does not appear to be a mp3 bit stream.\n");
return; return;
} }
...@@ -1107,8 +1106,8 @@ static struct tag *mp3_tag_dup(const char *file) ...@@ -1107,8 +1106,8 @@ static struct tag *mp3_tag_dup(const char *file)
ret = tag_new(); ret = tag_new();
ret->time = total_time; ret->time = total_time;
} else { } else {
DEBUG("mp3_tag_dup: Failed to get total song time from: %s\n", g_debug("mp3_tag_dup: Failed to get total song time from: %s\n",
file); file);
} }
return ret; return ret;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <mpcdec/mpcdec.h> #include <mpcdec/mpcdec.h>
#include <glib.h> #include <glib.h>
#include <unistd.h>
typedef struct _MpcCallbackData { typedef struct _MpcCallbackData {
struct input_stream *inStream; struct input_stream *inStream;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "_ogg_common.h" #include "_ogg_common.h"
#include <OggFLAC/seekable_stream_decoder.h> #include <OggFLAC/seekable_stream_decoder.h>
#include <unistd.h>
static void oggflac_cleanup(FlacData * data, static void oggflac_cleanup(FlacData * data,
OggFLAC__SeekableStreamDecoder * decoder) OggFLAC__SeekableStreamDecoder * decoder)
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <glib.h> #include <glib.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
#define OGG_DECODE_USE_BIGENDIAN 1 #define OGG_DECODE_USE_BIGENDIAN 1
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <wavpack/wavpack.h> #include <wavpack/wavpack.h>
#include <glib.h> #include <glib.h>
#include <unistd.h>
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */ /* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
#define CHUNK_SIZE 1020 #define CHUNK_SIZE 1020
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
#include "utils.h" #include "utils.h"
#include "normalize.h" #include "normalize.h"
#include "pipe.h" #include "pipe.h"
#include "gcc.h"
#include <assert.h> #include <assert.h>
#include <glib.h>
void decoder_initialized(struct decoder * decoder, void decoder_initialized(struct decoder * decoder,
const struct audio_format *audio_format, const struct audio_format *audio_format,
...@@ -54,17 +54,18 @@ void decoder_initialized(struct decoder * decoder, ...@@ -54,17 +54,18 @@ void decoder_initialized(struct decoder * decoder,
notify_signal(&pc.notify); notify_signal(&pc.notify);
} }
const char *decoder_get_url(mpd_unused struct decoder * decoder, char * buffer) const char *decoder_get_url(G_GNUC_UNUSED struct decoder * decoder,
char * buffer)
{ {
return song_get_url(dc.current_song, buffer); return song_get_url(dc.current_song, buffer);
} }
enum decoder_command decoder_get_command(mpd_unused struct decoder * decoder) enum decoder_command decoder_get_command(G_GNUC_UNUSED struct decoder * decoder)
{ {
return dc.command; return dc.command;
} }
void decoder_command_finished(mpd_unused struct decoder * decoder) void decoder_command_finished(G_GNUC_UNUSED struct decoder * decoder)
{ {
assert(dc.command != DECODE_COMMAND_NONE); assert(dc.command != DECODE_COMMAND_NONE);
assert(dc.command != DECODE_COMMAND_SEEK || assert(dc.command != DECODE_COMMAND_SEEK ||
...@@ -78,7 +79,7 @@ void decoder_command_finished(mpd_unused struct decoder * decoder) ...@@ -78,7 +79,7 @@ void decoder_command_finished(mpd_unused struct decoder * decoder)
notify_signal(&pc.notify); notify_signal(&pc.notify);
} }
double decoder_seek_where(mpd_unused struct decoder * decoder) double decoder_seek_where(G_GNUC_UNUSED struct decoder * decoder)
{ {
assert(dc.command == DECODE_COMMAND_SEEK); assert(dc.command == DECODE_COMMAND_SEEK);
...@@ -275,7 +276,7 @@ decoder_data(struct decoder *decoder, ...@@ -275,7 +276,7 @@ decoder_data(struct decoder *decoder,
} }
enum decoder_command enum decoder_command
decoder_tag(mpd_unused struct decoder *decoder, struct input_stream *is, decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is,
const struct tag *tag) const struct tag *tag)
{ {
struct tag *tag2 = is != NULL ? tag_add_stream_tags(tag, is) : NULL; struct tag *tag2 = is != NULL ? tag_add_stream_tags(tag, is) : NULL;
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "log.h" #include "log.h"
#include "ls.h" #include "ls.h"
#include <glib.h>
static bool static bool
decoder_stream_decode(const struct decoder_plugin *plugin, decoder_stream_decode(const struct decoder_plugin *plugin,
struct decoder *decoder, struct decoder *decoder,
...@@ -200,7 +202,7 @@ static void decoder_run(void) ...@@ -200,7 +202,7 @@ static void decoder_run(void)
dc.state = ret ? DECODE_STATE_STOP : DECODE_STATE_ERROR; dc.state = ret ? DECODE_STATE_STOP : DECODE_STATE_ERROR;
} }
static void * decoder_task(mpd_unused void *arg) static void * decoder_task(G_GNUC_UNUSED void *arg)
{ {
while (1) { while (1) {
assert(dc.state == DECODE_STATE_STOP || assert(dc.state == DECODE_STATE_STOP ||
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include "input_curl.h" #include "input_curl.h"
#include "input_stream.h" #include "input_stream.h"
#include "gcc.h"
#include "dlist.h" #include "dlist.h"
#include "config.h"
#include <assert.h> #include <assert.h>
#include <sys/select.h> #include <sys/select.h>
...@@ -327,7 +327,7 @@ input_curl_close(struct input_stream *is) ...@@ -327,7 +327,7 @@ input_curl_close(struct input_stream *is)
} }
static bool static bool
input_curl_eof(mpd_unused struct input_stream *is) input_curl_eof(G_GNUC_UNUSED struct input_stream *is)
{ {
struct input_curl *c = is->data; struct input_curl *c = is->data;
...@@ -460,6 +460,8 @@ input_curl_easy_init(struct input_stream *is) ...@@ -460,6 +460,8 @@ input_curl_easy_init(struct input_stream *is)
if (mcode != CURLM_OK) if (mcode != CURLM_OK)
return false; return false;
curl_easy_setopt(c->easy, CURLOPT_USERAGENT,
"Music Player Daemon " VERSION);
curl_easy_setopt(c->easy, CURLOPT_HEADERFUNCTION, curl_easy_setopt(c->easy, CURLOPT_HEADERFUNCTION,
input_curl_headerfunction); input_curl_headerfunction);
curl_easy_setopt(c->easy, CURLOPT_WRITEHEADER, is); curl_easy_setopt(c->easy, CURLOPT_WRITEHEADER, is);
...@@ -467,6 +469,8 @@ input_curl_easy_init(struct input_stream *is) ...@@ -467,6 +469,8 @@ input_curl_easy_init(struct input_stream *is)
input_curl_writefunction); input_curl_writefunction);
curl_easy_setopt(c->easy, CURLOPT_WRITEDATA, is); curl_easy_setopt(c->easy, CURLOPT_WRITEDATA, is);
curl_easy_setopt(c->easy, CURLOPT_HTTP200ALIASES, http_200_aliases); curl_easy_setopt(c->easy, CURLOPT_HTTP200ALIASES, http_200_aliases);
curl_easy_setopt(c->easy, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(c->easy, CURLOPT_MAXREDIRS, 5);
curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, true); curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, true);
curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error); curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error);
...@@ -475,8 +479,10 @@ input_curl_easy_init(struct input_stream *is) ...@@ -475,8 +479,10 @@ input_curl_easy_init(struct input_stream *is)
return false; return false;
c->request_headers = NULL; c->request_headers = NULL;
/*
c->request_headers = curl_slist_append(c->request_headers, c->request_headers = curl_slist_append(c->request_headers,
"Icy-Metadata: 1"); "Icy-Metadata: 1");
*/
curl_easy_setopt(c->easy, CURLOPT_HTTPHEADER, c->request_headers); curl_easy_setopt(c->easy, CURLOPT_HTTPHEADER, c->request_headers);
return true; return true;
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
*/ */
#include "input_file.h" #include "input_file.h"
#include "gcc.h"
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -117,7 +116,7 @@ input_file_eof(struct input_stream *is) ...@@ -117,7 +116,7 @@ input_file_eof(struct input_stream *is)
} }
static int static int
input_file_buffer(mpd_unused struct input_stream *is) input_file_buffer(G_GNUC_UNUSED struct input_stream *is)
{ {
return 0; return 0;
} }
......
...@@ -190,7 +190,10 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param) ...@@ -190,7 +190,10 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
DEBUG("binding to address for %s\n", param->value); DEBUG("binding to address for %s\n", param->value);
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_ADDRCONFIG; hints.ai_flags = AI_PASSIVE;
#ifdef AI_ADDRCONFIG
hints.ai_flags |= AI_ADDRCONFIG;
#endif
hints.ai_family = PF_UNSPEC; hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP; hints.ai_protocol = IPPROTO_TCP;
......
...@@ -164,7 +164,7 @@ void setup_log_output(bool use_stdout) ...@@ -164,7 +164,7 @@ void setup_log_output(bool use_stdout)
} }
#define log_func(func,level) \ #define log_func(func,level) \
mpd_printf void func(const char *fmt, ...) \ G_GNUC_PRINTF(1, 2) void func(const char *fmt, ...) \
{ \ { \
if (level <= (int)log_threshold) { \ if (level <= (int)log_threshold) { \
va_list args; \ va_list args; \
...@@ -182,7 +182,7 @@ log_func(DEBUG, G_LOG_LEVEL_DEBUG) ...@@ -182,7 +182,7 @@ log_func(DEBUG, G_LOG_LEVEL_DEBUG)
#undef log_func #undef log_func
mpd_printf mpd_noreturn void FATAL(const char *fmt, ...) G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN void FATAL(const char *fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
......
...@@ -19,16 +19,15 @@ ...@@ -19,16 +19,15 @@
#ifndef MPD_LOG_H #ifndef MPD_LOG_H
#define MPD_LOG_H #define MPD_LOG_H
#include "gcc.h" #include <glib.h>
#include <stdbool.h> #include <stdbool.h>
mpd_printf void ERROR(const char *fmt, ...); G_GNUC_PRINTF(1, 2) void ERROR(const char *fmt, ...);
mpd_printf void LOG(const char *fmt, ...); G_GNUC_PRINTF(1, 2) void LOG(const char *fmt, ...);
mpd_printf void SECURE(const char *fmt, ...); G_GNUC_PRINTF(1, 2) void SECURE(const char *fmt, ...);
mpd_printf void DEBUG(const char *fmt, ...); G_GNUC_PRINTF(1, 2) void DEBUG(const char *fmt, ...);
mpd_printf void WARNING(const char *fmt, ...); G_GNUC_PRINTF(1, 2) void WARNING(const char *fmt, ...);
mpd_printf mpd_noreturn void FATAL(const char *fmt, ...); G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN void FATAL(const char *fmt, ...);
void initLog(bool verbose); void initLog(bool verbose);
......
...@@ -416,6 +416,7 @@ int main(int argc, char *argv[]) ...@@ -416,6 +416,7 @@ int main(int argc, char *argv[])
initPermissions(); initPermissions();
initPlaylist(); initPlaylist();
decoder_plugin_init_all(); decoder_plugin_init_all();
update_global_init();
init_main_notify(); init_main_notify();
...@@ -470,6 +471,8 @@ int main(int argc, char *argv[]) ...@@ -470,6 +471,8 @@ int main(int argc, char *argv[])
} }
} }
g_timer_destroy(save_state_timer);
write_state_file(); write_state_file();
playerKill(); playerKill();
finishZeroconf(); finishZeroconf();
...@@ -495,6 +498,7 @@ int main(int argc, char *argv[]) ...@@ -495,6 +498,7 @@ int main(int argc, char *argv[])
dc_deinit(); dc_deinit();
pc_deinit(); pc_deinit();
command_finish(); command_finish();
update_global_finish();
decoder_plugin_deinit_all(); decoder_plugin_deinit_all();
music_pipe_free(); music_pipe_free();
cleanUpPidFile(); cleanUpPidFile();
......
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
#include "notify.h" #include "notify.h"
#include "utils.h" #include "utils.h"
#include "ioops.h" #include "ioops.h"
#include "gcc.h"
#include "log.h" #include "log.h"
#include <assert.h> #include <assert.h>
#include <glib.h>
#include <string.h> #include <string.h>
static struct ioOps main_notify_IO; static struct ioOps main_notify_IO;
...@@ -35,7 +35,8 @@ static struct notify main_notify; ...@@ -35,7 +35,8 @@ static struct notify main_notify;
static pthread_mutex_t select_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t select_mutex = PTHREAD_MUTEX_INITIALIZER;
static int ioops_fdset(fd_set * rfds, static int ioops_fdset(fd_set * rfds,
mpd_unused fd_set * wfds, mpd_unused fd_set * efds) G_GNUC_UNUSED fd_set * wfds,
G_GNUC_UNUSED fd_set * efds)
{ {
FD_SET(main_pipe[0], rfds); FD_SET(main_pipe[0], rfds);
return main_pipe[0]; return main_pipe[0];
...@@ -51,7 +52,8 @@ static void consume_pipe(void) ...@@ -51,7 +52,8 @@ static void consume_pipe(void)
} }
static int ioops_consume(int fd_count, fd_set * rfds, static int ioops_consume(int fd_count, fd_set * rfds,
mpd_unused fd_set * wfds, mpd_unused fd_set * efds) G_GNUC_UNUSED fd_set * wfds,
G_GNUC_UNUSED fd_set * efds)
{ {
if (FD_ISSET(main_pipe[0], rfds)) { if (FD_ISSET(main_pipe[0], rfds)) {
consume_pipe(); consume_pipe();
......
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
static const char default_device[] = "default"; static const char default_device[] = "default";
enum {
MPD_ALSA_BUFFER_TIME_US = 500000,
};
#define MPD_ALSA_RETRY_NR 5 #define MPD_ALSA_RETRY_NR 5
typedef snd_pcm_sframes_t alsa_writei_t(snd_pcm_t * pcm, const void *buffer, typedef snd_pcm_sframes_t alsa_writei_t(snd_pcm_t * pcm, const void *buffer,
...@@ -62,7 +66,7 @@ static AlsaData *newAlsaData(void) ...@@ -62,7 +66,7 @@ static AlsaData *newAlsaData(void)
ret->pcmHandle = NULL; ret->pcmHandle = NULL;
ret->writei = snd_pcm_writei; ret->writei = snd_pcm_writei;
ret->useMmap = 0; ret->useMmap = 0;
ret->buffer_time = 0; ret->buffer_time = MPD_ALSA_BUFFER_TIME_US;
ret->period_time = 0; ret->period_time = 0;
return ret; return ret;
......
...@@ -17,10 +17,12 @@ ...@@ -17,10 +17,12 @@
*/ */
#include "../output_api.h" #include "../output_api.h"
#include "../utils.h"
#include "../log.h"
#include <ao/ao.h> #include <ao/ao.h>
#include <glib.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "ao"
static int driverInitCount; static int driverInitCount;
...@@ -33,22 +35,43 @@ typedef struct _AoData { ...@@ -33,22 +35,43 @@ typedef struct _AoData {
static AoData *newAoData(void) static AoData *newAoData(void)
{ {
AoData *ret = xmalloc(sizeof(AoData)); AoData *ret = g_malloc(sizeof(AoData));
ret->device = NULL; ret->device = NULL;
ret->options = NULL; ret->options = NULL;
return ret; return ret;
} }
static void audioOutputAo_error(void) static void audioOutputAo_error(const char *msg)
{ {
if (errno == AO_ENOTLIVE) { const char *error;
ERROR("not a live ao device\n");
} else if (errno == AO_EOPENDEVICE) { switch (errno) {
ERROR("not able to open audio device\n"); case AO_ENODRIVER:
} else if (errno == AO_EBADOPTION) { error = "No such libao driver";
ERROR("bad driver option\n"); break;
case AO_ENOTLIVE:
error = "This driver is not a libao live device";
break;
case AO_EBADOPTION:
error = "Invalid libao option";
break;
case AO_EOPENDEVICE:
error = "Cannot open the libao device";
break;
case AO_EFAIL:
error = "Generic libao failure";
break;
default:
error = strerror(errno);
} }
g_warning("%s: %s\n", msg, error);
} }
static void *audioOutputAo_initDriver(struct audio_output *ao, static void *audioOutputAo_initDriver(struct audio_output *ao,
...@@ -69,8 +92,8 @@ static void *audioOutputAo_initDriver(struct audio_output *ao, ...@@ -69,8 +92,8 @@ static void *audioOutputAo_initDriver(struct audio_output *ao,
if ((blockParam = getBlockParam(param, "write_size"))) { if ((blockParam = getBlockParam(param, "write_size"))) {
ad->writeSize = strtol(blockParam->value, &test, 10); ad->writeSize = strtol(blockParam->value, &test, 10);
if (*test != '\0') { if (*test != '\0') {
FATAL("\"%s\" is not a valid write size at line %i\n", g_error("\"%s\" is not a valid write size at line %i\n",
blockParam->value, blockParam->line); blockParam->value, blockParam->line);
} }
} else } else
ad->writeSize = 1024; ad->writeSize = 1024;
...@@ -85,24 +108,24 @@ static void *audioOutputAo_initDriver(struct audio_output *ao, ...@@ -85,24 +108,24 @@ static void *audioOutputAo_initDriver(struct audio_output *ao,
if (!blockParam || 0 == strcmp(blockParam->value, "default")) { if (!blockParam || 0 == strcmp(blockParam->value, "default")) {
ad->driverId = ao_default_driver_id(); ad->driverId = ao_default_driver_id();
} else if ((ad->driverId = ao_driver_id(blockParam->value)) < 0) { } else if ((ad->driverId = ao_driver_id(blockParam->value)) < 0) {
FATAL("\"%s\" is not a valid ao driver at line %i\n", g_error("\"%s\" is not a valid ao driver at line %i\n",
blockParam->value, blockParam->line); blockParam->value, blockParam->line);
} }
if ((ai = ao_driver_info(ad->driverId)) == NULL) { if ((ai = ao_driver_info(ad->driverId)) == NULL) {
FATAL("problems getting driver info for device defined at line %i\n" g_error("problems getting driver info for device defined at line %i\n"
"you may not have permission to the audio device\n", param->line); "you may not have permission to the audio device\n", param->line);
} }
DEBUG("using ao driver \"%s\" for \"%s\"\n", ai->short_name, g_debug("using ao driver \"%s\" for \"%s\"\n", ai->short_name,
audio_output_get_name(ao)); audio_output_get_name(ao));
blockParam = getBlockParam(param, "options"); blockParam = getBlockParam(param, "options");
if (blockParam) { if (blockParam) {
duplicated = xstrdup(blockParam->value); duplicated = g_strdup(blockParam->value);
} else } else
duplicated = xstrdup(""); duplicated = g_strdup("");
if (strlen(duplicated)) { if (strlen(duplicated)) {
stk1 = NULL; stk1 = NULL;
...@@ -111,7 +134,7 @@ static void *audioOutputAo_initDriver(struct audio_output *ao, ...@@ -111,7 +134,7 @@ static void *audioOutputAo_initDriver(struct audio_output *ao,
stk2 = NULL; stk2 = NULL;
key = strtok_r(n1, "=", &stk2); key = strtok_r(n1, "=", &stk2);
if (!key) if (!key)
FATAL("problems parsing options \"%s\"\n", n1); g_error("problems parsing options \"%s\"\n", n1);
/*found = 0; /*found = 0;
for(i=0;i<ai->option_count;i++) { for(i=0;i<ai->option_count;i++) {
if(strcmp(ai->options[i],key)==0) { if(strcmp(ai->options[i],key)==0) {
...@@ -126,7 +149,7 @@ static void *audioOutputAo_initDriver(struct audio_output *ao, ...@@ -126,7 +149,7 @@ static void *audioOutputAo_initDriver(struct audio_output *ao,
} */ } */
value = strtok_r(NULL, "", &stk2); value = strtok_r(NULL, "", &stk2);
if (!value) if (!value)
FATAL("problems parsing options \"%s\"\n", n1); g_error("problems parsing options \"%s\"\n", n1);
ao_append_option(&ad->options, key, value); ao_append_option(&ad->options, key, value);
n1 = strtok_r(NULL, ";", &stk1); n1 = strtok_r(NULL, ";", &stk1);
} }
...@@ -185,8 +208,10 @@ audioOutputAo_openDevice(void *data, struct audio_format *audio_format) ...@@ -185,8 +208,10 @@ audioOutputAo_openDevice(void *data, struct audio_format *audio_format)
ad->device = ao_open_live(ad->driverId, &format, ad->options); ad->device = ao_open_live(ad->driverId, &format, ad->options);
if (ad->device == NULL) if (ad->device == NULL) {
audioOutputAo_error("Failed to open libao");
return false; return false;
}
return true; return true;
} }
...@@ -222,8 +247,7 @@ audioOutputAo_play(void *data, const char *playChunk, size_t size) ...@@ -222,8 +247,7 @@ audioOutputAo_play(void *data, const char *playChunk, size_t size)
? size : (size_t)ad->writeSize; ? size : (size_t)ad->writeSize;
if (ao_play_deconst(ad->device, playChunk, chunk_size) == 0) { if (ao_play_deconst(ad->device, playChunk, chunk_size) == 0) {
audioOutputAo_error(); audioOutputAo_error("Closing libao device due to play error");
ERROR("closing audio device due to write error\n");
return false; return false;
} }
......
...@@ -20,13 +20,18 @@ ...@@ -20,13 +20,18 @@
*/ */
#include "../output_api.h" #include "../output_api.h"
#include "../utils.h"
#include "../log.h"
#include <glib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "mvp"
typedef struct { typedef struct {
unsigned long dsp_status; unsigned long dsp_status;
...@@ -92,8 +97,8 @@ static bool mvp_testDefault(void) ...@@ -92,8 +97,8 @@ static bool mvp_testDefault(void)
return true; return true;
} }
WARNING("Error opening PCM device \"/dev/adec_pcm\": %s\n", g_warning("Error opening PCM device \"/dev/adec_pcm\": %s\n",
strerror(errno)); strerror(errno));
return false; return false;
} }
...@@ -102,7 +107,7 @@ static void *mvp_initDriver(mpd_unused struct audio_output *audio_output, ...@@ -102,7 +107,7 @@ static void *mvp_initDriver(mpd_unused struct audio_output *audio_output,
mpd_unused const struct audio_format *audio_format, mpd_unused const struct audio_format *audio_format,
mpd_unused ConfigParam *param) mpd_unused ConfigParam *param)
{ {
MvpData *md = xmalloc(sizeof(MvpData)); MvpData *md = g_new(MvpData, 1);
md->audio_output = audio_output; md->audio_output = audio_output;
md->fd = -1; md->fd = -1;
...@@ -156,22 +161,23 @@ static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels, ...@@ -156,22 +161,23 @@ static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels,
} }
if (iloop >= numfrequencies) { if (iloop >= numfrequencies) {
ERROR("Can not find suitable output frequency for %ld\n", rate); g_warning("Can not find suitable output frequency for %ld\n",
rate);
return -1; return -1;
} }
if (ioctl(md->fd, MVP_SET_AUD_FORMAT, &mix) < 0) { if (ioctl(md->fd, MVP_SET_AUD_FORMAT, &mix) < 0) {
ERROR("Can not set audio format\n"); g_warning("Can not set audio format\n");
return -1; return -1;
} }
if (ioctl(md->fd, MVP_SET_AUD_SYNC, 2) != 0) { if (ioctl(md->fd, MVP_SET_AUD_SYNC, 2) != 0) {
ERROR("Can not set audio sync\n"); g_warning("Can not set audio sync\n");
return -1; return -1;
} }
if (ioctl(md->fd, MVP_SET_AUD_PLAY, 0) < 0) { if (ioctl(md->fd, MVP_SET_AUD_PLAY, 0) < 0) {
ERROR("Can not set audio play mode\n"); g_warning("Can not set audio play mode\n");
return -1; return -1;
} }
...@@ -186,24 +192,29 @@ mvp_openDevice(void *data, struct audio_format *audioFormat) ...@@ -186,24 +192,29 @@ mvp_openDevice(void *data, struct audio_format *audioFormat)
int mix[5] = { 0, 2, 7, 1, 0 }; int mix[5] = { 0, 2, 7, 1, 0 };
if ((md->fd = open("/dev/adec_pcm", O_RDWR | O_NONBLOCK)) < 0) { if ((md->fd = open("/dev/adec_pcm", O_RDWR | O_NONBLOCK)) < 0) {
ERROR("Error opening /dev/adec_pcm: %s\n", strerror(errno)); g_warning("Error opening /dev/adec_pcm: %s\n",
strerror(errno));
return false; return false;
} }
if (ioctl(md->fd, MVP_SET_AUD_SRC, 1) < 0) { if (ioctl(md->fd, MVP_SET_AUD_SRC, 1) < 0) {
ERROR("Error setting audio source: %s\n", strerror(errno)); g_warning("Error setting audio source: %s\n",
strerror(errno));
return false; return false;
} }
if (ioctl(md->fd, MVP_SET_AUD_STREAMTYPE, 0) < 0) { if (ioctl(md->fd, MVP_SET_AUD_STREAMTYPE, 0) < 0) {
ERROR("Error setting audio streamtype: %s\n", strerror(errno)); g_warning("Error setting audio streamtype: %s\n",
strerror(errno));
return false; return false;
} }
if (ioctl(md->fd, MVP_SET_AUD_FORMAT, &mix) < 0) { if (ioctl(md->fd, MVP_SET_AUD_FORMAT, &mix) < 0) {
ERROR("Error setting audio format: %s\n", strerror(errno)); g_warning("Error setting audio format: %s\n",
strerror(errno));
return false; return false;
} }
ioctl(md->fd, MVP_SET_AUD_STC, &stc); ioctl(md->fd, MVP_SET_AUD_STC, &stc);
if (ioctl(md->fd, MVP_SET_AUD_BYPASS, 1) < 0) { if (ioctl(md->fd, MVP_SET_AUD_BYPASS, 1) < 0) {
ERROR("Error setting audio streamtype: %s\n", strerror(errno)); g_warning("Error setting audio streamtype: %s\n",
strerror(errno));
return false; return false;
} }
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
...@@ -251,8 +262,8 @@ mvp_playAudio(void *data, const char *playChunk, size_t size) ...@@ -251,8 +262,8 @@ mvp_playAudio(void *data, const char *playChunk, size_t size)
if (ret < 0) { if (ret < 0) {
if (errno == EINTR) if (errno == EINTR)
continue; continue;
ERROR("closing mvp PCM device due to write error: " g_warning("closing mvp PCM device due to write error: "
"%s\n", strerror(errno)); "%s\n", strerror(errno));
return false; return false;
} }
playChunk += ret; playChunk += ret;
......
...@@ -20,12 +20,17 @@ ...@@ -20,12 +20,17 @@
*/ */
#include "../output_api.h" #include "../output_api.h"
#include "../utils.h"
#include "../log.h"
#include <glib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "oss"
#if defined(__OpenBSD__) || defined(__NetBSD__) #if defined(__OpenBSD__) || defined(__NetBSD__)
# include <soundcard.h> # include <soundcard.h>
...@@ -153,8 +158,8 @@ static void addSupportedParam(OssData * od, unsigned param, int val) ...@@ -153,8 +158,8 @@ static void addSupportedParam(OssData * od, unsigned param, int val)
enum oss_param idx = getIndexForParam(param); enum oss_param idx = getIndexForParam(param);
od->numSupported[idx]++; od->numSupported[idx]++;
od->supported[idx] = xrealloc(od->supported[idx], od->supported[idx] = g_realloc(od->supported[idx],
od->numSupported[idx] * sizeof(int)); od->numSupported[idx] * sizeof(int));
od->supported[idx][od->numSupported[idx] - 1] = val; od->supported[idx][od->numSupported[idx] - 1] = val;
} }
...@@ -163,9 +168,9 @@ static void addUnsupportedParam(OssData * od, unsigned param, int val) ...@@ -163,9 +168,9 @@ static void addUnsupportedParam(OssData * od, unsigned param, int val)
enum oss_param idx = getIndexForParam(param); enum oss_param idx = getIndexForParam(param);
od->numUnsupported[idx]++; od->numUnsupported[idx]++;
od->unsupported[idx] = xrealloc(od->unsupported[idx], od->unsupported[idx] = g_realloc(od->unsupported[idx],
od->numUnsupported[idx] * od->numUnsupported[idx] *
sizeof(int)); sizeof(int));
od->unsupported[idx][od->numUnsupported[idx] - 1] = val; od->unsupported[idx][od->numUnsupported[idx] - 1] = val;
} }
...@@ -182,8 +187,8 @@ static void removeSupportedParam(OssData * od, unsigned param, int val) ...@@ -182,8 +187,8 @@ static void removeSupportedParam(OssData * od, unsigned param, int val)
} }
od->numSupported[idx]--; od->numSupported[idx]--;
od->supported[idx] = xrealloc(od->supported[idx], od->supported[idx] = g_realloc(od->supported[idx],
od->numSupported[idx] * sizeof(int)); od->numSupported[idx] * sizeof(int));
} }
static void removeUnsupportedParam(OssData * od, unsigned param, int val) static void removeUnsupportedParam(OssData * od, unsigned param, int val)
...@@ -199,9 +204,9 @@ static void removeUnsupportedParam(OssData * od, unsigned param, int val) ...@@ -199,9 +204,9 @@ static void removeUnsupportedParam(OssData * od, unsigned param, int val)
} }
od->numUnsupported[idx]--; od->numUnsupported[idx]--;
od->unsupported[idx] = xrealloc(od->unsupported[idx], od->unsupported[idx] = g_realloc(od->unsupported[idx],
od->numUnsupported[idx] * od->numUnsupported[idx] *
sizeof(int)); sizeof(int));
} }
static enum oss_support static enum oss_support
...@@ -244,7 +249,7 @@ static void unsupportParam(OssData * od, unsigned param, int val) ...@@ -244,7 +249,7 @@ static void unsupportParam(OssData * od, unsigned param, int val)
static OssData *newOssData(void) static OssData *newOssData(void)
{ {
OssData *ret = xmalloc(sizeof(OssData)); OssData *ret = g_new(OssData, 1);
ret->device = NULL; ret->device = NULL;
ret->fd = -1; ret->fd = -1;
...@@ -273,18 +278,12 @@ static OssData *newOssData(void) ...@@ -273,18 +278,12 @@ static OssData *newOssData(void)
static void freeOssData(OssData * od) static void freeOssData(OssData * od)
{ {
if (od->supported[OSS_RATE]) g_free(od->supported[OSS_RATE]);
free(od->supported[OSS_RATE]); g_free(od->supported[OSS_CHANNELS]);
if (od->supported[OSS_CHANNELS]) g_free(od->supported[OSS_BITS]);
free(od->supported[OSS_CHANNELS]); g_free(od->unsupported[OSS_RATE]);
if (od->supported[OSS_BITS]) g_free(od->unsupported[OSS_CHANNELS]);
free(od->supported[OSS_BITS]); g_free(od->unsupported[OSS_BITS]);
if (od->unsupported[OSS_RATE])
free(od->unsupported[OSS_RATE]);
if (od->unsupported[OSS_CHANNELS])
free(od->unsupported[OSS_CHANNELS]);
if (od->unsupported[OSS_BITS])
free(od->unsupported[OSS_BITS]);
free(od); free(od);
} }
...@@ -326,13 +325,13 @@ static bool oss_testDefault(void) ...@@ -326,13 +325,13 @@ static bool oss_testDefault(void)
{ {
int fd, i; int fd, i;
for (i = ARRAY_SIZE(default_devices); --i >= 0; ) { for (i = G_N_ELEMENTS(default_devices); --i >= 0; ) {
if ((fd = open(default_devices[i], O_WRONLY)) >= 0) { if ((fd = open(default_devices[i], O_WRONLY)) >= 0) {
xclose(fd); close(fd);
return true; return true;
} }
WARNING("Error opening OSS device \"%s\": %s\n", g_warning("Error opening OSS device \"%s\": %s\n",
default_devices[i], strerror(errno)); default_devices[i], strerror(errno));
} }
return false; return false;
...@@ -341,10 +340,10 @@ static bool oss_testDefault(void) ...@@ -341,10 +340,10 @@ static bool oss_testDefault(void)
static void *oss_open_default(ConfigParam *param) static void *oss_open_default(ConfigParam *param)
{ {
int i; int i;
int err[ARRAY_SIZE(default_devices)]; int err[G_N_ELEMENTS(default_devices)];
int ret[ARRAY_SIZE(default_devices)]; int ret[G_N_ELEMENTS(default_devices)];
for (i = ARRAY_SIZE(default_devices); --i >= 0; ) { for (i = G_N_ELEMENTS(default_devices); --i >= 0; ) {
ret[i] = oss_statDevice(default_devices[i], &err[i]); ret[i] = oss_statDevice(default_devices[i], &err[i]);
if (ret[i] == 0) { if (ret[i] == 0) {
OssData *od = newOssData(); OssData *od = newOssData();
...@@ -354,25 +353,26 @@ static void *oss_open_default(ConfigParam *param) ...@@ -354,25 +353,26 @@ static void *oss_open_default(ConfigParam *param)
} }
if (param) if (param)
ERROR("error trying to open specified OSS device" g_warning("error trying to open specified OSS device"
" at line %i\n", param->line); " at line %i\n", param->line);
else else
ERROR("error trying to open default OSS device\n"); g_warning("error trying to open default OSS device\n");
for (i = ARRAY_SIZE(default_devices); --i >= 0; ) { for (i = G_N_ELEMENTS(default_devices); --i >= 0; ) {
const char *dev = default_devices[i]; const char *dev = default_devices[i];
switch(ret[i]) { switch(ret[i]) {
case OSS_STAT_DOESN_T_EXIST: case OSS_STAT_DOESN_T_EXIST:
ERROR("%s not found\n", dev); g_warning("%s not found\n", dev);
break; break;
case OSS_STAT_NOT_CHAR_DEV: case OSS_STAT_NOT_CHAR_DEV:
ERROR("%s is not a character device\n", dev); g_warning("%s is not a character device\n", dev);
break; break;
case OSS_STAT_NO_PERMS: case OSS_STAT_NO_PERMS:
ERROR("%s: permission denied\n", dev); g_warning("%s: permission denied\n", dev);
break; break;
default: default:
ERROR("Error accessing %s: %s\n", dev, strerror(err[i])); g_warning("Error accessing %s: %s\n",
dev, strerror(err[i]));
} }
} }
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -443,24 +443,25 @@ static bool oss_open(OssData *od) ...@@ -443,24 +443,25 @@ static bool oss_open(OssData *od)
int tmp; int tmp;
if ((od->fd = open(od->device, O_WRONLY)) < 0) { if ((od->fd = open(od->device, O_WRONLY)) < 0) {
ERROR("Error opening OSS device \"%s\": %s\n", od->device, g_warning("Error opening OSS device \"%s\": %s\n", od->device,
strerror(errno)); strerror(errno));
goto fail; goto fail;
} }
tmp = od->audio_format.channels; tmp = od->audio_format.channels;
if (setParam(od, SNDCTL_DSP_CHANNELS, &tmp)) { if (setParam(od, SNDCTL_DSP_CHANNELS, &tmp)) {
ERROR("OSS device \"%s\" does not support %u channels: %s\n", g_warning("OSS device \"%s\" does not support %u channels: %s\n",
od->device, od->audio_format.channels, strerror(errno)); od->device, od->audio_format.channels,
strerror(errno));
goto fail; goto fail;
} }
od->audio_format.channels = tmp; od->audio_format.channels = tmp;
tmp = od->audio_format.sample_rate; tmp = od->audio_format.sample_rate;
if (setParam(od, SNDCTL_DSP_SPEED, &tmp)) { if (setParam(od, SNDCTL_DSP_SPEED, &tmp)) {
ERROR("OSS device \"%s\" does not support %u Hz audio: %s\n", g_warning("OSS device \"%s\" does not support %u Hz audio: %s\n",
od->device, od->audio_format.sample_rate, od->device, od->audio_format.sample_rate,
strerror(errno)); strerror(errno));
goto fail; goto fail;
} }
od->audio_format.sample_rate = tmp; od->audio_format.sample_rate = tmp;
...@@ -481,8 +482,8 @@ static bool oss_open(OssData *od) ...@@ -481,8 +482,8 @@ static bool oss_open(OssData *od)
} }
if (setParam(od, SNDCTL_DSP_SAMPLESIZE, &tmp)) { if (setParam(od, SNDCTL_DSP_SAMPLESIZE, &tmp)) {
ERROR("OSS device \"%s\" does not support %u bit audio: %s\n", g_warning("OSS device \"%s\" does not support %u bit audio: %s\n",
od->device, tmp, strerror(errno)); od->device, tmp, strerror(errno));
goto fail; goto fail;
} }
...@@ -507,10 +508,10 @@ oss_openDevice(void *data, struct audio_format *audioFormat) ...@@ -507,10 +508,10 @@ oss_openDevice(void *data, struct audio_format *audioFormat)
*audioFormat = od->audio_format; *audioFormat = od->audio_format;
DEBUG("oss device \"%s\" will be playing %u bit %u channel audio at " g_debug("device \"%s\" will be playing %u bit %u channel audio at "
"%u Hz\n", od->device, "%u Hz\n", od->device,
od->audio_format.bits, od->audio_format.channels, od->audio_format.bits, od->audio_format.channels,
od->audio_format.sample_rate); od->audio_format.sample_rate);
return ret; return ret;
} }
...@@ -547,8 +548,8 @@ oss_playAudio(void *data, const char *playChunk, size_t size) ...@@ -547,8 +548,8 @@ oss_playAudio(void *data, const char *playChunk, size_t size)
if (ret < 0) { if (ret < 0) {
if (errno == EINTR) if (errno == EINTR)
continue; continue;
ERROR("closing oss device \"%s\" due to write error: " g_warning("closing oss device \"%s\" due to write error: "
"%s\n", od->device, strerror(errno)); "%s\n", od->device, strerror(errno));
return false; return false;
} }
playChunk += ret; playChunk += ret;
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
*/ */
#include "shout_plugin.h" #include "shout_plugin.h"
#include "../utils.h"
#include <lame/lame.h> #include <lame/lame.h>
#include <stdlib.h>
struct lame_data { struct lame_data {
lame_global_flags *gfp; lame_global_flags *gfp;
...@@ -28,10 +28,8 @@ struct lame_data { ...@@ -28,10 +28,8 @@ struct lame_data {
static int shout_mp3_encoder_init(struct shout_data *sd) static int shout_mp3_encoder_init(struct shout_data *sd)
{ {
struct lame_data *ld; struct lame_data *ld = g_new(struct lame_data, 1);
if (NULL == (ld = xmalloc(sizeof(*ld))))
FATAL("error initializing lame encoder data\n");
sd->encoder_data = ld; sd->encoder_data = ld;
return 0; return 0;
...@@ -45,7 +43,7 @@ static int shout_mp3_encoder_clear_encoder(struct shout_data *sd) ...@@ -45,7 +43,7 @@ static int shout_mp3_encoder_clear_encoder(struct shout_data *sd)
if ((ret = lame_encode_flush(ld->gfp, buf->data + buf->len, if ((ret = lame_encode_flush(ld->gfp, buf->data + buf->len,
buf->len)) < 0) buf->len)) < 0)
ERROR("error flushing lame buffers\n"); g_warning("error flushing lame buffers\n");
return (ret > 0); return (ret > 0);
} }
...@@ -63,40 +61,40 @@ static int shout_mp3_encoder_init_encoder(struct shout_data *sd) ...@@ -63,40 +61,40 @@ static int shout_mp3_encoder_init_encoder(struct shout_data *sd)
struct lame_data *ld = (struct lame_data *)sd->encoder_data; struct lame_data *ld = (struct lame_data *)sd->encoder_data;
if (NULL == (ld->gfp = lame_init())) { if (NULL == (ld->gfp = lame_init())) {
ERROR("error initializing lame encoder for shout\n"); g_warning("error initializing lame encoder for shout\n");
return -1; return -1;
} }
if (sd->quality >= -1.0) { if (sd->quality >= -1.0) {
if (0 != lame_set_VBR(ld->gfp, vbr_rh)) { if (0 != lame_set_VBR(ld->gfp, vbr_rh)) {
ERROR("error setting lame VBR mode\n"); g_warning("error setting lame VBR mode\n");
return -1; return -1;
} }
if (0 != lame_set_VBR_q(ld->gfp, sd->quality)) { if (0 != lame_set_VBR_q(ld->gfp, sd->quality)) {
ERROR("error setting lame VBR quality\n"); g_warning("error setting lame VBR quality\n");
return -1; return -1;
} }
} else { } else {
if (0 != lame_set_brate(ld->gfp, sd->bitrate)) { if (0 != lame_set_brate(ld->gfp, sd->bitrate)) {
ERROR("error setting lame bitrate\n"); g_warning("error setting lame bitrate\n");
return -1; return -1;
} }
} }
if (0 != lame_set_num_channels(ld->gfp, if (0 != lame_set_num_channels(ld->gfp,
sd->audio_format.channels)) { sd->audio_format.channels)) {
ERROR("error setting lame num channels\n"); g_warning("error setting lame num channels\n");
return -1; return -1;
} }
if (0 != lame_set_in_samplerate(ld->gfp, if (0 != lame_set_in_samplerate(ld->gfp,
sd->audio_format.sample_rate)) { sd->audio_format.sample_rate)) {
ERROR("error setting lame sample rate\n"); g_warning("error setting lame sample rate\n");
return -1; return -1;
} }
if (0 > lame_init_params(ld->gfp)) if (0 > lame_init_params(ld->gfp))
FATAL("error initializing lame params\n"); g_error("error initializing lame params\n");
return 0; return 0;
} }
...@@ -133,9 +131,9 @@ static int shout_mp3_encoder_send_metadata(struct shout_data *sd, ...@@ -133,9 +131,9 @@ static int shout_mp3_encoder_send_metadata(struct shout_data *sd,
static int shout_mp3_encoder_encode(struct shout_data *sd, static int shout_mp3_encoder_encode(struct shout_data *sd,
const char * chunk, size_t len) const char * chunk, size_t len)
{ {
const int16_t *src = (const int16_t*)chunk;
unsigned int i; unsigned int i;
int j; float *left, *right;
float (*lamebuf)[2];
struct shout_buffer *buf = &(sd->buf); struct shout_buffer *buf = &(sd->buf);
unsigned int samples; unsigned int samples;
int bytes = audio_format_sample_size(&sd->audio_format); int bytes = audio_format_sample_size(&sd->audio_format);
...@@ -143,25 +141,31 @@ static int shout_mp3_encoder_encode(struct shout_data *sd, ...@@ -143,25 +141,31 @@ static int shout_mp3_encoder_encode(struct shout_data *sd,
int bytes_out; int bytes_out;
samples = len / (bytes * sd->audio_format.channels); samples = len / (bytes * sd->audio_format.channels);
/* rough estimate, from lame.h */ left = g_malloc(sizeof(left[0]) * samples);
lamebuf = xmalloc(sizeof(float) * (1.25 * samples + 7200)); if (sd->audio_format.channels > 1)
right = g_malloc(sizeof(left[0]) * samples);
else
right = left;
/* this is for only 16-bit audio */ /* this is for only 16-bit audio */
for (i = 0; i < samples; i++) { for (i = 0; i < samples; i++) {
for (j = 0; j < sd->audio_format.channels; j++) { left[i] = src[0];
lamebuf[j][i] = *((const int16_t *) chunk); if (right != left)
chunk += bytes; right[i] = src[1];
} src += sd->audio_format.channels;
} }
bytes_out = lame_encode_buffer_float(ld->gfp, lamebuf[0], lamebuf[1], bytes_out = lame_encode_buffer_float(ld->gfp, left, right,
samples, buf->data, samples, buf->data,
sizeof(buf->data) - buf->len); sizeof(buf->data) - buf->len);
free(lamebuf);
g_free(left);
if (right != left)
g_free(right);
if (0 > bytes_out) { if (0 > bytes_out) {
ERROR("error encoding lame buffer for shout\n"); g_warning("error encoding lame buffer for shout\n");
lame_close(ld->gfp); lame_close(ld->gfp);
ld->gfp = NULL; ld->gfp = NULL;
return -1; return -1;
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
*/ */
#include "shout_plugin.h" #include "shout_plugin.h"
#include "../utils.h"
#include <vorbis/vorbisenc.h> #include <vorbis/vorbisenc.h>
#include <stdlib.h>
struct ogg_vorbis_data { struct ogg_vorbis_data {
ogg_stream_state os; ogg_stream_state os;
...@@ -80,7 +80,7 @@ static int copy_ogg_buffer_to_shout_buffer(ogg_page *og, ...@@ -80,7 +80,7 @@ static int copy_ogg_buffer_to_shout_buffer(ogg_page *og,
og->header, og->header_len); og->header, og->header_len);
buf->len += og->header_len; buf->len += og->header_len;
} else { } else {
ERROR("%s: not enough buffer space!\n", __func__); g_warning("%s: not enough buffer space!\n", __func__);
return -1; return -1;
} }
...@@ -89,7 +89,7 @@ static int copy_ogg_buffer_to_shout_buffer(ogg_page *og, ...@@ -89,7 +89,7 @@ static int copy_ogg_buffer_to_shout_buffer(ogg_page *og,
og->body, og->body_len); og->body, og->body_len);
buf->len += og->body_len; buf->len += og->body_len;
} else { } else {
ERROR("%s: not enough buffer space!\n", __func__); g_warning("%s: not enough buffer space!\n", __func__);
return -1; return -1;
} }
...@@ -167,10 +167,8 @@ static void shout_ogg_encoder_finish(struct shout_data *sd) ...@@ -167,10 +167,8 @@ static void shout_ogg_encoder_finish(struct shout_data *sd)
static int shout_ogg_encoder_init(struct shout_data *sd) static int shout_ogg_encoder_init(struct shout_data *sd)
{ {
struct ogg_vorbis_data *od; struct ogg_vorbis_data *od = g_new(struct ogg_vorbis_data, 1);
if (NULL == (od = xmalloc(sizeof(*od))))
FATAL("error initializing ogg vorbis encoder data\n");
sd->encoder_data = od; sd->encoder_data = od;
return 0; return 0;
...@@ -187,7 +185,7 @@ static int reinit_encoder(struct shout_data *sd) ...@@ -187,7 +185,7 @@ static int reinit_encoder(struct shout_data *sd)
sd->audio_format.channels, sd->audio_format.channels,
sd->audio_format.sample_rate, sd->audio_format.sample_rate,
sd->quality * 0.1)) { sd->quality * 0.1)) {
ERROR("error initializing vorbis vbr\n"); g_warning("error initializing vorbis vbr\n");
vorbis_info_clear(&od->vi); vorbis_info_clear(&od->vi);
return -1; return -1;
} }
...@@ -196,7 +194,7 @@ static int reinit_encoder(struct shout_data *sd) ...@@ -196,7 +194,7 @@ static int reinit_encoder(struct shout_data *sd)
sd->audio_format.channels, sd->audio_format.channels,
sd->audio_format.sample_rate, -1.0, sd->audio_format.sample_rate, -1.0,
sd->bitrate * 1000, -1.0)) { sd->bitrate * 1000, -1.0)) {
ERROR("error initializing vorbis encoder\n"); g_warning("error initializing vorbis encoder\n");
vorbis_info_clear(&od->vi); vorbis_info_clear(&od->vi);
return -1; return -1;
} }
...@@ -216,7 +214,7 @@ static int shout_ogg_encoder_init_encoder(struct shout_data *sd) ...@@ -216,7 +214,7 @@ static int shout_ogg_encoder_init_encoder(struct shout_data *sd)
return -1; return -1;
if (send_ogg_vorbis_header(sd)) { if (send_ogg_vorbis_header(sd)) {
ERROR("error sending ogg vorbis header for shout\n"); g_warning("error sending ogg vorbis header for shout\n");
return -1; return -1;
} }
......
...@@ -18,11 +18,9 @@ ...@@ -18,11 +18,9 @@
#include "shout_plugin.h" #include "shout_plugin.h"
#ifdef HAVE_SHOUT
#include "../utils.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#define CONN_ATTEMPT_INTERVAL 60 #define CONN_ATTEMPT_INTERVAL 60
#define DEFAULT_CONN_TIMEOUT 2 #define DEFAULT_CONN_TIMEOUT 2
...@@ -53,7 +51,7 @@ shout_encoder_plugin_get(const char *name) ...@@ -53,7 +51,7 @@ shout_encoder_plugin_get(const char *name)
static struct shout_data *new_shout_data(void) static struct shout_data *new_shout_data(void)
{ {
struct shout_data *ret = xmalloc(sizeof(*ret)); struct shout_data *ret = g_new(struct shout_data, 1);
ret->shout_conn = shout_new(); ret->shout_conn = shout_new();
ret->shout_meta = shout_metadata_new(); ret->shout_meta = shout_metadata_new();
...@@ -88,8 +86,8 @@ static void free_shout_data(struct shout_data *sd) ...@@ -88,8 +86,8 @@ static void free_shout_data(struct shout_data *sd)
#define check_block_param(name) { \ #define check_block_param(name) { \
block_param = getBlockParam(param, name); \ block_param = getBlockParam(param, name); \
if (!block_param) { \ if (!block_param) { \
FATAL("no \"%s\" defined for shout device defined at line " \ g_error("no \"%s\" defined for shout device defined at line " \
"%i\n", name, param->line); \ "%i\n", name, param->line); \
} \ } \
} }
...@@ -129,8 +127,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output, ...@@ -129,8 +127,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
port = strtol(block_param->value, &test, 10); port = strtol(block_param->value, &test, 10);
if (*test != '\0' || port <= 0) { if (*test != '\0' || port <= 0) {
FATAL("shout port \"%s\" is not a positive integer, line %i\n", g_error("shout port \"%s\" is not a positive integer, line %i\n",
block_param->value, block_param->line); block_param->value, block_param->line);
} }
check_block_param("password"); check_block_param("password");
...@@ -157,31 +155,31 @@ static void *my_shout_init_driver(struct audio_output *audio_output, ...@@ -157,31 +155,31 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
sd->quality = strtod(block_param->value, &test); sd->quality = strtod(block_param->value, &test);
if (*test != '\0' || sd->quality < -1.0 || sd->quality > 10.0) { if (*test != '\0' || sd->quality < -1.0 || sd->quality > 10.0) {
FATAL("shout quality \"%s\" is not a number in the " g_error("shout quality \"%s\" is not a number in the "
"range -1 to 10, line %i\n", block_param->value, "range -1 to 10, line %i\n", block_param->value,
block_param->line); block_param->line);
} }
block_param = getBlockParam(param, "bitrate"); block_param = getBlockParam(param, "bitrate");
if (block_param) { if (block_param) {
FATAL("quality (line %i) and bitrate (line %i) are " g_error("quality (line %i) and bitrate (line %i) are "
"both defined for shout output\n", line, "both defined for shout output\n", line,
block_param->line); block_param->line);
} }
} else { } else {
block_param = getBlockParam(param, "bitrate"); block_param = getBlockParam(param, "bitrate");
if (!block_param) { if (!block_param) {
FATAL("neither bitrate nor quality defined for shout " g_error("neither bitrate nor quality defined for shout "
"output at line %i\n", param->line); "output at line %i\n", param->line);
} }
sd->bitrate = strtol(block_param->value, &test, 10); sd->bitrate = strtol(block_param->value, &test, 10);
if (*test != '\0' || sd->bitrate <= 0) { if (*test != '\0' || sd->bitrate <= 0) {
FATAL("bitrate at line %i should be a positive integer " g_error("bitrate at line %i should be a positive integer "
"\n", block_param->line); "\n", block_param->line);
} }
} }
...@@ -197,24 +195,24 @@ static void *my_shout_init_driver(struct audio_output *audio_output, ...@@ -197,24 +195,24 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
else if (0 == strcmp(block_param->value, "ogg")) else if (0 == strcmp(block_param->value, "ogg"))
encoding = block_param->value; encoding = block_param->value;
else else
FATAL("shout encoding \"%s\" is not \"ogg\" or " g_error("shout encoding \"%s\" is not \"ogg\" or "
"\"mp3\", line %i\n", block_param->value, "\"mp3\", line %i\n", block_param->value,
block_param->line); block_param->line);
} else { } else {
encoding = "ogg"; encoding = "ogg";
} }
sd->encoder = shout_encoder_plugin_get(encoding); sd->encoder = shout_encoder_plugin_get(encoding);
if (sd->encoder == NULL) if (sd->encoder == NULL)
FATAL("couldn't find shout encoder plugin for \"%s\" " g_error("couldn't find shout encoder plugin for \"%s\" "
"at line %i\n", encoding, block_param->line); "at line %i\n", encoding, block_param->line);
block_param = getBlockParam(param, "protocol"); block_param = getBlockParam(param, "protocol");
if (block_param) { if (block_param) {
if (0 == strcmp(block_param->value, "shoutcast") && if (0 == strcmp(block_param->value, "shoutcast") &&
0 != strcmp(encoding, "mp3")) 0 != strcmp(encoding, "mp3"))
FATAL("you cannot stream \"%s\" to shoutcast, use mp3\n", g_error("you cannot stream \"%s\" to shoutcast, use mp3\n",
encoding); encoding);
else if (0 == strcmp(block_param->value, "shoutcast")) else if (0 == strcmp(block_param->value, "shoutcast"))
protocol = SHOUT_PROTOCOL_ICY; protocol = SHOUT_PROTOCOL_ICY;
else if (0 == strcmp(block_param->value, "icecast1")) else if (0 == strcmp(block_param->value, "icecast1"))
...@@ -222,10 +220,10 @@ static void *my_shout_init_driver(struct audio_output *audio_output, ...@@ -222,10 +220,10 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
else if (0 == strcmp(block_param->value, "icecast2")) else if (0 == strcmp(block_param->value, "icecast2"))
protocol = SHOUT_PROTOCOL_HTTP; protocol = SHOUT_PROTOCOL_HTTP;
else else
FATAL("shout protocol \"%s\" is not \"shoutcast\" or " g_error("shout protocol \"%s\" is not \"shoutcast\" or "
"\"icecast1\"or " "\"icecast1\"or "
"\"icecast2\", line %i\n", block_param->value, "\"icecast2\", line %i\n", block_param->value,
block_param->line); block_param->line);
} else { } else {
protocol = SHOUT_PROTOCOL_HTTP; protocol = SHOUT_PROTOCOL_HTTP;
} }
...@@ -242,8 +240,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output, ...@@ -242,8 +240,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
!= SHOUTERR_SUCCESS || != SHOUTERR_SUCCESS ||
shout_set_protocol(sd->shout_conn, protocol) != SHOUTERR_SUCCESS || shout_set_protocol(sd->shout_conn, protocol) != SHOUTERR_SUCCESS ||
shout_set_agent(sd->shout_conn, "MPD") != SHOUTERR_SUCCESS) { shout_set_agent(sd->shout_conn, "MPD") != SHOUTERR_SUCCESS) {
FATAL("error configuring shout defined at line %i: %s\n", g_error("error configuring shout defined at line %i: %s\n",
param->line, shout_get_error(sd->shout_conn)); param->line, shout_get_error(sd->shout_conn));
} }
/* optional paramters */ /* optional paramters */
...@@ -251,22 +249,22 @@ static void *my_shout_init_driver(struct audio_output *audio_output, ...@@ -251,22 +249,22 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
if (block_param) { if (block_param) {
sd->timeout = (int)strtol(block_param->value, &test, 10); sd->timeout = (int)strtol(block_param->value, &test, 10);
if (*test != '\0' || sd->timeout <= 0) { if (*test != '\0' || sd->timeout <= 0) {
FATAL("shout timeout is not a positive integer, " g_error("shout timeout is not a positive integer, "
"line %i\n", block_param->line); "line %i\n", block_param->line);
} }
} }
block_param = getBlockParam(param, "genre"); block_param = getBlockParam(param, "genre");
if (block_param && shout_set_genre(sd->shout_conn, block_param->value)) { if (block_param && shout_set_genre(sd->shout_conn, block_param->value)) {
FATAL("error configuring shout defined at line %i: %s\n", g_error("error configuring shout defined at line %i: %s\n",
param->line, shout_get_error(sd->shout_conn)); param->line, shout_get_error(sd->shout_conn));
} }
block_param = getBlockParam(param, "description"); block_param = getBlockParam(param, "description");
if (block_param && shout_set_description(sd->shout_conn, if (block_param && shout_set_description(sd->shout_conn,
block_param->value)) { block_param->value)) {
FATAL("error configuring shout defined at line %i: %s\n", g_error("error configuring shout defined at line %i: %s\n",
param->line, shout_get_error(sd->shout_conn)); param->line, shout_get_error(sd->shout_conn));
} }
{ {
...@@ -292,8 +290,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output, ...@@ -292,8 +290,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
} }
if (sd->encoder->init_func(sd) != 0) if (sd->encoder->init_func(sd) != 0)
FATAL("shout: encoder plugin '%s' failed to initialize\n", g_error("shout: encoder plugin '%s' failed to initialize\n",
sd->encoder->name); sd->encoder->name);
return sd; return sd;
} }
...@@ -305,17 +303,17 @@ static int handle_shout_error(struct shout_data *sd, int err) ...@@ -305,17 +303,17 @@ static int handle_shout_error(struct shout_data *sd, int err)
break; break;
case SHOUTERR_UNCONNECTED: case SHOUTERR_UNCONNECTED:
case SHOUTERR_SOCKET: case SHOUTERR_SOCKET:
ERROR("Lost shout connection to %s:%i: %s\n", g_warning("Lost shout connection to %s:%i: %s\n",
shout_get_host(sd->shout_conn), shout_get_host(sd->shout_conn),
shout_get_port(sd->shout_conn), shout_get_port(sd->shout_conn),
shout_get_error(sd->shout_conn)); shout_get_error(sd->shout_conn));
sd->shout_error = 1; sd->shout_error = 1;
return -1; return -1;
default: default:
ERROR("shout: connection to %s:%i error: %s\n", g_warning("shout: connection to %s:%i error: %s\n",
shout_get_host(sd->shout_conn), shout_get_host(sd->shout_conn),
shout_get_port(sd->shout_conn), shout_get_port(sd->shout_conn),
shout_get_error(sd->shout_conn)); shout_get_error(sd->shout_conn));
sd->shout_error = 1; sd->shout_error = 1;
return -1; return -1;
} }
...@@ -348,8 +346,8 @@ static void close_shout_conn(struct shout_data * sd) ...@@ -348,8 +346,8 @@ static void close_shout_conn(struct shout_data * sd)
if (shout_get_connected(sd->shout_conn) != SHOUTERR_UNCONNECTED && if (shout_get_connected(sd->shout_conn) != SHOUTERR_UNCONNECTED &&
shout_close(sd->shout_conn) != SHOUTERR_SUCCESS) { shout_close(sd->shout_conn) != SHOUTERR_SUCCESS) {
ERROR("problem closing connection to shout server: %s\n", g_warning("problem closing connection to shout server: %s\n",
shout_get_error(sd->shout_conn)); shout_get_error(sd->shout_conn));
} }
sd->opened = false; sd->opened = false;
...@@ -403,11 +401,11 @@ static int shout_connect(struct shout_data *sd) ...@@ -403,11 +401,11 @@ static int shout_connect(struct shout_data *sd)
if (state == SHOUTERR_BUSY && sd->conn_attempts != 0) { if (state == SHOUTERR_BUSY && sd->conn_attempts != 0) {
/* timeout waiting to connect */ /* timeout waiting to connect */
if ((t - sd->last_attempt) > sd->timeout) { if ((t - sd->last_attempt) > sd->timeout) {
ERROR("timeout connecting to shout server %s:%i " g_warning("timeout connecting to shout server %s:%i "
"(attempt %i)\n", "(attempt %i)\n",
shout_get_host(sd->shout_conn), shout_get_host(sd->shout_conn),
shout_get_port(sd->shout_conn), shout_get_port(sd->shout_conn),
sd->conn_attempts); sd->conn_attempts);
return -1; return -1;
} }
...@@ -437,11 +435,11 @@ static int shout_connect(struct shout_data *sd) ...@@ -437,11 +435,11 @@ static int shout_connect(struct shout_data *sd)
case SHOUTERR_BUSY: case SHOUTERR_BUSY:
return 1; return 1;
default: default:
ERROR("problem opening connection to shout server %s:%i " g_warning("problem opening connection to shout server %s:%i "
"(attempt %i): %s\n", "(attempt %i): %s\n",
shout_get_host(sd->shout_conn), shout_get_host(sd->shout_conn),
shout_get_port(sd->shout_conn), shout_get_port(sd->shout_conn),
sd->conn_attempts, shout_get_error(sd->shout_conn)); sd->conn_attempts, shout_get_error(sd->shout_conn));
return -1; return -1;
} }
} }
...@@ -498,7 +496,7 @@ static void send_metadata(struct shout_data * sd) ...@@ -498,7 +496,7 @@ static void send_metadata(struct shout_data * sd)
shout_metadata_add(sd->shout_meta, "song", song); shout_metadata_add(sd->shout_meta, "song", song);
if (SHOUTERR_SUCCESS != shout_set_metadata(sd->shout_conn, if (SHOUTERR_SUCCESS != shout_set_metadata(sd->shout_conn,
sd->shout_meta)) { sd->shout_meta)) {
ERROR("error setting shout metadata\n"); g_warning("error setting shout metadata\n");
return; return;
} }
} }
...@@ -582,8 +580,3 @@ const struct audio_output_plugin shoutPlugin = { ...@@ -582,8 +580,3 @@ const struct audio_output_plugin shoutPlugin = {
.close = my_shout_close_device, .close = my_shout_close_device,
.send_tag = my_shout_set_tag, .send_tag = my_shout_set_tag,
}; };
#else
DISABLED_AUDIO_OUTPUT_PLUGIN(shoutPlugin)
#endif
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
#include "../timer.h" #include "../timer.h"
#include <shout/shout.h> #include <shout/shout.h>
#include <glib.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "shout"
struct shout_data; struct shout_data;
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "audio_format.h" #include "audio_format.h"
#include "tag.h" #include "tag.h"
#include "conf.h" #include "conf.h"
#include "log.h"
#include <stdbool.h> #include <stdbool.h>
......
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
#include "output_api.h" #include "output_api.h"
#include "output_internal.h" #include "output_internal.h"
#include "output_list.h" #include "output_list.h"
#include "log.h"
#include "audio.h" #include "audio.h"
#include <glib.h>
#define AUDIO_OUTPUT_TYPE "type" #define AUDIO_OUTPUT_TYPE "type"
#define AUDIO_OUTPUT_NAME "name" #define AUDIO_OUTPUT_NAME "name"
#define AUDIO_OUTPUT_FORMAT "format" #define AUDIO_OUTPUT_FORMAT "format"
...@@ -30,9 +31,9 @@ ...@@ -30,9 +31,9 @@
#define getBlockParam(name, str, force) { \ #define getBlockParam(name, str, force) { \
bp = getBlockParam(param, name); \ bp = getBlockParam(param, name); \
if(force && bp == NULL) { \ if(force && bp == NULL) { \
FATAL("couldn't find parameter \"%s\" in audio output " \ g_error("couldn't find parameter \"%s\" in audio output " \
"definition beginning at %i\n", \ "definition beginning at %i\n", \
name, param->line); \ name, param->line); \
} \ } \
if(bp) str = bp->value; \ if(bp) str = bp->value; \
} }
...@@ -53,30 +54,30 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param) ...@@ -53,30 +54,30 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
plugin = audio_output_plugin_get(type); plugin = audio_output_plugin_get(type);
if (plugin == NULL) { if (plugin == NULL) {
FATAL("couldn't find audio output plugin for type " g_error("couldn't find audio output plugin for type "
"\"%s\" at line %i\n", type, param->line); "\"%s\" at line %i\n", type, param->line);
} }
} else { } else {
unsigned i; unsigned i;
WARNING("No \"%s\" defined in config file\n", g_warning("No \"%s\" defined in config file\n",
CONF_AUDIO_OUTPUT); CONF_AUDIO_OUTPUT);
WARNING("Attempt to detect audio output device\n"); g_warning("Attempt to detect audio output device\n");
audio_output_plugins_for_each(plugin, i) { audio_output_plugins_for_each(plugin, i) {
if (plugin->test_default_device) { if (plugin->test_default_device) {
WARNING("Attempting to detect a %s audio " g_warning("Attempting to detect a %s audio "
"device\n", plugin->name); "device\n", plugin->name);
if (plugin->test_default_device()) { if (plugin->test_default_device()) {
WARNING("Successfully detected a %s " g_warning("Successfully detected a %s "
"audio device\n", plugin->name); "audio device\n", plugin->name);
break; break;
} }
} }
} }
if (plugin == NULL) { if (plugin == NULL) {
WARNING("Unable to detect an audio device\n"); g_warning("Unable to detect an audio device\n");
return 0; return 0;
} }
...@@ -96,7 +97,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param) ...@@ -96,7 +97,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
if (format) { if (format) {
if (0 != parseAudioConfig(&ao->reqAudioFormat, format)) { if (0 != parseAudioConfig(&ao->reqAudioFormat, format)) {
FATAL("error parsing format at line %i\n", bp->line); g_error("error parsing format at line %i\n", bp->line);
} }
} else } else
audio_format_clear(&ao->reqAudioFormat); audio_format_clear(&ao->reqAudioFormat);
......
...@@ -19,9 +19,11 @@ ...@@ -19,9 +19,11 @@
#include "output_thread.h" #include "output_thread.h"
#include "output_api.h" #include "output_api.h"
#include "output_internal.h" #include "output_internal.h"
#include "utils.h"
#include <glib.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <errno.h>
enum { enum {
/** after a failure, wait this number of seconds before /** after a failure, wait this number of seconds before
...@@ -46,7 +48,7 @@ static void convertAudioFormat(struct audio_output *audioOutput, ...@@ -46,7 +48,7 @@ static void convertAudioFormat(struct audio_output *audioOutput,
if (size > audioOutput->convBufferLen) { if (size > audioOutput->convBufferLen) {
if (audioOutput->convBuffer != NULL) if (audioOutput->convBuffer != NULL)
free(audioOutput->convBuffer); free(audioOutput->convBuffer);
audioOutput->convBuffer = xmalloc(size); audioOutput->convBuffer = g_malloc(size);
audioOutput->convBufferLen = size; audioOutput->convBufferLen = size;
} }
...@@ -164,5 +166,5 @@ void audio_output_thread_start(struct audio_output *ao) ...@@ -164,5 +166,5 @@ void audio_output_thread_start(struct audio_output *ao)
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (pthread_create(&ao->thread, &attr, audio_output_task, ao)) if (pthread_create(&ao->thread, &attr, audio_output_task, ao))
FATAL("Failed to spawn output task: %s\n", strerror(errno)); g_error("Failed to spawn output task: %s\n", strerror(errno));
} }
...@@ -110,7 +110,7 @@ char *pfx_dir(char *dst, ...@@ -110,7 +110,7 @@ char *pfx_dir(char *dst,
const char *path, const size_t path_len, const char *path, const size_t path_len,
const char *pfx, const size_t pfx_len) const char *pfx, const size_t pfx_len)
{ {
if (mpd_unlikely((pfx_len + path_len + 1) >= MPD_PATH_MAX)) if (G_UNLIKELY((pfx_len + path_len + 1) >= MPD_PATH_MAX))
FATAL("Cannot prefix '%s' to '%s', PATH_MAX: %d\n", FATAL("Cannot prefix '%s' to '%s', PATH_MAX: %d\n",
pfx, path, MPD_PATH_MAX); pfx, path, MPD_PATH_MAX);
......
...@@ -18,18 +18,18 @@ ...@@ -18,18 +18,18 @@
*/ */
#include "pcm_resample.h" #include "pcm_resample.h"
#include "gcc.h"
#include <assert.h> #include <assert.h>
#include <glib.h>
/* resampling code blatantly ripped from ESD */ /* resampling code blatantly ripped from ESD */
size_t size_t
pcm_resample_16(uint8_t channels, pcm_resample_16(uint8_t channels,
unsigned src_rate, unsigned src_rate,
const int16_t *src_buffer, mpd_unused size_t src_size, const int16_t *src_buffer, G_GNUC_UNUSED size_t src_size,
unsigned dest_rate, unsigned dest_rate,
int16_t *dest_buffer, size_t dest_size, int16_t *dest_buffer, size_t dest_size,
mpd_unused struct pcm_resample_state *state) G_GNUC_UNUSED struct pcm_resample_state *state)
{ {
unsigned src_pos, dest_pos = 0; unsigned src_pos, dest_pos = 0;
unsigned dest_samples = dest_size / sizeof(*dest_buffer); unsigned dest_samples = dest_size / sizeof(*dest_buffer);
...@@ -62,10 +62,10 @@ pcm_resample_16(uint8_t channels, ...@@ -62,10 +62,10 @@ pcm_resample_16(uint8_t channels,
size_t size_t
pcm_resample_24(uint8_t channels, pcm_resample_24(uint8_t channels,
unsigned src_rate, unsigned src_rate,
const int32_t *src_buffer, mpd_unused size_t src_size, const int32_t *src_buffer, G_GNUC_UNUSED size_t src_size,
unsigned dest_rate, unsigned dest_rate,
int32_t *dest_buffer, size_t dest_size, int32_t *dest_buffer, size_t dest_size,
mpd_unused struct pcm_resample_state *state) G_GNUC_UNUSED struct pcm_resample_state *state)
{ {
unsigned src_pos, dest_pos = 0; unsigned src_pos, dest_pos = 0;
unsigned dest_samples = dest_size / sizeof(*dest_buffer); unsigned dest_samples = dest_size / sizeof(*dest_buffer);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <glib.h>
static inline int static inline int
pcm_dither(void) pcm_dither(void)
...@@ -40,9 +41,9 @@ pcm_dither(void) ...@@ -40,9 +41,9 @@ pcm_dither(void)
static int32_t static int32_t
pcm_range(int32_t sample, unsigned bits) pcm_range(int32_t sample, unsigned bits)
{ {
if (mpd_unlikely(sample < (-1 << (bits - 1)))) if (G_UNLIKELY(sample < (-1 << (bits - 1))))
return -1 << (bits - 1); return -1 << (bits - 1);
if (mpd_unlikely(sample >= (1 << (bits - 1)))) if (G_UNLIKELY(sample >= (1 << (bits - 1))))
return (1 << (bits - 1)) - 1; return (1 << (bits - 1)) - 1;
return sample; return sample;
} }
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "pipe.h" #include "pipe.h"
#include "idle.h" #include "idle.h"
#include <glib.h>
enum xfade_state { enum xfade_state {
XFADE_DISABLED = -1, XFADE_DISABLED = -1,
XFADE_UNKNOWN = 0, XFADE_UNKNOWN = 0,
...@@ -107,6 +109,7 @@ static int player_wait_for_decoder(struct player *player) ...@@ -107,6 +109,7 @@ static int player_wait_for_decoder(struct player *player)
player->song = pc.next_song; player->song = pc.next_song;
pc.next_song = NULL; pc.next_song = NULL;
pc.elapsed_time = 0;
player->queued = false; player->queued = false;
player->decoder_starting = true; player->decoder_starting = true;
...@@ -349,9 +352,11 @@ static void do_play(void) ...@@ -349,9 +352,11 @@ static void do_play(void)
} }
#ifndef NDEBUG #ifndef NDEBUG
/*
music_pipe_check_format(&play_audio_format, music_pipe_check_format(&play_audio_format,
player.next_song_chunk, player.next_song_chunk,
&dc.out_audio_format); &dc.out_audio_format);
*/
#endif #endif
if (decoder_is_idle() && !player.queued && if (decoder_is_idle() && !player.queued &&
...@@ -488,7 +493,7 @@ static void do_play(void) ...@@ -488,7 +493,7 @@ static void do_play(void)
player_stop_decoder(); player_stop_decoder();
} }
static void * player_task(mpd_unused void *arg) static void * player_task(G_GNUC_UNUSED void *arg)
{ {
while (1) { while (1) {
switch (pc.command) { switch (pc.command) {
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <sys/signal.h> #include <sys/signal.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <errno.h> #include <errno.h>
#include <glib.h>
int handlePendingSignals(void) int handlePendingSignals(void)
{ {
...@@ -50,7 +51,7 @@ int handlePendingSignals(void) ...@@ -50,7 +51,7 @@ int handlePendingSignals(void)
return 0; return 0;
} }
static void chldSigHandler(mpd_unused int sig) static void chldSigHandler(G_GNUC_UNUSED int sig)
{ {
int status; int status;
int pid; int pid;
......
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
#include "../config.h" #include "../config.h"
#include "state_file.h" #include "state_file.h"
#include "conf.h" #include "conf.h"
#include "gcc.h"
#include "log.h" #include "log.h"
#include "audio.h" #include "audio.h"
#include "playlist.h" #include "playlist.h"
#include "utils.h" #include "utils.h"
#include "volume.h" #include "volume.h"
#include <glib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -58,7 +58,7 @@ void write_state_file(void) ...@@ -58,7 +58,7 @@ void write_state_file(void)
if (!sfpath) if (!sfpath)
return; return;
fp = fopen(sfpath, "w"); fp = fopen(sfpath, "w");
if (mpd_unlikely(!fp)) { if (G_UNLIKELY(!fp)) {
ERROR("problems opening state file \"%s\" for writing: %s\n", ERROR("problems opening state file \"%s\" for writing: %s\n",
sfpath, strerror(errno)); sfpath, strerror(errno));
return; return;
...@@ -87,7 +87,7 @@ void read_state_file(void) ...@@ -87,7 +87,7 @@ void read_state_file(void)
FATAL("state file \"%s\" is not a regular file\n", sfpath); FATAL("state file \"%s\" is not a regular file\n", sfpath);
while (!(fp = fopen(sfpath, "r")) && errno == EINTR); while (!(fp = fopen(sfpath, "r")) && errno == EINTR);
if (mpd_unlikely(!fp)) { if (G_UNLIKELY(!fp)) {
FATAL("problems opening state file \"%s\" for reading: %s\n", FATAL("problems opening state file \"%s\" for reading: %s\n",
sfpath, strerror(errno)); sfpath, strerror(errno));
} }
...@@ -99,7 +99,7 @@ void read_state_file(void) ...@@ -99,7 +99,7 @@ void read_state_file(void)
while(fclose(fp) && errno == EINTR) /* nothing */; while(fclose(fp) && errno == EINTR) /* nothing */;
} }
void mpd_noreturn state_file_fatal(void) void G_GNUC_NORETURN state_file_fatal(void)
{ {
FATAL("error parsing state file \"%s\"\n", sfpath); FATAL("error parsing state file \"%s\"\n", sfpath);
} }
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
#ifndef MPD_STATE_FILE_H #ifndef MPD_STATE_FILE_H
#define MPD_STATE_FILE_H #define MPD_STATE_FILE_H
#include "gcc.h" #include <glib.h>
void write_state_file(void); void write_state_file(void);
void read_state_file(void); void read_state_file(void);
void mpd_noreturn state_file_fatal(void); void G_GNUC_NORETURN state_file_fatal(void);
#endif /* STATE_FILE_H */ #endif /* STATE_FILE_H */
...@@ -47,7 +47,7 @@ static unsigned calc_hash(const char *p) { ...@@ -47,7 +47,7 @@ static unsigned calc_hash(const char *p) {
return hash; return hash;
} }
mpd_malloc struct strset *strset_new(void) G_GNUC_MALLOC struct strset *strset_new(void)
{ {
struct strset *set = xcalloc(1, sizeof(*set)); struct strset *set = xcalloc(1, sizeof(*set));
return set; return set;
......
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
#ifndef MPD_STRSET_H #ifndef MPD_STRSET_H
#define MPD_STRSET_H #define MPD_STRSET_H
#include "gcc.h" #include <glib.h>
struct strset; struct strset;
mpd_malloc struct strset *strset_new(void); G_GNUC_MALLOC struct strset *strset_new(void);
void strset_free(struct strset *set); void strset_free(struct strset *set);
......
...@@ -52,7 +52,7 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4, ...@@ -52,7 +52,7 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
GError *error = NULL; GError *error = NULL;
isostr = id3_ucs4_latin1duplicate(ucs4); isostr = id3_ucs4_latin1duplicate(ucs4);
if (mpd_unlikely(!isostr)) { if (G_UNLIKELY(!isostr)) {
return NULL; return NULL;
} }
...@@ -70,7 +70,7 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4, ...@@ -70,7 +70,7 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
free(isostr); free(isostr);
} else { } else {
utf8 = id3_ucs4_utf8duplicate(ucs4); utf8 = id3_ucs4_utf8duplicate(ucs4);
if (mpd_unlikely(!utf8)) { if (G_UNLIKELY(!utf8)) {
return NULL; return NULL;
} }
} }
......
...@@ -31,10 +31,10 @@ struct tag *tag_id3_load(const char *file); ...@@ -31,10 +31,10 @@ struct tag *tag_id3_load(const char *file);
#else #else
#include "gcc.h" #include <glib.h>
static inline struct tag * static inline struct tag *
tag_id3_load(mpd_unused const char *file) tag_id3_load(G_GNUC_UNUSED const char *file)
{ {
return NULL; return NULL;
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "condition.h" #include "condition.h"
#include "update.h" #include "update.h"
#include "idle.h" #include "idle.h"
#include "conf.h"
#include <glib.h> #include <glib.h>
...@@ -56,6 +57,14 @@ static struct song *delete; ...@@ -56,6 +57,14 @@ static struct song *delete;
static struct condition delete_cond; static struct condition delete_cond;
enum {
DEFAULT_FOLLOW_INSIDE_SYMLINKS = true,
DEFAULT_FOLLOW_OUTSIDE_SYMLINKS = false,
};
static bool follow_inside_symlinks;
static bool follow_outside_symlinks;
unsigned unsigned
isUpdatingDB(void) isUpdatingDB(void)
{ {
...@@ -89,7 +98,7 @@ delete_song(struct directory *dir, struct song *del) ...@@ -89,7 +98,7 @@ delete_song(struct directory *dir, struct song *del)
} }
static int static int
delete_each_song(struct song *song, mpd_unused void *data) delete_each_song(struct song *song, G_GNUC_UNUSED void *data)
{ {
struct directory *directory = data; struct directory *directory = data;
assert(song->parent == directory); assert(song->parent == directory);
...@@ -337,19 +346,28 @@ skip_symlink(const struct directory *directory, const char *utf8_name) ...@@ -337,19 +346,28 @@ skip_symlink(const struct directory *directory, const char *utf8_name)
/* don't skip if this is not a symlink */ /* don't skip if this is not a symlink */
return errno != EINVAL; return errno != EINVAL;
if (buffer[0] == '/') if (!follow_inside_symlinks && !follow_outside_symlinks) {
/* ignore all symlinks */
return true;
} else if (follow_inside_symlinks && follow_outside_symlinks) {
/* consider all symlinks */
return false; return false;
}
if (buffer[0] == '/')
return !follow_outside_symlinks;
p = buffer; p = buffer;
while (*p == '.') { while (*p == '.') {
if (p[1] == '.' && p[2] == '/') { if (p[1] == '.' && p[2] == '/') {
/* "../" moves to parent directory */ /* "../" moves to parent directory */
directory = directory->parent; directory = directory->parent;
if (directory == NULL) if (directory == NULL) {
/* we have moved outside the music /* we have moved outside the music
directory - don't skip this directory - skip this symlink
symlink */ if such symlinks are not allowed */
return false; return !follow_outside_symlinks;
}
p += 3; p += 3;
} else if (p[1] == '/') } else if (p[1] == '/')
/* eliminate "./" */ /* eliminate "./" */
...@@ -359,8 +377,9 @@ skip_symlink(const struct directory *directory, const char *utf8_name) ...@@ -359,8 +377,9 @@ skip_symlink(const struct directory *directory, const char *utf8_name)
} }
/* we are still in the music directory, so this symlink points /* we are still in the music directory, so this symlink points
to a song which is already in the database - skip it */ to a song which is already in the database - skip according
return true; to the follow_inside_symlinks param*/
return !follow_inside_symlinks;
} }
static bool static bool
...@@ -580,3 +599,18 @@ void reap_update_task(void) ...@@ -580,3 +599,18 @@ void reap_update_task(void)
progress = UPDATE_PROGRESS_IDLE; progress = UPDATE_PROGRESS_IDLE;
} }
} }
void update_global_init(void)
{
follow_inside_symlinks =
config_get_bool(CONF_FOLLOW_INSIDE_SYMLINKS,
DEFAULT_FOLLOW_INSIDE_SYMLINKS);
follow_outside_symlinks =
config_get_bool(CONF_FOLLOW_OUTSIDE_SYMLINKS,
DEFAULT_FOLLOW_OUTSIDE_SYMLINKS);
}
void update_global_finish(void)
{
}
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#ifndef MPD_UPDATE_H #ifndef MPD_UPDATE_H
#define MPD_UPDATE_H #define MPD_UPDATE_H
void update_global_init(void);
void update_global_finish(void);
unsigned unsigned
isUpdatingDB(void); isUpdatingDB(void);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <pwd.h> #include <pwd.h>
#include <fcntl.h> #include <fcntl.h>
#include <glib.h>
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
#include <sys/socket.h> #include <sys/socket.h>
...@@ -75,51 +76,51 @@ int ipv6Supported(void) ...@@ -75,51 +76,51 @@ int ipv6Supported(void)
#endif #endif
} }
mpd_malloc char *xstrdup(const char *s) G_GNUC_MALLOC char *xstrdup(const char *s)
{ {
char *ret = strdup(s); char *ret = strdup(s);
if (mpd_unlikely(!ret)) if (G_UNLIKELY(!ret))
FATAL("OOM: strdup\n"); FATAL("OOM: strdup\n");
return ret; return ret;
} }
/* borrowed from git :) */ /* borrowed from git :) */
mpd_malloc void *xmalloc(size_t size) G_GNUC_MALLOC void *xmalloc(size_t size)
{ {
void *ret; void *ret;
assert(mpd_likely(size)); assert(G_LIKELY(size));
ret = malloc(size); ret = malloc(size);
if (mpd_unlikely(!ret)) if (G_UNLIKELY(!ret))
FATAL("OOM: malloc\n"); FATAL("OOM: malloc\n");
return ret; return ret;
} }
mpd_malloc void *xrealloc(void *ptr, size_t size) G_GNUC_MALLOC void *xrealloc(void *ptr, size_t size)
{ {
void *ret = realloc(ptr, size); void *ret = realloc(ptr, size);
/* some C libraries return NULL when size == 0, /* some C libraries return NULL when size == 0,
* make sure we get a free()-able pointer (free(NULL) * make sure we get a free()-able pointer (free(NULL)
* doesn't work with all C libraries, either) */ * doesn't work with all C libraries, either) */
if (mpd_unlikely(!ret && !size)) if (G_UNLIKELY(!ret && !size))
ret = realloc(ptr, 1); ret = realloc(ptr, 1);
if (mpd_unlikely(!ret)) if (G_UNLIKELY(!ret))
FATAL("OOM: realloc\n"); FATAL("OOM: realloc\n");
return ret; return ret;
} }
mpd_malloc void *xcalloc(size_t nmemb, size_t size) G_GNUC_MALLOC void *xcalloc(size_t nmemb, size_t size)
{ {
void *ret; void *ret;
assert(mpd_likely(nmemb && size)); assert(G_LIKELY(nmemb && size));
ret = calloc(nmemb, size); ret = calloc(nmemb, size);
if (mpd_unlikely(!ret)) if (G_UNLIKELY(!ret))
FATAL("OOM: calloc\n"); FATAL("OOM: calloc\n");
return ret; return ret;
} }
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#ifndef MPD_UTILS_H #ifndef MPD_UTILS_H
#define MPD_UTILS_H #define MPD_UTILS_H
#include "gcc.h" #include <glib.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
...@@ -74,13 +73,13 @@ static inline ssize_t xwrite(int fd, const void *buf, size_t len) ...@@ -74,13 +73,13 @@ static inline ssize_t xwrite(int fd, const void *buf, size_t len)
} }
} }
mpd_malloc char *xstrdup(const char *s); G_GNUC_MALLOC char *xstrdup(const char *s);
mpd_malloc void *xmalloc(size_t size); G_GNUC_MALLOC void *xmalloc(size_t size);
mpd_malloc void *xrealloc(void *ptr, size_t size); G_GNUC_MALLOC void *xrealloc(void *ptr, size_t size);
mpd_malloc void *xcalloc(size_t nmemb, size_t size); G_GNUC_MALLOC void *xcalloc(size_t nmemb, size_t size);
/** /**
* free a const pointer - unfortunately free() expects a non-const * free a const pointer - unfortunately free() expects a non-const
......
...@@ -526,7 +526,7 @@ void read_sw_volume_state(FILE *fp) ...@@ -526,7 +526,7 @@ void read_sw_volume_state(FILE *fp)
if (!g_str_has_prefix(buf, SW_VOLUME_STATE)) if (!g_str_has_prefix(buf, SW_VOLUME_STATE))
continue; continue;
sv = strtol(buf + strlen(SW_VOLUME_STATE), &end, 10); sv = strtol(buf + strlen(SW_VOLUME_STATE), &end, 10);
if (mpd_likely(!*end)) if (G_LIKELY(!*end))
changeSoftwareVolume(sv, 0); changeSoftwareVolume(sv, 0);
else else
ERROR("Can't parse software volume: %s\n", buf); ERROR("Can't parse software volume: %s\n", buf);
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "ioops.h" #include "ioops.h"
#include "utils.h" #include "utils.h"
#include <glib.h>
/* The dns-sd service type qualifier to publish */ /* The dns-sd service type qualifier to publish */
#define SERVICE_TYPE "_mpd._tcp" #define SERVICE_TYPE "_mpd._tcp"
...@@ -92,7 +94,7 @@ struct AvahiTimeout { ...@@ -92,7 +94,7 @@ struct AvahiTimeout {
static AvahiWatch *avahiWatchList; static AvahiWatch *avahiWatchList;
static AvahiTimeout *avahiTimeoutList; static AvahiTimeout *avahiTimeoutList;
static AvahiWatch *avahiWatchNew(mpd_unused const AvahiPoll * api, int fd, static AvahiWatch *avahiWatchNew(G_GNUC_UNUSED const AvahiPoll * api, int fd,
AvahiWatchEvent event, AvahiWatchEvent event,
AvahiWatchCallback callback, void *userdata) AvahiWatchCallback callback, void *userdata)
{ {
...@@ -175,7 +177,7 @@ static void avahiTimeoutFree(AvahiTimeout * t) ...@@ -175,7 +177,7 @@ static void avahiTimeoutFree(AvahiTimeout * t)
free(t); free(t);
} }
static AvahiTimeout *avahiTimeoutNew(mpd_unused const AvahiPoll * api, static AvahiTimeout *avahiTimeoutNew(G_GNUC_UNUSED const AvahiPoll * api,
const struct timeval *tv, const struct timeval *tv,
AvahiTimeoutCallback callback, AvahiTimeoutCallback callback,
void *userdata) void *userdata)
...@@ -200,7 +202,7 @@ static AvahiTimeout *avahiTimeoutNew(mpd_unused const AvahiPoll * api, ...@@ -200,7 +202,7 @@ static AvahiTimeout *avahiTimeoutNew(mpd_unused const AvahiPoll * api,
/* Callback when the EntryGroup changes state */ /* Callback when the EntryGroup changes state */
static void avahiGroupCallback(AvahiEntryGroup * g, static void avahiGroupCallback(AvahiEntryGroup * g,
AvahiEntryGroupState state, AvahiEntryGroupState state,
mpd_unused void *userdata) G_GNUC_UNUSED void *userdata)
{ {
char *n; char *n;
assert(g); assert(g);
...@@ -290,7 +292,7 @@ fail: ...@@ -290,7 +292,7 @@ fail:
/* Callback when avahi changes state */ /* Callback when avahi changes state */
static void avahiClientCallback(AvahiClient * c, AvahiClientState state, static void avahiClientCallback(AvahiClient * c, AvahiClientState state,
mpd_unused void *userdata) G_GNUC_UNUSED void *userdata)
{ {
int reason; int reason;
assert(c); assert(c);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment