Compare commits

...

166 Commits

Author SHA1 Message Date
Avuton Olrich
3041409334 mpd version 0.16.5 2011-10-09 04:44:51 -07:00
Max Kellermann
71536eb412 decoder/wavpack: don't call WavpackGetMode() twice
Use local variable "is_float".
2011-10-08 15:37:47 +02:00
Max Kellermann
fe77230d84 pcm_convert: fix typo in error message 2011-10-08 15:36:55 +02:00
Max Kellermann
5ed0eb51d1 output/openal: auto-fallback to mono if channel count is unsupported
.. instead of failing playback completely.
2011-10-08 14:41:22 +02:00
Max Kellermann
72a1ca3b99 output/alsa: remove "default" case from switch
Allow gcc to warn when a new format isn't supported.
2011-10-08 14:41:11 +02:00
Max Kellermann
72ff9bd3e6 configure.ac: disable systemd service by default
Defaulting to "with systemd" causes problems for users who install MPD
as an unprivileged user, and it breaks "make distcheck".  It looks
like enabling it by default creates too many practical problems for
unexperienced users.

With --with-systemdsystemunitdir (without a parameter), configure.ac
attempts to auto-detect systemd.
2011-10-07 09:56:38 +02:00
Jesús Bravo Álvarez
039b354490 playlist_song: fix absolute path support in playlists
Right now, a playlist with absolute pathnames can only add songs that
are in the same the directory of the playlist or under it.

If uri is an absolute pathname and base_uri is set,
playlist_check_translate_song() will check that base_uri is a prefix
of uri, excluding every other song in the music directory outside
base_uri.

I think in this case base_uri should be completely ignored (and made
NULL) and uri should just be checked against music root directory.
2011-10-06 22:21:24 +02:00
Max Kellermann
b2f03e76ff player_thread: add flag "output_open", fixes assertion failure
Previously, the condition "defined(play_audio_format)" was used to see
if an output device has been opened, but if the device had failed on
startup, an assertion failure could occur.  This patch adds a separate
flag.
2011-10-06 21:22:48 +02:00
Max Kellermann
63b33b6ec5 player_thread: move code to player_open_output()
Common function that manages "player" attributes after
audio_output_all_open() has returned.
2011-10-06 20:55:52 +02:00
Max Kellermann
23670795db output_control: remove unused prototype _close_locked() 2011-10-06 19:51:37 +02:00
Max Kellermann
8ea6c113b5 player_control: auto-start playback when seeking is requested
Now that the player thread can handle SEEK commands while not (yet)
playing, we can remove the "pc.state" check from pc_seek().
2011-10-06 00:35:54 +02:00
Max Kellermann
37f026a0a6 player_thread: handle SEEK while not playing 2011-10-06 00:35:53 +02:00
Max Kellermann
f67136df19 decoder_api: call _prepare_initial_seek() in decoder_tag()
This checks both conditions: pending and running.  Fixes yet another
assertion failure!
2011-10-06 00:35:53 +02:00
Max Kellermann
e07073ff28 decoder_api: move code to _prepare_initial_seek()
.. and add a few code comments.
2011-10-06 00:35:53 +02:00
Max Kellermann
64b0ba6da7 decoder_control: add attributes start_ms, end_ms
Don't read song.start_ms and song.end_ms, let the player thread manage
this logic instead.
2011-10-05 23:15:22 +02:00
Max Kellermann
99d4ae0c1a decoder_api: don't copy tag to pipe during initial seek
Fixes one more assertion failure.
2011-10-05 22:54:30 +02:00
Max Kellermann
f185b35088 decoder_api: clear initial_seek_running on error
Fixes possible assertion failure.
2011-10-04 22:29:31 +02:00
Miklos Vajna
83f6498aac Install systemd service file if systemd is available 2011-09-30 08:37:36 +02:00
Max Kellermann
525a791987 decoder_api: emulate SEEK command for initial seek to CUE track
When playing a CUE track, the player thread waited for the decoder to
become ready, and then sent a SEEK command to the beginning of the CUE
track.  If that is near the start of the song file, and the track is
short enough, the decoder could have finished decoding already at that
point, and seeking fails.

This commit makes this initial seek more robust: instead of letting
the player thread deal with the difficult timings, let the decoder API
emulate a SEEK command, and return it to the decoder plugin, as soon
as the plugin finishes its initialization.
2011-09-22 00:04:48 +02:00
Max Kellermann
fb19210cfd decoder_internal.h: more API documentation 2011-09-22 00:04:20 +02:00
Jonathan Neuschäfer
b0b2c5b3e0 utils: uri.h: fix a typo: "schema" 2011-09-21 17:47:28 +02:00
Max Kellermann
29742d23d3 configure.ac: fix --enable-id3 help string 2011-09-20 22:18:42 +02:00
Max Kellermann
c476819cb1 fd_util: add function close_socket()
Wrap close(), use closesocket() on WIN32/WinSock.
2011-09-20 08:38:58 +02:00
Max Kellermann
77a56c7c5a fd_util: check HAVE_INOTIFY_INIT in header
Don't provide the prototype if inotify_init() was not detected.
2011-09-20 08:38:17 +02:00
Max Kellermann
46deb7ca82 fd_util: include check.h, verify config.h was included 2011-09-20 08:38:08 +02:00
Max Kellermann
b03f9ece05 glib_socket.h: wrap g_io_channel_*_new() calls portably
The server_socket library (used by the httpd output plugin) didn't
check for WIN32, that's fixed now.
2011-09-20 08:35:25 +02:00
Max Kellermann
1d8840412f configure.ac: add option --enable-solaris-output
Allow enabling the plugin explicitly without running Solaris, to test
the build.
2011-09-19 09:39:35 +02:00
Max Kellermann
df1152ee0f configure.ac: fix solaris result display
Wrong variable name.
2011-09-19 09:39:05 +02:00
Tim Harder
79435dbdec decoder/audiofile: include stdio header for SEEK_* defines
The stdio header is no longer pulled in by af_vfs.h in audiofile-0.3.0.
2011-09-17 07:33:42 +02:00
Max Kellermann
27206368da output/pulse: improve locking
Always lock the main loop when operating on PULSE objects.  Document
this.
2011-09-17 07:30:59 +02:00
Max Kellermann
443e96381a configure.ac: disable assertions in the non-debugging build
Add -DNDEBUG to AM_CPPFLAGS.
2011-09-16 07:41:41 +02:00
Max Kellermann
1cbba4fc59 input/curl, output/pulse: fix "unused local variable" warnings 2011-09-16 07:41:41 +02:00
Max Kellermann
344b6dd179 configure.ac: enable -Werror for C++ 2011-09-16 07:38:00 +02:00
Max Kellermann
d8c829fa0c configure.ac: pass AM_CXXFLAGS, AM_CPPFLAGS to Makefile.am 2011-09-16 07:35:46 +02:00
Max Kellermann
2ed870c854 decoder/ffmpeg: flush the codec after seeking
Let the codec start with fresh buffers.  This should fix the remaining
seeking issues.
2011-09-15 21:41:25 +02:00
Max Kellermann
ce35ba9ac9 decoder/ffmpeg: explicitly specify the current stream for seeking
Use AVStream.time_base to convert the decoder_seek_where() value, and
pass the current stream number to av_seek_frame().
2011-09-15 21:35:29 +02:00
Max Kellermann
724a59aaf7 decoder/ffmpeg: don't require key frame for seeking
Use flag AV_TIME_BASE.
2011-09-15 21:32:29 +02:00
Max Kellermann
42d8c2981f decoder/ffmpeg: higher precision timestamps 2011-09-15 21:30:27 +02:00
Max Kellermann
9aa91e0f17 decoder/ffmpeg: move formula to time_from_ffmpeg() 2011-09-15 21:23:48 +02:00
Max Kellermann
5aabee8996 decoder/ffmpeg: add local variable "av_stream"
Code simplification.
2011-09-15 21:14:53 +02:00
Max Kellermann
48a84ca23e input/rewind: copy the MIME type only once
Reduce heap usage by reducing the number of malloc() / free() calls.
2011-09-15 20:24:15 +02:00
Max Kellermann
c345c5ebae .gitignore: add doxygen.conf 2011-09-09 23:21:20 +02:00
Max Kellermann
5cf4ce9318 pcm_format: fix 32-to-24 bit conversion (the "silence" bug)
D'oh, we were reading 16 bit integers instead of 32 bit integers!
That caused silence when trying to play a 32 bit input file on a 24
bit sound card (e.g. USB sound chips with 24 bit packed samples).
2011-09-08 23:47:32 +02:00
Avuton Olrich
5469941f2b Modify version string to post-release version 0.16.5~git 2011-09-01 17:58:29 -07:00
Avuton Olrich
e888c9e827 mpd version 0.16.4 2011-09-01 17:58:28 -07:00
Max Kellermann
2556449b36 configure.ac: fail if Vorbis was enabled explicitly, but not found
.. and a minor tweak for libFLAC+libogg detection.
2011-09-01 19:02:23 +02:00
Max Kellermann
446f9973cc configure.ac: fail if FLAC was enabled explicitly, but not found 2011-09-01 19:02:22 +02:00
Max Kellermann
596f36bb78 output/osx: don't drain the buffer when closing
Eliminate an unnecessary source of deadlocks.
2011-09-01 18:21:46 +02:00
Max Kellermann
e7abdab58d output/osx: signal the GCond while mutex is locked 2011-09-01 18:21:46 +02:00
Max Kellermann
13cdc9a9f8 configure.ac: auto-detect libmad without pkg-config
The pkg-config file was added by the Debian package maintainers, and
unfortunately, the rest of the world doesn't have it.
2011-09-01 11:06:08 +02:00
Max Kellermann
a1b8806422 configure.ac: fail if libid3tag was enabled explicitly, but not found
Add M4 function MPD_AUTO_PKG_LIB for pkg-config with AC_CHECK_LIB
fallback.
2011-09-01 10:58:36 +02:00
Max Kellermann
e635d47912 configure.ac: use MPD_AUTO_PKG to detect avahi
Don't abort the configure script when avahi could not be
auto-detected.  It previously did, because there was no custom "fail"
action for PKG_CHECK_MODULES.
2011-09-01 10:11:23 +02:00
Max Kellermann
53ac72a878 Makefile.am: use AVAHI_CFLAGS, AVAHI_LIBS
Don't add those to MPD_CFLAGS / MPD_LIBS.
2011-09-01 10:09:46 +02:00
Max Kellermann
2be6184c8d output_all: move _lock_signal() to output_control.c
Better name, better documentation.
2011-09-01 07:59:15 +02:00
Max Kellermann
8b0b4ff086 output_thread: reimplement CANCEL synchronization
The output thread could hang indefinitely after finishing CANCEL,
because it could have missed the signal while the output was not
unlocked in ao_command_finished().

This patch removes the wait() call after CANCEL, and adds the flag
"allow_play" instead.  While this flag is set, playback is skipped.
With this flag, there will not be any excess wait() call after the
pipe has been cleared.

This patch fixes a bug that causes mpd to discontinue playback after
seeking, due to the race condition described above.
2011-09-01 07:13:21 +02:00
Max Kellermann
60f7ff3de5 output/pulse: reset callbacks before closing stream/context
Fixes assertion failure when a stream callback is invoked too late
after a format change.
2011-08-31 21:01:34 +02:00
Max Kellermann
e76c752987 output/pulse: add function _delete_stream()
Merge common code.
2011-08-31 21:01:22 +02:00
Max Kellermann
042c1abc6e output/pulse: use _delete_context()
Eliminate duplicate code.
2011-08-31 20:58:36 +02:00
Jonathan Neuschäfer
3d12d7de62 doc/developer.xml: change the coing style example return type to int 2011-08-27 11:27:32 +02:00
Jonathan Neuschäfer
87593f95d4 scripts/makedist.sh: fix test usage
Checkbashisms (part of the Debian devscripts) pionted this out.
2011-08-27 11:27:16 +02:00
Max Kellermann
11626e48bf input/curl: implement a hard-coded timeout of 10 seconds
Be sure to stop the operation at some point when the server isn't
responding.
2011-08-26 19:28:09 +02:00
Max Kellermann
b3df4dc2c9 output/pulse: fix deadlock when the stream was suspended
Check if the stream is suspended; wake up the main loop when it
becomes suspended.
2011-08-23 23:02:13 +02:00
Max Kellermann
3db9ab82ea output/pulse: add assertions 2011-08-23 22:48:22 +02:00
Max Kellermann
2dc3acc5f0 output/pulse: return 0 on error
Not a bool.
2011-08-23 22:48:22 +02:00
Max Kellermann
25686e5bce pulse/output: fix deadlock when resuming the stream
Unlock the mainloop in all code paths.
2011-08-23 22:45:47 +02:00
Max Kellermann
8d70f808d9 input/curl: limit the receive buffer size 2011-08-23 20:46:51 +02:00
Max Kellermann
7c887af1ea output/httpd: add assertions 2011-08-23 18:14:39 +02:00
Max Kellermann
b7f435b50e output/httpd: don't warn on client disconnect
This warning should only be logged when we really received something.
When the client disconnects, G_IO_IN is triggered, and the read
returns G_IO_STATUS_EOF.
2011-08-23 18:02:56 +02:00
Max Kellermann
d3b15f8fda decoder/mpcdec: fix gcc warning
Move the variable "vbr_update_acc" into the #ifdef block.
2011-08-23 17:58:56 +02:00
Max Kellermann
838f7cd210 encoder_plugin: add method pre_tag()
In the "vorbis" plugin, this is a copy of the old flush() method,
while flush() gets a lot of code remove, it just sets the "flush" flag
and nothing else.  It doesn't start a new stream now, which should fix
a few problems in some players.
2011-07-20 20:54:34 +02:00
Max Kellermann
13539961b2 output/httpd: explicitly convert size_t to bool in pause() 2011-07-20 19:16:47 +02:00
Max Kellermann
a26f2ef17d pipe: lock the mutex in music_pipe_size() 2011-07-20 19:05:32 +02:00
Max Kellermann
d97c46bcdc pipe: make read-only functions "pure"
Enable gcc optimizations.
2011-07-20 19:05:26 +02:00
Max Kellermann
2b6542467c output_thread: unlock the mutex while calling cancel()
The method may take longer, and we shouldn't be holding the lock.
2011-07-20 19:05:08 +02:00
Max Kellermann
8fa51faa38 player_thread: lock the player while setting the bite_rate 2011-07-20 19:04:54 +02:00
Max Kellermann
b2175629fd update_walk: apply follow_inside_symlinks to absolute symlinks 2011-07-20 14:15:20 +02:00
Max Kellermann
2e28ed8f81 wavpack: obey all decoder commands, stop at CUE track border
It used to ignore the decoder_data() return value.
2011-07-20 12:54:30 +02:00
Max Kellermann
4c4f8bf02a decoder/wavpack: use the correct integer types
libwavpack provides int32_t samples, and wants uin32_t for sample
counts.
2011-07-20 12:54:22 +02:00
Max Kellermann
e464be5f39 decoder/wavpack: simplify the WavpackUnpackSamples()==0 check
.. and remove one indent level.
2011-07-20 12:32:48 +02:00
Max Kellermann
d7d717f2ce playlist_control: don't resume playback when seeking to another song while paused
Use a shortcut in playlist_seek_song(), don't call
playlist_play_order() because that would reset the "paused" state.
2011-07-20 11:33:51 +02:00
Max Kellermann
d1eeed6a5b output/alsa: fix SIGFPE when alsa announces a period size of 0 2011-07-20 06:54:51 +02:00
Max Kellermann
736fd0e293 decoder/ffmpeg: use avformat_open_input() if available
av_open_input_stream() has been deprecated.
2011-07-18 23:31:47 +02:00
Max Kellermann
6592ca9f88 decoder: use AVDictionary instead of AVMetadata
AVMetadata has been deprecated.
2011-07-18 23:31:31 +02:00
Max Kellermann
762712c756 database: require X_OK on parent directory, not R_OK
For accessing the child of a directory, one needs X_OK on the
directory.
2011-07-18 22:48:07 +02:00
Max Kellermann
73f9e17951 NEWS: fix memory leaks 2011-07-18 22:47:51 +02:00
Jonathan Neuschäfer
7d6a605a85 output/shout: fix a memory leak 2011-07-18 22:04:48 +02:00
Jonathan Neuschäfer
a6a8bdffc3 output/recorder: fix a memory leak 2011-07-18 22:04:10 +02:00
Jonathan Neuschäfer
296085ff23 output/httpd: add missing g_free in error path 2011-07-18 22:04:06 +02:00
Jonathan Neuschäfer
36aa8ce3c9 output/ao: add missing g_free in error path 2011-07-18 22:03:48 +02:00
Jonathan Neuschäfer
c49c69d6ea conf: add missing fclose in error path
This patch seems a bit ugly, maybe it would be a bit cleaner with gotos.
2011-07-18 22:03:40 +02:00
Jonathan Neuschäfer
d5684f7444 sticker: fix a memory leak 2011-07-18 22:03:37 +02:00
Jonathan Neuschäfer
affb4bd923 ape: add missing g_free in error path 2011-07-18 22:03:34 +02:00
Max Kellermann
65772a74e0 configure: correct avahi/bonjour state on result page
Was always displayed as "no", even if one was found.
2011-07-03 15:42:22 +02:00
Max Kellermann
cca2c2f4ca test/run_filter: remove unused variable "frame_size" 2011-07-03 15:21:40 +02:00
Max Kellermann
52e2fa91c4 test/read_conf: make variables more local 2011-07-03 15:20:39 +02:00
Max Kellermann
dca405a746 test/read_conf: fix -Wunused-but-set-variable 2011-07-03 15:20:28 +02:00
Jonathan Ballet
3680a6bbbb doc/protocol: add some missing specifications 2011-07-03 15:05:04 +02:00
Max Kellermann
6aa6a9c272 decoder/flac: validate the sample rate when scanning the tag
Don't calculate the song duration when the sample rate is 0 (division
by zero crash).
2011-07-03 14:57:56 +02:00
oblique
8d1c7ca206 ffmpeg: workaround for semantic API change in recent ffmpeg versions 2011-07-03 14:54:56 +02:00
Tony Miller
52b8e0f9ec doc/user: Typo in playlist plugin documentation, 'playlist plugin' not 'filter'.
This patch fixes a typo in doc/user about playlist plugins.

Its in the top commit in my repository in a branch called 'doc_fix':
git://github.com/mcfiredrill/mpd.git
2011-07-03 14:53:37 +02:00
Avuton Olrich
3c4f4793b5 Modify version string to post-release version 0.16.4~git 2011-06-04 07:37:34 -07:00
Avuton Olrich
e2950a7e4d mpd version 0.16.3 2011-06-04 07:37:33 -07:00
Max Kellermann
4b4aa64261 directory: allow directories with just playlists
Keep those when scanning for empty directories.  The check in
playlist_vector_is_empty() was missing.
2011-05-09 21:37:43 +02:00
Max Kellermann
26735390ff playlist_song: fix playlist files in base music directory
g_path_get_dirname() returns "." when there is no directory name in
the given path.  This patch adds a workaround for that.
2011-05-09 18:05:11 +02:00
Max Kellermann
9402b23dd5 playlist_song: fix NULL pointer dereference 2011-05-09 18:03:54 +02:00
Max Kellermann
246db3d565 decoder/ffmpeg: use avcodec_decode_audio3() if available
avcodec_decode_audio3() has been added in libavformat 52.25.0, and the
predecessor avcodec_decode_audio2() has been deprecated.
2011-05-09 09:24:17 +02:00
Max Kellermann
eaf414cbc8 decoder/ffmpeg: make variables more local 2011-05-09 09:24:15 +02:00
Anton Khirnov
327d41c00f decoder/ffmpeg: don't use deprecated CODEC_TYPE_AUDIO with new lavc
fixes build with lavc 53.
2011-05-09 08:00:45 +02:00
Max Kellermann
05d8ce3bcd decoder/ffmpeg: define fallback macro AV_VERSION_INT()
For ffmpeg < 0.5.  Copied from libavutil 0.5.
2011-05-09 08:00:45 +02:00
Max Kellermann
def2fe8805 Merge branch 'v0.15.x' into v0.16.x
Conflicts:
	NEWS
	configure.ac
	src/listen.c
2011-04-12 07:39:01 +02:00
Max Kellermann
f680b0a431 decoder/flac: fix enum mismatch in flac_tell_cb()
Fix clang warning.
2011-03-23 22:31:40 +01:00
Max Kellermann
d4b00ff11c listen: suppress "unused variable" warning 2011-03-23 22:27:31 +01:00
Max Kellermann
532f94a187 audio_parser: fix assertion failure in audio format mask parser
Use audio_format_mask_valid() to verify a mask.
2011-03-23 22:22:51 +01:00
Max Kellermann
87ad2f8542 command: fix return value of handle_currentsong()
Thanks to clang for complaining.
2011-03-23 22:16:46 +01:00
Simon Kagstrom
a8f891efcd configure.ac: Enable HAVE_OGG_COMMON when using libtremor
Otherwise OGGs can't be played.
2011-03-23 22:09:58 +01:00
Avuton Olrich
b5fc2419e8 Modify version string to post-release version 0.16.3~git 2011-03-18 17:43:11 -07:00
Avuton Olrich
fe588a255b mpd version 0.16.2 2011-03-18 17:43:11 -07:00
Max Kellermann
1fc571088b command: print playlist load error
Call print_playlist_result() instead of casting the enum implicitly.
2011-03-18 19:45:59 +01:00
Max Kellermann
8d83914f05 output/httpd: include sys/socket.h only when building with libwrap
Fixes build failure on WIN32.
2011-03-18 19:44:12 +01:00
Max Kellermann
0fdcd381bc update_walk: ignore parameter "mode" on WIN32
Fix compiler warning.
2011-03-18 19:43:26 +01:00
Max Kellermann
4f293ecd6f audio_format, output_thread: add more audio_format_valid() assertions 2011-03-16 23:37:41 +01:00
Max Kellermann
b6303313f0 encoder/vorbis: reset the Ogg stream after flush
Without the ogg_stream_reset() call, the "e_o_s" flag never gets
reset, and libogg writes EOS packets over and over.
2011-03-16 19:16:06 +01:00
Max Kellermann
a28449a123 encoder/vorbis: reset the Ogg stream after flush
Without the ogg_stream_reset() call, the "e_o_s" flag never gets
reset, and libogg writes EOS packets over and over.
2011-03-16 19:13:46 +01:00
Max Kellermann
6dcec36621 Merge release 0.15.16 into v0.16.x
Conflicts:
	NEWS
	configure.ac
	src/output/jack_plugin.c
	src/update.c
2011-03-16 18:08:54 +01:00
Avuton Olrich
84d0fd39a3 Modify version string to post-release version 0.15.17~git 2011-03-13 20:27:33 -07:00
Avuton Olrich
4d4b7e3de0 mpd version 0.15.16 2011-03-13 20:27:33 -07:00
Ulrich Spörlein
e2aea6bce5 output/httpd: include sys/socket.h for AF_UNIX 2011-03-09 19:53:48 +01:00
Ulrich Spörlein
5779146a7f configure.ac: fix bashism in tremor test
This makes FreeBSD detect libogg correctly. The '==' operator is an
undocumented GNU extension to test(1) and cannot be relied upon to
exist and do the right thing. POSIX mandates string comparisons to be
done using "test foo = bar".
2011-03-09 19:50:54 +01:00
Max Kellermann
a1d1c2beaa output/oss: disable 24 bit playback on FreeBSD
See code comment.
2011-02-28 00:09:45 +01:00
Max Kellermann
ee9c60fad4 output/oss: AFMT_S24_PACKED is little-endian
According to the Solaris dsp manpage, AFMT_S24_PACKED is
little-endian:

 http://download.oracle.com/docs/cd/E19963-01/821-1475/6nmf5baot/index.html

The Minix soundcard.h header says the same.
2011-02-28 00:00:41 +01:00
Max Kellermann
1674a4ec82 output/jack: fix crash with mono playback
With mono sound, jack_sample_size is smaller than frame_size (4 vs 2
bytes), and "space/jack_sample_size==0".  That means mpd_jack_play()
will return 0, although no error has occurred.
2011-02-27 23:26:50 +01:00
Max Kellermann
ce370bee60 output/jack: rename variable sample_size to jack_sample_size 2011-02-25 10:46:44 +01:00
Max Kellermann
e257484870 Makefile.am: distribute test/stdbin.h 2011-02-18 08:19:37 +01:00
Christopher Brannon
2a1f4539f6 Insure proper initialization of stack-allocated struct.
Version 1.0.0 of the libao library added a new field to the
ao_sample_format struct.  It is a char * named matrix.  When
an ao_sample_format is allocated on the stack, this field contains
garbage.  The proper course is to insure that is initialized to NULL.
NULL indicates that we do not want any mapping.
The struct is now initialized using a static initializer, and this
technique is compatible with all known versions of libao.
2011-02-15 12:16:25 +01:00
Max Kellermann
906efdd320 Makefile.am: compile test/run_encoder with ENCODER_CFLAGS 2011-02-13 23:22:57 +01:00
Thomas Jansen
948b8f35e6 general: whitespace cleanup
Remove trailing whitespace found by this command:
find -name '*.[ch]' | xargs grep "[[:space:]]$"
2011-02-09 22:42:31 +01:00
Thomas Jansen
e776c605ad output/httpd: initialize unflushed_input
This fixes the following valgrind warning occuring on the first call of
httpd_output_read_page:
==20124== Conditional jump or move depends on uninitialised value(s)
==20124==    at 0x425E65: httpd_output_read_page (httpd_output_plugin.c:240)
==20124==    by 0x426087: httpd_output_open (httpd_output_plugin.c:279)
==20124==    by 0x41D862: ao_open (output_plugin.h:206)
==20124==    by 0x41E133: audio_output_task (output_thread.c:590)
2011-02-09 22:41:36 +01:00
Tony Miller
8b2f4fc823 Set fadeout in gme_decoder_plugin. Due to the nature of the gme library,
this needs to be done for the end of songs to be detected.
2011-02-03 00:25:35 +01:00
Max Kellermann
03018611f8 update: log all file permission problems 2011-01-31 09:39:24 +01:00
Max Kellermann
8f99c954ad NEWS: fix 0.16.1 release year 2011-01-28 21:12:17 +01:00
Max Kellermann
5735c9efc1 configure.ac: fix tremor configure test
When the configure options were moved around for 0.16, the order was
changed, and the Tremor check broke.
2011-01-28 12:21:03 +01:00
Andreas Wiese
e6c3acaa6f Fix NDEBUG test
<stdbool.h> needs to be included unconditionally from definition of
NDEBUG, since »bool« doesn't get defined otherwise.

Signed-off-by: Andreas Wiese <aw-devel@meterriblecrew.net>
2011-01-14 16:22:25 +01:00
Avuton Olrich
44b4b50949 Modify version string to post-release version 0.16.2~git 2011-01-09 18:00:12 -08:00
Avuton Olrich
9ad862d3a6 mpd version 0.16.1 2011-01-09 18:00:12 -08:00
Yuriy Kaminskiy
77d71c4ee6 Makefile.am: resolve modplug vs. libsndfile cflags/headers conflict
A bit of automake magic (see info automake "Per-Object Flags").
Compile-tested.
2011-01-09 18:21:27 +01:00
Max Kellermann
8c0afd8557 Merge branch 'v0.15.x' into v0.16.x
Conflicts:
	NEWS
	configure.ac
	src/directory.h
2011-01-07 23:50:23 +01:00
Max Kellermann
2a56300f7b player_thread: discard empty chunks while cross-fading
When a music_chunk to be crossfaded consists only of a tag,
cross-fading is not possible, and led to an assertion failure.  This
patch just discards those, as if cross-fading was not enabled.
2011-01-07 23:45:51 +01:00
Max Kellermann
5f06999686 output_thread: fix double lock
During the whole output thread, the audio_output object is locked, and
it is only unlocked while waiting for the GCond and while running a
plugin method.  The error handler in ao_play_chunk() attempted to lock
the object again, which was code from MPD 0.15.x which should have
been removed a long time ago.
2011-01-07 23:08:18 +01:00
Max Kellermann
4c09aeb5a1 player_thread: fix assertion failure due to early seek
Until the decoder plugin has called decoder_initialized(), the player
may not submit seek commands.  This however could occur with a slow
decoder and a CUE file with a virtual song offset.  This patch adds
another check.
2011-01-07 22:52:50 +01:00
Max Kellermann
af892e7e80 player_thread: make variables more local 2011-01-07 22:33:10 +01:00
Max Kellermann
0022fb100b encoder/lame: explicitly configure the output sample rate
When you don't explicitly set an output sample rate, liblame tries to
guess an output sample rate from the input sample rate.  You would
think that this "guessing" consists of just setting both equal, but
that is not the case.  For 44.1kHz at 96kbit/s, liblame chooses
32kHz.  This patch explicitly configures the output sample rate, to
stop the bad guessing.
2011-01-07 19:37:39 +01:00
Max Kellermann
4f2d67dfb0 output/httpd: define G_LOG_DOMAIN in httpd_client.c 2011-01-07 18:00:12 +01:00
Max Kellermann
b5645ab29f output/osx: fix up audio format first, then apply it to device
This is a MPD 0.16 regression: when playing a 24 bit file, the switch
to 16 bit was made only partially, after mBytesPerPacket and
mBytesPerFrame had already been applied.

That means mBytesPerFrame referred to 24 bit, and mBitsPerChannel
referred to 16 bits.  Of course, that cannot work.
2011-01-07 17:31:36 +01:00
Max Kellermann
3149d1abf9 configure.ac: eliminate bashism "echo -n"
Use "printf" instead.
2011-01-07 17:31:30 +01:00
Max Kellermann
59a417fc84 configure.ac: avoid GNU extension in "expr match" call 2011-01-07 17:29:19 +01:00
Max Kellermann
b75d53413d configure.ac: use AC_LANG_SOURCE
Fixes autotools warnings.
2011-01-07 17:25:52 +01:00
Max Kellermann
c44a744c0b fix version number in NEWS 2011-01-07 17:25:25 +01:00
Max Kellermann
76cddfab90 configure.ac: disable the FFADO plugin by default
It is known to crash instantly.
2010-12-22 07:31:17 +01:00
Max Kellermann
60b4f6b3eb directory: fix warning "comparison between signed and unsigned"
Cast the constant to dev_t, not to unsigned.
2010-12-21 20:21:22 +01:00
Max Kellermann
546232b1c0 zeroconf-bonjour: use g_htons() instead of htons()
Fixes the gcc warning "implicit declaration of function 'htons'".
2010-12-21 20:21:20 +01:00
Max Kellermann
42c5788de3 Modify version string to post-release version 0.15.16~git 2010-12-21 20:19:49 +01:00
Max Kellermann
fb00e7fddc add void casts to suppress "result unused" warnings (clang) 2010-12-21 08:06:02 +01:00
Alex Viskovatoff
41fdcf328c decoder/mad: work around build failure on Solaris
Rename the "version" struct, because it seems to be a reserved name on
Solaris:

 "src/decoder/mad_decoder_plugin.c", line 550: (enum) tag redeclared: version
 cc: acomp failed for src/decoder/mad_decoder_plugin.c
2010-12-21 07:57:07 +01:00
Alex Viskovatoff
144ad7992e output/solaris: add missing parameter to open_cloexec() call 2010-12-21 07:31:08 +01:00
Alex Viskovatoff
a0dd1a1b8b audio_check: fix parameter in prototype 2010-12-21 07:29:58 +01:00
Max Kellermann
c360e69162 Modify version string to post-release version 0.16.1~git 2010-12-21 07:29:31 +01:00
87 changed files with 1417 additions and 509 deletions

1
.gitignore vendored

@@ -39,6 +39,7 @@ tags
*~
.#*
.stgit*
doc/doxygen.conf
doc/protocol.html
doc/protocol
doc/user

@@ -1,14 +1,17 @@
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = foreign 1.10 dist-bzip2 subdir-objects
AM_CPPFLAGS = -I$(srcdir)/src $(GLIB_CFLAGS)
AM_CPPFLAGS += -I$(srcdir)/src $(GLIB_CFLAGS)
AM_CPPFLAGS += -DSYSTEM_CONFIG_FILE_LOCATION='"$(sysconfdir)/mpd.conf"'
bin_PROGRAMS = src/mpd
noinst_LIBRARIES =
src_mpd_CFLAGS = $(AM_CFLAGS) $(MPD_CFLAGS)
src_mpd_CPPFLAGS = $(AM_CPPFLAGS) \
$(AVAHI_CFLAGS) \
$(LIBWRAP_CFLAGS) \
$(SQLITE_CFLAGS) \
$(ARCHIVE_CFLAGS) \
@@ -19,6 +22,7 @@ src_mpd_CPPFLAGS = $(AM_CPPFLAGS) \
$(FILTER_CFLAGS) \
$(OUTPUT_CFLAGS)
src_mpd_LDADD = $(MPD_LIBS) \
$(AVAHI_LIBS) \
$(LIBWRAP_LDFLAGS) \
$(SQLITE_LIBS) \
$(ARCHIVE_LIBS) \
@@ -239,6 +243,7 @@ src_mpd_SOURCES = \
$(OUTPUT_API_SRC) $(OUTPUT_SRC) \
$(MIXER_API_SRC) $(MIXER_SRC) \
$(FILTER_SRC) \
src/glib_socket.h \
src/notify.c \
src/audio.c \
src/audio_check.c \
@@ -432,7 +437,6 @@ DECODER_CFLAGS = \
$(SNDFILE_CFLAGS) \
$(AUDIOFILE_CFLAGS) \
$(LIBMIKMOD_CFLAGS) \
$(MODPLUG_CFLAGS) \
$(GME_CFLAGS) \
$(SIDPLAY_CFLAGS) \
$(FLUIDSYNTH_CFLAGS) \
@@ -448,7 +452,6 @@ DECODER_LIBS = \
$(FLAC_LIBS) \
$(SNDFILE_LIBS) \
$(AUDIOFILE_LIBS) $(LIBMIKMOD_LIBS) \
$(MODPLUG_LIBS) \
$(GME_LIBS) \
$(SIDPLAY_LIBS) \
$(FLUIDSYNTH_LIBS) \
@@ -521,7 +524,11 @@ DECODER_SRC += src/decoder/mikmod_decoder_plugin.c
endif
if HAVE_MODPLUG
DECODER_SRC += src/decoder/modplug_decoder_plugin.c
libmodplug_decoder_plugin_a_SOURCES = src/decoder/modplug_decoder_plugin.c
libmodplug_decoder_plugin_a_CFLAGS = $(src_mpd_CFLAGS) $(MODPLUG_CFLAGS)
libmodplug_decoder_plugin_a_CPPFLAGS = $(src_mpd_CPPFLAGS)
noinst_LIBRARIES += libmodplug_decoder_plugin.a
DECODER_LIBS += libmodplug_decoder_plugin.a $(MODPLUG_LIBS)
endif
if ENABLE_SIDPLAY
@@ -795,6 +802,15 @@ FILTER_SRC = \
src/filter/volume_filter_plugin.c
#
# systemd unit
#
if HAVE_SYSTEMD
systemdsystemunit_DATA = \
mpd.service
endif
#
# Sparse code analysis
#
@@ -855,6 +871,7 @@ test_run_input_LDADD = $(MPD_LIBS) \
$(INPUT_LIBS) \
$(GLIB_LIBS)
test_run_input_SOURCES = test/run_input.c \
test/stdbin.h \
src/conf.c src/tokenizer.c src/utils.c \
src/tag.c src/tag_pool.c src/tag_save.c \
src/fd_util.c \
@@ -902,6 +919,7 @@ test_run_decoder_LDADD = $(MPD_LIBS) \
$(INPUT_LIBS) $(DECODER_LIBS) \
$(GLIB_LIBS)
test_run_decoder_SOURCES = test/run_decoder.c \
test/stdbin.h \
src/conf.c src/tokenizer.c src/utils.c src/log.c \
src/tag.c src/tag_pool.c \
src/replay_gain_info.c \
@@ -942,6 +960,7 @@ test_run_filter_LDADD = $(MPD_LIBS) \
$(SAMPLERATE_LIBS) \
$(GLIB_LIBS)
test_run_filter_SOURCES = test/run_filter.c \
test/stdbin.h \
src/filter_plugin.c \
src/filter_registry.c \
src/conf.c src/tokenizer.c src/utils.c \
@@ -964,6 +983,7 @@ endif
if ENABLE_ENCODER
noinst_PROGRAMS += test/run_encoder
test_run_encoder_SOURCES = test/run_encoder.c \
test/stdbin.h \
src/conf.c src/tokenizer.c \
src/utils.c \
src/tag.c src/tag_pool.c \
@@ -971,12 +991,15 @@ test_run_encoder_SOURCES = test/run_encoder.c \
src/audio_format.c \
src/audio_parser.c \
$(ENCODER_SRC)
test_run_encoder_CPPFLAGS = $(AM_CPPFLAGS) \
$(ENCODER_CFLAGS)
test_run_encoder_LDADD = $(MPD_LIBS) \
$(ENCODER_LIBS) \
$(GLIB_LIBS)
endif
test_software_volume_SOURCES = test/software_volume.c \
test/stdbin.h \
src/audio_check.c \
src/audio_parser.c \
src/pcm_volume.c
@@ -984,6 +1007,7 @@ test_software_volume_LDADD = \
$(GLIB_LIBS)
test_run_normalize_SOURCES = test/run_normalize.c \
test/stdbin.h \
src/audio_check.c \
src/audio_parser.c \
src/AudioCompress/compress.c
@@ -1021,6 +1045,7 @@ test_run_output_LDADD = $(MPD_LIBS) \
$(OUTPUT_LIBS) \
$(GLIB_LIBS)
test_run_output_SOURCES = test/run_output.c \
test/stdbin.h \
src/conf.c src/tokenizer.c src/utils.c src/log.c \
src/audio_check.c \
src/audio_format.c \

104
NEWS

@@ -1,3 +1,91 @@
ver 0.16.5 (2010/10/09)
* configure.ac
- disable assertions in the non-debugging build
- show solaris plugin result correctly
- add option --enable-solaris-output
* pcm_format: fix 32-to-24 bit conversion (the "silence" bug)
* input:
- rewind: reduce heap usage
* decoder:
- ffmpeg: higher precision timestamps
- ffmpeg: don't require key frame for seeking
- fix CUE track seeking
* output:
- openal: auto-fallback to mono if channel count is unsupported
* player:
- make seeking to CUE track more reliable
- the "seek" command works when MPD is stopped
- restore song position from state file (bug fix)
- fix crash that sometimes occurred when audio device fails on startup
- fix absolute path support in playlists
* WIN32: close sockets properly
* install systemd service file if systemd is available
ver 0.16.4 (2011/09/01)
* don't abort configure when avahi is not found
* auto-detect libmad without pkg-config
* fix memory leaks
* don't resume playback when seeking to another song while paused
* apply follow_inside_symlinks to absolute symlinks
* fix playback discontinuation after seeking
* input:
- curl: limit the receive buffer size
- curl: implement a hard-coded timeout of 10 seconds
* decoder:
- ffmpeg: workaround for semantic API change in recent ffmpeg versions
- flac: validate the sample rate when scanning the tag
- wavpack: obey all decoder commands, stop at CUE track border
* encoder:
- vorbis: don't send end-of-stream on flush
* output:
- alsa: fix SIGFPE when alsa announces a period size of 0
- httpd: don't warn on client disconnect
- osx: don't drain the buffer when closing
- pulse: fix deadlock when resuming the stream
- pulse: fix deadlock when the stream was suspended
ver 0.16.3 (2011/06/04)
* fix assertion failure in audio format mask parser
* fix NULL pointer dereference in playlist parser
* fix playlist files in base music directory
* database: allow directories with just playlists
* decoder:
- ffmpeg: support libavcodec 0.7
ver 0.16.2 (2011/03/18)
* configure.ac:
- fix bashism in tremor test
* decoder:
- tremor: fix configure test
- gme: detect end of song
* encoder:
- vorbis: reset the Ogg stream after flush
* output:
- httpd: fix uninitialized variable
- httpd: include sys/socket.h
- oss: AFMT_S24_PACKED is little-endian
- oss: disable 24 bit playback on FreeBSD
ver 0.16.1 (2011/01/09)
* audio_check: fix parameter in prototype
* add void casts to suppress "result unused" warnings (clang)
* input:
- ffado: disable by default
* decoder:
- mad: work around build failure on Solaris
- resolve modplug vs. libsndfile cflags/headers conflict
* output:
- solaris: add missing parameter to open_cloexec() cal
- osx: fix up audio format first, then apply it to device
* player_thread: discard empty chunks while cross-fading
* player_thread: fix assertion failure due to early seek
* output_thread: fix double lock
ver 0.16 (2010/12/11)
* protocol:
- send song modification time to client
@@ -112,6 +200,22 @@ ver 0.16 (2010/12/11)
* make single mode 'sticky'
ver 0.15.17 (2011/??/??)
* encoder:
- vorbis: reset the Ogg stream after flush
* decoders:
- vorbis: fix tremor support
ver 0.15.16 (2011/03/13)
* output:
- ao: initialize the ao_sample_format struct
- jack: fix crash with mono playback
* encoders:
- lame: explicitly configure the output sample rate
* update: log all file permission problems
ver 0.15.15 (2010/11/08)
* input:
- rewind: fix assertion failure

