Commit Graph

3806 Commits

Author SHA1 Message Date
Max Kellermann
c7c809ecba output_control: close mixer on pause
For non-global mixers (only "pulse" currently), close the mixer when
MPD playback is paused.
2009-04-21 22:17:52 +02:00
Max Kellermann
c9c0415d65 client: free the fifo buffer
This patch fixes a memory leak: the fifo_buffer object was not freed
when the client connection was closed.
2009-04-17 11:37:27 +02:00
Max Kellermann
2cbda895fb icy_server: don't export icy_server_metadata_string()
icy_server_metadata_string() is only called by
icy_server_metadata_page().
2009-04-13 19:39:33 +02:00
Max Kellermann
9919704be3 httpd: use C99 "bool" instead of GLib's gboolean
Plain "bool" consumes only one byte instead of four.
2009-04-13 19:39:19 +02:00
Max Kellermann
3f81f5b476 httpd: use g_ascii_strncasecmp() to compare headers
In HTTP, header names are case insensitive.
2009-04-13 19:39:16 +02:00
Hagen Schink
92ba754fc6 Implemented basic icy support for the httpd output
[mk: folded with patch "Put icy related functions in extra source
files"; moved icy_server.c from HAVE_CURL to ENABLE_HTTPD_OUTPUT;
removed an unused variable]
2009-04-13 19:35:02 +02:00
Max Kellermann
200be26371 decoder_api: submit the song tag to the music pipe
When a new song starts playing, send its tag (song->tag) to the music
pipe.  This allows output plugins to render tags for all songs, not
only those with embedded tags understood by the decoder plugin.
2009-04-13 19:25:53 +02:00
Max Kellermann
548e842799 log: removed "unused" attribute from log_level parameter 2009-04-10 09:14:21 +02:00
Avuton Olrich
0b36e7d944 decoder: prefer wildmidi over fluidsynth 2009-04-06 11:03:45 +02:00
Avuton Olrich
d38f72b902 vorbis: move #define out of function to top of sources 2009-04-02 16:07:52 -07:00
Avuton Olrich
fd90db35b7 decoder: Rename all main decoder plugins functions to *decoder_plugin. 2009-04-02 15:55:10 -07:00
Max Kellermann
a7685780ed configure.ac: renamed --enable-mod to --enable-mikmod 2009-04-01 22:48:06 +02:00
Max Kellermann
cd6182862a httpd: don't pass uninitialized page to httpd_client_check_queue()
The httpd_client_check_queue() callback function does not use its
"user_data" argument.  Don't pass any, and fix the gcc warning.
2009-04-01 22:45:21 +02:00
Max Kellermann
5242305a90 configure.ac: renamed --enable-oggvorbis to --enable-vorbis 2009-04-01 22:45:17 +02:00
Max Kellermann
e720b5bdf8 command: added command "sticker find"
This command allows clients to search for stickers with a specified
name.
2009-04-01 18:53:02 +02:00
Eric Wollesen
c95fa4b441 Move db_get_song into sub-handlers. (FReq 2112)
db_get_song was being called once for all sub-handlers, but with the
addition of the find command, we don't have a URI coming in, so doing
db_get_song once won't work anymore.

[mk: fixed initialization order]
2009-04-01 18:44:39 +02:00
Max Kellermann
c51e1bf1c0 song_sticker: added song_sticker_find()
This is a wrapper for sticker_find(), which looks up the song object.
2009-04-01 18:44:26 +02:00
Max Kellermann
3a4d20faa2 sticker: added sticker_find()
sticker_find() finds stickers with the specified name.
2009-04-01 18:42:06 +02:00
Max Kellermann
7f38c3fc78 directory: added directory_lookup_song()
Moved code from db_get_song().
2009-04-01 18:41:37 +02:00
Max Kellermann
36ec2edacf directory: renamed directory_get_directory()
Renamed directory_get_directory() to directory_lookup_directory().
Added API documentation.
2009-04-01 18:41:33 +02:00
Max Kellermann
cb35d6e687 sticker_print: new library for sending stickers to a client 2009-04-01 17:30:56 +02:00
Max Kellermann
efcf40f55b sticker: pass const sticker to sticker_foreach() 2009-04-01 17:27:59 +02:00
Max Kellermann
8ce2ec7aed client, event_pipe: explicitly ignore the write() result
On both locations, the result of write() can be ignored safely.  In
event_pipe_emit_fast(), that can only be "EAGAIN", which means that
the pipe buffer is full - no further notification required.  In
client_init(), that would be a fatal connection error, which would be
caught by the next event.

