Commit Graph

3653 Commits

Author SHA1 Message Date
Max Kellermann cbea8a2a00 playlist: pass const playlist pointers
Pass constant playlist objects to functions which do not modify it.
2009-02-04 22:08:39 +01:00
Max Kellermann 080dd095a5 playlist_print: added API documentation 2009-02-04 21:09:37 +01:00
Max Kellermann 60bec77664 playlist_print: use bool instead of int
Return true on success, instead of 0.  Converted the "detail"
parameter to bool.
2009-02-04 21:04:30 +01:00
Max Kellermann f817285922 playlist_print: no CamelCase
Renamed one function.
2009-02-04 21:02:11 +01:00
Max Kellermann cfaede610c playlist_print: include cleanup 2009-02-04 21:02:09 +01:00
Max Kellermann 15f914a74a playlist: moved code to playlist_edit.c
Moved functions for playlist editing (append, delete, shuffle, move)
to playlist_edit.c.
2009-02-04 20:31:53 +01:00
Max Kellermann f3d6d536f6 playlist: moved code to playlist_control.c
Moved handlers for control commands (play, stop, next, prev) to
playlist_control.c.
2009-02-04 20:31:22 +01:00
Max Kellermann 4db51eeccd playlist: call syncPlaylistWithQueue() only in the event handler
Don't call syncPlaylistWithQueue() in nextSongInPlaylist() and
previousSongInPlaylist().  This is a relic from the time when there
was no event, and was a workaround to the timing problem.
2009-02-04 19:44:32 +01:00
Max Kellermann 8d3205871c playlist: renamed global "playlist" variable to "g_playlist"
Export the "g_playlist" variable, and pass it to all playlist
functions.  This way, we can split playlist.c easier into separate
parts.  The code which initializes the singleton variable is moved to
playlist_global.c.
2009-02-04 18:56:41 +01:00
Max Kellermann 1720c7090d playlist: moved code to playlist_state.c
Moved everything related to saving or loading the playlist from/to the
state file to playlist_state.c.
2009-02-04 18:52:39 +01:00
Max Kellermann e27a665b89 playlist: simplified playlist.queued updates
Before every operation which modifies the playlist, remember a pointer
to the song struct.  After the modification, determine the "next song"
again, and if it differs, dequeue and queue the new song.

This removes a lot of complexity from the playlist update code, and
makes it more robust.
2009-02-04 18:52:37 +01:00
Max Kellermann b6e5c24878 configure.ac: raised protocol version to "0.15.0"
The protocol has been extended since MPD 0.14: playlist ranges,
stickers.  About time to give the protocol a new version number!
2009-02-04 18:52:34 +01:00
Max Kellermann cd98a72ca6 configure.ac: make DocBook processing optional
Disable the HTML documentation generator by default.  Most users will
pick it from the web site.
2009-02-04 15:25:57 +01:00
Max Kellermann 824d299eb1 ffmpeg: fixed seek integer overflow
The "current" variable is used for calculating the seek destination,
and was declared as "int".  With very long song files, the 32 bit
integer can overflow.  ffmpeg expects an int64_t, which is very
unlikely to overflow.  Switch to int64_t.
2009-02-03 22:51:44 +01:00
Max Kellermann f3b73b824f ffmpeg: check if the time stamp is valid
When ffmpeg cannot estimate the elapsed time, it sets
AVPacket.pts=AV_NOPTS_VALUE.  Our ffmpeg decoder plugin did not check
for that special value.
2009-02-03 22:51:41 +01:00
Max Kellermann 81b6c0d77b ffmpeg: don't warn of empty packet output
If avcodec_decode_audio2() returns no output for an AVPacket,
libavcodec may buffer some data, and return a larger chunk of output
later.  This patch disables a lot of bogus warnings.
2009-02-03 22:51:38 +01:00
Max Kellermann a7632b09e0 ffmpeg: print codec name
Output the name of the codec as a debug message.  During my tests,
ffmpeg never filled this struct member, but it may do so in the past,
and this debug message might become helpful.
2009-02-03 22:51:35 +01:00
Max Kellermann 3b0a78fe0d shout_mp3: call lame_close() in clear_encoder() method
The shout_mp3 encoder had two bugs: when no song was ever played, MPD
segfaulted during cleanup.  Second bug: memory leak, each time the
shout device was opened, lame_init() was called again, and
lame_close() is only called once during shutdown.

