Commit Graph

3472 Commits

Author SHA1 Message Date
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