This patch fixes gcc warnings.
2009-04-01 17:14:25 +02:00
Max Kellermann
a96bec3655 socket_util: fixed format warning
g_set_error() is a printf-like function, and expects a format string.
Using the return value of gai_strerror() is unsafe.
2009-04-01 16:45:03 +02:00
Max Kellermann
6419cc54ac flac: fixed "unused variable" warning without libcue
Move the declaration of "i" into the "for" loop.
2009-04-01 16:44:27 +02:00
Jochen Keil
4bfbdfe5c5 Tag subtracks according to "cuesheet" vorbis comment value
Cuesheets are often saved as vorbis comment
flac files (CUESHEET=.. case doesn't matter).
We can parse this now and use the information to
tag the subtracks (from the embedded cuesheets).
2009-03-31 22:17:56 +02:00
Jochen Keil
d7b0c768b0 track length is computed correctly now 2009-03-31 22:17:56 +02:00
Jochen Keil
6720a0a940 free previously allocated flac metadata object 2009-03-31 22:17:56 +02:00
Jochen Keil
a1bde6b99d remove old commented code 2009-03-31 22:17:56 +02:00
Jochen Keil
d41e7f7cec Build tags from information in cue sheets
With these methods a tag struct can be created
from the cdtext information in a cue sheet.
The methods depend on a cue parsing library.
Reading from strings (char*) as well as from
a file (FILE*) is supported.
2009-03-31 22:17:56 +02:00
Romain Bignon
62a72a5e4d do not consider single mode with "next" command
This is a little ugly, but as nextSongInPlaylist is both called when
queued is update (in case playlist ended) and for user "next" command,
there isn't any other (simple) solution
2009-03-31 14:15:33 +02:00
Avuton Olrich
98e81287e3 client: group static function declarations together. 2009-03-30 19:21:42 +02:00
Avuton Olrich
ee7369a8f1 queue_print: queue_print_song_info() is not necessry for export. 2009-03-30 19:21:41 +02:00
Avuton Olrich
68a4bb90da queue: queue_generate_id() is not necessary for export. 2009-03-30 19:21:41 +02:00
Avuton Olrich
ed96db3fae player_control: remove unused function playerCurrentDecodeSong(). 2009-03-30 19:21:41 +02:00
Avuton Olrich
6405db931b conf: config_param_free() not necessary for export. 2009-03-30 19:21:41 +02:00
Avuton Olrich
96ab110b44 command: command_error() is not necessary for export. 2009-03-30 19:21:41 +02:00
Avuton Olrich
215cdda08d client: client_write() does not necessary for export. 2009-03-30 19:21:41 +02:00
Romain Bignon
e81f683a18 implemented the 'consume' mode
Consume mode removes each song played
2009-03-30 17:37:55 +02:00
Jochen Keil
80e2aaf379 Bugfix for time/offset in flac plugin
Previous cast to float didn't have any effect because one value is uint
and the other is a floating type but the number itself is even..
This caused some tracks to end before they were really at an end.
2009-03-28 10:13:44 +01:00
Max Kellermann
43864762ee mixer: assert that the new volume value is valid
Added an assertion in mixer_set_volume().  Removed the range checks
from the ALSA and OSS plugins.
2009-03-27 20:10:39 +01:00
Max Kellermann
49e548e773 mpcdec: changed plugin name to "mpcdec"
The "mpcdec" plugin is based on the libmpcdec library.
2009-03-27 19:58:50 +01:00
Max Kellermann
f5548a8654 mpcdec: support the new libmpcdec SV8 API 2009-03-27 19:51:59 +01:00
Max Kellermann
0e18fab655 mpcdec: no CamelCase
Renamed variables and functions.
2009-03-27 19:37:08 +01:00
Max Kellermann
86827fc63e tag_pool: use memcmp() instead of strcmp() for non-terminated string
The strings passed to tag_pool_get_item() are not null-terminated, and
the caller passes the string length.  Don't assume it is
null-terminated anyway by using strcmp().
2009-03-27 19:36:24 +01:00
Max Kellermann
51894725ec tag_pool: use size_t for string length 2009-03-27 19:36:03 +01:00
Sean McNamara
94479ca40f event_pipe can only be non-blocking if !WIN32 2009-03-27 18:03:46 +01:00
Sean McNamara
f5ff243a8b More debugging for Win32 ioctlsocket: complain if it's not a Winsock
socket, because there is no ioctl for non-sockets on Windows
2009-03-27 18:03:10 +01:00
Sean McNamara
37531f6f1e Add winsock2 headers for curl's use of select() on sockets 2009-03-27 18:03:03 +01:00
Sean McNamara
b1e0bde529 Uniform getaddrinfo() on WIN32 or POSIX, because MinGW now supports it 2009-03-27 18:02:56 +01:00
Sean McNamara
9c63ffa546 Winsock2 is needed on MinGW (or other pure Win32 toolchains) for
networking, select(), ntohl(), etc.
2009-03-27 18:02:31 +01:00
Max Kellermann
b91517e761 sticker: move SQLite statements into an array
Simplify initialization and finalization.
2009-03-27 17:05:04 +01:00
Max Kellermann
7d3921bb88 pulse_mixer: protect the struct with a mutex
There are numerous race conditions between the libpulse thread
(pulse_mixer.c callbacks) and the rest of MPD.  Protect the volatile
attributes of the pulse_mixer struct with a mutex to fix that.
2009-03-27 16:55:17 +01:00
Max Kellermann
7f762a5cec pulse_mixer: return if mixer is offline
Eliminate one indent level.  Also remove several debug useless debug
messages.
2009-03-27 16:44:37 +01:00
Max Kellermann
13319e0b70 pulse_mixer: removed superfluous G_GNUC_UNUSED attributes
Those parameters are used after all.
2009-03-27 16:44:36 +01:00
Max Kellermann
d448392f25 pulse_mixer: use local pa_cvolume variable for set_volume()
Don't mess with pulse_mixer.volume for setting the volume.  This
variable should only be used to transfer the current volume from
sink_input_vol() to pulse_mixer_get_volume().
2009-03-27 16:44:36 +01:00
Max Kellermann
8258457b43 pulse_mixer: wait for get_volume() operation to complete
The pa_context_get_sink_input_info() function is asynchronous, and
after it returns, libpulse does not guarantee that the operation has
completed yet; in fact, it is not likely.  Explicitly wait for the
operation to complete.

The code for the new pulse_wait_for_operation() function was inspired
by mplayer and xine code.
2009-03-27 16:44:36 +01:00
Max Kellermann
1a411b1ced mixer_control: don't lock the mutex twice in mixer_failed()
The function mixer_failed() expects the mixer mutex to be already
locked, yet it calls mixer_close(), which attempts to lock the mutex
again, deadlocking itself.
2009-03-27 16:44:31 +01:00
Romain Bignon
e7519829ac renamed smartstop to single and changed behavior
When single mode is enabled, after current song it stops playback,
or it replay same song if repeat mode is activated.
2009-03-27 15:28:49 +01:00
Romain Bignon
e46722b2eb implements the smartstop feature
The smartstop feature is a way to tell mpd to stop playing after
current song.
This patche provides:
- 'state' command returns 'smartstop' state (1 or 0)
- 'smartstop' can activate or not the smartstop state
- when song is terminated, mpd stops playing and smartstop is set to 0
2009-03-27 14:58:31 +01:00
Max Kellermann
929c200c38 pulse_mixer: adapted code style
Use the same code style as the rest of MPD.
2009-03-27 00:43:47 +01:00
Max Kellermann
207786ffb1 output_all: synchronize playback with player_control.notify
This patch fixes a longer delay when moving around songs in the
playlist.  The main thread wants to enqueue a new "next" song into the
player thread, but the player thread is waiting inside
audio_output_all_wait() for the output threads.  Use
player_control.notify there, so audio_output_all_wait() gets woken up
by the main thread, too.
2009-03-26 23:40:50 +01:00
Max Kellermann
ed4837662a playlist_state: fix playback restore in random mode
The functions playPlaylist() and seekSongInPlaylist() expect a song
position, not a song order number.  Don't convert the "current"
variable with queue_position_to_order().
2009-03-26 22:16:51 +01:00
Jeffrey Middleton
13208bf5a7 queue/playlist/command: move range
The move command now accepts a range for the first argument, in the same
form as other range commands, e.g. move 15:17 3.  The first song in the
range is placed at the destination position. Note that as with other
range commands, the range is inclusive on the left only; this example
would move only songs 15 and 16, not 17.

[mk: fixed signed/unsigned warnings; use G_MAXUINT instead of
UINT_MAX]
2009-03-26 22:02:56 +01:00
Max Kellermann
4343c108b3 pulse_mixer: removed superfluous initializations
Don't initialize attributes which are only used in an open mixer.  As
long as nobody accesses them, their values are uninitialized and
undefined.
2009-03-26 19:50:31 +01:00
Max Kellermann
239e6da442 pulse_mixer: allocate "volume" statically
The pm->volume attribute was allocated in pulse_mixer_init(), but is
never freed.  This leaks memory.  Instead of adding the g_free() call
to pulse_mixer_finish(), let's just make "volume" a static attribute
of the pulse_mixer struct.  That is easier to deal with.
2009-03-26 19:50:27 +01:00
Max Kellermann
6c480d7db4 pulse_mixer: removed superfluous NULL checks in close()
When the MPD core knows that the pulse mixer is open, pm->mainloop and
pm->context must be non-NULL.
2009-03-26 19:50:23 +01:00
Max Kellermann
8cf206f2ee pulse_mixer: initialize "online" and "index" in open()
The attributes "online" and "index" were not properly reinitialized
after a close/open cycle.
2009-03-26 19:50:15 +01:00
Max Kellermann
52575d1b9d pulse: make configuration strings const
Nobody needs to modify these strings.  We can make them const, and
convert config_dup_block_string() to config_get_block_string().  This
also fixes memory leaks in the pulse mixer.
2009-03-26 19:50:10 +01:00
Max Kellermann
cd4964cdee pulse: don't check config_param!=NULL
The conf.h functions deal well with config_param==NULL and will return
the specified default value then.
2009-03-26 19:50:02 +01:00
Max Kellermann
74273d419a pulse_mixer: free libpulse objects on failure
When the mixer initialization fails, we have to free the libpulse
objects we have already created, to prevent resource leaks.
2009-03-26 19:49:58 +01:00
Max Kellermann
3d2c8b001a pulse_mixer: unlock the mainloop on failure
It's illegal to return from pulse_mixer_setup() without unlocking the
main loop.  In the error handling, that unlock() call was missing.
2009-03-26 19:49:55 +01:00
Max Kellermann
d113c07190 pulse_mixer: moved code to pulse_mixer_setup()
Prepare for adding proper error handling.
2009-03-26 19:49:39 +01:00
Max Kellermann
3be1850744 alsa_mixer: initialize "volume_set" in the open() method
"volume_set" is an attribute which becomes undefined when the mixer is
closed.  That means, it must be initialized each time the mixer is
opened.
2009-03-26 19:49:36 +01:00
Max Kellermann
0c9799babe alsa_mixer: removed superfluous checks
The MPD core guarantees that methods are always invoked in a
consistent state.  This means we can remove lots of checks from the
volume methods.
2009-03-26 19:49:31 +01:00
Max Kellermann
331b714a7a alsa_mixer: pass default device to config_get_block_string()
Instead of replacing NULL with the default device in the open()
method, pass the default device to config_get_block_string().
2009-03-26 19:49:26 +01:00
Max Kellermann
f06f049cd8 alsa_mixer: make "device" and "control" const
Use config_get_block_string() instead of config_dup_block_string().
2009-03-26 19:48:55 +01:00
Max Kellermann
c552d17c03 oss_mixer: call oss_find_mixer() in init() method
Detect misconfiguration during MPD startup.
2009-03-26 19:48:21 +01:00
Max Kellermann
881026623c oss_mixer: removed superfluous checks
The MPD core guarantees that methods are always invoked in a
consistent state.  This means we can remove lots of checks from the
volume methods.
2009-03-26 19:48:13 +01:00
Max Kellermann
dd8c6d6738 oss_mixer: use g_ascii_strncasecmp() instead of strncasecmp()
strncasecmp() is locale dependent, but we only need ASCII here.
2009-03-26 19:47:52 +01:00
Max Kellermann
114d5982bb oss_mixer: pass default path to config_get_block_string()
Instead of replacing NULL with the default path in the open() method,
pass the default path to config_get_block_string().
2009-03-26 19:47:47 +01:00
Max Kellermann
aec4fe06b5 oss_mixer: make "device" and "control" const
Use config_get_block_string() instead of config_dup_block_string().
2009-03-26 19:46:46 +01:00
Max Kellermann
69759b573f mixer: don't reopen failed mixer automatically
If a (global) mixer has been closed due to failure, don't reopen it
with every volume get/set.  Leave it closed until it is explicitly
opened.
2009-03-26 19:46:39 +01:00
Max Kellermann
1fcf09a816 mixer_control: close mixer on failure
When getting or setting the volume fails, the MPD core close the
mixer.  Moved the duplicated code from the mixer plugins.
2009-03-26 19:46:33 +01:00
Max Kellermann
617a4fd2d2 mixer: added flag "open"
Remember if a mixer object is open or closed.  Don't call open() again
if it is already open.  This guarantees that the mixer plugin is
always called in a consistent state, and we will be able to remove
lots of checks from the implementations.

To support mixers which are automatically opened even if the audio
output is still closed (to set the volume before playback starts),
this patch also adds the "global" flag to the mixer_plugin struct.
Both ALSA and OSS set this flag, while PULSE does not.
2009-03-26 19:43:18 +01:00
Max Kellermann
7475ded935 mixer_control: don't allow mixer==NULL
As a side effect, the previous patch added the mixer==NULL checks.  It
is now illegal to call mixer functions with a NULL argument.  Convert
the runtime checks to assertions.
2009-03-26 19:43:15 +01:00
Max Kellermann
66a2c5669e output_plugin: replaced output_plugin.get_mixer() with mixer_plugin
The mixer core library is now responsible for creating and managing
the mixer object.  This removes duplicated code from the output
plugins.
2009-03-26 18:23:23 +01:00
Max Kellermann
209c8a540c player_thread: wait for decoder before seeking
When the decoder initialization has not been completed yet, all calls
to dc_seek() will fail, because dc.seekable is not initialized yet.
Wait for the decoder to complete its initialization, i.e. until it has
called decoder_initialized().
2009-03-25 19:48:14 +01:00
Max Kellermann
1e9659bf1f playlist_state: start playing after restore is complete
Don't start playback as soon as the "current" song is being loaded
from the state file.  That is unclean, and leads to an obscure bug: in
repeat mode, when the song is started (which is yet the last song in
the list), the playlist code marked the very first song in the
playlist as "next" song, because the end of the playlist was wrapped.

It's easier to set up the playback after all songs have been loaded,
and after the random/repeat mode has been set.
2009-03-25 19:45:57 +01:00
Max Kellermann
3be1cdf8e0 output_all: synchronize playback with a notify object
Use audio_output_client_notify instead of g_usleep(1ms) in
audio_output_all_wait() to synchronize with the output_thread.  Signal
the audio_output_client_notify object in ao_play().
2009-03-25 18:04:41 +01:00
Max Kellermann
933fcf4232 output_all: moved code to audio_output_all_wait()
Synchronization with the output thread will be implemented in
output_all.c, not in player_thread.c.  Currently, that's just a simple
g_usleep(1ms).
2009-03-25 18:00:31 +01:00
Max Kellermann
4dbf73d88b output: protect audio_output.open with the mutex
There was a deadlock between the output thread and the player thread:
when the output thread failed (and closed itself) while the player
thread worked with the audio_output object, MPD could crash.
2009-03-25 17:07:15 +01:00
Viliam Mateicka
71cd24954a move printAllOutputPluginTypes to output_list.c 2009-03-21 09:45:42 +01:00
Max Kellermann
3d202e4609 output_control: close earlier on format mismatch
To prevent a race condition, close the output thread before assigning
the new audio format.
2009-03-20 16:21:49 +01:00
Max Kellermann
e6c753a474 output: convert audio_output.config_audio_format to boolean
The config_audio_format used to contain the configured audio format,
which is copied to out_audio_format.  Let's convert the former to a
boolean, which indicates whether out_audio_format was already set.
This simplifies some code and saves a few bytes.
2009-03-20 15:47:50 +01:00
Max Kellermann
67e65a7959 page: added page_new_concat() 2009-03-17 20:51:33 +01:00
Max Kellermann
47bbb73ee1 player_thread: ignore time stamp on empty chunks
If a music_chunk does not contain any PCM data, then the "times" and
"bit_rate" attributes are undefined.
2009-03-17 20:28:37 +01:00
Mario Lenz
7ba7e67323 flac/cue: added support for TITLE[n] comments
On 2009/03/17 Max Kellermann<max@duempel.org> wrote:

> There doesn't seem to be an "official" standard.  I'd say: search for
> TITLE[1] first (the most explicit form), then TITLE1, and finally fall
> back to TITLE.  This makes sure MPD supports every possible standard,
> without breaking.

I've also added some additional checks to make sure entry is long
enough.
2009-03-17 12:41:46 +01:00
David Guibert
2a52d49536 pulse_mixer: keep mixer attached when another pulse sink is closed.
The mixer state is defined as offline only if the associated stream is removed.

Signed-off-by: David Guibert <david.guibert@gmail.com>
2009-03-17 08:40:50 +01:00
David Guibert
0ad56e0f8e pulse_mixer: close
when the mixer is closed,
- the mainloop is stopped.
- the context is disconnected.
- then the mainloop is freed.

Signed-off-by: David Guibert <david.guibert@gmail.com>
2009-03-17 08:40:50 +01:00
Jeffrey Middleton
91f3370913 httpd: fixed encoder plugin check
Check if encoder_plugin!=NULL, not encoder_plugin_get (which is a
function).
2009-03-17 06:52:23 +01:00
Mario Lenz
36dab871f1 flac: get CUE track titles from additional FLAC comments
The cue sheet embedded in a flac file doen't contain any information
about track titles and similar.  There are three possibilities: Use an
external cue sheet that includes these information, use a tag CUESHEET
with a cue sheet including these information or use tags.  I think the
latter is the best option and is already used by other projects.
2009-03-16 19:38:34 +01:00
Max Kellermann
d47ef51cb3 socket_util: use g_strerror() instead of strerror()
g_strerror() is more portable, and guarantees that the returned string
is UTF-8 encoded.
2009-03-16 11:59:26 +01:00
Max Kellermann
bba127a392 solaris: new audio output plugin for Solaris /dev/audio 2009-03-16 09:55:10 +01:00
Max Kellermann
18cb4fa277 output_all: check param!=NULL before accessing it
When printing the error message, MPD dereferences the NULL pointer to
print an error message if no audio_output section is present.
2009-03-16 08:44:49 +01:00
Max Kellermann
870706519a httpd_output: check client->write_source_id in handler
Due to a race condition, httpd_client_out_event() could be called even
when its GLib event source was already removed.  Check that case.
2009-03-15 19:06:14 +01:00
Max Kellermann
58844aabac httpd_output: clear the client's page queue on cancel
When the httpd output is cancelled, it freed all pages, but didn't
remove them from the queue.  Call g_queue_clear() and remove the
write source id.
2009-03-15 19:06:10 +01:00
Max Kellermann
ae1a7fc84a vorbis_encoder: added support for all MPD tag types
Copy all tags know to MPD to the vorbis_comment.
2009-03-15 18:36:29 +01:00
Max Kellermann
4bb84c05d7 vorbis_encoder: removed vorbis_encoder.vc
Allocate the vorbis_comment object when it's used.  It is not used
anymore in vorbis_encoder_tag().
2009-03-15 18:36:26 +01:00
Max Kellermann
3333502edb vorbis_encoder: use vorbis_commentheader_out() in the tag() method
Don't reinitialize the encoder with every tag.
2009-03-15 18:36:25 +01:00
Max Kellermann
2b74311b0a vorbis_encoder: pass vorbis_comment to tag helper functions
Prepare the removal of vorbis_encoder.vc.
2009-03-15 18:23:04 +01:00
Max Kellermann
a899c210b9 log: removed DEBUG() and FATAL()
Use GLib the logging functions g_debug(), g_error() instead.
2009-03-15 18:23:00 +01:00
Max Kellermann
9e30dfb9c1 dbUtils: removed printSavedMemoryFromFilenames()
The function is unused.
2009-03-15 18:21:53 +01:00
Max Kellermann
1308f5f669 sig_handlers: include signal.h instead of sys/signal.h 2009-03-15 17:32:30 +01:00
Max Kellermann
e62580db0b httpd: new output plugin to replace "shout"
Let's get rid of the "shout" plugin, and the awfully complicated
icecast daemon setup!  MPD can do better if it's doing the HTTP server
stuff on its own.  This new plugin has several advantages:

- easier to set up - only one daemon, no password settings, no mount
  settings
- MPD controls the encoder and thus already knows the packet
  boundaries - icecast has to parse them
- MPD doesn't bother to encode data while nobody is listening

This implementation is very experimental (no header parsing, ignores
request URI, no icy-metadata, ...).  It should be able to suport
several encoders in parallel in the future (with different bit rates,
different codec, ...), to make MPD the perfect streaming server.  Once
MPD gets multi-player support, we can even mount several different
radio stations on one server.
2009-03-15 03:32:34 +01:00
Max Kellermann
565afefc66 page: new library for reference counted buffers 2009-03-15 02:29:12 +01:00
Max Kellermann
eb34bd2eff vorbis_encoder: make ogg_page a local variable
Converted the ogg_page attribute from the vorbis_encoder struct to a
local function of vorbis_encoder_read().  This simplifies some code,
because we don't need to check the page anymore before using it.
2009-03-15 02:26:16 +01:00
Max Kellermann
65cc280e1a vorbis_encoder: fill the ogg_page in the read() method
Add the "flush" flag, and defer the ogg_stream_flush() call.  Call
ogg_stream_pageout() or ogg_stream_flush() (depending on the "flush"
flag) in vorbis_encoder_read().  This prevents the ogg_page from
getting overwritten by consecutive ogg_stream_pageout() calls.
2009-03-15 02:23:36 +01:00
Max Kellermann
c8c3920500 socket_util: added socket_bind_listen()
Moved code from listen_add_address() (listen.c) to socket_util.c.
2009-03-14 18:29:38 +01:00
Max Kellermann
dccb973cfe client: use the new fifo_buffer library 2009-03-14 17:46:01 +01:00
Max Kellermann
c76d35969b fifo_buffer: added buffering library
It is a library which I have written years ago for other projects.
This library is licensed under BSD 2-clause, because it is very
generic.
2009-03-14 17:30:00 +01:00
Max Kellermann
e12140cfce pcm_resample: choose the fallback resampler at runtime
Even if libsamplerate support is enabled, compile the fallback
resampler.  When the user specifies the option
"samplerate_converter=internal", it is chosen in favor of
libsamplerate.  This may help users with a weak FPU who don't want to
compile a custom MPD from source, because the fallback resampler does
not use floating point operations.
2009-03-14 15:26:36 +01:00
Max Kellermann
456201fa22 pcm_resample: renamed implementation functions
Added diversion functions to pcm_resample.c.  These check which
resampler is enabled at compile time (libsamplerate or fallback).
This prepares the following patch.
2009-03-14 15:26:28 +01:00
Max Kellermann
f1eed721d2 output_all: added missing "unused" attribute
In NDEBUG, clear_tail_chunk() does not use its "chunk" parameter.
2009-03-14 15:26:27 +01:00
Max Kellermann
975ca2dae5 output_all: include chunk.h
The source output_all.c accesses music_chunk struct members, but did
not include chunk.h directly.
2009-03-14 15:26:27 +01:00
Max Kellermann
d56aa88660 pcm_volume: use #ifdef instead of #if __i386__ 2009-03-14 14:39:48 +01:00
Max Kellermann
35a04ccf07 tag_pool: make "slots" static
The variable is private.
2009-03-14 14:38:48 +01:00
Max Kellermann
f711198ab3 pcm_resample: return NULL on failure
Changed "0" to "NULL".
2009-03-14 14:37:31 +01:00
Max Kellermann
8df0a29cbc pcm_convert: return NULL on failure
Changed "0" to "NULL".
2009-03-14 14:36:44 +01:00
Max Kellermann
e5767d6da8 command: return COMMAND_RETURN_OK in handle_addid()
At the last line of handle_addid(), the playlist_result value has
already been evaluated.  Don't return this variable, it's the wrong
type.
2009-03-14 14:36:07 +01:00
Max Kellermann
7b53504a41 command: handle the addToPlaylist() result properly
addToPlaylist() has a "enum playlist_result" return value.  Convert
that to "enum command_return" properly.
2009-03-14 14:33:19 +01:00
Max Kellermann
0007d84d95 faad: faad_decoder_decode() returns NULL, not false
On failure, the function should return NULL, not a boolean.
2009-03-14 14:31:38 +01:00
Max Kellermann
d70591b652 sticker: sticker_load_value() returns NULL on error, not false
Turn the "return false" error handlers into "return NULL".
2009-03-14 14:29:54 +01:00
Max Kellermann
77eaab55a3 sticker: initialize hash table in sticker_new()
Moved the hash table initialization from sticker_list_values() to the
new function sticker_new().  This fixes a memory leak in
sticker_list_values().
2009-03-14 14:21:11 +01:00
Max Kellermann
be38ad5b93 sticker: don't export sticker_list_values()
sticker_list_values() is only used internally in sticker.c.  Remove
sticker_song_list_values() completely, it is superseded by
sticker_song_get().
2009-03-14 14:20:08 +01:00
Max Kellermann
24da9410fa command: use sticker_song_get() instead of sticker_song_list_values() 2009-03-14 14:20:04 +01:00
Max Kellermann
dd67992a0c sticker: added "struct sticker"
The sticker struct can be used for enumerating values.  This will
replace the sticker_list_values() function.
2009-03-14 14:20:01 +01:00
Max Kellermann
5b687795c4 mixer_all: removed debug message
Don't dump the volume of all mixers.
2009-03-14 11:54:39 +01:00
Max Kellermann
7deade8577 mixer: protect the mixer struct with a mutex
In some rare cases, there was a race condition between the output
thread and the main thread: when you disable/enable an output device
in the main thread, this caused a crash in the output thread.  Protect
the whole mixer struct with a GMutex to prevent that.
2009-03-14 11:53:28 +01:00
Max Kellermann
82963ee023 mixer_api: moved mixer_init() to mixer_api.c 2009-03-14 11:47:54 +01:00
Max Kellermann
b488355df8 mixer_api: moved mixer_plugin imports to mixer_list.h
This patch allows the output plugins to import only mixer_list.h,
instead of the full mixer_api.h (which would expose internal
structures).
2009-03-14 11:36:59 +01:00
Max Kellermann
a5017a2d7c mixer_api: moved functions to mixer_control.c
mixer_control.h should provide the functions needed to manipulate a
mixer, without exposing the internal mixer API (which is provided by
mixer_api.h).
2009-03-14 11:36:50 +01:00
Max Kellermann
8d01110c84 mixer_control: moved functions to mixer_all.c 2009-03-14 11:35:54 +01:00
Max Kellermann
88af35c0ab volume: moved code to mixer_all.c 2009-03-14 11:35:40 +01:00
Max Kellermann
e7c3f469c3 mixer_api: moved struct mixer_plugin to mixer_plugin.h 2009-03-14 11:33:51 +01:00
Max Kellermann
f15d879e37 volume: use bool instead of int
Return true/false on success/failure, instead of 0/-1.  Pass
true/false instead of 1/0 for the "rel" boolean parameter.
2009-03-14 11:10:21 +01:00
Jochen Keil
f31c371fbd Removed superfluous if statement in update.c:453
Check for NULL not necessary here
2009-03-14 09:33:55 +01:00
Avuton Olrich
0aee49bdf8 all: Update copyright header.
This updates the copyright header to all be the same, which is
pretty much an update of where to mail request for a copy of the GPL
and the years of the MPD project. This also puts all committers under
'The Music Player Project' umbrella. These entries should go
individually in the AUTHORS file, for consistancy.
2009-03-13 11:51:55 -07:00
Jeffrey Middleton
6e72755204 crossfade: added missing '&' 2009-03-12 20:23:46 +01:00
Max Kellermann
6352e75910 crossfade: copy chunk.audio_format in !NDEBUG
When the destination chunk was empty in cross_fade_apply(), it had no
audio_format attached (an attribute which is only used for assertion
in the debug build).  cross_fade_apply() should assign it the
audio_format of the second chunk (if available), otherwise MPD will
crash.
2009-03-12 19:49:15 +01:00
Max Kellermann
e3b9b57ecd output_all: fix off-by-one error in audio_output_all_check()
When there are chunks which are not yet finished,
audio_output_all_check() returned the size of its music pipe minus
one.  I can't remember exactly why I subtracted 1 from the return
value, it must have had something to do with a former meaning of this
function.  Now it induces assertion failures.
2009-03-12 19:49:10 +01:00
Max Kellermann
0bc7f584f4 mixer_control: don't touch mixers of disabled outputs
When an audio output device is disabled, also disable its mixer.
2009-03-12 18:40:03 +01:00
Max Kellermann
c37567a14f audio: converted device number check to assertion
No caller must ever pass an invalid device number to
mixer_control_setvol() or mixer_control_getvol().
2009-03-12 18:34:38 +01:00
Max Kellermann
e9cbb6be3f audio: moved mixer functions to mixer_control.c 2009-03-12 18:34:37 +01:00
Max Kellermann
9feaedd799 volume: removed unused variable "default_mixer" 2009-03-12 18:24:13 +01:00
Eric Wollesen
e2dc3c948f Move from the opaque GPtrArray to GHashTable for sticker lists. 2009-03-11 17:03:01 -06:00
Max Kellermann
bc3702a4fd player_thread: added comments 2009-03-11 09:35:16 +01:00
Max Kellermann
13cd6b2834 player_thread: removed player_stop_decoder()
Replaced both player_stop_decoder() invocations with player_dc_stop(),
which also cleans up the pipe.
2009-03-11 09:20:34 +01:00
Max Kellermann
903a07b80e player_thread: don't call dc_stop() twice
In the "CANCEL" command handler, the decoder is stopped twice: first
by player_dc_stop(), then by dc_stop().  Remove the latter.
2009-03-11 09:20:33 +01:00
Max Kellermann
923ac213b5 output_control: removed audio_output_signal()
This function was part of a workaround which we don't need anymore.
2009-03-10 22:48:12 +01:00
Jochen Keil
756b0022da Cleaned up update_regular_file() method in update.c
After adding the container_scan() method the update_regular_file() method was quite hard to read.
Now there's update_container_file() which deals with container files.
That way normal container files (i.e. without embedded tracks) are handled by the old code like a regular file.
This will fix some of the odd behaviour observed.
2009-03-10 22:09:51 +01:00
Max Kellermann
cff29f5e86 alsa: use snd_pcm_sframes_t instead of int
snd_pcm_writei() returns the type snd_pcm_sframes_t, not int.  Use the
correct variable type.
2009-03-10 21:31:13 +01:00
Max Kellermann
855054fee1 alsa: don't close PCM handle in alsa_recover()
If the PCM handle gets disconnected, don't close and clear it in
alsa_recover().  The MPD core will call alsa_close() anyway.  This
way, we can always assume that alsa_data.pcm is always valid.
2009-03-10 21:25:45 +01:00
Max Kellermann
538701e7c6 player_thread: fill buffer after seeking
After a seek, wait until enough new chunks are decoded before starting
playback.  If this takes too long, send silence chunks to the audio
outputs meanwhile.
2009-03-10 21:19:51 +01:00
Max Kellermann
2b57863144 output_all: clear input_audio_format on close
When the audio outputs are closed, also clear the audio format.  If we
don't do this, every call to audio_output_all_update() will open the
device, even if it's meant to be paused.
2009-03-10 21:04:47 +01:00
Max Kellermann
f2ec6ee184 output_all: don't allow audio_format==NULL in audio_output_all_open()
Don't allow reopening an audio device after pause with
audio_format==NULL, force the caller to provide the audio_format each
time.
2009-03-10 21:04:45 +01:00
Max Kellermann
d3eccb2324 player_thread: pass format to audio_output_all_open() after resume
When playback is unpaused, pass the audio_format to
audio_output_all_open().  Don't assume that output_all.c remembers the
previous audio format.  Also check if there has been an audio format
yet.
2009-03-10 21:00:52 +01:00
Max Kellermann
a790b64568 player_thread: moved code to player_send_silence() 2009-03-10 20:43:19 +01:00
Max Kellermann
5dfad1d5d6 output_thread: check commands while playing
Check audio_output.command after each sub-chunk has been played.  It
discards the rest of the chunk, but since all commands make the device
stop anyway, this is not a problem, but part of the improvement.  This
improves the latency of audio output commands.
2009-03-10 20:41:27 +01:00
Max Kellermann
92d74d4a78 player_thread: finish failed seek command
When seeking into a new song, and the decoder for the new song fails
to start up, MPD forgot to send the "command_finished" signal to the
main thread.
2009-03-10 18:04:09 +01:00
Max Kellermann
c6a43b691f player_thread: clear player.queued after failure
When pc.next_song is reset due to a decoder failure, also reset the
player.queued flag.  player.queued must not be true when there is no
pc.next_song.
2009-03-10 18:03:38 +01:00
Max Kellermann
7d52284a96 player_thread: moved code to player_seek_decoder()
Reset player.xfade and player.buffering from within
player_seek_decoder(), not in the player_process_command() switch
statement.
2009-03-10 17:52:38 +01:00
Max Kellermann
3ef8cba274 music_chunk: increased chunk size to 4 kB
A larger chunk size means less overhead for managing them.  4 kB seems
to be a reasonable choice: it contains 23 ms of 44.1 kHz 16 bit stereo
data, or 3 ms of 192 kHz 24 bit stereo data.  The original value of
1020 seemed to be too small, there were quite a lot of system calls
and context switches.
2009-03-10 16:11:58 +01:00
Max Kellermann
eeb54a5f35 player_thread: don't free music buffer after decoder failure
The music_buffer is a global variable, and must not be freed until the
player thread exits.
2009-03-10 07:17:14 +01:00
Max Kellermann
3291666b57 output: play from a music_pipe object
Instead of passing individual buffers to audio_output_all_play(), pass
music_chunk objects.  Append all those chunks asynchronously to a
music_pipe instance.  All output threads may then read chunks from
this pipe.  This reduces MPD's internal latency by an order of
magnitude.
2009-03-09 19:25:26 +01:00
Max Kellermann
ab3d7c29da player_thread: don't open audio device when paused
When a PAUSE command is received while the decoder starts, don't open
the audio device when the decoder becomes ready.  It's pointless,
because MPD will close if after that.
2009-03-09 19:16:50 +01:00
Max Kellermann
e1bd2c65d5 music_pipe: added music_pipe_contains() 2009-03-09 19:15:54 +01:00
Max Kellermann
9f79c05e43 player_thread: moved code to player_song_border()
Moved some more cruft out of do_play().
2009-03-09 19:15:14 +01:00
Max Kellermann
4459a46181 player_thread: moved code to play_next_chunk()
Moved some cruft out of do_play().
2009-03-09 19:14:06 +01:00
Max Kellermann
d213f9a3e5 player_thread: make the music_buffer instance global
Preparation for the next patch: since the output devices stay open
even when the player thread stops playing, we will need a persistent
music buffer.
2009-03-09 19:12:06 +01:00
Max Kellermann
8de179ef7b output_control: make audio_output_open() static
audio_output_open() is only called by audio_output_update().  Don't
export it.
2009-03-09 19:11:13 +01:00
Max Kellermann
c5c86452ce music_buffer: poison unallocated chunks
When a music chunk is freed (returned to the buffer), poison its
memory.
2009-03-09 19:11:10 +01:00
Max Kellermann
940af669b3 poison: added valgrind support
If the header valgrind/memcheck.h is available, add
VALGRIND_MAKE_MEM_NOACCESS() and VALGRIND_MAKE_MEM_UNDEFINED()
support, which enables nice warnings in the valgrind memory checker.
2009-03-09 19:10:18 +01:00
Max Kellermann
fd76e29fba added memory poisoning library
Memory poisoning is useful for marking memory regions as "undefined".
This poisoning only enabled in the debug build (!NDEBUG).
2009-03-09 19:09:30 +01:00
Max Kellermann
71e88271d9 output_thread: wait 10 seconds before reopening after play failure
This is similar to the MPD 0.14 patch "wait 10 seconds before
reopening a failed device", which only covered open() failures.  This
patch adds the same feature for play().
2009-03-09 19:08:35 +01:00
Jochen Keil
4d3d091c22 Fix remove-flac-song-on-every-update
Until now every flac file got removed unconditionally (and then re-added)
whenever the update command was issued. Now there is a check if we need
to that, so the file will only be removed if there is a embedded cuesheet
in that file
2009-03-09 15:15:26 +01:00
Jochen Keil
706112bb88 Initial support for embedded cue sheets found in flac files
So far only seekpoints are supported, so no proper tagging yet
except for track number and track length.
Tagging should be done by parsing the cue sheet which
is often embedded as vorbis comment in flac files.
Furthermore the pathname should be configurable like "%A - %t - %T",
where %A means Artist, %t track number and %T Title or so.
2009-03-09 07:58:44 +01:00
Jochen Keil
ab3d89f484 decoder_plugin: added method container_scan()
[mk: fixed whitespace errors; use delete_song() instead of
songvec_delete()]
2009-03-09 07:58:26 +01:00
Max Kellermann
94d1a87d04 music_chunk: added assertions on the audio format
In !NDEBUG, remember which audio_format is stored in every chunk and
every pipe.  Check the audio_format of every new data block appended
to the music_chunk, and the format of every new chunk appended to the
music_pipe.
2009-03-08 13:45:24 +01:00
Max Kellermann
359f9871b2 output_thread: print "closed" debug message 2009-03-08 04:13:55 +01:00
Max Kellermann
ab656a52da alsa: determine buffer_time if not already known
This patch fixes a theoretical (but practically impossible) flaw: the
variable "buffer_time" may be uninitialized when it is used.
Initialize the variable with snd_pcm_hw_params_get_buffer_time().
2009-03-08 04:11:30 +01:00
Max Kellermann
554a34fb95 alsa: better period_time default value for high sample rates
The default values for buffer_time and period_time were both capped by
the hardware limits on practically all chips.  The result was a
period_time which was half as big as the buffer_time.  On some chips,
this led to lots of underruns when using a high sample rate (192 kHz),
because MPD had very little time to send new samples to ALSA.

A period time which is one fourth of the buffer time turned out to be
much better.  If no period_time is configured, see how much
buffer_time the hardware accepts, and try to configure one fourth of
it as period_time, instead of hard-coding the default period_time
value.

This is yet another attempt to provide a solution which is valid for
all sound chips.  Using the SND_PCM_NONBLOCK flag also seemed to solve
the underruns, but put a lot more CPU load to MPD.
2009-03-08 03:55:01 +01:00
Max Kellermann
27193d8402 output_all: fix boolean short circuit in update()
Sometimes, audio_output_update() isn't called for the second device
when the first one has succeeded.  The patch
"audio_output_all_update() returns bool" broke it, because the boolean
evaluation ended after the first "true".
2009-03-07 23:48:28 +01:00
Max Kellermann
fc6d836a2d player_thread: moved code to player_check_decoder_startup() 2009-03-07 23:11:43 +01:00
Max Kellermann
bd6bcfb676 music_pipe: refuse to push empty chunks
Added two assertions.
2009-03-07 21:41:25 +01:00
Max Kellermann
85cc46ad6f decoder_internal: don't push empty chunk into pipe
When the decoder chunk is empty in decoder_flush_chunk(), don't push
it into the music pipe - return it to the music buffer instead.  An
empty chunk in the pipe wastes resources for no advantage.
2009-03-07 21:41:23 +01:00
Max Kellermann
eb2e3a554d chunk: added music_chunk_is_empty() 2009-03-07 21:40:27 +01:00
Max Kellermann
f8aebc52b5 music_pipe: poison music_chunk.next
The value of music_chunk.next is undefined for a chunk returned by
music_pipe_shift().  For more pedantic debugging, poison the reference
before returning the chunk.
2009-03-07 21:40:13 +01:00
Max Kellermann
39d3521956 music_pipe: added music_pipe_peek()
music_pipe_peek() is similar to music_pipe_shift(), but doesn't remove
the chunk.  This allows it to be used with a "const" music_pipe.
2009-03-07 19:56:31 +01:00
Max Kellermann
b13cd03f75 output_all: audio_output_all_update() returns bool
audio_output_all_update() returns true when there is at least open
output device which is open.
2009-03-07 19:55:57 +01:00
David Guibert
498ec26f25 pulse_mixer: allow mpd to reconnect to the pulse mixer
This patch follows the commit 21bb10f4b.

>From Max Kellermann:
> I removed the daemonization changes in main.c.  Please explain why you
> changed that.  If you need it for some reason, make that a separate
> patch with a good description of your rationale.

> That's the biggest flaw of your code: it opens the mixer device in the
> init() method, while the open() method is empty.  When the pulse
> daemon is not available (either during MPD startup or when it dies
> while MPD runs), the plugin will not even attempt to reconnect to
> pulse.  Please move the code to the open() method, to make that work.

I changed the daemonize call as the fork losts the connection to the
pulse server. According to your remark, the init() method should be
moved to the open() ones.

With the modification, mpd is able to reconnect the pulse mixer after
restarting the pulseaudio daemon.

Signed-off-by: David Guibert <david.guibert@gmail.com>
Signed-off-by: Max Kellermann <max@duempel.org>
2009-03-07 19:55:09 +01:00
Max Kellermann
5ffb2dd88c pulse_mixer: added missing copyright header 2009-03-07 15:59:29 +01:00
Max Kellermann
b1137fe81a pulse_mixer: added GLib log domain
Shorten some log messages, let GLib add the "pulse_mixer" prefix.
2009-03-07 15:59:26 +01:00
Max Kellermann
6069cafda0 pulse: clean up includes
Don't include output_api.h - this is not an output plugin.  Added
missing explicit conf.h and string.h includes.
2009-03-07 15:59:22 +01:00
David Guibert
21bb10f4bf pulse mixer
This patch introduces the mixer for the pulse output.

Technically speaking, the pulse index is needed to get or set
the volume. You must define callback fonctions to get this index since
the pulse output in mpd is done using the simpe api. The pulse simple api
does not provide the index of the newly defined output.

So callback fonctions are associated to the pulse context.
The list of all the sink input is then retreived.
Then we select the name of the mpd pulse output and control
its volume by its associated index number.

Signed-off-by: Patrice Linel <patnathanael@gmail.com>
Signed-off-by: David Guibert <david.guibert@gmail.com>

[mk: fixed whitespace errors and broke long lines; removed
daemonization changes from main.c]
2009-03-07 15:59:20 +01:00
Max Kellermann
a547d24eb2 mixer: check for init() failures
When the init() method of a mixer plugin fails, mixer_new()
dereferences the NULL pointer.
2009-03-07 15:50:26 +01:00
Max Kellermann
5e0acec118 curl: reverse GLIB_CHECK_VERSION()
The GLIB_CHECK_VERSION() macro was used improperly, which broke build
on GLib < 2.14.  Add a "!" for negation.
2009-03-06 15:42:33 +01:00
Max Kellermann
4c3ce9ef1c socket_util: check if IN6_IS_ADDR_V4MAPPED is defined
On some systems, the macro IN6_IS_ADDR_V4MAPPED() is not available.
Don't try to convert IPv6 to their IPV4 equivalents in this case.
2009-03-06 10:09:10 +01:00
Max Kellermann
01cf7feac7 pipe: added music_buffer, rewrite music_pipe
Turn the music_pipe into a simple music_chunk queue.  The music_chunk
allocation code is moved to music_buffer, and is now managed with a
linked list instead of a ring buffer.  Two separate music_pipe objects
are used by the decoder for the "current" and the "next" song, which
greatly simplifies the cross-fading code.
2009-03-06 00:42:03 +01:00
Max Kellermann
000b2d4f3a music_pipe: added music_pipe_push()
Added music_pipe_allocate(), music_pipe_push() and
music_pipe_cancel().  Those functions allow the caller (decoder thread
in this case) to do its own chunk management.  The functions
music_pipe_flush() and music_pipe_tag() can now be removed.
2009-03-06 00:42:01 +01:00
Max Kellermann
10be8a8714 playlist_control: fix requeue after seek
The queue update after a seek was wrong: the queued song is cleared by
a successful seek.  This caused queue/cross-fading problems after a
seek.
2009-03-06 00:41:59 +01:00
Max Kellermann
b0fcce65d8 flac: explicitly check for STOP command
After the decoder command was obtained, don't wait until libflac
detects EOF (as a side effect), quit the decoder immediately.  This
check was missing completely.
2009-03-05 18:20:43 +01:00
Max Kellermann
efd606337e flac: check command after flac_process_single() failure
When the MPD core sends the decoder a command while
flac_process_single() is executed, this function fails.  Abort the
decoder only if not seeking.  This fixes a seeking bug.
2009-03-05 18:20:41 +01:00
Max Kellermann
74a2813d78 music_chunk: added music_chunk_write(), music_chunk_expand()
Moved some code from music_pipe_write() and music_pipe_expand().  Only
music_chunk.c should access the music_chunk internals.
2009-03-05 17:37:11 +01:00
Max Kellermann
c655f804a9 music_pipe: moved struct music_chunk to chunk.h 2009-03-03 22:23:25 +01:00
Max Kellermann
1063c1f2e3 alsa: log period and buffer size
Log the real period and buffer size.  This might be useful when
debugging xruns.  Note that the same information is available in
/proc/asound/card*/pcm*p/sub*/hw_params
2009-03-03 22:19:37 +01:00
Avuton Olrich
3e5a445467 ls: Print output of supported uri to fp rather than stdout.
Since there are no other callers than stdout, this wouldn't be a
problem, but since there maybe in the future go ahead and fix it.
2009-03-03 13:12:39 -08:00
Viliam Mateicka
3b76ca7186 ffmpeg: fix version comparision for av_get_bits_per_sample_format() implemetation
function was implemented in the version we are comparing to so there must be higher or equal
2009-03-03 21:30:55 +01:00
Viliam Mateicka
c89482de65 ffmpeg: support for new metadata api 2009-03-03 21:30:46 +01:00
Avuton Olrich
e7f034dcef cmdline: Print available protocols when --version is run. 2009-03-03 21:25:19 +01:00
Max Kellermann
0f64e658fd alsa: fall back to 32 bit samples if 16 is not supported
There are a few high-end devices (e.g. ICE1724) which cannot even play
16 bit audio.  Try the 32 bit fallback, which we already implemented
for 24 bit.
2009-03-03 09:38:20 +01:00
Eric Wollesen
b8ebb748c9 Add sticker list command.
[mk: merged memory leak patch; fixed indentation (tabs); fixed
documentation typo]
2009-03-03 07:49:23 +01:00
Max Kellermann
4220e6b0ad input_lastfm: new input plugin for last.fm radio
The lastfm input plugin enables MPD to play lastfm:// URLs.  This
plugin is not complete yet: it plays only the first song in the
last.fm playlist, and the playlist parser isn't even implemented
properly.
2009-03-02 23:11:31 +01:00
Max Kellermann
cfb350f4f0 input: pass config_param to input_plugin.init()
Allow input plugins to configure with an "input" block in mpd.conf.
Also allow the user to disable a plugin completely.
2009-03-02 23:08:17 +01:00
Max Kellermann
9a350acf04 input_plugin: added methods init(), finish()
Instead of hard-coding the plugin global initialization in
input_stream_global_init(), make it walk the plugin list and
initialize all plugins.
2009-03-02 20:45:50 +01:00
Max Kellermann
36d24fb7ea input: moved plugins to ./src/input/
Create a sub directory for input plugins.
2009-03-02 20:40:31 +01:00
Max Kellermann
2e51365ea4 input_stream: moved struct input_plugin to input_plugin.h
Start to separate private from public input_stream API.
2009-03-02 20:13:08 +01:00
Viliam Mateicka
8694574f63 ffmpeg: use ffmpeg's sampleformat for output format 2009-03-02 20:12:36 +01:00
Viliam Mateicka
60a5b5562b fixing unused parameter warning 2009-03-02 19:00:21 +01:00
Viliam Mateicka
57d836da49 fixing unsigned to signed comparision
[mk: cast off_t to uint32_t; same fix for aiff.c]
2009-03-02 18:59:59 +01:00
Viliam Mateicka
406b0403a5 mixer: adding code to optionally disable all hw mixers 2009-03-02 18:57:49 +01:00
Max Kellermann
2f438e5d23 tag_id3: parse ID3 tags in AIFF files
Added a small AIFF parser library, code copied from the RIFF parser
(big-endian integers).  Look for an "ID3" chunk, and let libid3tag
parse it.
2009-03-02 18:12:44 +01:00
Max Kellermann
336f624277 tag_id3: parse ID3 tags in RIFF/WAV files
Added a small RIFF parser library.  Look for an "id3" chunk, and let
libid3tag parse it.
2009-03-02 18:00:46 +01:00
Max Kellermann
72176db429 alsa: fall back to 32 bit samples if 24 is not supported
Some sound chips/drivers (e.g. Intel HDA) don't support 24 bit
samples, they want to get 32 bit instead.  Now that MPD's PCM library
supports 32 bit, add a 32 bit fallback when 24 bit is not supported.
2009-03-02 16:41:38 +01:00
Max Kellermann
a5a15beac2 pcm_convert: added 32 bit support
All PCM sub libraries have 32 bit support now.  Add support to the
glue function pcm_convert().
2009-03-02 16:41:10 +01:00
Max Kellermann
3165e26f9a pcm_format: added conversion from 32 bit
Support converting 32 bit samples to any other supported sample
format.
2009-03-02 16:41:08 +01:00
Max Kellermann
d4e4c57b8d pcm_format: added pcm_convert_to_32()
Added code to convert all other sample formats to 32 bit.
2009-03-02 16:39:54 +01:00
Max Kellermann
d24f2ba5ee pcm_dither: added pcm_dither_32_to_16()
For 32 bit dithering, reuse the 24 bit dithering code, but apply a 8
bit right shift first.
2009-03-02 16:37:11 +01:00
Max Kellermann
78e08f655a pcm_dither: renamed struct pcm_dither_24 to struct pcm_dither
There is nothing 24 bit specific in the pcm_dither_24 struct.  Since
we want to reuse the struct for 32 bit dithering, let's drop the "_24"
suffix from the struct name.
2009-03-02 16:37:05 +01:00
Max Kellermann
d9c1434298 pcm_resample: use 24 bit resampling code for 32 bit samples
Resampling 32 bit samples is the same as resampling 24 bit samples -
both are stored in the int32_t type.
2009-03-02 16:37:00 +01:00
Max Kellermann
1b31f52285 pcm_channels: added implementation for 32 bit samples
Some 24 bit code can be reused.  The 32 bit variant has to use 64 bit
integers, because 32 bit integers could overflow.  This may be a
performance hit on 32 bit CPUs.
2009-03-02 16:36:49 +01:00
Max Kellermann
062f37071c audio_format: allow 32 bit samples
This is the first patch in a series to enable 32 bit audio samples in
MPD.  32 bit samples are more tricky than 24 bit samples, because the
integer may overflow when you operate on a sample.
2009-03-02 15:46:09 +01:00
Max Kellermann
8c0bce0b94 audio_format: allow up to 8 channels
audio_valid_sample_format() verifies the number of channels.  Let's
just say up to 8 channels is allowed (which is possible with some
consumer sound chips).  I don't know if there are bigger cards, and
since I cannot test it, I'll limit it to 8 for now.
2009-03-02 15:43:45 +01:00
Max Kellermann
a1561252d0 directory: directory_load() returns GError
Do error reporting with GLib's GError library in this library, too.
2009-03-02 15:42:42 +01:00
Max Kellermann
c0ffec2fd1 database: db_load() returns GError
Do error reporting with GLib's GError library.
2009-03-02 15:42:21 +01:00
Max Kellermann
eb5b3ce553 database: no CamelCase
Renamed a bunch of variables.
2009-03-02 15:41:44 +01:00
Max Kellermann
b7bfa24f22 pcm_volume: return bool
Don't abort MPD when a sample format is not supported by pcm_volume().
2009-03-02 09:42:16 +01:00
Max Kellermann
0579b6ed27 pcm_volume: no CamelCase 2009-03-01 20:11:41 +01:00
Max Kellermann
4194f4b18b audio_parser: added API documentation 2009-03-01 20:08:48 +01:00
Max Kellermann
f48c58d17b crossfade: fix doxygen tag 2009-03-01 20:05:27 +01:00
Max Kellermann
ba3a8474b6 flac: parse stream tags
Parse the vorbis comments in libflac's metadata_callback and pass them
as tag struct to the decoder API.
2009-03-01 14:07:23 +01:00
Max Kellermann
92db09fdf8 listen: return GError on "unix path too long"
When the unix domain socket path is too long, don't abort with
g_error().
2009-03-01 13:35:44 +01:00
Max Kellermann
f2664e329f listen: removed unused macro BINDERROR() 2009-03-01 13:34:44 +01:00
Max Kellermann
d399d4b63b output_init: removed getBlockParam()
Use config_get_block_string() and manual GError handling instead.
2009-03-01 13:32:42 +01:00
Max Kellermann
f298fcf3a6 output_init: return GError on error
Do error handling with GError instead of aborting with g_error().
2009-03-01 13:31:56 +01:00
Max Kellermann
cb942eeb45 output_init: moved code to audio_output_detect() 2009-03-01 13:31:32 +01:00
Max Kellermann
af66f666c6 audiofile: added 24 bit support
Don't hard code the "bits" parameter to 16.  Try to use the input's
sample format, if possible.
2009-03-01 10:53:46 +01:00
Max Kellermann
614fe8b341 output: removed duplicate debug messages from plugins
The MPD core logs the audio format of all audio outputs.  Remove the
duplicate message from the plugins.
2009-03-01 10:39:42 +01:00
Max Kellermann
e1b79479a5 output_thread: log audio format in a debug message
To aid debugging, print the audio format of the output plugin in a
debug message, and print information about PCM conversion.
2009-03-01 10:37:26 +01:00
Max Kellermann
a81a84eaa4 decoder_api: log audio format in a debug message
To aid debugging, print the audio format of the decoder plugin in a
debug message, and print information about PCM conversion.
2009-03-01 10:31:47 +01:00
Max Kellermann
c0e61687b6 listen: fix windows specific code
During the listen_add_host() API transition, the windows code wasn't
tested, and several removed arguments are still in use there.
2009-03-01 01:49:49 +01:00
Max Kellermann
8c3df4cc83 socket_util: include ws2tcpip.h for getnameinfo()
Windows doesn't have the standard headers sys/socket.h and netdb.h.
2009-03-01 01:35:54 +01:00
Max Kellermann
eb64f6542f daemon: disable daemonize_detach() on WIN32 2009-03-01 01:35:53 +01:00
Max Kellermann
80571d1b5a tag: convert ignore_tag_items to a bool array 2009-03-01 00:58:32 +01:00
Max Kellermann
6153c86bc3 tag: added API documentation 2009-03-01 00:55:20 +01:00
Max Kellermann
b49518c636 tag: no CamelCase
Renamed functions and variables.
2009-03-01 00:52:02 +01:00
Max Kellermann
ae87abae59 use GLIB_CHECK_VERSION()
Use GLIB_CHECK_VERSION() instead of manually checking
GLIB_MAJOR_VERSION, ...
2009-03-01 00:37:22 +01:00
Max Kellermann
82b081a6db volume: throttle access to hardware mixers
On some hardware, reading the mixer value from hardware is an
expensive operation, and MPD has to do it for every client.  Throttle
access to the hardware, cache the result for one second.
2009-02-28 21:12:15 +01:00
Max Kellermann
ec4fd9fd88 output: use GTimer instead of time_t for reopen after failure
time() is not a monotonic timer, and MPD might get confused by clock
skews.  clock_gettime() provides a monotonic clock, but is not
portable to non-POSIX systems (i.e. Windows).  This patch uses GLib's
GTimer API, which aims to be portable.
2009-02-28 20:43:23 +01:00
Max Kellermann
a5c09c91c4 output: added option to disable audio outputs by default
The option "enabled" is on by default.  If you specify "enabled no" in
an audio_output section, then this device is disabled by default.
2009-02-28 19:40:39 +01:00
Max Kellermann
d29db0111c audiofile: removed duplicate decoder_get_command() calls
decoder_data() returns a decoder_command, no need to call
decoder_get_command() twice after decoder_command().
2009-02-28 19:28:38 +01:00
Max Kellermann
0813092c63 audiofile: refuse to play non-seekable files
If an input_stream is not seekable, libaudiofile fails to play at all:

 Audio File Library: unrecognized audio file format [error 0]

Since we know in advance whether the input_stream is seekable, just
refuse to play on a non-seekable stream.
2009-02-28 19:24:40 +01:00
Max Kellermann
44b55bff89 audiofile: no CamelCase
Renamed several variables and a function.
2009-02-28 19:09:54 +01:00
Max Kellermann
4a2b315ab6 tag: moved APE code to tag_ape.c 2009-02-28 16:44:41 +01:00
Michal Nazarewicz
cabbf7ab4a pipe: new audio output plugin which runs a command
[mk: adapted to new output plugin API]
2009-02-28 16:11:59 +01:00
Max Kellermann
5ea8a0df3f decoder_list: print decoder list with suffixes
Print the list of suffixes supported by each decoder, instead of
prining a list of all suffixes of all decoders with duplicates.
2009-02-28 15:29:51 +01:00
Max Kellermann
1bb0124b77 listen: allocate sockaddr_storage struct for accept()
The generic sockaddr struct is too small for some addresses.  For
accept(), we have to allocate a sockaddr_storage struct on the stack,
which is large enough for all addresses.
2009-02-28 15:20:35 +01:00
Max Kellermann
5c10d2ded7 client: use sockaddr_to_string()
Removed the sockaddr_to_tmp_string() hack, use
the new function sockaddr_to_string() instead.
2009-02-28 15:20:35 +01:00
Max Kellermann
e085deb944 socket_util: unpack V4MAPPED addresses
Unpack IPv4 addresses which are packed inside an IPv6 address,
i.e. return "127.0.0.1" rather than "::ffff:127.0.0.1".
2009-02-28 15:20:33 +01:00
Max Kellermann
b55d9fcdb8 socket_util: added function sockaddr_to_string()
Create the socket_util.c library, the first function is
sockaddr_to_string(): it converts a sockaddr struct to a string
containing the IP address in a human-readable form.
2009-02-28 15:12:24 +01:00
Max Kellermann
0fcb7dc65c update: use G_FILE_TEST_IS_REGULAR for archive files
When checking whether database entries have been deleted, don't check
if an archive file is a directory (G_FILE_TEST_IS_DIR), use
G_FILE_TEST_IS_REGULAR for this case instead.  To determine if a
"struct directory" is an archive, check for device==DEVICE_INARCHIVE.
This is always false after loading the database, so this patch is not
complete yet.
2009-02-28 14:02:08 +01:00
Max Kellermann
83b1b0ff69 update: don't update unchanged archive
When the mtime of an archive time hasn't changed, don't update it
again.
2009-02-28 14:02:03 +01:00
Max Kellermann
2aebbf8460 directory: added "mtime" property
Remember the modification time of each directory.  This is important
for archives (which are virtual directories right now), but may also
be useful for an automatic update mechanism.
2009-02-28 14:02:00 +01:00
Max Kellermann
3d6e6416e5 update: moved code to update_archive_file()
Simplify the rather large function update_regular_file().
2009-02-28 14:01:33 +01:00
Max Kellermann
7473fa0f4e directory: moved DIRECTORY_* string constants
Moved some of them to to directory_save.c, and others to database.c.
2009-02-27 19:30:16 +01:00
Max Kellermann
eae0287466 song_print: hide HTTP password in playlist
Added the uri_remove_auth() library function which strips username
and password from a HTTP URI, and use it in song_print_url().  This
allows you to add HTTP URIs to the playlist including secret username
and password, without disclosing it to all MPD clients.
2009-02-27 19:20:11 +01:00
Max Kellermann
9dd00dfab7 client: removed duplicate "client" string from log
Since we introduced a GLib logging domain, the "client" string appears
twice in the log lines:

 client: client 0: command returned 0

Removed the second one, now it looks like this:

 client: [0] command returned 0

Still not quite good, but better than before.
2009-02-27 19:03:13 +01:00
Max Kellermann
53271e8ae7 update: print error when opendir() fails
MPD used to be silent when it could stat() a directory, but could not
opendir() it to read its contents.  This caused a lot of support
headache with users who have wrong file permissions.  Add another
warning message.
2009-02-27 09:05:58 +01:00
Max Kellermann
497c0b1c18 tag: don't accept invalid UTF-8 sequences
Overwrite invalid UTF-8 sequences with question marks.
2009-02-27 09:02:32 +01:00
Max Kellermann
c1ab2d06aa tag: make tag.num_items unsigned
There's no point in declaring num_items as a uint8_t, it doesn't save
any space, due to padding.  This allows us to lift the articial "255
items" limitation.
2009-02-27 09:02:13 +01:00
Max Kellermann
75c2029b1c tag: no CamelCase
Renamed numOfItems to num_items.
2009-02-27 09:01:55 +01:00
Max Kellermann
5b07cbf0b4 tag: make tag_equal() return bool 2009-02-27 08:06:59 +01:00
Max Kellermann
bcdf947afc player_thread: removed meaningless warning on output failure
The warning message "problems opening audio device while playing ..."
does not help at all, and should be removed.  At this point, the real
error message has already been logged by the output thread.
2009-02-26 22:21:35 +01:00
Max Kellermann
9e61c0503e output_all: print a warning when all outputs are disabled
When all outputs are disabled, MPD printed only a meaningless message
"problems opening audio device", although it didn't attempt to open a
device.
2009-02-26 22:21:32 +01:00
Max Kellermann
58c201ce14 output_all: removed "audio_outputs!=NULL" check
After initialization, audio_outputs is always non-NULL.  Don't check
that.
2009-02-26 22:14:54 +01:00
Max Kellermann
dfea6b7cdd mvp: fixed default device detection
The check "open()!=0" is wrong, you have to write "open()>=0", because
-1 means error, and 0 is a valid file handle.
2009-02-26 22:10:58 +01:00
Max Kellermann
ec926539a3 output_plugin: report errors with GError
Use GLib's GError library for reporting output device failures.

Note that some init() methods don't clean up properly after a failure,
but that's ok for now, because the MPD core will abort anyway.
2009-02-26 22:04:59 +01:00
Max Kellermann
353ae5e558 osx: use OSStatus and GetMacOSStatusCommentString()
The return type of most OS X functions is OSStatus, not int.  We can
get a nice error message from GetMacOSStatusCommentString(), log it.
2009-02-26 22:01:42 +01:00
Max Kellermann
9dc966041d osx: start the audio device in the open() method
Don't call AudioOutputUnitStart() in the play() method, do it after
the device has been opened.  We can eliminate the "started" property
now, because the device is always started when it's open.
2009-02-26 21:40:22 +01:00
Max Kellermann
fb5ca6aa29 osx: removed commented code
We don't need to keep commented code forever.  If we want that
test_default_device() implementation back one day, we'll pick it from
the git history.
2009-02-26 21:33:13 +01:00