Fix this by shutting down LAME each time the clear_encoder() method is
called.
2009-02-02 18:22:56 +01:00
Max Kellermann 1fdf25214f shout_mp3: free the lame_data struct on exit
Make valgrind a little bit happier: free the global lame_data struct
in the finish() method.
2009-02-02 18:22:53 +01:00
Max Kellermann 4b7c28f98e player_thread: set player error when output device fails
When the output device fails to play a chunk, set pc.error to
PLAYER_ERROR_AUDIO.  This way, the playlist knows that it should not
queue the next song.
2009-02-02 18:22:41 +01:00
Max Kellermann fdb80e74b7 main: don't pass argv[0] to openDB()
Don't mention the program name in the error message.
2009-02-02 16:58:51 +01:00
Max Kellermann 37bcd711b5 main: create database after daemonization
When the update thread is started before MPD has forked (for
daemonization), it is killed, because threads do not survive a fork().
This induces an inconsistent state where MPD won't start any update
thread at all, because it thinks the thread is already running.
2009-02-02 16:57:24 +01:00
Max Kellermann 231636b9eb output_api: moved the command check out of method pause()
Move the "while" loop which checks for commands to the caller
ao_pause().  This simplifies the pause() method, and lets us remove
audio_output_is_pending().
2009-01-30 20:12:38 +01:00
Max Kellermann 6aa734dc35 playlist: clear playlist.playing when deleting current song
This fixes an assertion failure: when the last song in the playlist
was playing, and you deleted it, MPD aborted.
2009-01-30 19:54:19 +01:00
Max Kellermann dd23e71953 output_api: removed DISABLED_AUDIO_OUTPUT_PLUGIN
The macro is unused.
2009-01-30 19:48:09 +01:00
Max Kellermann a2e0b71aad output_api: removed audio_output_closed()
The function is only used by the MVP output plugin, and this one call
is wrong.
2009-01-30 19:47:59 +01:00
Max Kellermann eeec32feaa jack: don't override output_ports in connect()
If no ports are configured, don't overwrite the (NULL) configuration
with the port names of the first JACK server.  If the server changes
after a JACK reconnect, MPD won't attempt to auto-detect again.
2009-01-30 19:44:58 +01:00
Max Kellermann a93e73bea8 jack: removed sample_rate callback
Currently, the JACK plugin manipulates the audio_format struct which
was passed to the open() method.  This is very likely to break,
because the plugin must not permanently store this pointer.  After
this patch, MPD ignores sample rate changes.  It looks like other
software is doing the same, and I guess this is a non-issue.

This patch converts the audio_format pointer within jack_data into a
static audio_format struct.
2009-01-30 19:43:31 +01:00
Max Kellermann 5900827675 configure.ac: detect jack_set_info_function()
jack_set_info_function() is not provided by older libjack versions.
Attempt to detect if it is available.
2009-01-30 19:43:25 +01:00
Matthias Drochner 5b85288664 mikmod: call MikMod_Exit() only in the finish() method
Hi -
independently of libmikmod's other problems - there seems
to be a problem in mpd's wrapper: MikMod_Exit() is called
after the first file is decoded, which frees some ressources
within the mikmod library. An attempt to play a second file
leads to a crash. The appended patch fixes this for me.
(I don't know what the "dup" entry is good for - someone
who knows should review that too.)
best regards
Matthias

[mk: removed 3 more MikMod_Exit() invocations]
2009-01-30 17:51:16 +01:00
Max Kellermann 02bfb0c4e4 wavpack: pass NULL if the .wvc file fails to open
The wavpack library seems to use the .wvc stream even if the OPEN_WVC
flag is not set.  In this case, pass NULL to be sure libwavpack won't
use it.
2009-01-30 16:05:02 +01:00
Max Kellermann 0d3dff9512 jack: print info messages
Use jack_set_info_function() to install an info callback.  Don't let
libjack print them to stderr.
2009-01-30 15:57:43 +01:00
Max Kellermann 76b217f71e client: check for G_IO_ERR and G_IO_HUP
When we do not explicitly catch G_IO_ERR and G_IO_HUP, GLib can go
into an infinite loop, because it won't deliver the socket error to
MPD.
2009-01-30 15:56:53 +01:00
Max Kellermann c38dd9e8d8 mapper: ignore duplicate slashes in playlists
When there are duplicate slashes in the song paths, eliminate them;
example:

 /var/lib/mpd/music//foo.mp3

