Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
2b2d267d
Commit
2b2d267d
authored
Dec 21, 2008
by
Led
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '0.14-beta2' into alt
parents
29e57c2d
dbb32d46
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
58 changed files
with
515 additions
and
371 deletions
+515
-371
AUTHORS
AUTHORS
+12
-20
INSTALL
INSTALL
+12
-0
NEWS
NEWS
+4
-0
configure
configure
+10
-10
configure.ac
configure.ac
+1
-1
mpd.conf.5
doc/mpd.conf.5
+11
-0
mpdconf.example
doc/mpdconf.example
+2
-0
audio.c
src/audio.c
+18
-19
client.c
src/client.c
+2
-2
client.h
src/client.h
+2
-3
command.c
src/command.c
+0
-0
command.h
src/command.h
+2
-3
conf.c
src/conf.c
+12
-0
conf.h
src/conf.h
+6
-0
dbUtils.c
src/dbUtils.c
+2
-2
flac_plugin.c
src/decoder/flac_plugin.c
+1
-0
mp3_plugin.c
src/decoder/mp3_plugin.c
+18
-19
mpc_plugin.c
src/decoder/mpc_plugin.c
+1
-0
oggflac_plugin.c
src/decoder/oggflac_plugin.c
+1
-0
oggvorbis_plugin.c
src/decoder/oggvorbis_plugin.c
+1
-0
wavpack_plugin.c
src/decoder/wavpack_plugin.c
+1
-0
decoder_api.c
src/decoder_api.c
+7
-6
decoder_thread.c
src/decoder_thread.c
+3
-1
input_curl.c
src/input_curl.c
+8
-2
input_file.c
src/input_file.c
+1
-2
listen.c
src/listen.c
+4
-1
log.c
src/log.c
+2
-2
log.h
src/log.h
+7
-8
main.c
src/main.c
+4
-0
main_notify.c
src/main_notify.c
+5
-3
alsa_plugin.c
src/output/alsa_plugin.c
+5
-1
ao_plugin.c
src/output/ao_plugin.c
+49
-25
mvp_plugin.c
src/output/mvp_plugin.c
+27
-16
oss_plugin.c
src/output/oss_plugin.c
+56
-55
shout_mp3.c
src/output/shout_mp3.c
+27
-23
shout_ogg.c
src/output/shout_ogg.c
+7
-9
shout_plugin.c
src/output/shout_plugin.c
+59
-66
shout_plugin.h
src/output/shout_plugin.h
+4
-0
output_api.h
src/output_api.h
+0
-1
output_init.c
src/output_init.c
+16
-15
output_thread.c
src/output_thread.c
+5
-3
path.c
src/path.c
+1
-1
pcm_resample_fallback.c
src/pcm_resample_fallback.c
+5
-5
pcm_utils.c
src/pcm_utils.c
+3
-2
player_thread.c
src/player_thread.c
+6
-1
sig_handlers.c
src/sig_handlers.c
+2
-1
state_file.c
src/state_file.c
+4
-4
state_file.h
src/state_file.h
+2
-2
strset.c
src/strset.c
+1
-1
strset.h
src/strset.h
+2
-2
tag_id3.c
src/tag_id3.c
+2
-2
tag_id3.h
src/tag_id3.h
+2
-2
update.c
src/update.c
+42
-8
update.h
src/update.h
+4
-0
utils.c
src/utils.c
+12
-11
utils.h
src/utils.h
+5
-6
volume.c
src/volume.c
+1
-1
zeroconf.c
src/zeroconf.c
+6
-4
No files found.
AUTHORS
View file @
2b2d267d
Current Developers
------------------
Max Kellermann <max@duempel.org>
general
Warren Dukes <warren.dukes
@gmail.com>
general
Avuton Olrich <avuton
@gmail.com>
release manager
J. Alexander Treuman <jat@spatialrift.net
>
general
, MP3, ID3, PulseAudio, format conversion, stored playlists
Max Kellermann <max@duempel.org
>
general
Jos Anarch <anarchsss@gmail.com>
JACK plugin
...
...
@@ -18,9 +16,6 @@ Guus Sliepen <guus@sliepen.eu.org>
Jim Ramsay <i.am@jimramsay.com>
Zerconf/avahi support
Qball Cow <qballcow@gmail.com>
Playlist commands
Patrik Weiskircher <pat@icore.at>
Stored playlist commands
...
...
@@ -30,23 +25,20 @@ Laszlo Ashin <kodest@gmail.com>
Viliam Mateicka <viliam.mateicka@gmail.com>
FFmpeg support
Eric Wollesen <encoded@xmtp.net>
encoder API, shout output
Former Developers
-----------------
tw-nym
Nagilum
setuid
Warren Dukes <warren.dukes@gmail.com>
general
Niklas Hofer
'next' and 'previous' patch
mackstann
command.c and signal handling cleanup
AliasMrJones
replayGain
J. Alexander Treuman <jat@spatialrift.net>
general, MP3, ID3, PulseAudio, format conversion, stored playlists
Eric Wong
mp4ff copyrighted by M. Bakker, Ahead Software AG, http://www.nero.com
compress.[ch] copyrighted by fluffy <fluffy@beesbuzz.biz>
INSTALL
View file @
2b2d267d
...
...
@@ -91,6 +91,18 @@ libcurl - http://curl.haxx.se/
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
--------
...
...
NEWS
View file @
2b2d267d
ver 0.14.0 (????/??/??)
* audio outputs:
- wait 10 seconds before reopening a failed device
- fifo: new plugin
- null: new plugin
- shout: block while trying to connect instead of failing
...
...
@@ -9,6 +10,7 @@ ver 0.14.0 (????/??/??)
* decoders:
- ffmpeg: new plugin
- wavpack: new plugin
- aac: stream support added
* commands:
- "addid" takes optional second argument to specify position
- "idle" notifies the client when a notable change occurs
...
...
@@ -25,6 +27,8 @@ ver 0.14.0 (????/??/??)
* optimized PCM conversions and dithering
* much code has been replaced by using GLib
* 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)
* New JACK audio output
...
...
configure
View file @
2b2d267d
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.63 for mpd 0.14~beta
1
.
# Generated by GNU Autoconf 2.63 for mpd 0.14~beta
2
.
#
# Report bugs to <musicpd-dev-team@lists.sourceforge.net>.
#
...
...
@@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME
=
'mpd'
PACKAGE_TARNAME
=
'mpd'
PACKAGE_VERSION
=
'0.14~beta
1
'
PACKAGE_STRING
=
'mpd 0.14~beta
1
'
PACKAGE_VERSION
=
'0.14~beta
2
'
PACKAGE_STRING
=
'mpd 0.14~beta
2
'
PACKAGE_BUGREPORT
=
'musicpd-dev-team@lists.sourceforge.net'
ac_unique_file
=
"src/main.c"
...
...
@@ -1481,7 +1481,7 @@ if test "$ac_init_help" = "long"; then
# 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.
cat
<<
_ACEOF
\`configure' configures mpd 0.14~beta
1
to adapt to many kinds of systems.
\`configure' configures mpd 0.14~beta
2
to adapt to many kinds of systems.
Usage:
$0
[OPTION]... [VAR=VALUE]...
...
...
@@ -1551,7 +1551,7 @@ fi
if
test
-n
"
$ac_init_help
"
;
then
case
$ac_init_help
in
short
|
recursive
)
echo
"Configuration of mpd 0.14~beta
1
:"
;;
short
|
recursive
)
echo
"Configuration of mpd 0.14~beta
2
:"
;;
esac
cat
<<
\
_ACEOF
...
...
@@ -1749,7 +1749,7 @@ fi
test
-n
"
$ac_init_help
"
&&
exit
$ac_status
if
$ac_init_version
;
then
cat
<<
\
_ACEOF
mpd configure 0.14~beta
1
mpd configure 0.14~beta
2
generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
...
...
@@ -1763,7 +1763,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by mpd
$as_me
0.14~beta
1
, which was
It was created by mpd
$as_me
0.14~beta
2
, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ $0
$@
...
...
@@ -2460,7 +2460,7 @@ fi
# Define the identity of the package.
PACKAGE
=
'mpd'
VERSION
=
'0.14~beta
1
'
VERSION
=
'0.14~beta
2
'
cat
>>
confdefs.h
<<
_ACEOF
...
...
@@ -13076,7 +13076,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by mpd
$as_me
0.14~beta
1
, which was
This file was extended by mpd
$as_me
0.14~beta
2
, which was
generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES =
$CONFIG_FILES
...
...
@@ -13139,7 +13139,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat
>>
$CONFIG_STATUS
<<
_ACEOF
|| ac_write_fail=1
ac_cs_version="\\
mpd config.status 0.14~beta
1
mpd config.status 0.14~beta
2
configured by
$0
, generated by GNU Autoconf 2.63,
with options \\"`
$as_echo
"
$ac_configure_args
" | sed 's/^ //; s/[\\""\`\
$]
/\\\\&/g'`\\"
...
...
configure.ac
View file @
2b2d267d
AC_PREREQ(2.60)
AC_INIT(mpd, 0.14~beta
1
, musicpd-dev-team@lists.sourceforge.net)
AC_INIT(mpd, 0.14~beta
2
, musicpd-dev-team@lists.sourceforge.net)
AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([foreign 1.9 dist-bzip2])
AM_CONFIG_HEADER(config.h)
...
...
doc/mpd.conf.5
View file @
2b2d267d
...
...
@@ -35,6 +35,17 @@ This specifies the directory where music is located.
.B playlist_directory <directory>
This specifies the directory where saved playlists are stored.
.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>
This specifies where the db file will be stored.
.TP
...
...
doc/mpdconf.example
View file @
2b2d267d
...
...
@@ -7,6 +7,8 @@ playlist_directory "~/.mpd/playlists"
db_file "~/.mpd/mpd.db"
log_file "~/.mpd/mpd.log"
error_file "~/.mpd/mpd.error"
#follow_outside_symlinks "no"
#follow_inside_symlinks "yes"
################################################################
...
...
src/audio.c
View file @
2b2d267d
...
...
@@ -21,7 +21,6 @@
#include "output_api.h"
#include "output_control.h"
#include "output_internal.h"
#include "log.h"
#include "path.h"
#include "client.h"
#include "idle.h"
...
...
@@ -73,21 +72,21 @@ void initAudioDriver(void)
if
(
!
audio_output_init
(
output
,
param
))
{
if
(
param
)
{
FATAL
(
"problems configuring output device "
"defined at line %i
\n
"
,
param
->
line
);
g_error
(
"problems configuring output device "
"defined at line %i
\n
"
,
param
->
line
);
}
else
{
FATAL
(
"No audio_output specified and unable to "
"detect a default audio output device
\n
"
);
g_error
(
"No audio_output specified and unable to "
"detect a default audio output device
\n
"
);
}
}
/* require output names to be unique: */
for
(
j
=
0
;
j
<
i
;
j
++
)
{
if
(
!
strcmp
(
output
->
name
,
audioOutputArray
[
j
].
name
))
{
FATAL
(
"output devices with identical "
"names: %s
\n
"
,
output
->
name
);
g_error
(
"output devices with identical "
"names: %s
\n
"
,
output
->
name
);
}
}
}
...
...
@@ -109,8 +108,8 @@ void initAudioConfig(void)
return
;
if
(
0
!=
parseAudioConfig
(
&
configured_audio_format
,
param
->
value
))
{
FATAL
(
"error parsing
\"
%s
\"
at line %i
\n
"
,
CONF_AUDIO_OUTPUT_FORMAT
,
param
->
line
);
g_error
(
"error parsing
\"
%s
\"
at line %i
\n
"
,
CONF_AUDIO_OUTPUT_FORMAT
,
param
->
line
);
}
}
...
...
@@ -123,34 +122,34 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
audioFormat
->
sample_rate
=
strtol
(
conf
,
&
test
,
10
);
if
(
*
test
!=
':'
)
{
ERROR
(
"error parsing audio output format: %s
\n
"
,
conf
);
g_warning
(
"error parsing audio output format: %s
\n
"
,
conf
);
return
-
1
;
}
if
(
audioFormat
->
sample_rate
<=
0
)
{
ERROR
(
"sample rate %u is not >= 0
\n
"
,
audioFormat
->
sample_rate
);
g_warning
(
"sample rate %u is not >= 0
\n
"
,
audioFormat
->
sample_rate
);
return
-
1
;
}
audioFormat
->
bits
=
(
uint8_t
)
strtoul
(
test
+
1
,
&
test
,
10
);
if
(
*
test
!=
':'
)
{
ERROR
(
"error parsing audio output format: %s
\n
"
,
conf
);
g_warning
(
"error parsing audio output format: %s
\n
"
,
conf
);
return
-
1
;
}
if
(
audioFormat
->
bits
!=
16
&&
audioFormat
->
bits
!=
24
&&
audioFormat
->
bits
!=
8
)
{
ERROR
(
"bits %u can not be used for audio output
\n
"
,
audioFormat
->
bits
);
g_warning
(
"bits %u can not be used for audio output
\n
"
,
audioFormat
->
bits
);
return
-
1
;
}
audioFormat
->
channels
=
(
uint8_t
)
strtoul
(
test
+
1
,
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
ERROR
(
"error parsing audio output format: %s
\n
"
,
conf
);
g_warning
(
"error parsing audio output format: %s
\n
"
,
conf
);
return
-
1
;
}
...
...
@@ -159,8 +158,8 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
case
2
:
break
;
default:
ERROR
(
"channels %i
can not be used for audio output
\n
"
,
(
int
)
audioFormat
->
channels
);
g_warning
(
"channels %u
can not be used for audio output
\n
"
,
audioFormat
->
channels
);
return
-
1
;
}
...
...
@@ -418,7 +417,7 @@ void readAudioDevicesState(FILE *fp)
continue
;
errline:
/* nonfatal */
ERROR
(
"invalid line in state_file: %s
\n
"
,
buffer
);
g_warning
(
"invalid line in state_file: %s
\n
"
,
buffer
);
}
}
src/client.c
View file @
2b2d267d
...
...
@@ -169,7 +169,7 @@ static void new_cmd_list_ptr(struct client *client, char *s)
}
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
;
g_free
(
buffer
);
...
...
@@ -760,7 +760,7 @@ void client_vprintf(struct client *client, const char *fmt, va_list args)
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
;
...
...
src/client.h
View file @
2b2d267d
...
...
@@ -19,8 +19,7 @@
#ifndef MPD_CLIENT_H
#define MPD_CLIENT_H
#include "gcc.h"
#include <glib.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdarg.h>
...
...
@@ -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.
*/
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
...
...
src/command.c
View file @
2b2d267d
This diff is collapsed.
Click to expand it.
src/command.h
View file @
2b2d267d
...
...
@@ -19,7 +19,6 @@
#ifndef MPD_COMMAND_H
#define MPD_COMMAND_H
#include "gcc.h"
#include "ack.h"
#include <glib.h>
...
...
@@ -47,7 +46,7 @@ command_process(struct client *client, char *commandString);
void
command_success
(
struct
client
*
client
);
mpd_fprintf_
void
command_error
(
struct
client
*
client
,
enum
ack
error
,
const
char
*
fmt
,
...);
G_GNUC_PRINTF
(
3
,
4
)
void
command_error
(
struct
client
*
client
,
enum
ack
error
,
const
char
*
fmt
,
...);
#endif
src/conf.c
View file @
2b2d267d
...
...
@@ -145,6 +145,8 @@ void initConf(void)
/* registerConfigParam(name, repeatable, block); */
registerConfigParam
(
CONF_MUSIC_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_LOG_FILE
,
0
,
0
);
registerConfigParam
(
CONF_ERROR_FILE
,
0
,
0
);
...
...
@@ -418,6 +420,16 @@ int getBoolConfigParam(const char *name, int force)
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
ret
;
...
...
src/conf.h
View file @
2b2d267d
...
...
@@ -19,8 +19,12 @@
#ifndef MPD_CONF_H
#define MPD_CONF_H
#include <stdbool.h>
#define CONF_MUSIC_DIR "music_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_LOG_FILE "log_file"
#define CONF_ERROR_FILE "error_file"
...
...
@@ -97,6 +101,8 @@ ConfigParam *parseConfigFilePath(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
);
#endif
src/dbUtils.c
View file @
2b2d267d
...
...
@@ -70,7 +70,7 @@ printDirectoryInDirectory(struct directory *directory, void *data)
}
static
int
printSongInDirectory
(
struct
song
*
song
,
mpd_unused
void
*
data
)
printSongInDirectory
(
struct
song
*
song
,
G_GNUC_UNUSED
void
*
data
)
{
struct
client
*
client
=
data
;
song_print_url
(
client
,
song
);
...
...
@@ -194,7 +194,7 @@ int printAllIn(struct client *client, const char *name)
}
static
int
directoryAddSongToPlaylist
(
struct
song
*
song
,
mpd_unused
void
*
data
)
directoryAddSongToPlaylist
(
struct
song
*
song
,
G_GNUC_UNUSED
void
*
data
)
{
return
addSongToPlaylist
(
song
,
NULL
);
}
...
...
src/decoder/flac_plugin.c
View file @
2b2d267d
...
...
@@ -19,6 +19,7 @@
#include "_flac_common.h"
#include <assert.h>
#include <unistd.h>
/* this code was based on flac123, from flac-tools */
...
...
src/decoder/mp3_plugin.c
View file @
2b2d267d
...
...
@@ -17,7 +17,6 @@
*/
#include "../decoder_api.h"
#include "../log.h"
#include "../conf.h"
#include <assert.h>
...
...
@@ -284,7 +283,7 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
}
if
(
count
!=
tagsize
)
{
DEBUG
(
"mp3_decode: error parsing ID3 tag
\n
"
);
g_debug
(
"mp3_decode: error parsing ID3 tag
\n
"
);
g_free
(
allocated
);
return
;
}
...
...
@@ -363,9 +362,9 @@ decode_next_frame_header(struct mp3_data *data, struct tag **tag,
if
((
data
->
stream
).
error
==
MAD_ERROR_BUFLEN
)
return
DECODE_CONT
;
else
{
ERROR
(
"unrecoverable frame level error "
"(%s).
\n
"
,
mad_stream_errorstr
(
&
data
->
stream
));
g_warning
(
"unrecoverable frame level error "
"(%s).
\n
"
,
mad_stream_errorstr
(
&
data
->
stream
));
return
DECODE_BREAK
;
}
}
...
...
@@ -415,9 +414,9 @@ decodeNextFrame(struct mp3_data *data)
if
((
data
->
stream
).
error
==
MAD_ERROR_BUFLEN
)
return
DECODE_CONT
;
else
{
ERROR
(
"unrecoverable frame level error "
"(%s).
\n
"
,
mad_stream_errorstr
(
&
data
->
stream
));
g_warning
(
"unrecoverable frame level error "
"(%s).
\n
"
,
mad_stream_errorstr
(
&
data
->
stream
));
return
DECODE_BREAK
;
}
}
...
...
@@ -588,8 +587,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
&
lame
->
version
.
major
,
&
lame
->
version
.
minor
)
!=
2
)
return
false
;
DEBUG
(
"detected LAME version %i.%i (
\"
%s
\"
)
\n
"
,
lame
->
version
.
major
,
lame
->
version
.
minor
,
lame
->
encoder
);
g_debug
(
"detected LAME version %i.%i (
\"
%s
\"
)
\n
"
,
lame
->
version
.
major
,
lame
->
version
.
minor
,
lame
->
encoder
);
/* 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
...
...
@@ -605,7 +604,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
mad_bit_read
(
ptr
,
16
);
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
;
name
=
mad_bit_read
(
ptr
,
3
);
/* gain name */
...
...
@@ -614,7 +613,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
gain
=
mad_bit_read
(
ptr
,
9
);
/* gain*10 */
if
(
gain
&&
name
==
1
&&
orig
!=
0
)
{
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
...
...
@@ -629,7 +628,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
gain = mad_bit_read(ptr, 9); /* gain*10 */
if (gain && name == 2 && orig != 0) {
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
mad_bit_read
(
ptr
,
16
);
...
...
@@ -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_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
);
mad_bit_read
(
ptr
,
80
);
...
...
@@ -771,8 +770,8 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag,
return
false
;
if
(
data
->
max_frames
>
8
*
1024
*
1024
)
{
ERROR
(
"mp3 file header indicates too many frames: %lu
"
,
data
->
max_frames
);
g_warning
(
"mp3 file header indicates too many frames: %lu
\n
"
,
data
->
max_frames
);
return
false
;
}
...
...
@@ -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
(
decoder_get_command
(
decoder
)
==
DECODE_COMMAND_NONE
)
ERROR
g_warning
(
"Input does not appear to be a mp3 bit stream.
\n
"
);
return
;
}
...
...
@@ -1107,8 +1106,8 @@ static struct tag *mp3_tag_dup(const char *file)
ret
=
tag_new
();
ret
->
time
=
total_time
;
}
else
{
DEBUG
(
"mp3_tag_dup: Failed to get total song time from: %s
\n
"
,
file
);
g_debug
(
"mp3_tag_dup: Failed to get total song time from: %s
\n
"
,
file
);
}
return
ret
;
...
...
src/decoder/mpc_plugin.c
View file @
2b2d267d
...
...
@@ -20,6 +20,7 @@
#include <mpcdec/mpcdec.h>
#include <glib.h>
#include <unistd.h>
typedef
struct
_MpcCallbackData
{
struct
input_stream
*
inStream
;
...
...
src/decoder/oggflac_plugin.c
View file @
2b2d267d
...
...
@@ -23,6 +23,7 @@
#include "_ogg_common.h"
#include <OggFLAC/seekable_stream_decoder.h>
#include <unistd.h>
static
void
oggflac_cleanup
(
FlacData
*
data
,
OggFLAC__SeekableStreamDecoder
*
decoder
)
...
...
src/decoder/oggvorbis_plugin.c
View file @
2b2d267d
...
...
@@ -38,6 +38,7 @@
#include <glib.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef WORDS_BIGENDIAN
#define OGG_DECODE_USE_BIGENDIAN 1
...
...
src/decoder/wavpack_plugin.c
View file @
2b2d267d
...
...
@@ -24,6 +24,7 @@
#include <wavpack/wavpack.h>
#include <glib.h>
#include <unistd.h>
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
#define CHUNK_SIZE 1020
...
...
src/decoder_api.c
View file @
2b2d267d
...
...
@@ -26,9 +26,9 @@
#include "utils.h"
#include "normalize.h"
#include "pipe.h"
#include "gcc.h"
#include <assert.h>
#include <glib.h>
void
decoder_initialized
(
struct
decoder
*
decoder
,
const
struct
audio_format
*
audio_format
,
...
...
@@ -54,17 +54,18 @@ void decoder_initialized(struct decoder * decoder,
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
);
}
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
;
}
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_SEEK
||
...
...
@@ -78,7 +79,7 @@ void decoder_command_finished(mpd_unused struct decoder * decoder)
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
);
...
...
@@ -275,7 +276,7 @@ decoder_data(struct decoder *decoder,
}
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
)
{
struct
tag
*
tag2
=
is
!=
NULL
?
tag_add_stream_tags
(
tag
,
is
)
:
NULL
;
...
...
src/decoder_thread.c
View file @
2b2d267d
...
...
@@ -28,6 +28,8 @@
#include "log.h"
#include "ls.h"
#include <glib.h>
static
bool
decoder_stream_decode
(
const
struct
decoder_plugin
*
plugin
,
struct
decoder
*
decoder
,
...
...
@@ -200,7 +202,7 @@ static void decoder_run(void)
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
)
{
assert
(
dc
.
state
==
DECODE_STATE_STOP
||
...
...
src/input_curl.c
View file @
2b2d267d
...
...
@@ -18,8 +18,8 @@
#include "input_curl.h"
#include "input_stream.h"
#include "gcc.h"
#include "dlist.h"
#include "config.h"
#include <assert.h>
#include <sys/select.h>
...
...
@@ -327,7 +327,7 @@ input_curl_close(struct input_stream *is)
}
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
;
...
...
@@ -460,6 +460,8 @@ input_curl_easy_init(struct input_stream *is)
if
(
mcode
!=
CURLM_OK
)
return
false
;
curl_easy_setopt
(
c
->
easy
,
CURLOPT_USERAGENT
,
"Music Player Daemon "
VERSION
);
curl_easy_setopt
(
c
->
easy
,
CURLOPT_HEADERFUNCTION
,
input_curl_headerfunction
);
curl_easy_setopt
(
c
->
easy
,
CURLOPT_WRITEHEADER
,
is
);
...
...
@@ -467,6 +469,8 @@ input_curl_easy_init(struct input_stream *is)
input_curl_writefunction
);
curl_easy_setopt
(
c
->
easy
,
CURLOPT_WRITEDATA
,
is
);
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_ERRORBUFFER
,
c
->
error
);
...
...
@@ -475,8 +479,10 @@ input_curl_easy_init(struct input_stream *is)
return
false
;
c
->
request_headers
=
NULL
;
/*
c->request_headers = curl_slist_append(c->request_headers,
"Icy-Metadata: 1");
*/
curl_easy_setopt
(
c
->
easy
,
CURLOPT_HTTPHEADER
,
c
->
request_headers
);
return
true
;
...
...
src/input_file.c
View file @
2b2d267d
...
...
@@ -17,7 +17,6 @@
*/
#include "input_file.h"
#include "gcc.h"
#include <sys/stat.h>
#include <fcntl.h>
...
...
@@ -117,7 +116,7 @@ input_file_eof(struct input_stream *is)
}
static
int
input_file_buffer
(
mpd_unused
struct
input_stream
*
is
)
input_file_buffer
(
G_GNUC_UNUSED
struct
input_stream
*
is
)
{
return
0
;
}
...
...
src/listen.c
View file @
2b2d267d
...
...
@@ -190,7 +190,10 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
DEBUG
(
"binding to address for %s
\n
"
,
param
->
value
);
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_socktype
=
SOCK_STREAM
;
hints
.
ai_protocol
=
IPPROTO_TCP
;
...
...
src/log.c
View file @
2b2d267d
...
...
@@ -164,7 +164,7 @@ void setup_log_output(bool use_stdout)
}
#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) { \
va_list args; \
...
...
@@ -182,7 +182,7 @@ log_func(DEBUG, G_LOG_LEVEL_DEBUG)
#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_start
(
args
,
fmt
);
...
...
src/log.h
View file @
2b2d267d
...
...
@@ -19,16 +19,15 @@
#ifndef MPD_LOG_H
#define MPD_LOG_H
#include "gcc.h"
#include <glib.h>
#include <stdbool.h>
mpd_printf
void
ERROR
(
const
char
*
fmt
,
...);
mpd_printf
void
LOG
(
const
char
*
fmt
,
...);
mpd_printf
void
SECURE
(
const
char
*
fmt
,
...);
mpd_printf
void
DEBUG
(
const
char
*
fmt
,
...);
mpd_printf
void
WARNING
(
const
char
*
fmt
,
...);
mpd_printf
mpd_noreturn
void
FATAL
(
const
char
*
fmt
,
...);
G_GNUC_PRINTF
(
1
,
2
)
void
ERROR
(
const
char
*
fmt
,
...);
G_GNUC_PRINTF
(
1
,
2
)
void
LOG
(
const
char
*
fmt
,
...);
G_GNUC_PRINTF
(
1
,
2
)
void
SECURE
(
const
char
*
fmt
,
...);
G_GNUC_PRINTF
(
1
,
2
)
void
DEBUG
(
const
char
*
fmt
,
...);
G_GNUC_PRINTF
(
1
,
2
)
void
WARNING
(
const
char
*
fmt
,
...);
G_GNUC_PRINTF
(
1
,
2
)
G_GNUC_NORETURN
void
FATAL
(
const
char
*
fmt
,
...);
void
initLog
(
bool
verbose
);
...
...
src/main.c
View file @
2b2d267d
...
...
@@ -416,6 +416,7 @@ int main(int argc, char *argv[])
initPermissions
();
initPlaylist
();
decoder_plugin_init_all
();
update_global_init
();
init_main_notify
();
...
...
@@ -470,6 +471,8 @@ int main(int argc, char *argv[])
}
}
g_timer_destroy
(
save_state_timer
);
write_state_file
();
playerKill
();
finishZeroconf
();
...
...
@@ -495,6 +498,7 @@ int main(int argc, char *argv[])
dc_deinit
();
pc_deinit
();
command_finish
();
update_global_finish
();
decoder_plugin_deinit_all
();
music_pipe_free
();
cleanUpPidFile
();
...
...
src/main_notify.c
View file @
2b2d267d
...
...
@@ -22,10 +22,10 @@
#include "notify.h"
#include "utils.h"
#include "ioops.h"
#include "gcc.h"
#include "log.h"
#include <assert.h>
#include <glib.h>
#include <string.h>
static
struct
ioOps
main_notify_IO
;
...
...
@@ -35,7 +35,8 @@ static struct notify main_notify;
static
pthread_mutex_t
select_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
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
);
return
main_pipe
[
0
];
...
...
@@ -51,7 +52,8 @@ static void consume_pipe(void)
}
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
))
{
consume_pipe
();
...
...
src/output/alsa_plugin.c
View file @
2b2d267d
...
...
@@ -28,6 +28,10 @@
static
const
char
default_device
[]
=
"default"
;
enum
{
MPD_ALSA_BUFFER_TIME_US
=
500000
,
};
#define MPD_ALSA_RETRY_NR 5
typedef
snd_pcm_sframes_t
alsa_writei_t
(
snd_pcm_t
*
pcm
,
const
void
*
buffer
,
...
...
@@ -62,7 +66,7 @@ static AlsaData *newAlsaData(void)
ret
->
pcmHandle
=
NULL
;
ret
->
writei
=
snd_pcm_writei
;
ret
->
useMmap
=
0
;
ret
->
buffer_time
=
0
;
ret
->
buffer_time
=
MPD_ALSA_BUFFER_TIME_US
;
ret
->
period_time
=
0
;
return
ret
;
...
...
src/output/ao_plugin.c
View file @
2b2d267d
...
...
@@ -17,10 +17,12 @@
*/
#include "../output_api.h"
#include "../utils.h"
#include "../log.h"
#include <ao/ao.h>
#include <glib.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "ao"
static
int
driverInitCount
;
...
...
@@ -33,22 +35,43 @@ typedef struct _AoData {
static
AoData
*
newAoData
(
void
)
{
AoData
*
ret
=
x
malloc
(
sizeof
(
AoData
));
AoData
*
ret
=
g_
malloc
(
sizeof
(
AoData
));
ret
->
device
=
NULL
;
ret
->
options
=
NULL
;
return
ret
;
}
static
void
audioOutputAo_error
(
void
)
static
void
audioOutputAo_error
(
const
char
*
msg
)
{
if
(
errno
==
AO_ENOTLIVE
)
{
ERROR
(
"not a live ao device
\n
"
);
}
else
if
(
errno
==
AO_EOPENDEVICE
)
{
ERROR
(
"not able to open audio device
\n
"
);
}
else
if
(
errno
==
AO_EBADOPTION
)
{
ERROR
(
"bad driver option
\n
"
);
const
char
*
error
;
switch
(
errno
)
{
case
AO_ENODRIVER
:
error
=
"No such libao driver"
;
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
,
...
...
@@ -69,8 +92,8 @@ static void *audioOutputAo_initDriver(struct audio_output *ao,
if
((
blockParam
=
getBlockParam
(
param
,
"write_size"
)))
{
ad
->
writeSize
=
strtol
(
blockParam
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
FATAL
(
"
\"
%s
\"
is not a valid write size at line %i
\n
"
,
blockParam
->
value
,
blockParam
->
line
);
g_error
(
"
\"
%s
\"
is not a valid write size at line %i
\n
"
,
blockParam
->
value
,
blockParam
->
line
);
}
}
else
ad
->
writeSize
=
1024
;
...
...
@@ -85,24 +108,24 @@ static void *audioOutputAo_initDriver(struct audio_output *ao,
if
(
!
blockParam
||
0
==
strcmp
(
blockParam
->
value
,
"default"
))
{
ad
->
driverId
=
ao_default_driver_id
();
}
else
if
((
ad
->
driverId
=
ao_driver_id
(
blockParam
->
value
))
<
0
)
{
FATAL
(
"
\"
%s
\"
is not a valid ao driver at line %i
\n
"
,
blockParam
->
value
,
blockParam
->
line
);
g_error
(
"
\"
%s
\"
is not a valid ao driver at line %i
\n
"
,
blockParam
->
value
,
blockParam
->
line
);
}
if
((
ai
=
ao_driver_info
(
ad
->
driverId
))
==
NULL
)
{
FATAL
(
"problems getting driver info for device defined at line %i
\n
"
"you may not have permission to the audio device
\n
"
,
param
->
line
);
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
);
}
DEBUG
(
"using ao driver
\"
%s
\"
for
\"
%s
\"\n
"
,
ai
->
short_name
,
audio_output_get_name
(
ao
));
g_debug
(
"using ao driver
\"
%s
\"
for
\"
%s
\"\n
"
,
ai
->
short_name
,
audio_output_get_name
(
ao
));
blockParam
=
getBlockParam
(
param
,
"options"
);
if
(
blockParam
)
{
duplicated
=
x
strdup
(
blockParam
->
value
);
duplicated
=
g_
strdup
(
blockParam
->
value
);
}
else
duplicated
=
x
strdup
(
""
);
duplicated
=
g_
strdup
(
""
);
if
(
strlen
(
duplicated
))
{
stk1
=
NULL
;
...
...
@@ -111,7 +134,7 @@ static void *audioOutputAo_initDriver(struct audio_output *ao,
stk2
=
NULL
;
key
=
strtok_r
(
n1
,
"="
,
&
stk2
);
if
(
!
key
)
FATAL
(
"problems parsing options
\"
%s
\"\n
"
,
n1
);
g_error
(
"problems parsing options
\"
%s
\"\n
"
,
n1
);
/*found = 0;
for(i=0;i<ai->option_count;i++) {
if(strcmp(ai->options[i],key)==0) {
...
...
@@ -126,7 +149,7 @@ static void *audioOutputAo_initDriver(struct audio_output *ao,
} */
value
=
strtok_r
(
NULL
,
""
,
&
stk2
);
if
(
!
value
)
FATAL
(
"problems parsing options
\"
%s
\"\n
"
,
n1
);
g_error
(
"problems parsing options
\"
%s
\"\n
"
,
n1
);
ao_append_option
(
&
ad
->
options
,
key
,
value
);
n1
=
strtok_r
(
NULL
,
";"
,
&
stk1
);
}
...
...
@@ -185,8 +208,10 @@ audioOutputAo_openDevice(void *data, struct audio_format *audio_format)
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
true
;
}
...
...
@@ -222,8 +247,7 @@ audioOutputAo_play(void *data, const char *playChunk, size_t size)
?
size
:
(
size_t
)
ad
->
writeSize
;
if
(
ao_play_deconst
(
ad
->
device
,
playChunk
,
chunk_size
)
==
0
)
{
audioOutputAo_error
();
ERROR
(
"closing audio device due to write error
\n
"
);
audioOutputAo_error
(
"Closing libao device due to play error"
);
return
false
;
}
...
...
src/output/mvp_plugin.c
View file @
2b2d267d
...
...
@@ -20,13 +20,18 @@
*/
#include "../output_api.h"
#include "../utils.h"
#include "../log.h"
#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "mvp"
typedef
struct
{
unsigned
long
dsp_status
;
...
...
@@ -92,8 +97,8 @@ static bool mvp_testDefault(void)
return
true
;
}
WARNING
(
"Error opening PCM device
\"
/dev/adec_pcm
\"
: %s
\n
"
,
strerror
(
errno
));
g_warning
(
"Error opening PCM device
\"
/dev/adec_pcm
\"
: %s
\n
"
,
strerror
(
errno
));
return
false
;
}
...
...
@@ -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
ConfigParam
*
param
)
{
MvpData
*
md
=
xmalloc
(
sizeof
(
MvpData
)
);
MvpData
*
md
=
g_new
(
MvpData
,
1
);
md
->
audio_output
=
audio_output
;
md
->
fd
=
-
1
;
...
...
@@ -156,22 +161,23 @@ static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels,
}
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
;
}
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
;
}
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
;
}
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
;
}
...
...
@@ -186,24 +192,29 @@ mvp_openDevice(void *data, struct audio_format *audioFormat)
int
mix
[
5
]
=
{
0
,
2
,
7
,
1
,
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
;
}
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
;
}
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
;
}
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
;
}
ioctl
(
md
->
fd
,
MVP_SET_AUD_STC
,
&
stc
);
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
;
}
#ifdef WORDS_BIGENDIAN
...
...
@@ -251,8 +262,8 @@ mvp_playAudio(void *data, const char *playChunk, size_t size)
if
(
ret
<
0
)
{
if
(
errno
==
EINTR
)
continue
;
ERROR
(
"closing mvp PCM device due to write error: "
"%s
\n
"
,
strerror
(
errno
));
g_warning
(
"closing mvp PCM device due to write error: "
"%s
\n
"
,
strerror
(
errno
));
return
false
;
}
playChunk
+=
ret
;
...
...
src/output/oss_plugin.c
View file @
2b2d267d
...
...
@@ -20,12 +20,17 @@
*/
#include "../output_api.h"
#include "../utils.h"
#include "../log.h"
#include <glib.h>
#include <sys/stat.h>
#include <sys/ioctl.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__)
# include <soundcard.h>
...
...
@@ -153,8 +158,8 @@ static void addSupportedParam(OssData * od, unsigned param, int val)
enum
oss_param
idx
=
getIndexForParam
(
param
);
od
->
numSupported
[
idx
]
++
;
od
->
supported
[
idx
]
=
x
realloc
(
od
->
supported
[
idx
],
od
->
numSupported
[
idx
]
*
sizeof
(
int
));
od
->
supported
[
idx
]
=
g_
realloc
(
od
->
supported
[
idx
],
od
->
numSupported
[
idx
]
*
sizeof
(
int
));
od
->
supported
[
idx
][
od
->
numSupported
[
idx
]
-
1
]
=
val
;
}
...
...
@@ -163,9 +168,9 @@ static void addUnsupportedParam(OssData * od, unsigned param, int val)
enum
oss_param
idx
=
getIndexForParam
(
param
);
od
->
numUnsupported
[
idx
]
++
;
od
->
unsupported
[
idx
]
=
x
realloc
(
od
->
unsupported
[
idx
],
od
->
numUnsupported
[
idx
]
*
sizeof
(
int
));
od
->
unsupported
[
idx
]
=
g_
realloc
(
od
->
unsupported
[
idx
],
od
->
numUnsupported
[
idx
]
*
sizeof
(
int
));
od
->
unsupported
[
idx
][
od
->
numUnsupported
[
idx
]
-
1
]
=
val
;
}
...
...
@@ -182,8 +187,8 @@ static void removeSupportedParam(OssData * od, unsigned param, int val)
}
od
->
numSupported
[
idx
]
--
;
od
->
supported
[
idx
]
=
x
realloc
(
od
->
supported
[
idx
],
od
->
numSupported
[
idx
]
*
sizeof
(
int
));
od
->
supported
[
idx
]
=
g_
realloc
(
od
->
supported
[
idx
],
od
->
numSupported
[
idx
]
*
sizeof
(
int
));
}
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
->
unsupported
[
idx
]
=
x
realloc
(
od
->
unsupported
[
idx
],
od
->
numUnsupported
[
idx
]
*
sizeof
(
int
));
od
->
unsupported
[
idx
]
=
g_
realloc
(
od
->
unsupported
[
idx
],
od
->
numUnsupported
[
idx
]
*
sizeof
(
int
));
}
static
enum
oss_support
...
...
@@ -244,7 +249,7 @@ static void unsupportParam(OssData * od, unsigned param, int val)
static
OssData
*
newOssData
(
void
)
{
OssData
*
ret
=
xmalloc
(
sizeof
(
OssData
)
);
OssData
*
ret
=
g_new
(
OssData
,
1
);
ret
->
device
=
NULL
;
ret
->
fd
=
-
1
;
...
...
@@ -273,18 +278,12 @@ static OssData *newOssData(void)
static
void
freeOssData
(
OssData
*
od
)
{
if
(
od
->
supported
[
OSS_RATE
])
free
(
od
->
supported
[
OSS_RATE
]);
if
(
od
->
supported
[
OSS_CHANNELS
])
free
(
od
->
supported
[
OSS_CHANNELS
]);
if
(
od
->
supported
[
OSS_BITS
])
free
(
od
->
supported
[
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
]);
g_free
(
od
->
supported
[
OSS_RATE
]);
g_free
(
od
->
supported
[
OSS_CHANNELS
]);
g_free
(
od
->
supported
[
OSS_BITS
]);
g_free
(
od
->
unsupported
[
OSS_RATE
]);
g_free
(
od
->
unsupported
[
OSS_CHANNELS
]);
g_free
(
od
->
unsupported
[
OSS_BITS
]);
free
(
od
);
}
...
...
@@ -326,13 +325,13 @@ static bool oss_testDefault(void)
{
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
)
{
x
close
(
fd
);
close
(
fd
);
return
true
;
}
WARNING
(
"Error opening OSS device
\"
%s
\"
: %s
\n
"
,
default_devices
[
i
],
strerror
(
errno
));
g_warning
(
"Error opening OSS device
\"
%s
\"
: %s
\n
"
,
default_devices
[
i
],
strerror
(
errno
));
}
return
false
;
...
...
@@ -341,10 +340,10 @@ static bool oss_testDefault(void)
static
void
*
oss_open_default
(
ConfigParam
*
param
)
{
int
i
;
int
err
[
ARRAY_SIZE
(
default_devices
)];
int
ret
[
ARRAY_SIZE
(
default_devices
)];
int
err
[
G_N_ELEMENTS
(
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
]);
if
(
ret
[
i
]
==
0
)
{
OssData
*
od
=
newOssData
();
...
...
@@ -354,25 +353,26 @@ static void *oss_open_default(ConfigParam *param)
}
if
(
param
)
ERROR
(
"error trying to open specified OSS device"
" at line %i
\n
"
,
param
->
line
);
g_warning
(
"error trying to open specified OSS device"
" at line %i
\n
"
,
param
->
line
);
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
];
switch
(
ret
[
i
])
{
case
OSS_STAT_DOESN_T_EXIST
:
ERROR
(
"%s not found
\n
"
,
dev
);
g_warning
(
"%s not found
\n
"
,
dev
);
break
;
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
;
case
OSS_STAT_NO_PERMS
:
ERROR
(
"%s: permission denied
\n
"
,
dev
);
g_warning
(
"%s: permission denied
\n
"
,
dev
);
break
;
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
);
...
...
@@ -443,24 +443,25 @@ static bool oss_open(OssData *od)
int
tmp
;
if
((
od
->
fd
=
open
(
od
->
device
,
O_WRONLY
))
<
0
)
{
ERROR
(
"Error opening OSS device
\"
%s
\"
: %s
\n
"
,
od
->
device
,
strerror
(
errno
));
g_warning
(
"Error opening OSS device
\"
%s
\"
: %s
\n
"
,
od
->
device
,
strerror
(
errno
));
goto
fail
;
}
tmp
=
od
->
audio_format
.
channels
;
if
(
setParam
(
od
,
SNDCTL_DSP_CHANNELS
,
&
tmp
))
{
ERROR
(
"OSS device
\"
%s
\"
does not support %u channels: %s
\n
"
,
od
->
device
,
od
->
audio_format
.
channels
,
strerror
(
errno
));
g_warning
(
"OSS device
\"
%s
\"
does not support %u channels: %s
\n
"
,
od
->
device
,
od
->
audio_format
.
channels
,
strerror
(
errno
));
goto
fail
;
}
od
->
audio_format
.
channels
=
tmp
;
tmp
=
od
->
audio_format
.
sample_rate
;
if
(
setParam
(
od
,
SNDCTL_DSP_SPEED
,
&
tmp
))
{
ERROR
(
"OSS device
\"
%s
\"
does not support %u Hz audio: %s
\n
"
,
od
->
device
,
od
->
audio_format
.
sample_rate
,
strerror
(
errno
));
g_warning
(
"OSS device
\"
%s
\"
does not support %u Hz audio: %s
\n
"
,
od
->
device
,
od
->
audio_format
.
sample_rate
,
strerror
(
errno
));
goto
fail
;
}
od
->
audio_format
.
sample_rate
=
tmp
;
...
...
@@ -481,8 +482,8 @@ static bool oss_open(OssData *od)
}
if
(
setParam
(
od
,
SNDCTL_DSP_SAMPLESIZE
,
&
tmp
))
{
ERROR
(
"OSS device
\"
%s
\"
does not support %u bit audio: %s
\n
"
,
od
->
device
,
tmp
,
strerror
(
errno
));
g_warning
(
"OSS device
\"
%s
\"
does not support %u bit audio: %s
\n
"
,
od
->
device
,
tmp
,
strerror
(
errno
));
goto
fail
;
}
...
...
@@ -507,10 +508,10 @@ oss_openDevice(void *data, struct audio_format *audioFormat)
*
audioFormat
=
od
->
audio_format
;
DEBUG
(
"oss
device
\"
%s
\"
will be playing %u bit %u channel audio at "
"%u Hz
\n
"
,
od
->
device
,
od
->
audio_format
.
bits
,
od
->
audio_format
.
channels
,
od
->
audio_format
.
sample_rate
);
g_debug
(
"
device
\"
%s
\"
will be playing %u bit %u channel audio at "
"%u Hz
\n
"
,
od
->
device
,
od
->
audio_format
.
bits
,
od
->
audio_format
.
channels
,
od
->
audio_format
.
sample_rate
);
return
ret
;
}
...
...
@@ -547,8 +548,8 @@ oss_playAudio(void *data, const char *playChunk, size_t size)
if
(
ret
<
0
)
{
if
(
errno
==
EINTR
)
continue
;
ERROR
(
"closing oss device
\"
%s
\"
due to write error: "
"%s
\n
"
,
od
->
device
,
strerror
(
errno
));
g_warning
(
"closing oss device
\"
%s
\"
due to write error: "
"%s
\n
"
,
od
->
device
,
strerror
(
errno
));
return
false
;
}
playChunk
+=
ret
;
...
...
src/output/shout_mp3.c
View file @
2b2d267d
...
...
@@ -17,9 +17,9 @@
*/
#include "shout_plugin.h"
#include "../utils.h"
#include <lame/lame.h>
#include <stdlib.h>
struct
lame_data
{
lame_global_flags
*
gfp
;
...
...
@@ -28,10 +28,8 @@ struct lame_data {
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
;
return
0
;
...
...
@@ -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
,
buf
->
len
))
<
0
)
ERROR
(
"error flushing lame buffers
\n
"
);
g_warning
(
"error flushing lame buffers
\n
"
);
return
(
ret
>
0
);
}
...
...
@@ -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
;
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
;
}
if
(
sd
->
quality
>=
-
1
.
0
)
{
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
;
}
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
;
}
}
else
{
if
(
0
!=
lame_set_brate
(
ld
->
gfp
,
sd
->
bitrate
))
{
ERROR
(
"error setting lame bitrate
\n
"
);
g_warning
(
"error setting lame bitrate
\n
"
);
return
-
1
;
}
}
if
(
0
!=
lame_set_num_channels
(
ld
->
gfp
,
sd
->
audio_format
.
channels
))
{
ERROR
(
"error setting lame num channels
\n
"
);
g_warning
(
"error setting lame num channels
\n
"
);
return
-
1
;
}
if
(
0
!=
lame_set_in_samplerate
(
ld
->
gfp
,
sd
->
audio_format
.
sample_rate
))
{
ERROR
(
"error setting lame sample rate
\n
"
);
g_warning
(
"error setting lame sample rate
\n
"
);
return
-
1
;
}
if
(
0
>
lame_init_params
(
ld
->
gfp
))
FATAL
(
"error initializing lame params
\n
"
);
g_error
(
"error initializing lame params
\n
"
);
return
0
;
}
...
...
@@ -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
,
const
char
*
chunk
,
size_t
len
)
{
const
int16_t
*
src
=
(
const
int16_t
*
)
chunk
;
unsigned
int
i
;
int
j
;
float
(
*
lamebuf
)[
2
];
float
*
left
,
*
right
;
struct
shout_buffer
*
buf
=
&
(
sd
->
buf
);
unsigned
int
samples
;
int
bytes
=
audio_format_sample_size
(
&
sd
->
audio_format
);
...
...
@@ -143,25 +141,31 @@ static int shout_mp3_encoder_encode(struct shout_data *sd,
int
bytes_out
;
samples
=
len
/
(
bytes
*
sd
->
audio_format
.
channels
);
/* rough estimate, from lame.h */
lamebuf
=
xmalloc
(
sizeof
(
float
)
*
(
1
.
25
*
samples
+
7200
));
left
=
g_malloc
(
sizeof
(
left
[
0
])
*
samples
);
if
(
sd
->
audio_format
.
channels
>
1
)
right
=
g_malloc
(
sizeof
(
left
[
0
])
*
samples
);
else
right
=
left
;
/* this is for only 16-bit audio */
for
(
i
=
0
;
i
<
samples
;
i
++
)
{
for
(
j
=
0
;
j
<
sd
->
audio_format
.
channels
;
j
++
)
{
lamebuf
[
j
][
i
]
=
*
((
const
int16_t
*
)
chunk
);
chunk
+=
bytes
;
}
left
[
i
]
=
src
[
0
];
if
(
right
!=
left
)
right
[
i
]
=
src
[
1
]
;
src
+=
sd
->
audio_format
.
channels
;
}
bytes_out
=
lame_encode_buffer_float
(
ld
->
gfp
,
l
amebuf
[
0
],
lamebuf
[
1
]
,
bytes_out
=
lame_encode_buffer_float
(
ld
->
gfp
,
l
eft
,
right
,
samples
,
buf
->
data
,
sizeof
(
buf
->
data
)
-
buf
->
len
);
free
(
lamebuf
);
g_free
(
left
);
if
(
right
!=
left
)
g_free
(
right
);
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
);
ld
->
gfp
=
NULL
;
return
-
1
;
...
...
src/output/shout_ogg.c
View file @
2b2d267d
...
...
@@ -17,9 +17,9 @@
*/
#include "shout_plugin.h"
#include "../utils.h"
#include <vorbis/vorbisenc.h>
#include <stdlib.h>
struct
ogg_vorbis_data
{
ogg_stream_state
os
;
...
...
@@ -80,7 +80,7 @@ static int copy_ogg_buffer_to_shout_buffer(ogg_page *og,
og
->
header
,
og
->
header_len
);
buf
->
len
+=
og
->
header_len
;
}
else
{
ERROR
(
"%s: not enough buffer space!
\n
"
,
__func__
);
g_warning
(
"%s: not enough buffer space!
\n
"
,
__func__
);
return
-
1
;
}
...
...
@@ -89,7 +89,7 @@ static int copy_ogg_buffer_to_shout_buffer(ogg_page *og,
og
->
body
,
og
->
body_len
);
buf
->
len
+=
og
->
body_len
;
}
else
{
ERROR
(
"%s: not enough buffer space!
\n
"
,
__func__
);
g_warning
(
"%s: not enough buffer space!
\n
"
,
__func__
);
return
-
1
;
}
...
...
@@ -167,10 +167,8 @@ static void shout_ogg_encoder_finish(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
;
return
0
;
...
...
@@ -187,7 +185,7 @@ static int reinit_encoder(struct shout_data *sd)
sd
->
audio_format
.
channels
,
sd
->
audio_format
.
sample_rate
,
sd
->
quality
*
0
.
1
))
{
ERROR
(
"error initializing vorbis vbr
\n
"
);
g_warning
(
"error initializing vorbis vbr
\n
"
);
vorbis_info_clear
(
&
od
->
vi
);
return
-
1
;
}
...
...
@@ -196,7 +194,7 @@ static int reinit_encoder(struct shout_data *sd)
sd
->
audio_format
.
channels
,
sd
->
audio_format
.
sample_rate
,
-
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
);
return
-
1
;
}
...
...
@@ -216,7 +214,7 @@ static int shout_ogg_encoder_init_encoder(struct shout_data *sd)
return
-
1
;
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
;
}
...
...
src/output/shout_plugin.c
View file @
2b2d267d
...
...
@@ -18,11 +18,9 @@
#include "shout_plugin.h"
#ifdef HAVE_SHOUT
#include "../utils.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#define CONN_ATTEMPT_INTERVAL 60
#define DEFAULT_CONN_TIMEOUT 2
...
...
@@ -53,7 +51,7 @@ shout_encoder_plugin_get(const char *name)
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_meta
=
shout_metadata_new
();
...
...
@@ -88,8 +86,8 @@ static void free_shout_data(struct shout_data *sd)
#define check_block_param(name) { \
block_param = getBlockParam(param, name); \
if (!block_param) { \
FATAL
("no \"%s\" defined for shout device defined at line " \
"%i\n", name, param->line); \
g_error
("no \"%s\" defined for shout device defined at line " \
"%i\n", name, param->line); \
} \
}
...
...
@@ -129,8 +127,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
port
=
strtol
(
block_param
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
||
port
<=
0
)
{
FATAL
(
"shout port
\"
%s
\"
is not a positive integer, line %i
\n
"
,
block_param
->
value
,
block_param
->
line
);
g_error
(
"shout port
\"
%s
\"
is not a positive integer, line %i
\n
"
,
block_param
->
value
,
block_param
->
line
);
}
check_block_param
(
"password"
);
...
...
@@ -157,31 +155,31 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
sd
->
quality
=
strtod
(
block_param
->
value
,
&
test
);
if
(
*
test
!=
'\0'
||
sd
->
quality
<
-
1
.
0
||
sd
->
quality
>
10
.
0
)
{
FATAL
(
"shout quality
\"
%s
\"
is not a number in the "
"range -1 to 10, line %i
\n
"
,
block_param
->
value
,
block_param
->
line
);
g_error
(
"shout quality
\"
%s
\"
is not a number in the "
"range -1 to 10, line %i
\n
"
,
block_param
->
value
,
block_param
->
line
);
}
block_param
=
getBlockParam
(
param
,
"bitrate"
);
if
(
block_param
)
{
FATAL
(
"quality (line %i) and bitrate (line %i) are "
"both defined for shout output
\n
"
,
line
,
block_param
->
line
);
g_error
(
"quality (line %i) and bitrate (line %i) are "
"both defined for shout output
\n
"
,
line
,
block_param
->
line
);
}
}
else
{
block_param
=
getBlockParam
(
param
,
"bitrate"
);
if
(
!
block_param
)
{
FATAL
(
"neither bitrate nor quality defined for shout "
"output at line %i
\n
"
,
param
->
line
);
g_error
(
"neither bitrate nor quality defined for shout "
"output at line %i
\n
"
,
param
->
line
);
}
sd
->
bitrate
=
strtol
(
block_param
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
||
sd
->
bitrate
<=
0
)
{
FATAL
(
"bitrate at line %i should be a positive integer "
"
\n
"
,
block_param
->
line
);
g_error
(
"bitrate at line %i should be a positive integer "
"
\n
"
,
block_param
->
line
);
}
}
...
...
@@ -197,24 +195,24 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
else
if
(
0
==
strcmp
(
block_param
->
value
,
"ogg"
))
encoding
=
block_param
->
value
;
else
FATAL
(
"shout encoding
\"
%s
\"
is not
\"
ogg
\"
or "
"
\"
mp3
\"
, line %i
\n
"
,
block_param
->
value
,
block_param
->
line
);
g_error
(
"shout encoding
\"
%s
\"
is not
\"
ogg
\"
or "
"
\"
mp3
\"
, line %i
\n
"
,
block_param
->
value
,
block_param
->
line
);
}
else
{
encoding
=
"ogg"
;
}
sd
->
encoder
=
shout_encoder_plugin_get
(
encoding
);
if
(
sd
->
encoder
==
NULL
)
FATAL
(
"couldn't find shout encoder plugin for
\"
%s
\"
"
"at line %i
\n
"
,
encoding
,
block_param
->
line
);
g_error
(
"couldn't find shout encoder plugin for
\"
%s
\"
"
"at line %i
\n
"
,
encoding
,
block_param
->
line
);
block_param
=
getBlockParam
(
param
,
"protocol"
);
if
(
block_param
)
{
if
(
0
==
strcmp
(
block_param
->
value
,
"shoutcast"
)
&&
0
!=
strcmp
(
encoding
,
"mp3"
))
FATAL
(
"you cannot stream
\"
%s
\"
to shoutcast, use mp3
\n
"
,
encoding
);
g_error
(
"you cannot stream
\"
%s
\"
to shoutcast, use mp3
\n
"
,
encoding
);
else
if
(
0
==
strcmp
(
block_param
->
value
,
"shoutcast"
))
protocol
=
SHOUT_PROTOCOL_ICY
;
else
if
(
0
==
strcmp
(
block_param
->
value
,
"icecast1"
))
...
...
@@ -222,10 +220,10 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
else
if
(
0
==
strcmp
(
block_param
->
value
,
"icecast2"
))
protocol
=
SHOUT_PROTOCOL_HTTP
;
else
FATAL
(
"shout protocol
\"
%s
\"
is not
\"
shoutcast
\"
or "
"
\"
icecast1
\"
or "
"
\"
icecast2
\"
, line %i
\n
"
,
block_param
->
value
,
block_param
->
line
);
g_error
(
"shout protocol
\"
%s
\"
is not
\"
shoutcast
\"
or "
"
\"
icecast1
\"
or "
"
\"
icecast2
\"
, line %i
\n
"
,
block_param
->
value
,
block_param
->
line
);
}
else
{
protocol
=
SHOUT_PROTOCOL_HTTP
;
}
...
...
@@ -242,8 +240,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
!=
SHOUTERR_SUCCESS
||
shout_set_protocol
(
sd
->
shout_conn
,
protocol
)
!=
SHOUTERR_SUCCESS
||
shout_set_agent
(
sd
->
shout_conn
,
"MPD"
)
!=
SHOUTERR_SUCCESS
)
{
FATAL
(
"error configuring shout defined at line %i: %s
\n
"
,
param
->
line
,
shout_get_error
(
sd
->
shout_conn
));
g_error
(
"error configuring shout defined at line %i: %s
\n
"
,
param
->
line
,
shout_get_error
(
sd
->
shout_conn
));
}
/* optional paramters */
...
...
@@ -251,22 +249,22 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
if
(
block_param
)
{
sd
->
timeout
=
(
int
)
strtol
(
block_param
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
||
sd
->
timeout
<=
0
)
{
FATAL
(
"shout timeout is not a positive integer, "
"line %i
\n
"
,
block_param
->
line
);
g_error
(
"shout timeout is not a positive integer, "
"line %i
\n
"
,
block_param
->
line
);
}
}
block_param
=
getBlockParam
(
param
,
"genre"
);
if
(
block_param
&&
shout_set_genre
(
sd
->
shout_conn
,
block_param
->
value
))
{
FATAL
(
"error configuring shout defined at line %i: %s
\n
"
,
param
->
line
,
shout_get_error
(
sd
->
shout_conn
));
g_error
(
"error configuring shout defined at line %i: %s
\n
"
,
param
->
line
,
shout_get_error
(
sd
->
shout_conn
));
}
block_param
=
getBlockParam
(
param
,
"description"
);
if
(
block_param
&&
shout_set_description
(
sd
->
shout_conn
,
block_param
->
value
))
{
FATAL
(
"error configuring shout defined at line %i: %s
\n
"
,
param
->
line
,
shout_get_error
(
sd
->
shout_conn
));
g_error
(
"error configuring shout defined at line %i: %s
\n
"
,
param
->
line
,
shout_get_error
(
sd
->
shout_conn
));
}
{
...
...
@@ -292,8 +290,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
}
if
(
sd
->
encoder
->
init_func
(
sd
)
!=
0
)
FATAL
(
"shout: encoder plugin '%s' failed to initialize
\n
"
,
sd
->
encoder
->
name
);
g_error
(
"shout: encoder plugin '%s' failed to initialize
\n
"
,
sd
->
encoder
->
name
);
return
sd
;
}
...
...
@@ -305,17 +303,17 @@ static int handle_shout_error(struct shout_data *sd, int err)
break
;
case
SHOUTERR_UNCONNECTED
:
case
SHOUTERR_SOCKET
:
ERROR
(
"Lost shout connection to %s:%i: %s
\n
"
,
shout_get_host
(
sd
->
shout_conn
),
shout_get_port
(
sd
->
shout_conn
),
shout_get_error
(
sd
->
shout_conn
));
g_warning
(
"Lost shout connection to %s:%i: %s
\n
"
,
shout_get_host
(
sd
->
shout_conn
),
shout_get_port
(
sd
->
shout_conn
),
shout_get_error
(
sd
->
shout_conn
));
sd
->
shout_error
=
1
;
return
-
1
;
default:
ERROR
(
"shout: connection to %s:%i error: %s
\n
"
,
shout_get_host
(
sd
->
shout_conn
),
shout_get_port
(
sd
->
shout_conn
),
shout_get_error
(
sd
->
shout_conn
));
g_warning
(
"shout: connection to %s:%i error: %s
\n
"
,
shout_get_host
(
sd
->
shout_conn
),
shout_get_port
(
sd
->
shout_conn
),
shout_get_error
(
sd
->
shout_conn
));
sd
->
shout_error
=
1
;
return
-
1
;
}
...
...
@@ -348,8 +346,8 @@ static void close_shout_conn(struct shout_data * sd)
if
(
shout_get_connected
(
sd
->
shout_conn
)
!=
SHOUTERR_UNCONNECTED
&&
shout_close
(
sd
->
shout_conn
)
!=
SHOUTERR_SUCCESS
)
{
ERROR
(
"problem closing connection to shout server: %s
\n
"
,
shout_get_error
(
sd
->
shout_conn
));
g_warning
(
"problem closing connection to shout server: %s
\n
"
,
shout_get_error
(
sd
->
shout_conn
));
}
sd
->
opened
=
false
;
...
...
@@ -403,11 +401,11 @@ static int shout_connect(struct shout_data *sd)
if
(
state
==
SHOUTERR_BUSY
&&
sd
->
conn_attempts
!=
0
)
{
/* timeout waiting to connect */
if
((
t
-
sd
->
last_attempt
)
>
sd
->
timeout
)
{
ERROR
(
"timeout connecting to shout server %s:%i "
"(attempt %i)
\n
"
,
shout_get_host
(
sd
->
shout_conn
),
shout_get_port
(
sd
->
shout_conn
),
sd
->
conn_attempts
);
g_warning
(
"timeout connecting to shout server %s:%i "
"(attempt %i)
\n
"
,
shout_get_host
(
sd
->
shout_conn
),
shout_get_port
(
sd
->
shout_conn
),
sd
->
conn_attempts
);
return
-
1
;
}
...
...
@@ -437,11 +435,11 @@ static int shout_connect(struct shout_data *sd)
case
SHOUTERR_BUSY
:
return
1
;
default:
ERROR
(
"problem opening connection to shout server %s:%i "
"(attempt %i): %s
\n
"
,
shout_get_host
(
sd
->
shout_conn
),
shout_get_port
(
sd
->
shout_conn
),
sd
->
conn_attempts
,
shout_get_error
(
sd
->
shout_conn
));
g_warning
(
"problem opening connection to shout server %s:%i "
"(attempt %i): %s
\n
"
,
shout_get_host
(
sd
->
shout_conn
),
shout_get_port
(
sd
->
shout_conn
),
sd
->
conn_attempts
,
shout_get_error
(
sd
->
shout_conn
));
return
-
1
;
}
}
...
...
@@ -498,7 +496,7 @@ static void send_metadata(struct shout_data * sd)
shout_metadata_add
(
sd
->
shout_meta
,
"song"
,
song
);
if
(
SHOUTERR_SUCCESS
!=
shout_set_metadata
(
sd
->
shout_conn
,
sd
->
shout_meta
))
{
ERROR
(
"error setting shout metadata
\n
"
);
g_warning
(
"error setting shout metadata
\n
"
);
return
;
}
}
...
...
@@ -582,8 +580,3 @@ const struct audio_output_plugin shoutPlugin = {
.
close
=
my_shout_close_device
,
.
send_tag
=
my_shout_set_tag
,
};
#else
DISABLED_AUDIO_OUTPUT_PLUGIN
(
shoutPlugin
)
#endif
src/output/shout_plugin.h
View file @
2b2d267d
...
...
@@ -24,6 +24,10 @@
#include "../timer.h"
#include <shout/shout.h>
#include <glib.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "shout"
struct
shout_data
;
...
...
src/output_api.h
View file @
2b2d267d
...
...
@@ -24,7 +24,6 @@
#include "audio_format.h"
#include "tag.h"
#include "conf.h"
#include "log.h"
#include <stdbool.h>
...
...
src/output_init.c
View file @
2b2d267d
...
...
@@ -20,9 +20,10 @@
#include "output_api.h"
#include "output_internal.h"
#include "output_list.h"
#include "log.h"
#include "audio.h"
#include <glib.h>
#define AUDIO_OUTPUT_TYPE "type"
#define AUDIO_OUTPUT_NAME "name"
#define AUDIO_OUTPUT_FORMAT "format"
...
...
@@ -30,9 +31,9 @@
#define getBlockParam(name, str, force) { \
bp = getBlockParam(param, name); \
if(force && bp == NULL) { \
FATAL
("couldn't find parameter \"%s\" in audio output " \
"definition beginning at %i\n",
\
name, param->line);
\
g_error
("couldn't find parameter \"%s\" in audio output " \
"definition beginning at %i\n",
\
name, param->line);
\
} \
if(bp) str = bp->value; \
}
...
...
@@ -53,30 +54,30 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
plugin
=
audio_output_plugin_get
(
type
);
if
(
plugin
==
NULL
)
{
FATAL
(
"couldn't find audio output plugin for type "
"
\"
%s
\"
at line %i
\n
"
,
type
,
param
->
line
);
g_error
(
"couldn't find audio output plugin for type "
"
\"
%s
\"
at line %i
\n
"
,
type
,
param
->
line
);
}
}
else
{
unsigned
i
;
WARNING
(
"No
\"
%s
\"
defined in config file
\n
"
,
CONF_AUDIO_OUTPUT
);
WARNING
(
"Attempt to detect audio output device
\n
"
);
g_warning
(
"No
\"
%s
\"
defined in config file
\n
"
,
CONF_AUDIO_OUTPUT
);
g_warning
(
"Attempt to detect audio output device
\n
"
);
audio_output_plugins_for_each
(
plugin
,
i
)
{
if
(
plugin
->
test_default_device
)
{
WARNING
(
"Attempting to detect a %s audio "
"device
\n
"
,
plugin
->
name
);
g_warning
(
"Attempting to detect a %s audio "
"device
\n
"
,
plugin
->
name
);
if
(
plugin
->
test_default_device
())
{
WARNING
(
"Successfully detected a %s "
"audio device
\n
"
,
plugin
->
name
);
g_warning
(
"Successfully detected a %s "
"audio device
\n
"
,
plugin
->
name
);
break
;
}
}
}
if
(
plugin
==
NULL
)
{
WARNING
(
"Unable to detect an audio device
\n
"
);
g_warning
(
"Unable to detect an audio device
\n
"
);
return
0
;
}
...
...
@@ -96,7 +97,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
if
(
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
audio_format_clear
(
&
ao
->
reqAudioFormat
);
...
...
src/output_thread.c
View file @
2b2d267d
...
...
@@ -19,9 +19,11 @@
#include "output_thread.h"
#include "output_api.h"
#include "output_internal.h"
#include "utils.h"
#include <glib.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
enum
{
/** after a failure, wait this number of seconds before
...
...
@@ -46,7 +48,7 @@ static void convertAudioFormat(struct audio_output *audioOutput,
if
(
size
>
audioOutput
->
convBufferLen
)
{
if
(
audioOutput
->
convBuffer
!=
NULL
)
free
(
audioOutput
->
convBuffer
);
audioOutput
->
convBuffer
=
x
malloc
(
size
);
audioOutput
->
convBuffer
=
g_
malloc
(
size
);
audioOutput
->
convBufferLen
=
size
;
}
...
...
@@ -164,5 +166,5 @@ void audio_output_thread_start(struct audio_output *ao)
pthread_attr_init
(
&
attr
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
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
));
}
src/path.c
View file @
2b2d267d
...
...
@@ -110,7 +110,7 @@ char *pfx_dir(char *dst,
const
char
*
path
,
const
size_t
path_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
"
,
pfx
,
path
,
MPD_PATH_MAX
);
...
...
src/pcm_resample_fallback.c
View file @
2b2d267d
...
...
@@ -18,18 +18,18 @@
*/
#include "pcm_resample.h"
#include "gcc.h"
#include <assert.h>
#include <glib.h>
/* resampling code blatantly ripped from ESD */
size_t
pcm_resample_16
(
uint8_t
channels
,
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
,
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
dest_samples
=
dest_size
/
sizeof
(
*
dest_buffer
);
...
...
@@ -62,10 +62,10 @@ pcm_resample_16(uint8_t channels,
size_t
pcm_resample_24
(
uint8_t
channels
,
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
,
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
dest_samples
=
dest_size
/
sizeof
(
*
dest_buffer
);
...
...
src/pcm_utils.c
View file @
2b2d267d
...
...
@@ -26,6 +26,7 @@
#include <assert.h>
#include <string.h>
#include <math.h>
#include <glib.h>
static
inline
int
pcm_dither
(
void
)
...
...
@@ -40,9 +41,9 @@ pcm_dither(void)
static
int32_t
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
);
if
(
mpd_unlikely
(
sample
>=
(
1
<<
(
bits
-
1
))))
if
(
G_UNLIKELY
(
sample
>=
(
1
<<
(
bits
-
1
))))
return
(
1
<<
(
bits
-
1
))
-
1
;
return
sample
;
}
...
...
src/player_thread.c
View file @
2b2d267d
...
...
@@ -29,6 +29,8 @@
#include "pipe.h"
#include "idle.h"
#include <glib.h>
enum
xfade_state
{
XFADE_DISABLED
=
-
1
,
XFADE_UNKNOWN
=
0
,
...
...
@@ -107,6 +109,7 @@ static int player_wait_for_decoder(struct player *player)
player
->
song
=
pc
.
next_song
;
pc
.
next_song
=
NULL
;
pc
.
elapsed_time
=
0
;
player
->
queued
=
false
;
player
->
decoder_starting
=
true
;
...
...
@@ -349,9 +352,11 @@ static void do_play(void)
}
#ifndef NDEBUG
/*
music_pipe_check_format(&play_audio_format,
player.next_song_chunk,
&dc.out_audio_format);
*/
#endif
if
(
decoder_is_idle
()
&&
!
player
.
queued
&&
...
...
@@ -488,7 +493,7 @@ static void do_play(void)
player_stop_decoder
();
}
static
void
*
player_task
(
mpd_unused
void
*
arg
)
static
void
*
player_task
(
G_GNUC_UNUSED
void
*
arg
)
{
while
(
1
)
{
switch
(
pc
.
command
)
{
...
...
src/sig_handlers.c
View file @
2b2d267d
...
...
@@ -28,6 +28,7 @@
#include <sys/signal.h>
#include <sys/wait.h>
#include <errno.h>
#include <glib.h>
int
handlePendingSignals
(
void
)
{
...
...
@@ -50,7 +51,7 @@ int handlePendingSignals(void)
return
0
;
}
static
void
chldSigHandler
(
mpd_unused
int
sig
)
static
void
chldSigHandler
(
G_GNUC_UNUSED
int
sig
)
{
int
status
;
int
pid
;
...
...
src/state_file.c
View file @
2b2d267d
...
...
@@ -19,13 +19,13 @@
#include "../config.h"
#include "state_file.h"
#include "conf.h"
#include "gcc.h"
#include "log.h"
#include "audio.h"
#include "playlist.h"
#include "utils.h"
#include "volume.h"
#include <glib.h>
#include <string.h>
#include <sys/stat.h>
...
...
@@ -58,7 +58,7 @@ void write_state_file(void)
if
(
!
sfpath
)
return
;
fp
=
fopen
(
sfpath
,
"w"
);
if
(
mpd_unlikely
(
!
fp
))
{
if
(
G_UNLIKELY
(
!
fp
))
{
ERROR
(
"problems opening state file
\"
%s
\"
for writing: %s
\n
"
,
sfpath
,
strerror
(
errno
));
return
;
...
...
@@ -87,7 +87,7 @@ void read_state_file(void)
FATAL
(
"state file
\"
%s
\"
is not a regular file
\n
"
,
sfpath
);
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
"
,
sfpath
,
strerror
(
errno
));
}
...
...
@@ -99,7 +99,7 @@ void read_state_file(void)
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
);
}
...
...
src/state_file.h
View file @
2b2d267d
...
...
@@ -19,10 +19,10 @@
#ifndef MPD_STATE_FILE_H
#define MPD_STATE_FILE_H
#include
"gcc.h"
#include
<glib.h>
void
write_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 */
src/strset.c
View file @
2b2d267d
...
...
@@ -47,7 +47,7 @@ static unsigned calc_hash(const char *p) {
return
hash
;
}
mpd_malloc
struct
strset
*
strset_new
(
void
)
G_GNUC_MALLOC
struct
strset
*
strset_new
(
void
)
{
struct
strset
*
set
=
xcalloc
(
1
,
sizeof
(
*
set
));
return
set
;
...
...
src/strset.h
View file @
2b2d267d
...
...
@@ -28,11 +28,11 @@
#ifndef MPD_STRSET_H
#define MPD_STRSET_H
#include
"gcc.h"
#include
<glib.h>
struct
strset
;
mpd_malloc
struct
strset
*
strset_new
(
void
);
G_GNUC_MALLOC
struct
strset
*
strset_new
(
void
);
void
strset_free
(
struct
strset
*
set
);
...
...
src/tag_id3.c
View file @
2b2d267d
...
...
@@ -52,7 +52,7 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
GError
*
error
=
NULL
;
isostr
=
id3_ucs4_latin1duplicate
(
ucs4
);
if
(
mpd_unlikely
(
!
isostr
))
{
if
(
G_UNLIKELY
(
!
isostr
))
{
return
NULL
;
}
...
...
@@ -70,7 +70,7 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
free
(
isostr
);
}
else
{
utf8
=
id3_ucs4_utf8duplicate
(
ucs4
);
if
(
mpd_unlikely
(
!
utf8
))
{
if
(
G_UNLIKELY
(
!
utf8
))
{
return
NULL
;
}
}
...
...
src/tag_id3.h
View file @
2b2d267d
...
...
@@ -31,10 +31,10 @@ struct tag *tag_id3_load(const char *file);
#else
#include
"gcc.h"
#include
<glib.h>
static
inline
struct
tag
*
tag_id3_load
(
mpd_unused
const
char
*
file
)
tag_id3_load
(
G_GNUC_UNUSED
const
char
*
file
)
{
return
NULL
;
}
...
...
src/update.c
View file @
2b2d267d
...
...
@@ -31,6 +31,7 @@
#include "condition.h"
#include "update.h"
#include "idle.h"
#include "conf.h"
#include <glib.h>
...
...
@@ -56,6 +57,14 @@ static struct song *delete;
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
isUpdatingDB
(
void
)
{
...
...
@@ -89,7 +98,7 @@ delete_song(struct directory *dir, struct song *del)
}
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
;
assert
(
song
->
parent
==
directory
);
...
...
@@ -337,19 +346,28 @@ skip_symlink(const struct directory *directory, const char *utf8_name)
/* don't skip if this is not a symlink */
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
;
}
if
(
buffer
[
0
]
==
'/'
)
return
!
follow_outside_symlinks
;
p
=
buffer
;
while
(
*
p
==
'.'
)
{
if
(
p
[
1
]
==
'.'
&&
p
[
2
]
==
'/'
)
{
/* "../" moves to parent directory */
directory
=
directory
->
parent
;
if
(
directory
==
NULL
)
if
(
directory
==
NULL
)
{
/* we have moved outside the music
directory - don't skip this
symlink */
return
false
;
directory - skip this symlink
if such symlinks are not allowed */
return
!
follow_outside_symlinks
;
}
p
+=
3
;
}
else
if
(
p
[
1
]
==
'/'
)
/* eliminate "./" */
...
...
@@ -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
to a song which is already in the database - skip it */
return
true
;
to a song which is already in the database - skip according
to the follow_inside_symlinks param*/
return
!
follow_inside_symlinks
;
}
static
bool
...
...
@@ -580,3 +599,18 @@ void reap_update_task(void)
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
)
{
}
src/update.h
View file @
2b2d267d
...
...
@@ -20,6 +20,10 @@
#ifndef MPD_UPDATE_H
#define MPD_UPDATE_H
void
update_global_init
(
void
);
void
update_global_finish
(
void
);
unsigned
isUpdatingDB
(
void
);
...
...
src/utils.c
View file @
2b2d267d
...
...
@@ -27,6 +27,7 @@
#include <sys/types.h>
#include <pwd.h>
#include <fcntl.h>
#include <glib.h>
#ifdef HAVE_IPV6
#include <sys/socket.h>
...
...
@@ -75,51 +76,51 @@ int ipv6Supported(void)
#endif
}
mpd_malloc
char
*
xstrdup
(
const
char
*
s
)
G_GNUC_MALLOC
char
*
xstrdup
(
const
char
*
s
)
{
char
*
ret
=
strdup
(
s
);
if
(
mpd_unlikely
(
!
ret
))
if
(
G_UNLIKELY
(
!
ret
))
FATAL
(
"OOM: strdup
\n
"
);
return
ret
;
}
/* borrowed from git :) */
mpd_malloc
void
*
xmalloc
(
size_t
size
)
G_GNUC_MALLOC
void
*
xmalloc
(
size_t
size
)
{
void
*
ret
;
assert
(
mpd_likely
(
size
));
assert
(
G_LIKELY
(
size
));
ret
=
malloc
(
size
);
if
(
mpd_unlikely
(
!
ret
))
if
(
G_UNLIKELY
(
!
ret
))
FATAL
(
"OOM: malloc
\n
"
);
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
);
/* some C libraries return NULL when size == 0,
* make sure we get a free()-able pointer (free(NULL)
* doesn't work with all C libraries, either) */
if
(
mpd_unlikely
(
!
ret
&&
!
size
))
if
(
G_UNLIKELY
(
!
ret
&&
!
size
))
ret
=
realloc
(
ptr
,
1
);
if
(
mpd_unlikely
(
!
ret
))
if
(
G_UNLIKELY
(
!
ret
))
FATAL
(
"OOM: realloc
\n
"
);
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
;
assert
(
mpd_likely
(
nmemb
&&
size
));
assert
(
G_LIKELY
(
nmemb
&&
size
));
ret
=
calloc
(
nmemb
,
size
);
if
(
mpd_unlikely
(
!
ret
))
if
(
G_UNLIKELY
(
!
ret
))
FATAL
(
"OOM: calloc
\n
"
);
return
ret
;
}
...
...
src/utils.h
View file @
2b2d267d
...
...
@@ -19,8 +19,7 @@
#ifndef MPD_UTILS_H
#define MPD_UTILS_H
#include "gcc.h"
#include <glib.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
...
...
@@ -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
...
...
src/volume.c
View file @
2b2d267d
...
...
@@ -526,7 +526,7 @@ void read_sw_volume_state(FILE *fp)
if
(
!
g_str_has_prefix
(
buf
,
SW_VOLUME_STATE
))
continue
;
sv
=
strtol
(
buf
+
strlen
(
SW_VOLUME_STATE
),
&
end
,
10
);
if
(
mpd_likely
(
!*
end
))
if
(
G_LIKELY
(
!*
end
))
changeSoftwareVolume
(
sv
,
0
);
else
ERROR
(
"Can't parse software volume: %s
\n
"
,
buf
);
...
...
src/zeroconf.c
View file @
2b2d267d
...
...
@@ -26,6 +26,8 @@
#include "ioops.h"
#include "utils.h"
#include <glib.h>
/* The dns-sd service type qualifier to publish */
#define SERVICE_TYPE "_mpd._tcp"
...
...
@@ -92,7 +94,7 @@ struct AvahiTimeout {
static
AvahiWatch
*
avahiWatchList
;
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
,
AvahiWatchCallback
callback
,
void
*
userdata
)
{
...
...
@@ -175,7 +177,7 @@ static void avahiTimeoutFree(AvahiTimeout * t)
free
(
t
);
}
static
AvahiTimeout
*
avahiTimeoutNew
(
mpd_unused
const
AvahiPoll
*
api
,
static
AvahiTimeout
*
avahiTimeoutNew
(
G_GNUC_UNUSED
const
AvahiPoll
*
api
,
const
struct
timeval
*
tv
,
AvahiTimeoutCallback
callback
,
void
*
userdata
)
...
...
@@ -200,7 +202,7 @@ static AvahiTimeout *avahiTimeoutNew(mpd_unused const AvahiPoll * api,
/* Callback when the EntryGroup changes state */
static
void
avahiGroupCallback
(
AvahiEntryGroup
*
g
,
AvahiEntryGroupState
state
,
mpd_unused
void
*
userdata
)
G_GNUC_UNUSED
void
*
userdata
)
{
char
*
n
;
assert
(
g
);
...
...
@@ -290,7 +292,7 @@ fail:
/* Callback when avahi changes state */
static
void
avahiClientCallback
(
AvahiClient
*
c
,
AvahiClientState
state
,
mpd_unused
void
*
userdata
)
G_GNUC_UNUSED
void
*
userdata
)
{
int
reason
;
assert
(
c
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment