Commit Graph

3826 Commits

Author SHA1 Message Date
Max Kellermann
e8787ac4a4 audio: added output enumeration functions
Added audio_output_get(), audio_output_find().
2009-02-10 17:21:19 +01:00
Max Kellermann
3e87033145 audio: added audio_output_config_count()
audio_output_config_count() returns the number of audio outputs in the
configuration file.  It is only used by initAudioDriver().  The public
function audio_output_count() now returns audioOutputArraySize.
2009-02-10 17:21:10 +01:00
Max Kellermann
ff09a41807 output_internal: added missing output_api.h include
output_api.h is required for enum audio_output_command.
2009-02-10 17:21:08 +01:00
Max Kellermann
c2bbf876fb player: added some more assertions
Assertions on pc.command and pc.next_song.
2009-02-10 08:18:28 +01:00
Max Kellermann
799d1c9dc2 player_thread: reset pc.next_song only if queued
When we reset pc.next_song if there is no song queued, this might
cause a race condition: the next song to be played is cleared, while
pc.command was already set.  Clear the "next_song" only if there is a
song queued for the current do_play() invocation.
2009-02-10 08:18:01 +01:00
Max Kellermann
40393ae64f playlist: update queued song after seeking
If a new song is queued before calling playerSeek(), then the player
and the playlist enter an inconsistent state, because the player
discards the playlist's "queued" song in favor of the seeked song.

Call playlist_update_queued_song() after playerSeek().
2009-02-10 00:17:46 +01:00
Max Kellermann
2274434e53 player_thread: reset pc.next_song
After a player command (successful or not), reset pc.next_song,
because the queue is supposed to be empty then.  Otherwise,
playlist.queued and pc.next_song may disagree, which triggers an
assertion failure.
2009-02-10 00:17:34 +01:00
Max Kellermann
710b3275ea queue: update order array after song move
Commit f78cddb4 introduced a regression: after a song was moved, the
order array was not updated (in random mode).  This caused MPD to
think the "current" song has changed when you moved something to the
position of the current song.
2009-02-09 22:47:23 +01:00
Max Kellermann
bee688e99a configure.ac: define HAVE_FFMPEG after all checks
Don't define HAVE_FFMPEG if the ffmpeg libraries were found via
pkg-config, but ffmpeg support was disabled because
avcodec_decode_audio2() is not available.
2009-02-09 22:22:54 +01:00
Vladimir S Eremin
d9ce8d8342 playlist: fixed "next song" check
Check if the "current+1" position is actually valid.
2009-02-09 21:14:38 +01:00
Max Kellermann
e2f22229a6 output_api: include "config.h" without "../"
Including "../config.h" breaks on some systems.
2009-02-09 16:50:25 +01:00
Max Kellermann
1ac328b553 shout: clear buffer before calling the encoder
Always assume the buffer is empty before calling the encoder.  Always
flush the buffer immediately after there has been added something.
This reduces the risk of buffer overruns, because there will never be
a "rest" in the current buffer.
2009-02-09 16:38:25 +01:00
Max Kellermann
7fc25ad567 shout: don't postpone metadata
Don't duplicate the tag received by the send_metadata() method - send
it to the shout server directly.
2009-02-09 16:38:22 +01:00
Max Kellermann
f5c43889c3 shout: use libshout's synchronization
Removed the manual timer synchronization from the shout plugin.
libshout's shout_sync() function does it for us.
2009-02-09 16:38:20 +01:00
Max Kellermann
f6455d5f79 shout: switch to blocking mode
The non-blocking mode of libshout is sparsely documented, and MPD's
implementation had several bugs.  Also removed connect throttling
code, that is done by the MPD core since 0.14.
2009-02-09 16:38:03 +01:00
Max Kellermann
cf94008b27 shout: removed shout_data.tag_to_send
When shout_data.tag!=NULL, there is a "tag to send".  The tag_to_send
flag is redundant.
2009-02-09 16:37:16 +01:00
Max Kellermann
044f2561ce shout: removed shout_data.shout_error
That variable is set in handle_shout_error(), but is never read.
2009-02-09 16:37:12 +01:00
Vladimir S Eremin
cde4cb944e playlist: provide information about "next song"
In random mode, this patch allows clients to see the "next song" in
the queue.
2009-02-09 10:38:03 +01:00
Max Kellermann
b358962960 playlist: increase playlist version after loading state
After the state file has been loaded, the playlist version is still
"1", and "plchanges 1" returns the whole playlist.  Fix this by
increasing the playlist version after the state file has been loaded.
2009-02-04 23:50:04 +01:00
Max Kellermann
5d0c83ba5e update: check whether stickers are enabled
If stickers are not configured at runtime, don't call
sticker_song_delete().
2009-02-04 22:33:43 +01:00
Max Kellermann
94685aa9bd playlist_save: added spl_save_playlist()
spl_save_playlist() is a wrapper for spl_save_queue().
2009-02-04 22:15:37 +01:00
Max Kellermann
19397a84cc playlist: added G_LOG_DOMAIN
Removed the explicit "playlist:" prefix from all log messages.
2009-02-04 22:15:31 +01:00
Max Kellermann
2a1bef2225 playlist_print: added wrappers for printing the queue
Hide the details of the playlist behind wrapper functions.
2009-02-04 22:09:04 +01:00
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