becomes:

 /var/lib/mpd/music/foo.mp3

The slash is only detected at the border between the music_directory
and the local part.
2009-01-30 13:51:18 +01:00
Max Kellermann e3d4fa6946 mapper: remove trailing slashes from music_directory
When the user configures a music_directory with a trailing slash, it
may break playlist loading, because MPD expects a double slash.  Chop
off the trailing slash.
2009-01-30 13:50:24 +01:00
David Horn efb04532df ffmeg: added support for the tags comment, genre, year
ffmpeg_tag_internal() does not look for a few tags that mpd
supports. Most noteably:

 comment -> TAG_ITEM_COMMENT -> Description
 genre -> TAG_ITEM_GENRE -> WM/Genre (not WM/GenreID)
 year -> TAG_ITEM_DATE -> WM/Year

I *think* that this is the last of the tags that AVFormatContext() in
ffmpeg supports that mpd also uses.
2009-01-30 09:42:49 +01:00
Max Kellermann 32d6d4499e input_stream: make seek(), buffer() optional
Make those two methods optional to implement, and let input_stream.c
provide fallbacks.  The buffer() method will be removed one day, and
there is now only one implementation left (input_curl.c).
2009-01-30 00:58:03 +01:00
Max Kellermann 82cfce76eb archive: replaced setup_stream() with open_stream()
The open_stream() method opens the input_stream.  This allows the
archive plugin to do its own initialization, and it also allows it to
use input_stream.data.  We can remove input_stream.archive now, which
was unnatural to have in the first place.
2009-01-30 00:53:32 +01:00
Max Kellermann dc1cc7e7e5 input_stream: let the implementation assign is->plugin
This way, plugins can manipulate the plugin pointer during open().
2009-01-30 00:40:14 +01:00
Max Kellermann 297101c3f8 input_stream: documented the API 2009-01-30 00:07:53 +01:00
Max Kellermann 864dee823d configure.ac: disable MMS by default
MMS streaming is experimental; sync the default value with the help
text.
2009-01-29 23:44:24 +01:00
Max Kellermann 27c5b90dc3 jack: don't manually close on shutdown
Return false from mpd_jack_play(), let the MPD core close the device.
2009-01-29 23:16:34 +01:00
Max Kellermann 846f126259 jack: initialize output_ports if not configured
Don't leave uninitialized bytes in the jack_data struct.
2009-01-29 23:16:30 +01:00
Max Kellermann e959c8e084 jack: close JACK client on stop
When MPD stops playback, close the JACK client connection.
2009-01-29 23:16:21 +01:00
Max Kellermann e68924435a jack: removed "bps" attribute
The "bps" attribute is calculated, but never used.
2009-01-29 23:15:55 +01:00
Max Kellermann 5a2949552b jack: make mpd_jack_connect() return bool
Return true/false instead of 1/-1.
2009-01-29 23:15:27 +01:00
Max Kellermann eccc7c21bd jack: use loops for allocating/freeing ports/buffers
Preparation for supporting other channel numbers than stereo: use
loops instead of duplicating code for the second channel.  Most
likely, gcc will unroll these loops, so the binary won't be any
different.
2009-01-29 23:14:04 +01:00
Max Kellermann 3baeddbcae jack: fail if jack_get_ports() returns NULL
When jack_get_ports() returns NULL, we cannot have any ports to
connect to, and the device cannot play anything.
2009-01-29 23:12:16 +01:00
Max Kellermann 5bcf415ad0 jack: use jack_port_name() instead of g_malloc()+sprintf()
libjack's jack_port_name() function returns the effective port name,
we don't need to do it manually.
2009-01-29 23:12:10 +01:00
Max Kellermann 67cf2ee6e4 jack: initialize libjack's error function in mpd_jack_init()
Do the global libjack initialization in the global plugin
initialization function.
2009-01-29 23:12:08 +01:00