@@ -1,5 +1,5 @@
AC_PREREQ(2.60)
AC_INIT(mpd, 0.16, musicpd-dev-team@lists.sourceforge.net)
AC_INIT(mpd, 0.16.5, musicpd-dev-team@lists.sourceforge.net)
AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([foreign 1.10 dist-bzip2 subdir-objects])
AM_CONFIG_HEADER(config.h)
@@ -13,6 +13,7 @@ dnl Programs
dnl ---------------------------------------------------------------------------
AC_PROG_CC_C99
AC_PROG_CXX
AC_PROG_RANLIB
HAVE_CXX=yes
if test x$CXX = xg++; then
@@ -32,11 +33,28 @@ fi
AC_PROG_INSTALL
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
[], [with_systemdsystemunitdir=no])
if test "x$with_systemdsystemunitdir" = xyes; then
AC_MSG_CHECKING(for systemd)
with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
if test -z "$with_systemdsystemunitdir"; then
AC_MSG_ERROR([Failed to detect systemd])
fi
AC_MSG_RESULT([$with_systemdsystemunitdir])
fi
if test "x$with_systemdsystemunitdir" != xno; then
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
dnl ---------------------------------------------------------------------------
dnl Declare Variables
dnl ---------------------------------------------------------------------------
AC_SUBST(AM_CPPFLAGS,"")
AC_SUBST(AM_CFLAGS,"")
AC_SUBST(AM_CXXFLAGS,"")
AC_SUBST(MPD_LIBS)
AC_SUBST(MPD_CFLAGS)
@@ -157,7 +175,7 @@ AC_ARG_ENABLE(documentation,
AC_ARG_ENABLE(ffado,
AS_HELP_STRING([--enable-ffado], [enable libffado (FireWire) support]),,
[enable_ffado=auto])
[enable_ffado=no])
AC_ARG_ENABLE(ffmpeg,
AS_HELP_STRING([--enable-ffmpeg],
@@ -170,9 +188,9 @@ AC_ARG_ENABLE(fifo,
enable_fifo=yes)
AC_ARG_ENABLE(flac,
AS_HELP_STRING([--disable-flac],
[disable flac support (default: enable)]),,
enable_flac=yes)
AS_HELP_STRING([--enable-flac],
[enable FLAC decoder]),,
enable_flac=auto)
AC_ARG_ENABLE(fluidsynth,
AS_HELP_STRING([--enable-fluidsynth],
@@ -195,9 +213,9 @@ AC_ARG_ENABLE(httpd-output,
[enable_httpd_output=auto])
AC_ARG_ENABLE(id3,
AS_HELP_STRING([--disable-id3],
[disable id3 support (default: enable)]),,
enable_id3=yes)
AS_HELP_STRING([--enable-id3],
[enable id3 support]),,
enable_id3=auto)
AC_ARG_ENABLE(inotify,
AS_HELP_STRING([--disable-inotify],
@@ -321,6 +339,11 @@ AC_ARG_ENABLE(sndfile,
[enable sndfile support]),,
enable_sndfile=auto)
AC_ARG_ENABLE(solaris_output,
AS_HELP_STRING([--enable-solaris-output],
[enables the Solaris /dev/audio output]),,
[enable_solaris_output=auto])
AC_ARG_ENABLE(sqlite,
AS_HELP_STRING([--enable-sqlite],
[enable support for the SQLite database]),,
@@ -352,9 +375,9 @@ AC_ARG_ENABLE(un,
[enable_un=yes])
AC_ARG_ENABLE(vorbis,
AS_HELP_STRING([--disable-vorbis],
[disable Ogg Vorbis support (default: enable)]),,
enable_vorbis=yes)
AS_HELP_STRING([--enable-vorbis],
[enable Ogg Vorbis decoder]),,
enable_vorbis=auto)
AC_ARG_ENABLE(vorbis-encoder,
AS_HELP_STRING([--enable-vorbis-encoder],
@@ -509,13 +532,8 @@ fi
AM_CONDITIONAL(HAVE_CUE, test x$enable_cue = xyes)
dnl -------------------------------- libid3tag --------------------------------
if test x$enable_id3 = xyes; then
PKG_CHECK_MODULES([ID3TAG], [id3tag],,
AC_CHECK_LIB(id3tag, id3_file_open,
[ID3TAG_LIBS="-lid3tag -lz" ID3TAG_CFLAGS=""],
enable_id3=no))
fi
MPD_AUTO_PKG_LIB(id3, ID3TAG, id3tag, id3tag, id3_file_open, [-lid3tag -lz], [],
[id3tag], [libid3tag not found])
if test x$enable_id3 = xyes; then
AC_DEFINE(HAVE_ID3TAG, 1, [Define to use id3tag])
fi
@@ -529,36 +547,39 @@ dnl ---------------------------------------------------------------------------
dnl --------------------------------- zeroconf --------------------------------
case $with_zeroconf in
no|avahi|bonjour)
no|bonjour)
enable_avahi=no
;;
avahi)
enable_avahi=yes
;;
*)
with_zeroconf=auto
enable_avahi=auto
;;
esac
MPD_AUTO_PKG(avahi, AVAHI, [avahi-client avahi-glib],
[avahi client library], [avahi client+glib not found])
if test x$enable_avahi = xyes; then
AC_DEFINE([HAVE_AVAHI], 1, [Define to enable Avahi Zeroconf support])
with_zeroconf=avahi
fi
AM_CONDITIONAL(HAVE_AVAHI, test x$enable_avahi = xyes)
enable_bounjour=no
if test x$with_zeroconf != xno; then
if test x$with_zeroconf = xavahi || test x$with_zeroconf = xauto; then
PKG_CHECK_MODULES([AVAHI], [avahi-client avahi-glib],
[found_avahi=1;AC_DEFINE([HAVE_AVAHI], 1, [Define to enable Avahi Zeroconf support])]
MPD_LIBS="$MPD_LIBS $AVAHI_LIBS" MPD_CFLAGS="$MPD_CFLAGS $AVAHI_CFLAGS",
[found_avahi=0])
fi
if test x$found_avahi = x1; then
with_zeroconf=avahi
elif test x$with_zeroconf = xavahi; then
AC_MSG_ERROR([Avahi support requested but not found])
fi
if test x$with_zeroconf = xbonjour || test x$with_zeroconf = xauto; then
AC_CHECK_HEADER(dns_sd.h,
[found_bonjour=1;AC_DEFINE([HAVE_BONJOUR], 1, [Define to enable Bonjour Zeroconf support])],
[found_bonjour=0])
[enable_bonjour=yes;AC_DEFINE([HAVE_BONJOUR], 1, [Define to enable Bonjour Zeroconf support])])
AC_CHECK_LIB(dns_sd, DNSServiceRegister,
MPD_LIBS="$MPD_LIBS -ldns_sd")
fi
if test x$found_bonjour = x1; then
if test x$enable_bonjour = xyes; then
with_zeroconf=bonjour
elif test x$with_zeroconf = xbonjour; then
AC_MSG_ERROR([Bonjour support requested but not found])
@@ -573,7 +594,6 @@ if test x$with_zeroconf != xno; then
fi
AM_CONDITIONAL(HAVE_ZEROCONF, test x$with_zeroconf != xno)
AM_CONDITIONAL(HAVE_AVAHI, test x$with_zeroconf = xavahi)
AM_CONDITIONAL(HAVE_BONJOUR, test x$with_zeroconf = xbonjour)
dnl ---------------------------------------------------------------------------
@@ -633,11 +653,6 @@ if test x$enable_lastfm = xyes; then
fi
AM_CONDITIONAL(ENABLE_LASTFM, test x$enable_lastfm = xyes)
dnl ---------------------------------- libogg ---------------------------------
if test x$with_tremor == xno || test -z $with_tremor; then
PKG_CHECK_MODULES(OGG, [ogg], enable_ogg=yes, enable_ogg=no)
fi
dnl ---------------------------------- libmms ---------------------------------
MPD_AUTO_PKG(mms, MMS, [libmms >= 0.4],
[libmms mms:// protocol support], [libmms not found])
@@ -752,10 +767,12 @@ fi
AM_CONDITIONAL(HAVE_FFMPEG, test x$enable_ffmpeg = xyes)
dnl ----------------------------------- FLAC ----------------------------------
MPD_AUTO_PKG(flac, FLAC, [flac >= 1.1],
[FLAC decoder], [libFLAC not found])
if test x$enable_flac = xyes; then
PKG_CHECK_MODULES(FLAC, [flac >= 1.1],
AC_DEFINE(HAVE_FLAC, 1, [Define for FLAC support]),
enable_flac=no)
AC_DEFINE(HAVE_FLAC, 1, [Define for FLAC support])
oldcflags="$CFLAGS"
oldlibs="$LIBS"
@@ -770,12 +787,10 @@ if test x$enable_flac = xyes; then
LIBS="$oldlibs"
if test x$enable_oggflac = xflac; then
if test x$enable_ogg = xyes; then
FLAC_LIBS="${FLAC_LIBS} -logg"
else
enable_oggflac=yes
AC_MSG_WARN("FLAC has the ogg API built in, but couldn't find ogg. Disabling oggflac.")
fi
PKG_CHECK_MODULES(OGG, [ogg],
[FLAC_LIBS="${FLAC_LIBS} ${OGG_LIBS}" FLAC_CFLAGS="${FLAC_CFLAGS} ${OGG_CFLAGS}"],
[enable_oggflac=yes;
AC_MSG_WARN("FLAC has the ogg API built in, but couldn't find ogg. Disabling oggflac.")])
fi
fi
@@ -801,7 +816,8 @@ if test x$enable_gme = xyes; then
fi
dnl ---------------------------------- libmad ---------------------------------
MPD_AUTO_PKG(mad, MAD, [mad],
MPD_AUTO_PKG_LIB(mad, MAD, [mad],
mad, mad_stream_init, [-lmad], [],
[libmad MP3 decoder plugin], [libmad not found])
if test x$enable_mad = xyes; then
AC_DEFINE(HAVE_MAD, 1, [Define to use libmad])
@@ -849,15 +865,6 @@ if test x$enable_modplug = xyes; then
fi
AM_CONDITIONAL(HAVE_MODPLUG, test x$enable_modplug = xyes)
dnl --------------------------- sndfile/modplug test --------------------------
if test x$enable_sndfile = xauto && test x$enable_modplug = xyes; then
dnl If modplug is enabled, enable sndfile only if explicitly
dnl requested - modplug's modplug/sndfile.h is known to
dnl conflict with libsndfile's sndfile.h.
AC_MSG_NOTICE([disabling libsndfile auto-detection, because the modplug decoder is enabled])
enable_sndfile=no
fi
dnl -------------------------------- libsndfile -------------------------------
dnl See above test, which may disable this.
MPD_AUTO_PKG(sndfile, SNDFILE, [sndfile],
@@ -942,13 +949,19 @@ if test x$enable_tremor = xyes; then
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $TREMOR_CFLAGS"
LIBS="$LIBS $TREMOR_LIBS"
AC_CHECK_LIB(vorbisidec,ov_read,enable_vorbis=yes,enable_vorbis=no;
AC_CHECK_LIB(vorbisidec,ov_read,,enable_tremor=no;
AC_MSG_WARN([vorbisidec lib needed for ogg support with tremor -- disabling ogg support]))
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
if test x$enable_tremor = xyes; then
AC_DEFINE(HAVE_TREMOR,1,
[Define to use tremor (libvorbisidec) for ogg support])
AC_DEFINE(ENABLE_VORBIS_DECODER, 1, [Define for Ogg Vorbis support])
else
TREMOR_CFLAGS=
TREMOR_LIBS=
fi
AC_SUBST(TREMOR_CFLAGS)
@@ -974,21 +987,21 @@ fi
AM_CONDITIONAL(HAVE_OGGFLAC, test x$enable_oggflac = xyes)
dnl -------------------------------- Ogg Vorbis -------------------------------
if test x$enable_vorbis = xyes; then
if test x$enable_tremor = xyes; then
if test x$enable_tremor = xyes; then
if test x$enable_vorbis = xyes; then
AC_MSG_WARN(["OggTremor detected, could not enable Vorbis."])
enable_vorbis=no
elif test x$enable_ogg = xyes; then
PKG_CHECK_MODULES(VORBIS, [vorbis vorbisfile],
AC_DEFINE(ENABLE_VORBIS_DECODER, 1, [Define for Ogg Vorbis support]),
enable_vorbis=no)
else
AC_MSG_WARN(["Ogg not detected, could not enable Vorbis."])
enable_vorbis=no
fi
enable_vorbis=no
fi
AM_CONDITIONAL(ENABLE_VORBIS_DECODER, test x$enable_vorbis = xyes)
MPD_AUTO_PKG(vorbis, VORBIS, [vorbis vorbisfile ogg],
[Ogg Vorbis decoder], [libvorbis not found])
if test x$enable_vorbis = xyes; then
AC_DEFINE(ENABLE_VORBIS_DECODER, 1, [Define for Ogg Vorbis support])
fi
AM_CONDITIONAL(ENABLE_VORBIS_DECODER, test x$enable_vorbis = xyes || test x$enable_tremor = xyes)
dnl --------------------------------- sidplay ---------------------------------
found_sidplay=$HAVE_CXX
@@ -1083,7 +1096,7 @@ if
fi
AM_CONDITIONAL(HAVE_OGG_COMMON,
test x$enable_vorbis = xyes || test x$enable_oggflac = xyes || test x$enable_flac = xyes)
test x$enable_vorbis = xyes || test x$enable_tremor = xyes || test x$enable_oggflac = xyes || test x$enable_flac = xyes)
AM_CONDITIONAL(HAVE_FLAC_COMMON,
test x$enable_flac = xyes || test x$enable_oggflac = xyes)
@@ -1377,16 +1390,22 @@ fi
AM_CONDITIONAL(HAVE_SHOUT, test x$enable_shout = xyes)
dnl --------------------------------- Solaris ---------------------------------
case "$host_os" in
if test x$enable_solaris_output = xauto; then
case "$host_os" in
solaris*)
AC_DEFINE(ENABLE_SOLARIS_OUTPUT, 1, [Define to enable Solaris /dev/audio support])
enable_solaris_output=yes
;;
*)
enable_solaris_output=no
;;
esac
esac
fi
if test x$enable_solaris_output = xyes; then
AC_DEFINE(ENABLE_SOLARIS_OUTPUT, 1, [Define to enable Solaris /dev/audio support])
fi
AM_CONDITIONAL(ENABLE_SOLARIS_OUTPUT, test x$enable_solaris_output = xyes)
@@ -1458,10 +1477,9 @@ dnl CFLAGS
dnl ---------------------------------------------------------------------------
dnl ---------------------------------- debug ----------------------------------
#if test "x$enable_debug" = xno; then
# don't set NDEBUG for now, until MPD is stable
#AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
#fi
if test "x$enable_debug" = xno; then
AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
fi
dnl ----------------------------------- GCC -----------------------------------
if test x$GCC = xyes
@@ -1487,6 +1505,7 @@ fi
dnl ---------------------------- warnings as errors ---------------------------
if test "x$enable_werror" = xyes; then
AM_CFLAGS="$AM_CFLAGS -Werror -pedantic-errors"
AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
fi
dnl ---------------------------------------------------------------------------
@@ -1495,23 +1514,23 @@ dnl ---------------------------------------------------------------------------
echo ''
echo '########### MPD CONFIGURATION ############'
echo -ne '\nArchive support:\n\t'
printf '\nArchive support:\n\t'
results(bzip2,[bzip2])
results(iso9660,[ISO9660])
results(zzip,[ZIP])
if test x$with_zeroconf != xno; then
echo -ne '\nAutodiscovery support:\n\t'
printf '\nAutodiscovery support:\n\t'
results(avahi, [Avahi])
results(bonjour, [Bonjour])
fi
echo -ne '\nClient support:\n\t'
printf '\nClient support:\n\t'
results(ipv6, "IPv6")
results(tcp, "TCP")
results(un,[UNIX Domain Sockets])
echo -ne '\nFile format support:\n\t'
printf '\nFile format support:\n\t'
results(aac, [AAC])
results(sidplay, [C64 SID])
results(ffmpeg, [FFMPEG])
@@ -1519,7 +1538,7 @@ results(flac, [FLAC])
results(fluidsynth, [FluidSynth])
results(gme, [GME])
results(sndfile, [libsndfile])
echo -ne '\n\t'
printf '\n\t'
results(mikmod, [MikMod])
results(modplug, [MODPLUG])
results(mad, [MAD])
@@ -1527,23 +1546,23 @@ results(mpg123, [MPG123])
results(mp4, [MP4])
results(mpc, [Musepack])
results(oggflac, [OggFLAC], flac)
echo -ne '\n\t'
printf '\n\t'
results(tremor, [OggTremor])
results(vorbis, [OggVorbis])
results(audiofile, [WAVE])
results(wavpack, [WavPack])
results(wildmidi, [WildMidi])
echo -en '\nOther features:\n\t'
printf '\nOther features:\n\t'
results(lsr, [libsamplerate])
results(inotify, [inotify])
results(sqlite, [SQLite])
echo -en '\nMetadata support:\n\t'
printf '\nMetadata support:\n\t'
results(cue,[cue])
results(id3,[ID3])
echo -en '\nPlayback support:\n\t'
printf '\nPlayback support:\n\t'
results(alsa,ALSA)
results(ffado,FFADO)
results(fifo,FIFO)
@@ -1552,22 +1571,22 @@ results(httpd_output,[HTTP Daemon])
results(jack,[JACK])
results(ao,[libao])
results(oss,[OSS])
echo -ne '\n\t'
printf '\n\t'
results(openal,[OpenAL])
results(osx, [OS X])
results(pipe_output, [Pipeline])
results(pulse, [PulseAudio])
results(mvp, [Media MVP])
results(shout, [SHOUTcast])
echo -ne '\n\t'
results(solaris, [Solaris])
printf '\n\t'
results(solaris_output, [Solaris])
results(winmm_output, [WinMM])
if
test x$enable_shout = xyes ||
test x$enable_recorder = xyes ||
test x$enable_httpd_output = xyes; then
echo -en '\nStreaming encoder support:\n\t'
printf '\nStreaming encoder support:\n\t'
results(flac_encoder, [FLAC])
results(lame_encoder, [LAME])
results(vorbis_encoder, [Ogg Vorbis])
@@ -1575,23 +1594,19 @@ if
results(wave_encoder, [WAVE])
fi
echo -en '\nStreaming support:\n\t'
printf '\nStreaming support:\n\t'
results(curl,[CURL])
results(lastfm,[Last.FM])
results(mms,[MMS])
echo -ne '\n\n##########################################\n\n'
printf '\n\n##########################################\n\n'
if test x$enable_sndfile = xyes && test x$enable_modplug = xyes; then
AC_MSG_WARN([compilation may fail, because libmodplug conflicts with libsndfile])
AC_MSG_WARN([libmodplug ships modplug/sndfile.h, which hides libsndfile's sndfile.h])
fi
echo -ne 'Generating files needed for compilation\n'
echo 'Generating files needed for compilation'
dnl ---------------------------------------------------------------------------
dnl Generate files
dnl ---------------------------------------------------------------------------
AC_OUTPUT(Makefile)
AC_OUTPUT(mpd.service)
echo 'MPD is ready for compilation, type "make" to begin.'

@@ -57,7 +57,7 @@
Some example code:
</para>
<programlisting lang="C">static inline bool
<programlisting lang="C">static inline int
foo(const char *abc, int xyz)
{
if (abc == NULL) {

@@ -8,18 +8,54 @@
<title>General protocol syntax</title>
<section>
<title>Requests</title>
<title>Protocol overview</title>
<para>
If arguments contain spaces, they should be surrounded by double quotation
marks.
The MPD command protocol exchanges line-based text records
between client and server over TCP. Once the client is
connected to the server, they conduct a conversation until the
client closes the connection. The conversation flow is always
initiated by the client.
</para>
<para>
The client transmits a command sequence, terminated by the
newline character <constant>\n</constant>. The server will
respond with one or more lines, the last of which will be a
completion code.
</para>
<para>
When the client connects to the server, the server will answer
with the following line:
<synopsis>OK MPD version</synopsis>
where <varname>version</varname> is a version identifier such as
0.12.2. This version identifier is the version of the protocol
spoken, not the real version of the daemon. (There is no way to
retrieve this real version identifier from the connection.)
</para>
</section>
<section>
<title>Requests</title>
<cmdsynopsis>
<command>COMMAND</command>
<arg rep="repeat"><replaceable>ARG</replaceable></arg>
</cmdsynopsis>
<para>
If arguments contain spaces, they should be surrounded by double
quotation marks.
</para>
<para>
Argument strings are separated from the command and any other
arguments by linear white-space (' ' or '\t').
</para>
<para>
All data between the client and the server is encoded in
UTF-8. (Note: In UTF-8 all standard ansi characters, 0-127 are
@@ -38,13 +74,97 @@
<title>Responses</title>
<para>
A command returns <returnvalue>OK</returnvalue> on completion
or <returnvalue>ACK some error</returnvalue> on failure.
These denote the end of command execution.
A command returns <returnvalue>OK</returnvalue> on completion or
<returnvalue>ACK some error</returnvalue> on failure. These
denote the end of command execution.
</para>
<section>
<title>Failure responses</title>
<para>
The nature of the error can be gleaned from the information
that follows the <returnvalue>ACK</returnvalue>.
<returnvalue>ACK</returnvalue> lines are of the form:
<synopsis>ACK [error@command_listNum] {current_command} message_text\n</synopsis>
These responses are generated by a call to
<function>commandError</function>. They contain four separate
terms. Let's look at each of them:
<itemizedlist>
<listitem>
<para>
<returnvalue>error</returnvalue>: numeric value of one
of the <constant>ACK_ERROR</constant> constants defined
in <filename>ack.h</filename>.
</para>
</listitem>
<listitem>
<para>
<returnvalue>command_listNum</returnvalue>:
offset of the command that caused the error in a <link
linkend="command_lists">Command List</link>.
An error will always cause a command list to terminate
at the command that causes the error.
</para>
</listitem>
<listitem>
<para>
<returnvalue>current_command</returnvalue>:
name of the command, in a <link
linkend="command_lists">Command List</link>,
that was executing when the error occurred.
</para>
</listitem>
<listitem>
<para>
<returnvalue>message_text</returnvalue>:
some (hopefully) informative text that describes the
nature of the error.
</para>
</listitem>
</itemizedlist>
</para>
<example>
<title>foo</title>
<para>
An example might help. Consider the following sequence
sent from the client to the server.
<synopsis>
command_list_begin
volume 86
play 10240
status
command_list_end
</synopsis>
</para>
<para>
The server responds with:
<returnvalue>
ACK [50@1] {play} song doesn't exist: "10240"
</returnvalue>
</para>
<para>
This tells us that the play command, which was the
second in the list (the first or only command is
numbered 0), failed with error 50. The number 50
translates to <constant>ACK_ERROR_NO_EXIST</constant>--the
song doesn't exist. This is reiterated by the message text
which also tells us which song doesn't exist.
</para>
</example>
</section>
</section>
<section>
<section id="command_lists">
<title>Command lists</title>
<para>

@@ -446,7 +446,7 @@ cd mpd-version</programlisting>
</para>
<para>
To configure a filter, add a
To configure a playlist plugin, add a
<varname>playlist_plugin</varname> block to
<filename>mpd.conf</filename>:
</para>

@@ -58,7 +58,7 @@ if test x$enable_aac = xyes; then
fi
if test x$enable_aac = xyes; then
AC_MSG_CHECKING(that FAAD2 uses buffer and bufferlen)
AC_COMPILE_IFELSE([
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <faad.h>
int main() {
@@ -82,9 +82,9 @@ int main() {
return 0;
}
],[AC_MSG_RESULT(yes);AC_DEFINE(HAVE_FAAD_BUFLEN_FUNCS,1,[Define if FAAD2 uses buflen in function calls])],[AC_MSG_RESULT(no);
])],[AC_MSG_RESULT(yes);AC_DEFINE(HAVE_FAAD_BUFLEN_FUNCS,1,[Define if FAAD2 uses buflen in function calls])],[AC_MSG_RESULT(no);
AC_MSG_CHECKING(that FAAD2 can even be used)
AC_COMPILE_IFELSE([
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <faad.h>
int main() {
@@ -113,7 +113,7 @@ int main() {
return 0;
}
],AC_MSG_RESULT(yes),[AC_MSG_RESULT(no);enable_aac=no])
])],AC_MSG_RESULT(yes),[AC_MSG_RESULT(no);enable_aac=no])
])
fi
if test x$enable_aac = xyes; then
@@ -136,7 +136,7 @@ if test x$enable_aac = xyes; then
CPPFLAGS=$CFLAGS
AC_MSG_CHECKING(for broken libfaad headers)
AC_COMPILE_IFELSE([
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <faad.h>
#include <stddef.h>
#include <stdint.h>
@@ -148,7 +148,7 @@ int main() {
faacDecInit2(NULL, NULL, 0, &sample_rate, &channels);
return 0;
}
],
])],
[AC_MSG_RESULT(correct)],
[AC_MSG_RESULT(broken);
AC_DEFINE(HAVE_FAAD_LONG, 1, [Define if faad.h uses the broken "unsigned long" pointers])])

@@ -63,3 +63,18 @@ AC_DEFUN([MPD_AUTO_PKG], [
MPD_AUTO_RESULT([$1], [$4], [$5])
])
dnl Check with pkg-config first, fall back to AC_CHECK_LIB.
dnl
dnl Parameters: varname1, varname2, pkgname, libname, symname, libs, cflags, description, errmsg
AC_DEFUN([MPD_AUTO_PKG_LIB], [
if eval "test x`echo '$'enable_$1` != xno"; then
PKG_CHECK_MODULES([$2], [$3],
[eval "found_$1=yes"],
AC_CHECK_LIB($4, $5,
[eval "found_$1=yes $2_LIBS='$6' $2_CFLAGS='$7'"],
[eval "found_$1=no"]))
fi
MPD_AUTO_RESULT([$1], [$8], [$9])
])

@@ -4,9 +4,9 @@ AC_DEFUN([MPD_CHECK_FLAG],[
[mpd_check_cflag_$var],[
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_COMPILE_IFELSE([
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
int main(void) { return 0; }
], [ eval "mpd_check_cflag_$var=yes"
])], [ eval "mpd_check_cflag_$var=yes"
], [ eval "mpd_check_cflag_$var=no" ])
CFLAGS="$save_CFLAGS"
])

@@ -1,19 +1,19 @@
AC_DEFUN([results], [
dnl This is a hack to allow "with" names, otherwise "enable".
num=`expr match $1 'with'`
num=`expr $1 : 'with'`
if test "$num" != "0"; then
var="`echo '$'$1`"
else
var="`echo '$'enable_$1`"
fi
echo -n '('
printf '('
if eval "test x$var = xyes"; then
echo -n '+'
printf '+'
elif test -n "$3" && eval "test x$var = x$3"; then
echo -n '+'
printf '+'
else
echo -n '-'
printf '-'
fi
echo -n "$2) "
printf '%s) ' "$2"
])

9
mpd.service.in Normal file

@@ -0,0 +1,9 @@
[Unit]
Description=Music Player Daemon
After=sound.target
[Service]
ExecStart=@prefix@/bin/mpd --no-daemon
[Install]
WantedBy=multi-user.target

@@ -3,7 +3,7 @@ PWD=`pwd`
## If we're not in the scripts directory
## assume the base directory.
if test "`basename $PWD`" == "scripts"; then
if test "`basename $PWD`" = "scripts"; then
cd ../
else
MYOLDPWD=`pwd`
@@ -18,7 +18,7 @@ fi
make
make dist
if test "`basename $PWD`" == "scripts"; then
if test "`basename $PWD`" = "scripts"; then
cd contrib/
else
cd $MYOLDPWD

@@ -16,16 +16,16 @@
struct Compressor {
//! The compressor's preferences
struct CompressorConfig prefs;
//! History of the peak values
int *peaks;
//! History of the gain values
int *gain;
//! History of clip amounts
int *clipped;
unsigned int pos;
unsigned int bufsz;
};
@@ -41,9 +41,9 @@ struct Compressor *Compressor_new(unsigned int history)
obj->peaks = obj->gain = obj->clipped = NULL;
obj->bufsz = 0;
obj->pos = 0;
Compressor_setHistory(obj, history);
return obj;
}
@@ -70,7 +70,7 @@ void Compressor_setHistory(struct Compressor *obj, unsigned int history)
{
if (!history)
history = BUCKETS;
obj->peaks = resizeArray(obj->peaks, history, obj->bufsz);
obj->gain = resizeArray(obj->gain, history, obj->bufsz);
obj->clipped = resizeArray(obj->clipped, history, obj->bufsz);
@@ -82,7 +82,7 @@ struct CompressorConfig *Compressor_getConfig(struct Compressor *obj)
return &obj->prefs;
}
void Compressor_Process_int16(struct Compressor *obj, int16_t *audio,
void Compressor_Process_int16(struct Compressor *obj, int16_t *audio,
unsigned int count)
{
struct CompressorConfig *prefs = Compressor_getConfig(obj);
@@ -97,7 +97,7 @@ void Compressor_Process_int16(struct Compressor *obj, int16_t *audio,
int *clipped = obj->clipped + slot;
unsigned int ramp = count;
int delta;
ap = audio;
for (i = 0; i < count; i++)
{
@@ -124,15 +124,15 @@ void Compressor_Process_int16(struct Compressor *obj, int16_t *audio,
//! Determine target gain
newGain = (1 << 10)*prefs->target/peakVal;
//! Adjust the gain with inertia from the previous gain value
newGain = (curGain*((1 << prefs->smooth) - 1) + newGain)
newGain = (curGain*((1 << prefs->smooth) - 1) + newGain)
>> prefs->smooth;
//! Make sure it's no more than the maximum gain value
if (newGain > (prefs->maxgain << 10))
newGain = prefs->maxgain << 10;
//! Make sure it's no less than 1:1
if (newGain < (1 << 10))
newGain = 1 << 10;
@@ -144,7 +144,7 @@ void Compressor_Process_int16(struct Compressor *obj, int16_t *audio,
//! Truncate the ramp time
ramp = peakPos;
}
//! Record the new gain
obj->gain[slot] = newGain;

@@ -60,8 +60,10 @@ ape_scan_internal(FILE *fp, tag_ape_callback_t callback, void *ctx)
assert(remaining > 10);
char *buffer = g_malloc(remaining);
if (fread(buffer, 1, remaining, fp) != remaining)
if (fread(buffer, 1, remaining, fp) != remaining) {
g_free(buffer);
return false;
}
/* read tags */
unsigned n = GUINT32_FROM_LE(footer.count);

@@ -38,7 +38,7 @@ bool
audio_check_sample_rate(unsigned long sample_rate, GError **error_r);
bool
audio_check_sample_format(unsigned sample_format, GError **error_r);
audio_check_sample_format(enum sample_format, GError **error_r);
bool
audio_check_channel_count(unsigned sample_format, GError **error_r);

@@ -22,6 +22,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
enum sample_format {
SAMPLE_FORMAT_UNDEFINED = 0,
@@ -219,6 +220,9 @@ static inline void
audio_format_mask_apply(struct audio_format *af,
const struct audio_format *mask)
{
assert(audio_format_valid(af));
assert(audio_format_mask_valid(mask));
if (mask->sample_rate != 0)
af->sample_rate = mask->sample_rate;
@@ -227,6 +231,8 @@ audio_format_mask_apply(struct audio_format *af,
if (mask->channels != 0)
af->channels = mask->channels;
assert(audio_format_valid(af));
}
/**

@@ -192,6 +192,8 @@ audio_format_parse(struct audio_format *dest, const char *src,
}
audio_format_init(dest, rate, sample_format, channels);
assert(mask ? audio_format_mask_valid(dest)
: audio_format_valid(dest));
return true;
}

@@ -19,9 +19,11 @@
#include "config.h"
#include "client_internal.h"
#include "fd_util.h"
#include "fifo_buffer.h"
#include "socket_util.h"
#include "permission.h"
#include "glib_socket.h"
#include <assert.h>
#include <sys/types.h>
@@ -66,7 +68,7 @@ void client_new(int fd, const struct sockaddr *sa, size_t sa_length, int uid)
progname, hostaddr);
g_free(hostaddr);
close(fd);
close_socket(fd);
return;
}
@@ -76,17 +78,13 @@ void client_new(int fd, const struct sockaddr *sa, size_t sa_length, int uid)
if (client_list_is_full()) {
g_warning("Max Connections Reached!");
close(fd);
close_socket(fd);
return;
}
client = g_new0(struct client, 1);
#ifndef G_OS_WIN32
client->channel = g_io_channel_unix_new(fd);
#else
client->channel = g_io_channel_win32_new_socket(fd);
#endif
client->channel = g_io_channel_new_socket(fd);
/* GLib is responsible for closing the file descriptor */
g_io_channel_set_close_on_unref(client->channel, true);
/* NULL encoding means the stream is binary safe; the MPD

@@ -464,7 +464,7 @@ handle_currentsong(struct client *client,
G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
{
playlist_print_current(client, &g_playlist);
return PLAYLIST_RESULT_SUCCESS;
return COMMAND_RETURN_OK;
}
static enum command_return
@@ -749,7 +749,7 @@ handle_load(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
result = playlist_open_into_queue(argv[1], &g_playlist);
if (result != PLAYLIST_RESULT_NO_SUCH_LIST)
return result;
return print_playlist_result(client, result);
result = playlist_load_spl(&g_playlist, argv[1]);
return print_playlist_result(client, result);

@@ -367,6 +367,7 @@ config_read_file(const char *file, GError **error_r)
assert(*line != 0);
g_propagate_prefixed_error(error_r, error,
"line %i: ", count);
fclose(fp);
return false;
}
@@ -378,6 +379,7 @@ config_read_file(const char *file, GError **error_r)
g_set_error(error_r, config_quark(), 0,
"unrecognized parameter in config file at "
"line %i: %s\n", count, name);
fclose(fp);
return false;
}
@@ -387,6 +389,7 @@ config_read_file(const char *file, GError **error_r)
"config parameter \"%s\" is first defined "
"on line %i and redefined on line %i\n",
name, param->line, count);
fclose(fp);
return false;
}
@@ -398,6 +401,7 @@ config_read_file(const char *file, GError **error_r)
if (*line != '{') {
g_set_error(error_r, config_quark(), 0,
"line %i: '{' expected", count);
fclose(fp);
return false;
}
@@ -406,12 +410,15 @@ config_read_file(const char *file, GError **error_r)
g_set_error(error_r, config_quark(), 0,
"line %i: Unknown tokens after '{'",
count);
fclose(fp);
return false;
}
param = config_read_block(fp, &count, string, error_r);
if (param == NULL)
if (param == NULL) {
fclose(fp);
return false;
}
} else {
/* a string value */
@@ -428,6 +435,7 @@ config_read_file(const char *file, GError **error_r)
g_error_free(error);
}
fclose(fp);
return false;
}
@@ -435,6 +443,7 @@ config_read_file(const char *file, GError **error_r)
g_set_error(error_r, config_quark(), 0,
"line %i: Unknown tokens after value",
count);
fclose(fp);
return false;
}

@@ -180,7 +180,7 @@ db_check(void)
}
/* Check if we can write to the directory */
if (access(dirPath, R_OK | W_OK)) {
if (access(dirPath, X_OK | W_OK)) {
g_warning("Can't create db file in \"%s\": %s",
dirPath, strerror(errno));
g_free(dirPath);

@@ -25,6 +25,7 @@
#include <af_vfs.h>
#include <assert.h>
#include <glib.h>
#include <stdio.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "audiofile"
@@ -244,7 +245,7 @@ static const char *const audiofile_suffixes[] = {
static const char *const audiofile_mime_types[] = {
"audio/x-wav",
"audio/x-aiff",
NULL
NULL
};
const struct decoder_plugin audiofile_decoder_plugin = {

@@ -81,11 +81,19 @@ mpd_ffmpeg_log_callback(G_GNUC_UNUSED void *ptr, int level,
#endif /* !OLD_FFMPEG_INCLUDES */
#ifndef AV_VERSION_INT
#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c)
#endif
struct mpd_ffmpeg_stream {
struct decoder *decoder;
struct input_stream *input;
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,101,0)
AVIOContext *io;
#else
ByteIOContext *io;
#endif
unsigned char buffer[8192];
};
@@ -102,13 +110,11 @@ static int64_t
mpd_ffmpeg_stream_seek(void *opaque, int64_t pos, int whence)
{
struct mpd_ffmpeg_stream *stream = opaque;
bool ret;
if (whence == AVSEEK_SIZE)
return stream->input->size;
ret = input_stream_seek(stream->input, pos, whence, NULL);
if (!ret)
if (!input_stream_seek(stream->input, pos, whence, NULL))
return -1;
return stream->input->offset;
@@ -133,6 +139,33 @@ mpd_ffmpeg_stream_open(struct decoder *decoder, struct input_stream *input)
return stream;
}
/**
* API compatibility wrapper for av_open_input_stream() and
* avformat_open_input().
*/
static int
mpd_ffmpeg_open_input(AVFormatContext **ic_ptr,
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,101,0)
AVIOContext *pb,
#else
ByteIOContext *pb,
#endif
const char *filename,
AVInputFormat *fmt)
{
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,1,3)
AVFormatContext *context = avformat_alloc_context();
if (context == NULL)
return AVERROR(ENOMEM);
context->pb = pb;
*ic_ptr = context;
return avformat_open_input(ic_ptr, filename, fmt, NULL);
#else
return av_open_input_stream(ic_ptr, pb, filename, fmt, NULL);
#endif
}
static void
mpd_ffmpeg_stream_close(struct mpd_ffmpeg_stream *stream)
{
@@ -156,7 +189,11 @@ ffmpeg_find_audio_stream(const AVFormatContext *format_context)
{
for (unsigned i = 0; i < format_context->nb_streams; ++i)
if (format_context->streams[i]->codec->codec_type ==
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 64, 0)
AVMEDIA_TYPE_AUDIO)
#else
CODEC_TYPE_AUDIO)
#endif
return i;
return -1;
@@ -177,36 +214,63 @@ align16(void *p, size_t *length_p)
return (char *)p + add;
}
G_GNUC_CONST
static double
time_from_ffmpeg(int64_t t, const AVRational time_base)
{
assert(t != (int64_t)AV_NOPTS_VALUE);
return (double)av_rescale_q(t, time_base, (AVRational){1, 1024})
/ (double)1024;
}
G_GNUC_CONST
static int64_t
time_to_ffmpeg(double t, const AVRational time_base)
{
return av_rescale_q((int64_t)(t * 1024), (AVRational){1, 1024},
time_base);
}
static enum decoder_command
ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
const AVPacket *packet,
AVCodecContext *codec_context,
const AVRational *time_base)
{
enum decoder_command cmd = DECODE_COMMAND_NONE;
uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
int16_t *aligned_buffer;
size_t buffer_size;
int len, audio_size;
uint8_t *packet_data;
int packet_size;
if (packet->pts != (int64_t)AV_NOPTS_VALUE)
decoder_timestamp(decoder,
av_rescale_q(packet->pts, *time_base,
(AVRational){1, 1}));
time_from_ffmpeg(packet->pts, *time_base));
packet_data = packet->data;
packet_size = packet->size;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
AVPacket packet2 = *packet;
#else
const uint8_t *packet_data = packet->data;
int packet_size = packet->size;
#endif
buffer_size = sizeof(audio_buf);
aligned_buffer = align16(audio_buf, &buffer_size);
uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
size_t buffer_size = sizeof(audio_buf);
int16_t *aligned_buffer = align16(audio_buf, &buffer_size);
while ((packet_size > 0) && (cmd == DECODE_COMMAND_NONE)) {
audio_size = buffer_size;
len = avcodec_decode_audio2(codec_context,
aligned_buffer, &audio_size,
packet_data, packet_size);
enum decoder_command cmd = DECODE_COMMAND_NONE;
while (
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
packet2.size > 0 &&
#else
packet_size > 0 &&
#endif
cmd == DECODE_COMMAND_NONE) {
int audio_size = buffer_size;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
int len = avcodec_decode_audio3(codec_context,
aligned_buffer, &audio_size,
&packet2);
#else
int len = avcodec_decode_audio2(codec_context,
aligned_buffer, &audio_size,
packet_data, packet_size);
#endif
if (len < 0) {
/* if error, we skip the frame */
@@ -214,8 +278,13 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
break;
}
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
packet2.data += len;
packet2.size -= len;
#else
packet_data += len;
packet_size -= len;
#endif
if (audio_size <= 0)
continue;
@@ -230,7 +299,7 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
static enum sample_format
ffmpeg_sample_format(G_GNUC_UNUSED const AVCodecContext *codec_context)
{
#if LIBAVCODEC_VERSION_INT >= ((51<<16)+(41<<8)+0)
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(51, 41, 0)
switch (codec_context->sample_fmt) {
case SAMPLE_FMT_S16:
return SAMPLE_FORMAT_S16;
@@ -299,14 +368,10 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
return;
}
AVFormatContext *format_context;
AVCodecContext *codec_context;
AVCodec *codec;
int audio_stream;
//ffmpeg works with ours "fileops" helper
if (av_open_input_stream(&format_context, stream->io, input->uri,
input_format, NULL) != 0) {
AVFormatContext *format_context = NULL;
if (mpd_ffmpeg_open_input(&format_context, stream->io, input->uri,
input_format) != 0) {
g_warning("Open failed\n");
mpd_ffmpeg_stream_close(stream);
return;
@@ -319,7 +384,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
return;
}
audio_stream = ffmpeg_find_audio_stream(format_context);
int audio_stream = ffmpeg_find_audio_stream(format_context);
if (audio_stream == -1) {
g_warning("No audio stream inside\n");
av_close_input_stream(format_context);
@@ -327,11 +392,13 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
return;
}
codec_context = format_context->streams[audio_stream]->codec;
AVStream *av_stream = format_context->streams[audio_stream];
AVCodecContext *codec_context = av_stream->codec;
if (codec_context->codec_name[0] != 0)
g_debug("codec '%s'", codec_context->codec_name);
codec = avcodec_find_decoder(codec_context->codec_id);
AVCodec *codec = avcodec_find_decoder(codec_context->codec_id);
if (!codec) {
g_warning("Unsupported audio codec\n");
@@ -378,7 +445,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
if (packet.stream_index == audio_stream)
cmd = ffmpeg_send_packet(decoder, input,
&packet, codec_context,
&format_context->streams[audio_stream]->time_base);
&av_stream->time_base);
else
cmd = decoder_get_command(decoder);
@@ -386,12 +453,16 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
if (cmd == DECODE_COMMAND_SEEK) {
int64_t where =
decoder_seek_where(decoder) * AV_TIME_BASE;
time_to_ffmpeg(decoder_seek_where(decoder),
av_stream->time_base);
if (av_seek_frame(format_context, -1, where, 0) < 0)
if (av_seek_frame(format_context, audio_stream, where,
AV_TIME_BASE) < 0)
decoder_seek_error(decoder);
else
else {
avcodec_flush_buffers(codec_context);
decoder_command_finished(decoder);
}
}
} while (cmd != DECODE_COMMAND_STOP);
@@ -428,13 +499,26 @@ static const ffmpeg_tag_map ffmpeg_tag_maps[] = {
};
static bool
ffmpeg_copy_metadata(struct tag *tag, AVMetadata *m,
ffmpeg_copy_metadata(struct tag *tag,
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,1,0)
AVDictionary *m,
#else
AVMetadata *m,
#endif
const ffmpeg_tag_map tag_map)
{
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,1,0)
AVDictionaryEntry *mt = NULL;
while ((mt = av_dict_get(m, tag_map.name, mt, 0)) != NULL)
tag_add_item(tag, tag_map.type, mt->value);
#else
AVMetadataTag *mt = NULL;
while ((mt = av_metadata_get(m, tag_map.name, mt, 0)) != NULL)
tag_add_item(tag, tag_map.type, mt->value);
#endif
return mt != NULL;
}
@@ -452,9 +536,9 @@ ffmpeg_stream_tag(struct input_stream *is)
if (stream == NULL)
return NULL;
AVFormatContext *f;
if (av_open_input_stream(&f, stream->io, is->uri,
input_format, NULL) != 0) {
AVFormatContext *f = NULL;
if (mpd_ffmpeg_open_input(&f, stream->io, is->uri,
input_format) != 0) {
mpd_ffmpeg_stream_close(stream);
return NULL;
}

@@ -81,7 +81,7 @@ flac_tell_cb(G_GNUC_UNUSED const FLAC__StreamDecoder *fd,
struct flac_data *data = (struct flac_data *) fdata;
if (!data->input_stream->seekable)
return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED;
*offset = (long)(data->input_stream->offset);

@@ -224,7 +224,8 @@ flac_tag_apply_metadata(struct tag *tag, const char *track,
break;
case FLAC__METADATA_TYPE_STREAMINFO:
tag->time = flac_duration(&block->data.stream_info);
if (block->data.stream_info.sample_rate > 0)
tag->time = flac_duration(&block->data.stream_info);
break;
default:

@@ -20,6 +20,7 @@
#ifndef MPD_FLAC_METADATA_H
#define MPD_FLAC_METADATA_H
#include <assert.h>
#include <stdbool.h>
#include <FLAC/metadata.h>
@@ -29,6 +30,8 @@ struct replay_gain_info;
static inline unsigned
flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info)
{
assert(stream_info->sample_rate > 0);
return (stream_info->total_samples + stream_info->sample_rate - 1) /
stream_info->sample_rate;
}

@@ -153,6 +153,9 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
if((gme_err = gme_start_track(emu, song_num)) != NULL)
g_warning("%s", gme_err);
if(ti->length > 0)
gme_set_fade(emu, ti->length);
/* play */
do {
gme_err = gme_play(emu, GME_BUFFER_SAMPLES, buf);

@@ -547,14 +547,14 @@ enum {
XING_SCALE = 0x00000008L
};
struct version {
struct lame_version {
unsigned major;
unsigned minor;
};
struct lame {
char encoder[10]; /* 9 byte encoder name/version ("LAME3.97b") */
struct version version; /* struct containing just the version */
struct lame_version version; /* struct containing just the version */
float peak; /* replaygain peak */
float track_gain; /* replaygain track gain */
float album_gain; /* replaygain album gain */

@@ -153,7 +153,6 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
mpc_uint32_t ret;
int32_t chunk[G_N_ELEMENTS(sample_buffer)];
long bit_rate = 0;
mpc_uint32_t vbr_update_acc;
mpc_uint32_t vbr_update_bits;
enum decoder_command cmd = DECODE_COMMAND_NONE;
@@ -243,10 +242,11 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
decoder_seek_error(mpd_decoder);
}
vbr_update_acc = 0;
vbr_update_bits = 0;
#ifdef MPC_IS_OLD_API
mpc_uint32_t vbr_update_acc = 0;
ret = mpc_decoder_decode(&decoder, sample_buffer,
&vbr_update_acc, &vbr_update_bits);
if (ret == 0 || ret == (mpc_uint32_t)-1)

@@ -34,9 +34,6 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "wavpack"
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
#define CHUNK_SIZE 1020
#define ERRORLEN 80
static struct {
@@ -162,8 +159,6 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
enum sample_format sample_format;
struct audio_format audio_format;
format_samples_t format_samples;
char chunk[CHUNK_SIZE];
int samples_requested, samples_got;
float total_time;
int bytes_per_sample, output_sample_size;
@@ -181,7 +176,7 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
return;
}
if ((WavpackGetMode(wpc) & MODE_FLOAT) == MODE_FLOAT) {
if (is_float) {
format_samples = format_samples_float;
} else {
format_samples = format_samples_int;
@@ -193,12 +188,15 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
output_sample_size = audio_format_frame_size(&audio_format);
/* wavpack gives us all kind of samples in a 32-bit space */
samples_requested = sizeof(chunk) / (4 * audio_format.channels);
int32_t chunk[1024];
const uint32_t samples_requested = G_N_ELEMENTS(chunk) /
audio_format.channels;
decoder_initialized(decoder, &audio_format, can_seek, total_time);
do {
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
enum decoder_command cmd = decoder_get_command(decoder);
while (cmd != DECODE_COMMAND_STOP) {
if (cmd == DECODE_COMMAND_SEEK) {
if (can_seek) {
unsigned where = decoder_seek_where(decoder) *
audio_format.sample_rate;
@@ -213,29 +211,20 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
}
}
if (decoder_get_command(decoder) == DECODE_COMMAND_STOP) {
uint32_t samples_got = WavpackUnpackSamples(wpc, chunk,
samples_requested);
if (samples_got == 0)
break;
}
samples_got = WavpackUnpackSamples(
wpc, (int32_t *)chunk, samples_requested
);
if (samples_got > 0) {
int bitrate = (int)(WavpackGetInstantBitrate(wpc) /
1000 + 0.5);
int bitrate = (int)(WavpackGetInstantBitrate(wpc) / 1000 +
0.5);
format_samples(bytes_per_sample, chunk,
samples_got * audio_format.channels);
format_samples(
bytes_per_sample, chunk,
samples_got * audio_format.channels
);
decoder_data(
decoder, NULL, chunk,
samples_got * output_sample_size,
bitrate
);
}
} while (samples_got > 0);
cmd = decoder_data(decoder, NULL, chunk,
samples_got * output_sample_size,
bitrate);
}
}
/**

@@ -78,15 +78,64 @@ decoder_initialized(struct decoder *decoder,
&af_string));
}
enum decoder_command decoder_get_command(G_GNUC_UNUSED struct decoder * decoder)
/**
* Checks if we need an "initial seek". If so, then the initial seek
* is prepared, and the function returns true.
*/
G_GNUC_PURE
static bool
decoder_prepare_initial_seek(struct decoder *decoder)
{
const struct decoder_control *dc = decoder->dc;
assert(dc->pipe != NULL);
if (decoder->initial_seek_running)
/* initial seek has already begun - override any other
command */
return true;
if (decoder->initial_seek_pending) {
if (dc->command == DECODE_COMMAND_NONE) {
/* begin initial seek */
decoder->initial_seek_pending = false;
decoder->initial_seek_running = true;
return true;
}
/* skip initial seek when there's another command
(e.g. STOP) */
decoder->initial_seek_pending = false;
}
return false;
}
/**
* Returns the current decoder command. May return a "virtual"
* synthesized command, e.g. to seek to the beginning of the CUE
* track.
*/
G_GNUC_PURE
static enum decoder_command
decoder_get_virtual_command(struct decoder *decoder)
{
const struct decoder_control *dc = decoder->dc;
assert(dc->pipe != NULL);
if (decoder_prepare_initial_seek(decoder))
return DECODE_COMMAND_SEEK;
return dc->command;
}
enum decoder_command
decoder_get_command(struct decoder *decoder)
{
return decoder_get_virtual_command(decoder);
}
void
decoder_command_finished(struct decoder *decoder)
{
@@ -94,11 +143,24 @@ decoder_command_finished(struct decoder *decoder)
decoder_lock(dc);
assert(dc->command != DECODE_COMMAND_NONE);
assert(dc->command != DECODE_COMMAND_NONE ||
decoder->initial_seek_running);
assert(dc->command != DECODE_COMMAND_SEEK ||
decoder->initial_seek_running ||
dc->seek_error || decoder->seeking);
assert(dc->pipe != NULL);
if (decoder->initial_seek_running) {
assert(!decoder->seeking);
assert(decoder->chunk == NULL);
assert(music_pipe_empty(dc->pipe));
decoder->initial_seek_running = false;
decoder->timestamp = dc->start_ms / 1000.;
decoder_unlock(dc);
return;
}
if (decoder->seeking) {
decoder->seeking = false;
@@ -124,9 +186,13 @@ double decoder_seek_where(G_GNUC_UNUSED struct decoder * decoder)
{
const struct decoder_control *dc = decoder->dc;
assert(dc->command == DECODE_COMMAND_SEEK);
assert(dc->pipe != NULL);
if (decoder->initial_seek_running)
return dc->start_ms / 1000.;
assert(dc->command == DECODE_COMMAND_SEEK);
decoder->seeking = true;
return dc->seek_where;
@@ -136,9 +202,17 @@ void decoder_seek_error(struct decoder * decoder)
{
struct decoder_control *dc = decoder->dc;
assert(dc->command == DECODE_COMMAND_SEEK);
assert(dc->pipe != NULL);
if (decoder->initial_seek_running) {
/* d'oh, we can't seek to the sub-song start position,
what now? - no idea, ignoring the problem for now. */
decoder->initial_seek_running = false;
return;
}
assert(dc->command == DECODE_COMMAND_SEEK);
dc->seek_error = true;
decoder->seeking = false;
@@ -270,7 +344,7 @@ decoder_data(struct decoder *decoder,
assert(length % audio_format_frame_size(&dc->in_audio_format) == 0);
decoder_lock(dc);
cmd = dc->command;
cmd = decoder_get_virtual_command(decoder);
decoder_unlock(dc);
if (cmd == DECODE_COMMAND_STOP || cmd == DECODE_COMMAND_SEEK ||
@@ -357,8 +431,8 @@ decoder_data(struct decoder *decoder,
decoder->timestamp += (double)nbytes /
audio_format_time_to_size(&dc->out_audio_format);
if (dc->song->end_ms > 0 &&
decoder->timestamp >= dc->song->end_ms / 1000.0)
if (dc->end_ms > 0 &&
decoder->timestamp >= dc->end_ms / 1000.0)
/* the end of this range has been reached:
stop decoding */
return DECODE_COMMAND_STOP;
@@ -388,6 +462,14 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is,
update_stream_tag(decoder, is);
/* check if we're seeking */
if (decoder_prepare_initial_seek(decoder))
/* during initial seek, no music chunk must be created
until seeking is finished; skip the rest of the
function here */
return DECODE_COMMAND_SEEK;
/* send tag to music pipe */
if (decoder->stream_tag != NULL) {

@@ -102,6 +102,7 @@ dc_command_async(struct decoder_control *dc, enum decoder_command cmd)
void
dc_start(struct decoder_control *dc, struct song *song,
unsigned start_ms, unsigned end_ms,
struct music_buffer *buffer, struct music_pipe *pipe)
{
assert(song != NULL);
@@ -110,6 +111,8 @@ dc_start(struct decoder_control *dc, struct song *song,
assert(music_pipe_empty(pipe));
dc->song = song;
dc->start_ms = start_ms;
dc->end_ms = end_ms;
dc->buffer = buffer;
dc->pipe = pipe;
dc_command(dc, DECODE_COMMAND_START);

@@ -79,6 +79,23 @@ struct decoder_control {
*/
const struct song *song;
/**
* The initial seek position (in milliseconds), e.g. to the
* start of a sub-track described by a CUE file.
*
* This attribute is set by dc_start().
*/
unsigned start_ms;
/**
* The decoder will stop when it reaches this position (in
* milliseconds). 0 means don't stop before the end of the
* file.
*
* This attribute is set by dc_start().
*/
unsigned end_ms;
float total_time;
/** the #music_chunk allocator */
@@ -225,11 +242,14 @@ dc_command_wait(struct decoder_control *dc);
*
* @param the decoder
* @param song the song to be decoded
* @param start_ms see #decoder_control
* @param end_ms see #decoder_control
* @param pipe the pipe which receives the decoded chunks (owned by
* the caller)
*/
void
dc_start(struct decoder_control *dc, struct song *song,
unsigned start_ms, unsigned end_ms,
struct music_buffer *buffer, struct music_pipe *pipe);
void

@@ -36,6 +36,25 @@ struct decoder {
*/
double timestamp;
/**
* Is the initial seek (to the start position of the sub-song)
* pending, or has it been performed already?
*/
bool initial_seek_pending;
/**
* Is the initial seek currently running? During this time,
* the decoder command is SEEK. This flag is set by
* decoder_get_virtual_command(), when the virtual SEEK
* command is generated for the first time.
*/
bool initial_seek_running;
/**
* This flag is set by decoder_seek_where(), and checked by
* decoder_command_finished(). It is used to clean up after
* seeking.
*/
bool seeking;
/**

@@ -369,6 +369,8 @@ decoder_run_song(struct decoder_control *dc,
{
struct decoder decoder = {
.dc = dc,
.initial_seek_pending = dc->start_ms > 0,
.initial_seek_running = false,
};
int ret;

@@ -30,8 +30,8 @@
#define DIRECTORY_DIR "directory: "
#define DEVICE_INARCHIVE (dev_t)(-1)
#define DEVICE_CONTAINER (dev_t)(-2)
#define DEVICE_INARCHIVE (dev_t)(-1)
#define DEVICE_CONTAINER (dev_t)(-2)
struct directory {
struct dirvec children;
@@ -62,7 +62,8 @@ directory_free(struct directory *directory);
static inline bool
directory_is_empty(const struct directory *directory)
{
return directory->children.nr == 0 && directory->songs.nr == 0;
return directory->children.nr == 0 && directory->songs.nr == 0 &&
playlist_vector_is_empty(&directory->playlists);
}
static inline const char *

@@ -55,7 +55,7 @@ static bool
flac_encoder_configure(struct flac_encoder *encoder,
const struct config_param *param, G_GNUC_UNUSED GError **error)
{
encoder->compression = config_get_block_unsigned(param,
encoder->compression = config_get_block_unsigned(param,
"compression", 5);
return true;
@@ -218,7 +218,7 @@ flac_encoder_open(struct encoder *_encoder, struct audio_format *audio_format,
if (init_status != FLAC__STREAM_ENCODER_OK) {
g_set_error(error, flac_encoder_quark(), 0,
"failed to initialize encoder: %s\n",
"failed to initialize encoder: %s\n",
FLAC__StreamEncoderStateString[init_status]);
flac_encoder_close(_encoder);
return false;
@@ -234,7 +234,7 @@ flac_encoder_open(struct encoder *_encoder, struct audio_format *audio_format,
if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
g_set_error(error, flac_encoder_quark(), 0,
"failed to initialize encoder: %s\n",
"failed to initialize encoder: %s\n",
FLAC__StreamEncoderInitStatusString[init_status]);
flac_encoder_close(_encoder);
return false;

@@ -170,6 +170,13 @@ lame_encoder_setup(struct lame_encoder *encoder, GError **error)
return false;
}
if (0 != lame_set_out_samplerate(encoder->gfp,
encoder->audio_format.sample_rate)) {
g_set_error(error, lame_encoder_quark(), 0,
"error setting lame out sample rate");
return false;
}
if (0 > lame_init_params(encoder->gfp)) {
g_set_error(error, lame_encoder_quark(), 0,
"error initializing lame params");

@@ -266,6 +266,15 @@ vorbis_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error)
{
struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder;
encoder->flush = true;
return true;
}
static bool
vorbis_encoder_pre_tag(struct encoder *_encoder, G_GNUC_UNUSED GError **error)
{
struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder;
vorbis_analysis_wrote(&encoder->vd, 0);
vorbis_encoder_blockout(encoder);
@@ -276,6 +285,8 @@ vorbis_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error)
vorbis_analysis_init(&encoder->vd, &encoder->vi);
vorbis_block_init(&encoder->vd, &encoder->vb);
ogg_stream_reset(&encoder->os);
encoder->flush = true;
return true;
}
@@ -364,6 +375,7 @@ vorbis_encoder_read(struct encoder *_encoder, void *_dest, size_t length)
if (ret == 0 && encoder->flush) {
encoder->flush = false;
ret = ogg_stream_flush(&encoder->os, &page);
}
if (ret == 0)
@@ -396,6 +408,7 @@ const struct encoder_plugin vorbis_encoder_plugin = {
.open = vorbis_encoder_open,
.close = vorbis_encoder_close,
.flush = vorbis_encoder_flush,
.pre_tag = vorbis_encoder_pre_tag,
.tag = vorbis_encoder_tag,
.write = vorbis_encoder_write,
.read = vorbis_encoder_read,

@@ -58,7 +58,7 @@ wave_encoder_quark(void)
}
static void
fill_wave_header(struct wave_header *header, int channels, int bits,
fill_wave_header(struct wave_header *header, int channels, int bits,
int freq, int block_size)
{
int data_size = 0x0FFFFFFF;
@@ -142,7 +142,7 @@ wave_encoder_open(struct encoder *_encoder,
buffer = pcm_buffer_get(&encoder->buffer, sizeof(struct wave_header) );
/* create PCM wave header in initial buffer */
fill_wave_header((struct wave_header *) buffer,
fill_wave_header((struct wave_header *) buffer,
audio_format->channels,
encoder->bits,
audio_format->sample_rate,

@@ -50,6 +50,8 @@ struct encoder_plugin {
bool (*flush)(struct encoder *encoder, GError **error);
bool (*pre_tag)(struct encoder *encoder, GError **error);
bool (*tag)(struct encoder *encoder, const struct tag *tag,
GError **error);
@@ -147,9 +149,31 @@ encoder_flush(struct encoder *encoder, GError **error)
: true;
}
/**
* Prepare for sending a tag to the encoder. This is used by some
* encoders to flush the previous sub-stream, in preparation to begin
* a new one.
*
* @param encoder the encoder
* @param tag the tag object
* @param error location to store the error occuring, or NULL to ignore errors.
* @return true on success
*/
static inline bool
encoder_pre_tag(struct encoder *encoder, GError **error)
{
/* this method is optional */
return encoder->plugin->pre_tag != NULL
? encoder->plugin->pre_tag(encoder, error)
: true;
}
/**
* Sends a tag to the encoder.
*
* Instructions: call encoder_pre_tag(); then obtain flushed data with
* encoder_read(); finally call encoder_tag().
*
* @param encoder the encoder
* @param tag the tag object
* @param error location to store the error occuring, or NULL to ignore errors.

@@ -21,6 +21,7 @@
#include "event_pipe.h"
#include "fd_util.h"
#include "mpd_error.h"
#include "glib_socket.h"
#include <stdbool.h>
#include <assert.h>
@@ -94,11 +95,7 @@ void event_pipe_init(void)
if (ret < 0)
MPD_ERROR("Couldn't open pipe: %s", strerror(errno));
#ifndef G_OS_WIN32
channel = g_io_channel_unix_new(event_pipe[0]);
#else
channel = g_io_channel_win32_new_fd(event_pipe[0]);
#endif
channel = g_io_channel_new_socket(event_pipe[0]);
g_io_channel_set_encoding(channel, NULL, NULL);
g_io_channel_set_buffered(channel, false);

@@ -304,3 +304,13 @@ inotify_init_cloexec(void)
}
#endif
int
close_socket(int fd)
{
#ifdef WIN32
return closesocket(fd);
#else
return close(fd);
#endif
}

@@ -36,6 +36,8 @@
#ifndef FD_UTIL_H
#define FD_UTIL_H
#include "check.h"
#include <stdbool.h>
#include <stddef.h>
@@ -120,6 +122,8 @@ recvmsg_cloexec(int sockfd, struct msghdr *msg, int flags);
#endif
#ifdef HAVE_INOTIFY_INIT
/**
* Wrapper for inotify_init(), which sets the CLOEXEC flag (atomically
* if supported by the OS).
@@ -128,3 +132,11 @@ int
inotify_init_cloexec(void);
#endif
/**
* Portable wrapper for close(); use closesocket() on WIN32/WinSock.
*/
int
close_socket(int fd);
#endif

40
src/glib_socket.h Normal file

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_GLIB_SOCKET_H
#define MPD_GLIB_SOCKET_H
#include <glib.h>
/**
* Portable wrapper for g_io_channel_unix_new() or
* g_io_channel_win32_new_socket().
*/
G_GNUC_MALLOC
static inline GIOChannel *
g_io_channel_new_socket(int fd)
{
#ifdef G_OS_WIN32
return g_io_channel_win32_new_socket(fd);
#else
return g_io_channel_unix_new(fd);
#endif
}
#endif

@@ -42,6 +42,13 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "input_curl"
/**
* Do not buffer more than this number of bytes. It should be a
* reasonable limit that doesn't make low-end machines suffer too
* much, but doesn't cause stuttering on high-latency lines.
*/
static const size_t CURL_MAX_BUFFERED = 512 * 1024;
/**
* Buffers created by input_curl_writefunction().
*/
@@ -144,6 +151,25 @@ input_curl_finish(void)
curl_global_cleanup();
}
/**
* Determine the total sizes of all buffers, including portions that
* have already been consumed.
*/
G_GNUC_PURE
static size_t
curl_total_buffer_size(const struct input_curl *c)
{
size_t total = 0;
for (GList *i = g_queue_peek_head_link(c->buffers);
i != NULL; i = g_list_next(i)) {
struct buffer *buffer = i->data;
total += buffer->size;
}
return total;
}
static void
buffer_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
@@ -151,7 +177,7 @@ buffer_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
assert(buffer->consumed <= buffer->size);
g_free(data);
g_free(buffer);
}
/**
@@ -473,6 +499,10 @@ static int
input_curl_buffer(struct input_stream *is, GError **error_r)
{
struct input_curl *c = (struct input_curl *)is;
if (curl_total_buffer_size(c) >= CURL_MAX_BUFFERED)
return 0;
CURLMcode mcode;
int running_handles;
bool ret;
@@ -650,6 +680,9 @@ input_curl_easy_init(struct input_curl *c, GError **error_r)
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);
curl_easy_setopt(c->easy, CURLOPT_NOPROGRESS, 1l);
curl_easy_setopt(c->easy, CURLOPT_NOSIGNAL, 1l);
curl_easy_setopt(c->easy, CURLOPT_CONNECTTIMEOUT, 10l);
if (proxy != NULL)
curl_easy_setopt(c->easy, CURLOPT_PROXY, proxy);

@@ -83,12 +83,14 @@ copy_attributes(struct input_rewind *r)
assert(dest != src);
assert(src->mime == NULL || dest->mime != src->mime);
bool dest_ready = dest->ready;
dest->ready = src->ready;
dest->seekable = src->seekable;
dest->size = src->size;
dest->offset = src->offset;
if (src->mime != NULL) {
if (!dest_ready && src->ready) {
g_free(dest->mime);
dest->mime = g_strdup(src->mime);
}

@@ -58,11 +58,11 @@ winmm_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param,
G_GNUC_UNUSED GError **error_r)
{
assert(ao != NULL);
struct winmm_mixer *wm = g_new(struct winmm_mixer, 1);
mixer_init(&wm->base, &winmm_mixer_plugin);
wm->output = (struct winmm_output *) ao;
return &wm->base;
}
@@ -79,13 +79,13 @@ winmm_mixer_get_volume(struct mixer *mixer, GError **error_r)
DWORD volume;
HWAVEOUT handle = winmm_output_get_handle(wm->output);
MMRESULT result = waveOutGetVolume(handle, &volume);
if (result != MMSYSERR_NOERROR) {
g_set_error(error_r, 0, winmm_mixer_quark(),
"Failed to get winmm volume");
return -1;
}
return winmm_volume_decode(volume);
}
@@ -102,7 +102,7 @@ winmm_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
"Failed to set winmm volume");
return false;
}
return true;
}

@@ -186,6 +186,9 @@ static snd_pcm_format_t
get_bitformat(enum sample_format sample_format)
{
switch (sample_format) {
case SAMPLE_FORMAT_UNDEFINED:
return SND_PCM_FORMAT_UNKNOWN;
case SAMPLE_FORMAT_S8:
return SND_PCM_FORMAT_S8;
@@ -202,10 +205,10 @@ get_bitformat(enum sample_format sample_format)
case SAMPLE_FORMAT_S32:
return SND_PCM_FORMAT_S32;
default:
return SND_PCM_FORMAT_UNKNOWN;
}
assert(false);
return SND_PCM_FORMAT_UNKNOWN;
}
static snd_pcm_format_t
@@ -508,6 +511,14 @@ configure_hw:
g_debug("buffer_size=%u period_size=%u",
(unsigned)alsa_buffer_size, (unsigned)alsa_period_size);
if (alsa_period_size == 0)
/* this works around a SIGFPE bug that occurred when
an ALSA driver indicated period_size==0; this
caused a division by zero in alsa_play(). By using
the fallback "1", we make sure that this won't
happen again. */
alsa_period_size = 1;
ad->period_frames = alsa_period_size;
ad->period_position = 0;

@@ -26,6 +26,9 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "ao"
/* An ao_sample_format, with all fields set to zero: */
static const ao_sample_format OUR_AO_FORMAT_INITIALIZER;
static unsigned ao_output_ref;
struct ao_data {
@@ -103,12 +106,14 @@ ao_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
g_set_error(error, ao_output_quark(), 0,
"\"%s\" is not a valid ao driver",
value);
g_free(ad);
return NULL;
}
if ((ai = ao_driver_info(ad->driver)) == NULL) {
g_set_error(error, ao_output_quark(), 0,
"problems getting driver info");
g_free(ad);
return NULL;
}
@@ -126,6 +131,7 @@ ao_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
g_set_error(error, ao_output_quark(), 0,
"problems parsing options \"%s\"",
options[i]);
g_free(ad);
return NULL;
}
@@ -167,7 +173,7 @@ static bool
ao_output_open(void *data, struct audio_format *audio_format,
GError **error)
{
ao_sample_format format;
ao_sample_format format = OUR_AO_FORMAT_INITIALIZER;
struct ao_data *ad = (struct ao_data *)data;
switch (audio_format->format) {

@@ -24,11 +24,15 @@
#include "page.h"
#include "icy_server.h"
#include "glib_compat.h"
#include "glib_socket.h"
#include <stdbool.h>
#include <assert.h>
#include <string.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "httpd_output"
struct httpd_client {
/**
* The httpd output object this client is connected to.
@@ -140,6 +144,8 @@ httpd_client_unref_page(gpointer data, G_GNUC_UNUSED gpointer user_data)
void
httpd_client_free(struct httpd_client *client)
{
assert(client != NULL);
if (client->state == RESPONSE) {
if (client->write_source_id != 0)
g_source_remove(client->write_source_id);
@@ -166,6 +172,8 @@ httpd_client_free(struct httpd_client *client)
static void
httpd_client_close(struct httpd_client *client)
{
assert(client != NULL);
httpd_output_remove_client(client->httpd, client);
httpd_client_free(client);
}
@@ -176,6 +184,9 @@ httpd_client_close(struct httpd_client *client)
static void
httpd_client_begin_response(struct httpd_client *client)
{
assert(client != NULL);
assert(client->state != RESPONSE);
client->state = RESPONSE;
client->write_source_id = 0;
client->pages = g_queue_new();
@@ -236,6 +247,9 @@ httpd_client_handle_line(struct httpd_client *client, const char *line)
static char *
httpd_client_read_line(struct httpd_client *client)
{
assert(client != NULL);
assert(client->state != RESPONSE);
const char *p, *newline;
size_t length;
char *line;
@@ -268,6 +282,7 @@ httpd_client_send_response(struct httpd_client *client)
GIOStatus status;
gsize bytes_written;
assert(client != NULL);
assert(client->state == RESPONSE);
if (!client->metadata_requested) {
@@ -331,14 +346,19 @@ httpd_client_send_response(struct httpd_client *client)
static bool
httpd_client_received(struct httpd_client *client)
{
assert(client != NULL);
assert(client->state != RESPONSE);
char *line;
bool success;
while ((line = httpd_client_read_line(client)) != NULL) {
success = httpd_client_handle_line(client, line);
g_free(line);
if (!success)
if (!success) {
assert(client->state != RESPONSE);
return false;
}
if (client->state == RESPONSE) {
if (!fifo_buffer_is_empty(client->input)) {
@@ -367,7 +387,14 @@ httpd_client_read(struct httpd_client *client)
if (client->state == RESPONSE) {
/* the client has already sent the request, and he
must not send more */
g_warning("unexpected input from client");
char buffer[1];
status = g_io_channel_read_chars(client->channel, buffer,
sizeof(buffer), &bytes_read,
NULL);
if (status == G_IO_STATUS_NORMAL)
g_warning("unexpected input from client");
return false;
}
@@ -433,11 +460,7 @@ httpd_client_new(struct httpd_output *httpd, int fd, bool metadata_supported)
client->httpd = httpd;
#ifndef G_OS_WIN32
client->channel = g_io_channel_unix_new(fd);
#else
client->channel = g_io_channel_win32_new_socket(fd);
#endif
client->channel = g_io_channel_new_socket(fd);
/* GLib is responsible for closing the file descriptor */
g_io_channel_set_close_on_unref(client->channel, true);

@@ -111,7 +111,7 @@ struct httpd_output {
char buffer[32768];
/**
* The maximum and current number of clients connected
* The maximum and current number of clients connected
* at the same time.
*/
guint clients_max, clients_cnt;

@@ -36,6 +36,7 @@
#include <errno.h>
#ifdef HAVE_LIBWRAP
#include <sys/socket.h> /* needed for AF_UNIX */
#include <tcpd.h>
#endif
@@ -102,6 +103,7 @@ httpd_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
if (encoder_plugin == NULL) {
g_set_error(error, httpd_output_quark(), 0,
"No such encoder: %s", encoder_name);
g_free(httpd);
return NULL;
}
@@ -123,6 +125,7 @@ httpd_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
/* initialize metadata */
httpd->metadata = NULL;
httpd->unflushed_input = 0;
/* initialize encoder */
@@ -198,7 +201,7 @@ httpd_listen_in_event(int fd, const struct sockaddr *address,
g_warning("libwrap refused connection (libwrap=%s) from %s",
progname, hostaddr);
g_free(hostaddr);
close(fd);
close_socket(fd);
g_mutex_unlock(httpd->mutex);
return;
}
@@ -219,7 +222,7 @@ httpd_listen_in_event(int fd, const struct sockaddr *address,
httpd->clients_cnt < httpd->clients_max))
httpd_client_add(httpd, fd);
else
close(fd);
close_socket(fd);
} else if (fd < 0 && errno != EINTR) {
g_warning("accept() failed: %s", g_strerror(errno));
}
@@ -490,7 +493,8 @@ httpd_output_pause(void *data)
if (has_clients) {
static const char silence[1020];
return httpd_output_play(data, silence, sizeof(silence), NULL);
return httpd_output_play(data, silence, sizeof(silence),
NULL) > 0;
} else {
g_usleep(100000);
return true;
@@ -519,7 +523,7 @@ httpd_output_tag(void *data, const struct tag *tag)
/* flush the current stream, and end it */
encoder_flush(httpd->encoder, NULL);
encoder_pre_tag(httpd->encoder, NULL);
httpd_output_encoder_to_clients(httpd);
/* send the tag to the encoder - which starts a new

@@ -40,7 +40,7 @@ enum {
MAX_PORTS = 16,
};
static const size_t sample_size = sizeof(jack_default_audio_sample_t);
static const size_t jack_sample_size = sizeof(jack_default_audio_sample_t);
struct jack_data {
/**
@@ -103,9 +103,9 @@ mpd_jack_available(const struct jack_data *jd)
min = current;
}
assert(min % sample_size == 0);
assert(min % jack_sample_size == 0);
return min / sample_size;
return min / jack_sample_size;
}
static int
@@ -123,7 +123,7 @@ mpd_jack_process(jack_nframes_t nframes, void *arg)
const jack_nframes_t available = mpd_jack_available(jd);
for (unsigned i = 0; i < jd->audio_format.channels; ++i)
jack_ringbuffer_read_advance(jd->ringbuffer[i],
available * sample_size);
available * jack_sample_size);
/* generate silence while MPD is paused */
@@ -144,7 +144,7 @@ mpd_jack_process(jack_nframes_t nframes, void *arg)
for (unsigned i = 0; i < jd->audio_format.channels; ++i) {
out = jack_port_get_buffer(jd->ports[i], nframes);
jack_ringbuffer_read(jd->ringbuffer[i],
(char *)out, available * sample_size);
(char *)out, available * jack_sample_size);
for (jack_nframes_t f = available; f < nframes; ++f)
/* ringbuffer underrun, fill with silence */
@@ -675,7 +675,7 @@ mpd_jack_play(void *data, const void *chunk, size_t size, GError **error_r)
space = space1;
}
if (space >= frame_size)
if (space >= jack_sample_size)
break;
/* XXX do something more intelligent to
@@ -683,7 +683,7 @@ mpd_jack_play(void *data, const void *chunk, size_t size, GError **error_r)
g_usleep(1000);
}
space /= sample_size;
space /= jack_sample_size;
if (space < size)
size = space;

@@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
/*
* Media MVP audio output based on code from MVPMC project:
* http://mvpmc.sourceforge.net/
*/

@@ -64,26 +64,26 @@ openal_audio_format(struct audio_format *audio_format)
return AL_FORMAT_STEREO16;
if (audio_format->channels == 1)
return AL_FORMAT_MONO16;
break;
/* fall back to mono */
audio_format->channels = 1;
return openal_audio_format(audio_format);
case SAMPLE_FORMAT_S8:
if (audio_format->channels == 2)
return AL_FORMAT_STEREO8;
if (audio_format->channels == 1)
return AL_FORMAT_MONO8;
break;
/* fall back to mono */
audio_format->channels = 1;
return openal_audio_format(audio_format);
default:
/* fall back to 16 bit */
audio_format->format = SAMPLE_FORMAT_S16;
if (audio_format->channels == 2)
return AL_FORMAT_STEREO16;
if (audio_format->channels == 1)
return AL_FORMAT_MONO16;
break;
return openal_audio_format(audio_format);
}
return 0;
}
static bool

@@ -41,6 +41,15 @@
# include <sys/soundcard.h>
#endif /* !(defined(__OpenBSD__) || defined(__NetBSD__) */
/* We got bug reports from FreeBSD users who said that the two 24 bit
formats generate white noise on FreeBSD, but 32 bit works. This is
a workaround until we know what exactly is expected by the kernel
audio drivers. */
#ifndef __linux__
#undef AFMT_S24_PACKED
#undef AFMT_S24_NE
#endif
struct oss_data {
int fd;
const char *device;
@@ -347,7 +356,7 @@ oss_setup_sample_rate(int fd, struct audio_format *audio_format,
case SUCCESS:
if (!audio_valid_sample_rate(sample_rate))
break;
audio_format->sample_rate = sample_rate;
return true;
@@ -461,6 +470,12 @@ oss_setup_sample_format(int fd, struct audio_format *audio_format,
break;
audio_format->format = mpd_format;
#ifdef AFMT_S24_PACKED
if (oss_format == AFMT_S24_PACKED)
audio_format->reverse_endian =
G_BYTE_ORDER != G_LITTLE_ENDIAN;
#endif
return true;
case ERROR:
@@ -502,6 +517,12 @@ oss_setup_sample_format(int fd, struct audio_format *audio_format,
break;
audio_format->format = mpd_format;
#ifdef AFMT_S24_PACKED
if (oss_format == AFMT_S24_PACKED)
audio_format->reverse_endian =
G_BYTE_ORDER != G_LITTLE_ENDIAN;
#endif
return true;
case ERROR:

@@ -95,12 +95,6 @@ static void osx_output_close(void *data)
{
struct osx_output *od = data;
g_mutex_lock(od->mutex);
while (od->len) {
g_cond_wait(od->condition, od->mutex);
}
g_mutex_unlock(od->mutex);
AudioOutputUnitStop(od->au);
AudioUnitUninitialize(od->au);
CloseComponent(od->au);
@@ -143,8 +137,8 @@ osx_render(void *vdata,
if (od->pos >= od->buffer_size)
od->pos = 0;
g_mutex_unlock(od->mutex);
g_cond_signal(od->condition);
g_mutex_unlock(od->mutex);
buffer->mDataByteSize = buffer_size;
@@ -214,15 +208,6 @@ osx_output_open(void *data, struct audio_format *audio_format, GError **error)
stream_description.mSampleRate = audio_format->sample_rate;
stream_description.mFormatID = kAudioFormatLinearPCM;
stream_description.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
#if G_BYTE_ORDER == G_BIG_ENDIAN
stream_description.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
#endif
stream_description.mBytesPerPacket =
audio_format_frame_size(audio_format);
stream_description.mFramesPerPacket = 1;
stream_description.mBytesPerFrame = stream_description.mBytesPerPacket;
stream_description.mChannelsPerFrame = audio_format->channels;
switch (audio_format->format) {
case SAMPLE_FORMAT_S8:
@@ -239,6 +224,16 @@ osx_output_open(void *data, struct audio_format *audio_format, GError **error)
break;
}
#if G_BYTE_ORDER == G_BIG_ENDIAN
stream_description.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
#endif
stream_description.mBytesPerPacket =
audio_format_frame_size(audio_format);
stream_description.mFramesPerPacket = 1;
stream_description.mBytesPerFrame = stream_description.mBytesPerPacket;
stream_description.mChannelsPerFrame = audio_format->channels;
result = AudioUnitSetProperty(od->au, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 0,
&stream_description,

@@ -72,7 +72,8 @@ pulse_output_set_mixer(struct pulse_output *po, struct pulse_mixer *pm)
}
void
pulse_output_clear_mixer(struct pulse_output *po, struct pulse_mixer *pm)
pulse_output_clear_mixer(struct pulse_output *po,
G_GNUC_UNUSED struct pulse_mixer *pm)
{
assert(po != NULL);
assert(pm != NULL);
@@ -207,6 +208,9 @@ pulse_output_subscribe_cb(pa_context *context,
static bool
pulse_output_connect(struct pulse_output *po, GError **error_r)
{
assert(po != NULL);
assert(po->context != NULL);
int error;
error = pa_context_connect(po->context, po->server,
@@ -221,14 +225,59 @@ pulse_output_connect(struct pulse_output *po, GError **error_r)
return true;
}
/**
* Frees and clears the stream.
*/
static void
pulse_output_delete_stream(struct pulse_output *po)
{
assert(po != NULL);
assert(po->stream != NULL);
#if PA_CHECK_VERSION(0,9,8)
pa_stream_set_suspended_callback(po->stream, NULL, NULL);
#endif
pa_stream_set_state_callback(po->stream, NULL, NULL);
pa_stream_set_write_callback(po->stream, NULL, NULL);
pa_stream_disconnect(po->stream);
pa_stream_unref(po->stream);
po->stream = NULL;
}
/**
* Frees and clears the context.
*
* Caller must lock the main loop.
*/
static void
pulse_output_delete_context(struct pulse_output *po)
{
assert(po != NULL);
assert(po->context != NULL);
pa_context_set_state_callback(po->context, NULL, NULL);
pa_context_set_subscribe_callback(po->context, NULL, NULL);
pa_context_disconnect(po->context);
pa_context_unref(po->context);
po->context = NULL;
}
/**
* Create, set up and connect a context.
*
* Caller must lock the main loop.
*
* @return true on success, false on error
*/
static bool
pulse_output_setup_context(struct pulse_output *po, GError **error_r)
{
assert(po != NULL);
assert(po->mainloop != NULL);
po->context = pa_context_new(pa_threaded_mainloop_get_api(po->mainloop),
MPD_PULSE_NAME);
if (po->context == NULL) {
@@ -243,25 +292,13 @@ pulse_output_setup_context(struct pulse_output *po, GError **error_r)
pulse_output_subscribe_cb, po);
if (!pulse_output_connect(po, error_r)) {
pa_context_unref(po->context);
po->context = NULL;
pulse_output_delete_context(po);
return false;
}
return true;
}
/**
* Frees and clears the context.
*/
static void
pulse_output_delete_context(struct pulse_output *po)
{
pa_context_disconnect(po->context);
pa_context_unref(po->context);
po->context = NULL;
}
static void *
pulse_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
const struct config_param *param,
@@ -323,12 +360,8 @@ pulse_output_enable(void *data, GError **error_r)
return false;
}
pa_threaded_mainloop_unlock(po->mainloop);
/* create the libpulse context and connect it */
pa_threaded_mainloop_lock(po->mainloop);
if (!pulse_output_setup_context(po, error_r)) {
pa_threaded_mainloop_unlock(po->mainloop);
pa_threaded_mainloop_stop(po->mainloop);
@@ -347,6 +380,8 @@ pulse_output_disable(void *data)
{
struct pulse_output *po = data;
assert(po->mainloop != NULL);
pa_threaded_mainloop_stop(po->mainloop);
if (po->context != NULL)
pulse_output_delete_context(po);
@@ -358,14 +393,16 @@ pulse_output_disable(void *data)
* Check if the context is (already) connected, and waits if not. If
* the context has been disconnected, retry to connect.
*
* Caller must lock the main loop.
*
* @return true on success, false on error
*/
static bool
pulse_output_wait_connection(struct pulse_output *po, GError **error_r)
{
pa_context_state_t state;
assert(po->mainloop != NULL);
pa_threaded_mainloop_lock(po->mainloop);
pa_context_state_t state;
if (po->context == NULL && !pulse_output_setup_context(po, error_r))
return false;
@@ -375,7 +412,6 @@ pulse_output_wait_connection(struct pulse_output *po, GError **error_r)
switch (state) {
case PA_CONTEXT_READY:
/* nothing to do */
pa_threaded_mainloop_unlock(po->mainloop);
return true;
case PA_CONTEXT_UNCONNECTED:
@@ -386,7 +422,6 @@ pulse_output_wait_connection(struct pulse_output *po, GError **error_r)
"failed to connect: %s",
pa_strerror(pa_context_errno(po->context)));
pulse_output_delete_context(po);
pa_threaded_mainloop_unlock(po->mainloop);
return false;
case PA_CONTEXT_CONNECTING:
@@ -399,11 +434,32 @@ pulse_output_wait_connection(struct pulse_output *po, GError **error_r)
}
}
#if PA_CHECK_VERSION(0,9,8)
static void
pulse_output_stream_suspended_cb(G_GNUC_UNUSED pa_stream *stream, void *userdata)
{
struct pulse_output *po = userdata;
assert(stream == po->stream || po->stream == NULL);
assert(po->mainloop != NULL);
/* wake up the main loop to break out of the loop in
pulse_output_play() */
pa_threaded_mainloop_signal(po->mainloop, 0);
}
#endif
static void
pulse_output_stream_state_cb(pa_stream *stream, void *userdata)
{
struct pulse_output *po = userdata;
assert(stream == po->stream || po->stream == NULL);
assert(po->mainloop != NULL);
assert(po->context != NULL);
switch (pa_stream_get_state(stream)) {
case PA_STREAM_READY:
if (po->mixer != NULL)
@@ -432,6 +488,8 @@ pulse_output_stream_write_cb(G_GNUC_UNUSED pa_stream *stream, size_t nbytes,
{
struct pulse_output *po = userdata;
assert(po->mainloop != NULL);
po->writable = nbytes;
pa_threaded_mainloop_signal(po->mainloop, 0);
}
@@ -444,6 +502,10 @@ pulse_output_open(void *data, struct audio_format *audio_format,
pa_sample_spec ss;
int error;
assert(po->mainloop != NULL);
pa_threaded_mainloop_lock(po->mainloop);
if (po->context != NULL) {
switch (pa_context_get_state(po->context)) {
case PA_CONTEXT_UNCONNECTED:
@@ -463,8 +525,10 @@ pulse_output_open(void *data, struct audio_format *audio_format,
}
}
if (!pulse_output_wait_connection(po, error_r))
if (!pulse_output_wait_connection(po, error_r)) {
pa_threaded_mainloop_unlock(po->mainloop);
return false;
}
/* MPD doesn't support the other pulseaudio sample formats, so
we just force MPD to send us everything as 16 bit */
@@ -474,8 +538,6 @@ pulse_output_open(void *data, struct audio_format *audio_format,
ss.rate = audio_format->sample_rate;
ss.channels = audio_format->channels;
pa_threaded_mainloop_lock(po->mainloop);
/* create a stream .. */
po->stream = pa_stream_new(po->context, po->name, &ss, NULL);
@@ -487,6 +549,11 @@ pulse_output_open(void *data, struct audio_format *audio_format,
return false;
}
#if PA_CHECK_VERSION(0,9,8)
pa_stream_set_suspended_callback(po->stream,
pulse_output_stream_suspended_cb, po);
#endif
pa_stream_set_state_callback(po->stream,
pulse_output_stream_state_cb, po);
pa_stream_set_write_callback(po->stream,
@@ -497,8 +564,7 @@ pulse_output_open(void *data, struct audio_format *audio_format,
error = pa_stream_connect_playback(po->stream, po->sink,
NULL, 0, NULL, NULL);
if (error < 0) {
pa_stream_unref(po->stream);
po->stream = NULL;
pulse_output_delete_stream(po);
g_set_error(error_r, pulse_output_quark(), 0,
"pa_stream_connect_playback() has failed: %s",
@@ -522,6 +588,8 @@ pulse_output_close(void *data)
struct pulse_output *po = data;
pa_operation *o;
assert(po->mainloop != NULL);
pa_threaded_mainloop_lock(po->mainloop);
if (pa_stream_get_state(po->stream) == PA_STREAM_READY) {
@@ -534,9 +602,7 @@ pulse_output_close(void *data)
pulse_wait_for_operation(po->mainloop, o);
}
pa_stream_disconnect(po->stream);
pa_stream_unref(po->stream);
po->stream = NULL;
pulse_output_delete_stream(po);
if (po->context != NULL &&
pa_context_get_state(po->context) != PA_CONTEXT_READY)
@@ -556,6 +622,8 @@ pulse_output_check_stream(struct pulse_output *po)
{
pa_stream_state_t state = pa_stream_get_state(po->stream);
assert(po->mainloop != NULL);
switch (state) {
case PA_STREAM_READY:
case PA_STREAM_FAILED:
@@ -637,6 +705,8 @@ pulse_output_stream_pause(struct pulse_output *po, bool pause,
{
pa_operation *o;
assert(po->mainloop != NULL);
assert(po->context != NULL);
assert(po->stream != NULL);
o = pa_stream_cork(po->stream, pause,
@@ -667,6 +737,7 @@ pulse_output_play(void *data, const void *chunk, size_t size, GError **error_r)
struct pulse_output *po = data;
int error;
assert(po->mainloop != NULL);
assert(po->stream != NULL);
pa_threaded_mainloop_lock(po->mainloop);
@@ -683,19 +754,30 @@ pulse_output_play(void *data, const void *chunk, size_t size, GError **error_r)
/* unpause if previously paused */
if (pulse_output_stream_is_paused(po) &&
!pulse_output_stream_pause(po, false, error_r))
!pulse_output_stream_pause(po, false, error_r)) {
pa_threaded_mainloop_unlock(po->mainloop);
return 0;
}
/* wait until the server allows us to write */
while (po->writable == 0) {
#if PA_CHECK_VERSION(0,9,8)
if (pa_stream_is_suspended(po->stream)) {
pa_threaded_mainloop_unlock(po->mainloop);
g_set_error(error_r, pulse_output_quark(), 0,
"suspended");
return 0;
}
#endif
pa_threaded_mainloop_wait(po->mainloop);
if (pa_stream_get_state(po->stream) != PA_STREAM_READY) {
pa_threaded_mainloop_unlock(po->mainloop);
g_set_error(error_r, pulse_output_quark(), 0,
"disconnected");
return false;
return 0;
}
}
@@ -725,6 +807,7 @@ pulse_output_cancel(void *data)
struct pulse_output *po = data;
pa_operation *o;
assert(po->mainloop != NULL);
assert(po->stream != NULL);
pa_threaded_mainloop_lock(po->mainloop);
@@ -756,6 +839,7 @@ pulse_output_pause(void *data)
struct pulse_output *po = data;
GError *error = NULL;
assert(po->mainloop != NULL);
assert(po->stream != NULL);
pa_threaded_mainloop_lock(po->mainloop);

@@ -79,23 +79,27 @@ recorder_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
if (encoder_plugin == NULL) {
g_set_error(error_r, recorder_output_quark(), 0,
"No such encoder: %s", encoder_name);
return NULL;
goto failure;
}
recorder->path = config_get_block_string(param, "path", NULL);
if (recorder->path == NULL) {
g_set_error(error_r, recorder_output_quark(), 0,
"'path' not configured");
return NULL;
goto failure;
}
/* initialize encoder */
recorder->encoder = encoder_init(encoder_plugin, param, error_r);
if (recorder->encoder == NULL)
return NULL;
goto failure;
return recorder;
failure:
g_free(recorder);
return NULL;
}
static void

@@ -152,7 +152,7 @@ my_shout_init_driver(const struct audio_format *audio_format,
if (port == 0) {
g_set_error(error, shout_output_quark(), 0,
"shout port must be configured");
return NULL;
goto failure;
}
check_block_param("password");
@@ -174,21 +174,21 @@ my_shout_init_driver(const struct audio_format *audio_format,
"shout quality \"%s\" is not a number in the "
"range -1 to 10, line %i",
value, param->line);
return NULL;
goto failure;
}
if (config_get_block_string(param, "bitrate", NULL) != NULL) {
g_set_error(error, shout_output_quark(), 0,
"quality and bitrate are "
"both defined");
return NULL;
goto failure;
}
} else {
value = config_get_block_string(param, "bitrate", NULL);
if (value == NULL) {
g_set_error(error, shout_output_quark(), 0,
"neither bitrate nor quality defined");
return NULL;
goto failure;
}
sd->bitrate = strtol(value, &test, 10);
@@ -196,7 +196,7 @@ my_shout_init_driver(const struct audio_format *audio_format,
if (*test != '\0' || sd->bitrate <= 0) {
g_set_error(error, shout_output_quark(), 0,
"bitrate must be a positive integer");
return NULL;
goto failure;
}
}
@@ -206,12 +206,12 @@ my_shout_init_driver(const struct audio_format *audio_format,
g_set_error(error, shout_output_quark(), 0,
"couldn't find shout encoder plugin \"%s\"",
encoding);
return NULL;
goto failure;
}
sd->encoder = encoder_init(encoder_plugin, param, error);
if (sd->encoder == NULL)
return NULL;
goto failure;
if (strcmp(encoding, "mp3") == 0 || strcmp(encoding, "lame") == 0)
shout_format = SHOUT_FORMAT_MP3;
@@ -225,7 +225,7 @@ my_shout_init_driver(const struct audio_format *audio_format,
g_set_error(error, shout_output_quark(), 0,
"you cannot stream \"%s\" to shoutcast, use mp3",
encoding);
return NULL;
goto failure;
} else if (0 == strcmp(value, "shoutcast"))
protocol = SHOUT_PROTOCOL_ICY;
else if (0 == strcmp(value, "icecast1"))
@@ -237,7 +237,7 @@ my_shout_init_driver(const struct audio_format *audio_format,
"shout protocol \"%s\" is not \"shoutcast\" or "
"\"icecast1\"or \"icecast2\"",
value);
return NULL;
goto failure;
}
} else {
protocol = SHOUT_PROTOCOL_HTTP;
@@ -256,7 +256,7 @@ my_shout_init_driver(const struct audio_format *audio_format,
shout_set_agent(sd->shout_conn, "MPD") != SHOUTERR_SUCCESS) {
g_set_error(error, shout_output_quark(), 0,
"%s", shout_get_error(sd->shout_conn));
return NULL;
goto failure;
}
/* optional paramters */
@@ -267,14 +267,14 @@ my_shout_init_driver(const struct audio_format *audio_format,
if (value != NULL && shout_set_genre(sd->shout_conn, value)) {
g_set_error(error, shout_output_quark(), 0,
"%s", shout_get_error(sd->shout_conn));
return NULL;
goto failure;
}
value = config_get_block_string(param, "description", NULL);
if (value != NULL && shout_set_description(sd->shout_conn, value)) {
g_set_error(error, shout_output_quark(), 0,
"%s", shout_get_error(sd->shout_conn));
return NULL;
goto failure;
}
{
@@ -300,6 +300,10 @@ my_shout_init_driver(const struct audio_format *audio_format,
}
return sd;
failure:
free_shout_data(sd);
return NULL;
}
static bool
@@ -507,7 +511,7 @@ static void my_shout_set_tag(void *data,
if (sd->encoder->plugin->tag != NULL) {
/* encoder plugin supports stream tags */
ret = encoder_flush(sd->encoder, &error);
ret = encoder_pre_tag(sd->encoder, &error);
if (!ret) {
g_warning("%s", error->message);
g_error_free(error);

@@ -23,7 +23,6 @@
#include <glib.h>
#include <sys/audio.h>
#include <sys/stropts.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -31,6 +30,25 @@
#include <fcntl.h>
#include <errno.h>
#ifdef __sun
#include <sys/audio.h>
#else
/* some fake declarations that allow build this plugin on systems
other than Solaris, just to see if it compiles */
#define AUDIO_GETINFO 0
#define AUDIO_SETINFO 0
#define AUDIO_ENCODING_LINEAR 0
struct audio_info {
struct {
unsigned sample_rate, channels, precision, encoding;
} play;
};
#endif
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "solaris_output"
@@ -93,7 +111,7 @@ solaris_output_open(void *data, struct audio_format *audio_format,
/* open the device in non-blocking mode */
so->fd = open_cloexec(so->device, O_WRONLY|O_NONBLOCK);
so->fd = open_cloexec(so->device, O_WRONLY|O_NONBLOCK, 0);
if (so->fd < 0) {
g_set_error(error, solaris_output_quark(), errno,
"Failed to open %s: %s",

@@ -205,27 +205,14 @@ static void audio_output_wait_all(void)
notify_wait(&audio_output_client_notify);
}
/**
* Signals the audio output if it is open. This function locks the
* mutex.
*/
static void
audio_output_lock_signal(struct audio_output *ao)
{
g_mutex_lock(ao->mutex);
if (audio_output_is_open(ao))
g_cond_signal(ao->cond);
g_mutex_unlock(ao->mutex);
}
/**
* Signals all audio outputs which are open.
*/
static void
audio_output_signal_all(void)
audio_output_allow_play_all(void)
{
for (unsigned i = 0; i < num_audio_outputs; ++i)
audio_output_lock_signal(&audio_outputs[i]);
audio_output_allow_play(&audio_outputs[i]);
}
static void
@@ -530,7 +517,7 @@ audio_output_all_cancel(void)
/* the audio outputs are now waiting for a signal, to
synchronize the cleared music pipe */
audio_output_signal_all();
audio_output_allow_play_all();
/* invalidate elapsed_time */

@@ -102,9 +102,6 @@ audio_output_disable(struct audio_output *ao)
g_mutex_unlock(ao->mutex);
}
static void
audio_output_close_locked(struct audio_output *ao);
/**
* Object must be locked (and unlocked) by the caller.
*/
@@ -115,6 +112,9 @@ audio_output_open(struct audio_output *ao,
{
bool open;
assert(ao != NULL);
assert(ao->allow_play);
assert(audio_format_valid(audio_format));
assert(mp != NULL);
if (ao->fail_timer != NULL) {
@@ -139,10 +139,6 @@ audio_output_open(struct audio_output *ao,
/* we're not using audio_output_cancel() here,
because that function is asynchronous */
ao_command(ao, AO_COMMAND_CANCEL);
/* the audio output is now waiting for a
signal; wake it up immediately */
g_cond_signal(ao->cond);
}
return true;
@@ -180,6 +176,7 @@ static void
audio_output_close_locked(struct audio_output *ao)
{
assert(ao != NULL);
assert(ao->allow_play);
if (ao->mixer != NULL)
mixer_auto_close(ao->mixer);
@@ -222,6 +219,8 @@ audio_output_play(struct audio_output *ao)
{
g_mutex_lock(ao->mutex);
assert(ao->allow_play);
if (audio_output_is_open(ao))
g_cond_signal(ao->cond);
@@ -237,6 +236,7 @@ void audio_output_pause(struct audio_output *ao)
mixer_auto_close(ao->mixer);
g_mutex_lock(ao->mutex);
assert(ao->allow_play);
if (audio_output_is_open(ao))
ao_command_async(ao, AO_COMMAND_PAUSE);
g_mutex_unlock(ao->mutex);
@@ -246,6 +246,7 @@ void
audio_output_drain_async(struct audio_output *ao)
{
g_mutex_lock(ao->mutex);
assert(ao->allow_play);
if (audio_output_is_open(ao))
ao_command_async(ao, AO_COMMAND_DRAIN);
g_mutex_unlock(ao->mutex);
@@ -254,8 +255,24 @@ audio_output_drain_async(struct audio_output *ao)
void audio_output_cancel(struct audio_output *ao)
{
g_mutex_lock(ao->mutex);
if (audio_output_is_open(ao))
if (audio_output_is_open(ao)) {
ao->allow_play = false;
ao_command_async(ao, AO_COMMAND_CANCEL);
}
g_mutex_unlock(ao->mutex);
}
void
audio_output_allow_play(struct audio_output *ao)
{
g_mutex_lock(ao->mutex);
ao->allow_play = true;
if (audio_output_is_open(ao))
g_cond_signal(ao->cond);
g_mutex_unlock(ao->mutex);
}
@@ -286,6 +303,7 @@ void audio_output_finish(struct audio_output *ao)
if (ao->thread != NULL) {
g_mutex_lock(ao->mutex);
assert(ao->allow_play);
ao_command(ao, AO_COMMAND_KILL);
g_mutex_unlock(ao->mutex);
g_thread_join(ao->thread);

@@ -70,8 +70,19 @@ void audio_output_pause(struct audio_output *ao);
void
audio_output_drain_async(struct audio_output *ao);
/**
* Clear the "allow_play" flag and send the "CANCEL" command
* asynchronously. To finish the operation, the caller has to call
* audio_output_allow_play().
*/
void audio_output_cancel(struct audio_output *ao);
/**
* Set the "allow_play" and signal the thread.
*/
void
audio_output_allow_play(struct audio_output *ao);
void audio_output_close(struct audio_output *ao);
/**

@@ -189,6 +189,7 @@ audio_output_init(struct audio_output *ao, const struct config_param *param,
ao->really_enabled = false;
ao->open = false;
ao->pause = false;
ao->allow_play = true;
ao->fail_timer = NULL;
pcm_buffer_init(&ao->cross_fade_buffer);

@@ -109,6 +109,15 @@ struct audio_output {
*/
bool pause;
/**
* When this flag is set, the output thread will not do any
* playback. It will wait until the flag is cleared.
*
* This is used to synchronize the "clear" operation on the
* shared music pipe during the CANCEL command.
*/
bool allow_play;
/**
* If not NULL, the device has failed, and this timer is used
* to estimate how long it should stay disabled (unless

@@ -95,6 +95,8 @@ ao_filter_open(struct audio_output *ao,
struct audio_format *audio_format,
GError **error_r)
{
assert(audio_format_valid(audio_format));
/* the replay_gain filter cannot fail here */
if (ao->replay_gain_filter != NULL)
filter_open(ao->replay_gain_filter, audio_format, error_r);
@@ -136,6 +138,7 @@ ao_open(struct audio_output *ao)
assert(!ao->open);
assert(ao->pipe != NULL);
assert(ao->chunk == NULL);
assert(audio_format_valid(&ao->in_audio_format));
if (ao->fail_timer != NULL) {
/* this can only happen when this
@@ -164,6 +167,8 @@ ao_open(struct audio_output *ao)
return;
}
assert(audio_format_valid(filter_audio_format));
ao->out_audio_format = *filter_audio_format;
audio_format_mask_apply(&ao->out_audio_format,
&ao->config_audio_format);
@@ -303,7 +308,7 @@ ao_wait(struct audio_output *ao)
GTimeVal tv;
g_get_current_time(&tv);
g_time_val_add(&tv, delay * 1000);
g_cond_timed_wait(ao->cond, ao->mutex, &tv);
(void)g_cond_timed_wait(ao->cond, ao->mutex, &tv);
if (ao->command != AO_COMMAND_NONE)
return false;
@@ -463,12 +468,9 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk)
/* don't automatically reopen this device for
10 seconds */
g_mutex_lock(ao->mutex);
assert(ao->fail_timer == NULL);
ao->fail_timer = g_timer_new();
g_mutex_unlock(ao->mutex);
return false;
}
@@ -638,15 +640,14 @@ static gpointer audio_output_task(gpointer arg)
case AO_COMMAND_CANCEL:
ao->chunk = NULL;
if (ao->open)
ao_plugin_cancel(ao->plugin, ao->data);
ao_command_finished(ao);
/* the player thread will now clear our music
pipe - wait for a notify, to give it some
time */
if (ao->command == AO_COMMAND_NONE)
g_cond_wait(ao->cond, ao->mutex);
if (ao->open) {
g_mutex_unlock(ao->mutex);
ao_plugin_cancel(ao->plugin, ao->data);
g_mutex_lock(ao->mutex);
}
ao_command_finished(ao);
continue;
case AO_COMMAND_KILL:
@@ -656,7 +657,7 @@ static gpointer audio_output_task(gpointer arg)
return NULL;
}
if (ao->open && ao_play(ao))
if (ao->open && ao->allow_play && ao_play(ao))
/* don't wait for an event if there are more
chunks in the pipe */
continue;

@@ -49,7 +49,7 @@ const int16_t *pcm_byteswap_16(struct pcm_buffer *buffer,
static inline uint32_t swab32(uint32_t x)
{
return (x << 24) |
return (x << 24) |
((x & 0xff00) << 8) |
((x & 0xff0000) >> 8) |
(x >> 24);

@@ -222,7 +222,7 @@ pcm_convert_32(struct pcm_convert_state *state,
src_buffer, src_size, &len);
if (buf == NULL) {
g_set_error(error_r, pcm_convert_quark(), 0,
"Conversion from %s to 24 bit is not implemented",
"Conversion from %s to 32 bit is not implemented",
sample_format_to_string(src_format->format));
return NULL;
}

@@ -143,7 +143,7 @@ pcm_convert_16_to_24(int32_t *out, const int16_t *in,
}
static void
pcm_convert_32_to_24(int32_t *out, const int16_t *in,
pcm_convert_32_to_24(int32_t *out, const int32_t *in,
unsigned num_samples)
{
while (num_samples > 0) {
@@ -197,7 +197,7 @@ pcm_convert_to_24(struct pcm_buffer *buffer,
*dest_size_r = num_samples * sizeof(*dest);
dest = pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_32_to_24(dest, (const int16_t *)src,
pcm_convert_32_to_24(dest, (const int32_t *)src,
num_samples);
return dest;
}

@@ -187,5 +187,8 @@ music_pipe_push(struct music_pipe *mp, struct music_chunk *chunk)
unsigned
music_pipe_size(const struct music_pipe *mp)
{
return mp->size;
g_mutex_lock(mp->mutex);
unsigned size = mp->size;
g_mutex_unlock(mp->mutex);
return size;
}

@@ -20,9 +20,10 @@
#ifndef MPD_PIPE_H
#define MPD_PIPE_H
#ifndef NDEBUG
#include <glib.h>
#include <stdbool.h>
#ifndef NDEBUG
struct audio_format;
#endif
@@ -38,6 +39,7 @@ struct music_pipe;
/**
* Creates a new #music_pipe object. It is empty.
*/
G_GNUC_MALLOC
struct music_pipe *
music_pipe_new(void);
@@ -70,6 +72,7 @@ music_pipe_contains(const struct music_pipe *mp,
* Returns the first #music_chunk from the pipe. Returns NULL if the
* pipe is empty.
*/
G_GNUC_PURE
const struct music_chunk *
music_pipe_peek(const struct music_pipe *mp);
@@ -96,9 +99,11 @@ music_pipe_push(struct music_pipe *mp, struct music_chunk *chunk);
/**
* Returns the number of chunks currently in this pipe.
*/
G_GNUC_PURE
unsigned
music_pipe_size(const struct music_pipe *mp);
G_GNUC_PURE
static inline bool
music_pipe_empty(const struct music_pipe *mp)
{

@@ -309,9 +309,6 @@ pc_seek(struct song *song, float seek_time)
{
assert(song != NULL);
if (pc.state == PLAYER_STATE_STOP)
return false;
player_lock();
pc.next_song = song;
pc.seek_where = seek_time;

@@ -73,6 +73,14 @@ struct player {
*/
bool queued;
/**
* Was any audio output opened successfully? It might have
* failed meanwhile, but was not explicitly closed by the
* player thread. When this flag is unset, some output
* methods must not be called.
*/
bool output_open;
/**
* the song currently being played
*/
@@ -145,7 +153,13 @@ player_dc_start(struct player *player, struct music_pipe *pipe)
assert(player->queued || pc.command == PLAYER_COMMAND_SEEK);
assert(pc.next_song != NULL);
dc_start(dc, pc.next_song, player_buffer, pipe);
unsigned start_ms = pc.next_song->start_ms;
if (pc.command == PLAYER_COMMAND_SEEK)
start_ms += (unsigned)(pc.seek_where * 1000);
dc_start(dc, pc.next_song,
start_ms, pc.next_song->end_ms,
player_buffer, pipe);
}
/**
@@ -270,6 +284,44 @@ real_song_duration(const struct song *song, double decoder_duration)
return decoder_duration - song->start_ms / 1000.0;
}
/**
* Wrapper for audio_output_all_open(). Upon failure, it pauses the
* player.
*
* @return true on success
*/
static bool
player_open_output(struct player *player)
{
assert(audio_format_defined(&player->play_audio_format));
assert(pc.state == PLAYER_STATE_PLAY ||
pc.state == PLAYER_STATE_PAUSE);
if (audio_output_all_open(&player->play_audio_format, player_buffer)) {
player->output_open = true;
player->paused = false;
player_lock();
pc.state = PLAYER_STATE_PLAY;
player_unlock();
return true;
} else {
player->output_open = false;
/* pause: the user may resume playback as soon as an
audio output becomes available */
player->paused = true;
player_lock();
pc.error = PLAYER_ERROR_AUDIO;
pc.state = PLAYER_STATE_PAUSE;
player_unlock();
return false;
}
}
/**
* The decoder has acknowledged the "START" command (see
* player_wait_for_decoder()). This function checks if the decoder
@@ -301,7 +353,7 @@ player_check_decoder_startup(struct player *player)
decoder_unlock(dc);
if (audio_format_defined(&player->play_audio_format) &&
if (player->output_open &&
!audio_output_all_wait(1))
/* the output devices havn't finished playing
all chunks yet - wait for that */
@@ -315,23 +367,12 @@ player_check_decoder_startup(struct player *player)
player->play_audio_format = dc->out_audio_format;
player->decoder_starting = false;
if (!player->paused &&
!audio_output_all_open(&dc->out_audio_format,
player_buffer)) {
if (!player->paused && !player_open_output(player)) {
char *uri = song_get_uri(dc->song);
g_warning("problems opening audio device "
"while playing \"%s\"", uri);
g_free(uri);
player_lock();
pc.error = PLAYER_ERROR_AUDIO;
/* pause: the user may resume playback as soon
as an audio output becomes available */
pc.state = PLAYER_STATE_PAUSE;
player_unlock();
player->paused = true;
return true;
}
@@ -356,16 +397,10 @@ player_check_decoder_startup(struct player *player)
static bool
player_send_silence(struct player *player)
{
struct music_chunk *chunk;
size_t frame_size =
audio_format_frame_size(&player->play_audio_format);
/* this formula ensures that we don't send
partial frames */
unsigned num_frames = sizeof(chunk->data) / frame_size;
assert(player->output_open);
assert(audio_format_defined(&player->play_audio_format));
chunk = music_buffer_allocate(player_buffer);
struct music_chunk *chunk = music_buffer_allocate(player_buffer);
if (chunk == NULL) {
g_warning("Failed to allocate silence buffer");
return false;
@@ -375,6 +410,12 @@ player_send_silence(struct player *player)
chunk->audio_format = player->play_audio_format;
#endif
size_t frame_size =
audio_format_frame_size(&player->play_audio_format);
/* this formula ensures that we don't send
partial frames */
unsigned num_frames = sizeof(chunk->data) / frame_size;
chunk->times = -1.0; /* undefined time stamp */
chunk->length = num_frames * frame_size;
memset(chunk->data, 0, chunk->length);
@@ -396,8 +437,6 @@ static bool player_seek_decoder(struct player *player)
{
struct song *song = pc.next_song;
struct decoder_control *dc = player->dc;
double where;
bool ret;
assert(pc.next_song != NULL);
@@ -413,8 +452,7 @@ static bool player_seek_decoder(struct player *player)
/* re-start the decoder */
player_dc_start(player, player->pipe);
ret = player_wait_for_decoder(player);
if (!ret) {
if (!player_wait_for_decoder(player)) {
/* decoder failure */
player_command_finished();
return false;
@@ -435,8 +473,7 @@ static bool player_seek_decoder(struct player *player)
/* wait for the decoder to complete initialization */
while (player->decoder_starting) {
ret = player_check_decoder_startup(player);
if (!ret) {
if (!player_check_decoder_startup(player)) {
/* decoder failure */
player_command_finished();
return false;
@@ -445,14 +482,13 @@ static bool player_seek_decoder(struct player *player)
/* send the SEEK command */
where = pc.seek_where;
double where = pc.seek_where;
if (where > pc.total_time)
where = pc.total_time - 0.1;
if (where < 0.0)
where = 0.0;
ret = dc_seek(dc, where + song->start_ms / 1000.0);
if (!ret) {
if (!dc_seek(dc, where + song->start_ms / 1000.0)) {
/* decoder failure */
player_command_finished();
return false;
@@ -516,18 +552,9 @@ static void player_process_command(struct player *player)
yet - don't open the audio device yet */
player_lock();
pc.state = PLAYER_STATE_PLAY;
} else if (audio_output_all_open(&player->play_audio_format, player_buffer)) {
/* unpaused, continue playing */
player_lock();
pc.state = PLAYER_STATE_PLAY;
} else {
/* the audio device has failed - rollback to
pause mode */
pc.error = PLAYER_ERROR_AUDIO;
player->paused = true;
player_open_output(player);
player_lock();
}
@@ -564,8 +591,7 @@ static void player_process_command(struct player *player)
break;
case PLAYER_COMMAND_REFRESH:
if (audio_format_defined(&player->play_audio_format) &&
!player->paused) {
if (player->output_open && !player->paused) {
player_unlock();
audio_output_all_check();
player_lock();
@@ -583,14 +609,12 @@ static void player_process_command(struct player *player)
static void
update_song_tag(struct song *song, const struct tag *new_tag)
{
struct tag *old_tag;
if (song_is_file(song))
/* don't update tags of local files, only remote
streams may change tags dynamically */
return;
old_tag = song->tag;
struct tag *old_tag = song->tag;
song->tag = tag_dup(new_tag);
if (old_tag != NULL)
@@ -626,7 +650,9 @@ play_chunk(struct song *song, struct music_chunk *chunk,
return true;
}
player_lock();
pc.bit_rate = chunk->bit_rate;
player_unlock();
/* send the chunk to the audio outputs */
@@ -648,15 +674,14 @@ static bool
play_next_chunk(struct player *player)
{
struct decoder_control *dc = player->dc;
struct music_chunk *chunk = NULL;
unsigned cross_fade_position;
bool success;
if (!audio_output_all_wait(64))
/* the output pipe is still large enough, don't send
another chunk */
return true;
unsigned cross_fade_position;
struct music_chunk *chunk = NULL;
if (player->xfade == XFADE_ENABLED &&
player_dc_at_next_song(player) &&
(cross_fade_position = music_pipe_size(player->pipe))
@@ -694,6 +719,19 @@ play_next_chunk(struct player *player)
chunk->mix_ratio = nan("");
}
if (music_chunk_is_empty(other_chunk)) {
/* the "other" chunk was a music_chunk
which had only a tag, but no music
data - we cannot cross-fade that;
but since this happens only at the
beginning of the new song, we can
easily recover by throwing it away
now */
music_buffer_return(player_buffer,
other_chunk);
other_chunk = NULL;
}
chunk->other = other_chunk;
} else {
/* there are not enough decoded chunks yet */
@@ -732,9 +770,7 @@ play_next_chunk(struct player *player)
/* play the current chunk */
success = play_chunk(player->song, chunk, &player->play_audio_format);
if (!success) {
if (!play_chunk(player->song, chunk, &player->play_audio_format)) {
music_buffer_return(player_buffer, chunk);
player_lock();
@@ -776,11 +812,9 @@ play_next_chunk(struct player *player)
static bool
player_song_border(struct player *player)
{
char *uri;
player->xfade = XFADE_UNKNOWN;
uri = song_get_uri(player->song);
char *uri = song_get_uri(player->song);
g_message("played \"%s\"", uri);
g_free(uri);
@@ -808,6 +842,7 @@ static void do_play(struct decoder_control *dc)
.decoder_starting = false,
.paused = false,
.queued = true,
.output_open = false,
.song = NULL,
.xfade = XFADE_UNKNOWN,
.cross_fading = false,
@@ -831,6 +866,10 @@ static void do_play(struct decoder_control *dc)
}
player_lock();
if (pc.command == PLAYER_COMMAND_SEEK)
player.elapsed_time = pc.seek_where;
pc.state = PLAYER_STATE_PLAY;
player_command_finished_locked();
@@ -856,7 +895,7 @@ static void do_play(struct decoder_control *dc)
/* not enough decoded buffer space yet */
if (!player.paused &&
audio_format_defined(&player.play_audio_format) &&
player.output_open &&
audio_output_all_check() < 4 &&
!player_send_silence(&player))
break;
@@ -875,19 +914,10 @@ static void do_play(struct decoder_control *dc)
if (player.decoder_starting) {
/* wait until the decoder is initialized completely */
bool success;
const struct song *song;
success = player_check_decoder_startup(&player);
if (!success)
if (!player_check_decoder_startup(&player))
break;
/* seek to the beginning of the range */
song = decoder_current_song(dc);
if (song != NULL && song->start_ms > 0 &&
!dc_seek(dc, song->start_ms / 1000.0))
player_dc_stop(&player);
player_lock();
continue;
}
@@ -970,7 +1000,7 @@ static void do_play(struct decoder_control *dc)
audio_output_all_drain();
break;
}
} else {
} else if (player.output_open) {
/* the decoder is too busy and hasn't provided
new PCM data in time: send silence (if the
output pipe is empty) */
@@ -1018,6 +1048,7 @@ static gpointer player_task(G_GNUC_UNUSED gpointer arg)
while (1) {
switch (pc.command) {
case PLAYER_COMMAND_SEEK:
case PLAYER_COMMAND_QUEUE:
assert(pc.next_song != NULL);
@@ -1031,7 +1062,6 @@ static gpointer player_task(G_GNUC_UNUSED gpointer arg)
/* fall through */
case PLAYER_COMMAND_SEEK:
case PLAYER_COMMAND_PAUSE:
pc.next_song = NULL;
player_command_finished_locked();
@@ -1092,10 +1122,9 @@ static gpointer player_task(G_GNUC_UNUSED gpointer arg)
void player_create(void)
{
GError *e = NULL;
assert(pc.thread == NULL);
GError *e = NULL;
pc.thread = g_thread_create(player_task, NULL, true, &e);
if (pc.thread == NULL)
MPD_ERROR("Failed to spawn player task: %s", e->message);

@@ -222,10 +222,12 @@ playlist_seek_song(struct playlist *playlist, unsigned song, float seek_time)
playlist->error_count = 0;
if (!playlist->playing || (unsigned)playlist->current != i) {
/* seeking is not within the current song - first
start playing the new song */
/* seeking is not within the current song - prepare
song change */
playlist->playing = true;
playlist->current = i;
playlist_play_order(playlist, i);
queued = NULL;
}

@@ -105,11 +105,16 @@ playlist_check_translate_song(struct song *song, const char *base_uri)
}
}
if (base_uri != NULL && strcmp(base_uri, ".") == 0)
/* g_path_get_dirname() returns "." when there is no
directory name in the given path; clear that now,
because it would break the database lookup
functions */
base_uri = NULL;
if (g_path_is_absolute(uri)) {
/* XXX fs_charset vs utf8? */
char *prefix = base_uri != NULL
? map_uri_fs(base_uri)
: map_directory_fs(db_get_root());
char *prefix = map_directory_fs(db_get_root());
if (prefix == NULL || !g_str_has_prefix(uri, prefix) ||
uri[strlen(prefix)] != '/') {
@@ -120,6 +125,7 @@ playlist_check_translate_song(struct song *song, const char *base_uri)
return NULL;
}
base_uri = NULL;
uri += strlen(prefix) + 1;
g_free(prefix);
}
@@ -129,7 +135,7 @@ playlist_check_translate_song(struct song *song, const char *base_uri)
else
uri = g_strdup(uri);
if (uri_has_scheme(base_uri)) {
if (uri_has_scheme(uri)) {
dest = song_remote_new(uri);
g_free(uri);
} else {

@@ -51,6 +51,12 @@ playlist_vector_init(struct playlist_vector *pv)
void
playlist_vector_deinit(struct playlist_vector *pv);
static inline bool
playlist_vector_is_empty(const struct playlist_vector *pv)
{
return pv->head == NULL;
}
struct playlist_metadata *
playlist_vector_find(struct playlist_vector *pv, const char *name);

@@ -47,7 +47,7 @@ poison_noaccess(void *p, size_t length)
memset(p, 0x01, length);
#ifdef HAVE_VALGRIND_MEMCHECK_H
VALGRIND_MAKE_MEM_NOACCESS(p, length);
(void)VALGRIND_MAKE_MEM_NOACCESS(p, length);
#endif
#endif
}
@@ -68,7 +68,7 @@ poison_undefined(void *p, size_t length)
memset(p, 0x02, length);
#ifdef HAVE_VALGRIND_MEMCHECK_H
VALGRIND_MAKE_MEM_UNDEFINED(p, length);
(void)VALGRIND_MAKE_MEM_UNDEFINED(p, length);
#endif
#endif
}

@@ -22,6 +22,7 @@
#include "socket_util.h"
#include "fd_util.h"
#include "glib_compat.h"
#include "glib_socket.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -218,7 +219,7 @@ server_socket_open(struct server_socket *ss, GError **error_r)
/* register in the GLib main loop */
GIOChannel *channel = g_io_channel_unix_new(s->fd);
GIOChannel *channel = g_io_channel_new_socket(s->fd);
s->source_id = g_io_add_watch(channel, G_IO_IN,
server_socket_in_event, s);
g_io_channel_unref(channel);
@@ -252,7 +253,7 @@ server_socket_close(struct server_socket *ss)
continue;
g_source_remove(s->source_id);
close(s->fd);
close_socket(s->fd);
s->fd = -1;
}
}

@@ -122,7 +122,7 @@ socket_bind_listen(int domain, int type, int protocol,
if (ret < 0) {
g_set_error(error, listen_quark(), errno,
"setsockopt() failed: %s", g_strerror(errno));
close(fd);
close_socket(fd);
return -1;
}
@@ -130,7 +130,7 @@ socket_bind_listen(int domain, int type, int protocol,
if (ret < 0) {
g_set_error(error, listen_quark(), errno,
"%s", g_strerror(errno));
close(fd);
close_socket(fd);
return -1;
}
@@ -138,7 +138,7 @@ socket_bind_listen(int domain, int type, int protocol,
if (ret < 0) {
g_set_error(error, listen_quark(), errno,
"listen() failed: %s", g_strerror(errno));
close(fd);
close_socket(fd);
return -1;
}

@@ -579,8 +579,10 @@ sticker_load(const char *type, const char *uri)
bool success;
success = sticker_list_values(sticker->table, type, uri);
if (!success)
if (!success) {
sticker_free(sticker);
return NULL;
}
if (g_hash_table_size(sticker->table) == 0) {
/* don't return empty sticker objects */

@@ -300,6 +300,9 @@ stat_directory(const struct directory *directory, struct stat *st)
if (path_fs == NULL)
return -1;
ret = stat(path_fs, st);
if (ret < 0)
g_warning("Failed to stat %s: %s", path_fs, g_strerror(errno));
g_free(path_fs);
return ret;
}
@@ -316,6 +319,9 @@ stat_directory_child(const struct directory *parent, const char *name,
return -1;
ret = stat(path_fs, st);
if (ret < 0)
g_warning("Failed to stat %s: %s", path_fs, g_strerror(errno));
g_free(path_fs);
return ret;
}
@@ -557,6 +563,7 @@ directory_child_access(const struct directory *directory,
/* access() is useless on WIN32 */
(void)directory;
(void)name;
(void)mode;
return true;
#else
char *path = map_directory_child_fs(directory, name);
@@ -707,8 +714,14 @@ skip_symlink(const struct directory *directory, const char *utf8_name)
return false;
}
if (buffer[0] == '/')
return !follow_outside_symlinks;
if (g_path_is_absolute(buffer)) {
/* if the symlink points to an absolute path, see if
that path is inside the music directory */
const char *relative = map_to_relative_path(buffer);
return relative > buffer
? !follow_inside_symlinks
: !follow_outside_symlinks;
}
p = buffer;
while (*p == '.') {

@@ -25,7 +25,7 @@
#include <stdbool.h>
/**
* Checks whether the specified URI has a schema in the form
* Checks whether the specified URI has a scheme in the form
* "scheme://".
*/
G_GNUC_PURE

@@ -37,30 +37,28 @@ my_log_func(G_GNUC_UNUSED const gchar *log_domain,
int main(int argc, char **argv)
{
const char *path, *name, *value;
GError *error = NULL;
bool success;
int ret;
if (argc != 3) {
g_printerr("Usage: read_conf FILE SETTING\n");
return 1;
}
path = argv[1];
name = argv[2];
const char *path = argv[1];
const char *name = argv[2];
g_log_set_default_handler(my_log_func, NULL);
config_global_init();
success = config_read_file(path, &error);
GError *error = NULL;
bool success = config_read_file(path, &error);
if (!success) {
g_printerr("%s:", error->message);
g_error_free(error);
return 1;
}
value = config_get_string(name, NULL);
const char *value = config_get_string(name, NULL);
int ret;
if (value != NULL) {
g_print("%s\n", value);
ret = 0;
@@ -70,5 +68,5 @@ int main(int argc, char **argv)
}
config_global_finish();
return 0;
return ret;
}

@@ -106,7 +106,6 @@ int main(int argc, char **argv)
struct filter *filter;
const struct audio_format *out_audio_format;
char buffer[4096];
size_t frame_size;
if (argc < 3 || argc > 4) {
g_printerr("Usage: run_filter CONFIG NAME [FORMAT] <IN\n");
@@ -162,8 +161,6 @@ int main(int argc, char **argv)
g_printerr("audio_format=%s\n",
audio_format_to_string(out_audio_format, &af_string));
frame_size = audio_format_frame_size(&audio_format);
/* play */
while (true) {