Commit Graph

84 Commits

Author SHA1 Message Date
Max Kellermann
54889c72e3 pcm_convert: use GError for error handling
Don't abort the whole MPD process when the conversion fails.  This has
been a denial-of-service attack vector for years.
2009-07-23 12:01:03 +02:00
Daniel Seuthe
4ffd9bce5a Preamp for missing replay-gain 2009-06-25 08:36:35 +02:00
Max Kellermann
f4966ba42c decoder_api: removed dc.pipe assertion from decoder_read()
Database update was broken due to the dc.pipe!=NULL assertion.  This
assertion is only valid while MPD decodes a song, not during database
update.
2009-04-26 10:57:02 +02:00
Max Kellermann
ceb00f787e decoder: added assertions on dc.pipe
dc.pipe must be non-NULL while the decoder thread is running.  Ensure
that with a load of assertions.
2009-04-25 15:07:22 +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
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
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
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
adea76a6ed decoder_api: fixed shadow warning, rename "wait"
The parameter name "wait" overlaps with the POSIX wait() function.
Rename it.
2009-02-19 13:33:06 +01:00
Max Kellermann
e7131b5da2 utils: use g_usleep() instead of my_usleep()
Now that I've found this nice function in the GLib docs, we can
finally remove our custom sleep function.  Still all those callers of
g_usleep() have to be migrated one day to use events, instead of
regular polling.
2009-02-19 13:33:03 +01:00
Max Kellermann
a28287073b decoder_api: moved struct decoder_plugin to decoder_plugin.h
The decoder_plugin struct is used by both the MPD core and the decoder
plugin implementations.  Move it to a shared header file, to minimize
header dependencies.
2009-02-15 17:48:37 +01:00
Max Kellermann
7f3be96efa decoder_api: always notify_wait() for free chunks
One of the previous patches made MPD consume 100% CPU in a busy wait:
when the music_pipe was full, it did not wait (with notify_wait()) for
free chunks, because a variable has a different meaning now.  Always
pass "true" as the "wait" parameter.
2009-01-17 15:23:57 +01:00
Max Kellermann
43eefe9c41 decoder_api: pass const pointer to decoder_data() 2009-01-17 13:23:12 +01:00
Max Kellermann
356526457c pcm_convert: return PCM buffer from pcm_convert()
Removed yet another superfluous buffer layer: return the PCM buffer
from pcm_convert() instead of copying PCM data into the
caller-supplied buffer.
2009-01-17 13:11:16 +01:00
Max Kellermann
610e79500e decoder_api: use music_pipe_write() instead of music_pipe_append()
Copy PCM data to the music_pipe_write() buffer, and apply replay gain
/ normalization to it, instead of manipulating the source buffer.
2009-01-17 13:11:10 +01:00
Max Kellermann
da6f8c270a decoder_api: added assertion on partial frames
Decoder plugins must not send partial frames.
2009-01-16 18:53:32 +01:00
Max Kellermann
8fe867c71d decoder_api: added G_GNUC_UNUSED attribute to decoder_initialized()
In NDEBUG, the parameter "decoder" is not used.
2009-01-15 08:33:32 +01:00
Max Kellermann
d82061b7ff decoder_api: don't ignore DECODE_COMMAND_STOP
When the decoder thread is waiting for free chunks in the music pipe,
don't ignore the STOP command.  Just return dc.command without further
checks.
2009-01-13 18:15:25 +01:00
Max Kellermann
7f34e9410e pcm: added pcm_convert_deinit(), pcm_resample_deinit()
Free memory allocated by libsamplerate when the output or the decoder
is closed.
2009-01-07 22:20:30 +01:00
Max Kellermann
fed719197c song: allocate the result of song_get_url() 2009-01-04 19:09:34 +01:00
Max Kellermann
700bd44fda input_stream: added tag() method
The tag() method reads a tag from the stream.  This replaces the
meta_name and meta_title attributes.
2009-01-03 23:29:45 +01:00
Max Kellermann
149f4e10cf decoder_api: moved code to do_send_tag(), free temporary tag
This patch fixes a minor memory leak: when decoder_tag() attempted to
send a merged tag object (created by tag_add_stream_tags()), and was
interrupted by a decoder command, it did not free the temporary merged
tag object.
2009-01-03 23:28:51 +01:00
Max Kellermann
2d6f469091 decoder_api: use GLib instead of utils.h 2009-01-03 14:51:28 +01:00
Max Kellermann
0d9d82a932 pcm_utils: check pcm_convert()==0
It is illegal to pass an empty audio buffer around.  pcm_resample()
sometimes seems to result in 0 samples, maybe related to
libsamplerate.  To work around that problem, add special checks after
both pcm_convert() invocations.  Removed the pcm_resample()==0 checks
from pcm_convert().
2008-12-24 03:08:39 +01:00
Thomas Jansen
7c7b0431fe decoder_api.c: replaced mpd_unused by G_GNUC_UNUSED 2008-11-24 14:32:53 +01:00
Max Kellermann
976d5045c6 decoder: check audio_format_valid() in all decoders
Refuse to play audio formats which are not supported by MPD.
2008-11-21 20:27:30 +01:00
Max Kellermann
774417f12f decoder: ignore decoder_data() calls with length==0
Pushing buffers with a zero length into the MPD core causes failures;
don't let them pass beyond the decoder plugi API.
2008-11-21 20:26:57 +01:00
Max Kellermann
362ca300d6 decoder: pass the correct buffer length to pcm_convert()
When a global audio format is configured (setting
"audio_output_format"), decoder_data() overwrote the "length"
parameter with the size of the output buffer (result of
pcm_convert_size()).  Declare a separate variable for the output
buffer length.
2008-11-18 22:45:51 +01:00
Max Kellermann
acfba02310 decoder: check length==0 in decoder_read()
When the caller passes length==0, decoder_read() entered an endless
loop.  Check that condition before entering the "while" loop.
2008-11-15 19:27:30 +01:00
Max Kellermann
2dacd16b5b decoder: additional dc.command checks in decoder_data()
When a command is sent while the decoder waits for a free chunk in the
music pipe, it was not returned by decoder_data().
2008-11-13 14:43:19 +01:00
Max Kellermann
2860b1b60f decoder: wait for the player only if the music pipe is full
Prevent superfluous wakeups and a deadlock condition.
2008-11-13 02:54:56 +01:00
Max Kellermann
1a3945b563 decoder: check dc.command at the beginning of decoder_data()
Seeking was somewhat broken in some decoder plugins because they sent
empty chunks, and never got a command.  Check the decoder command
before doing anything else in decoder_data().
2008-11-13 02:42:40 +01:00
Max Kellermann
998d9a8225 decoder: ignore SEEK commands during initialization
When the decoder receives a SEEK during initialization, it should
ignore that for now.  The old code made most decoders abort.
2008-11-13 02:06:55 +01:00
Max Kellermann
114b3c1e78 replay_gain: no CamelCase
Renamed functions and variables.
2008-11-11 15:55:34 +01:00
Max Kellermann
130659e856 decoder: fixed assertion failure for decoder==NULL in decoder_read()
The assertion on dc.state in decoder_read() was too strict: when a
decoder tried to call decoder_read() from tag_dup(), the decoder state
was NONE.  Allow this special case.
2008-11-11 15:55:28 +01:00
Max Kellermann
84b540f435 decoder: added more assertions
Added a lot of assertions checking the state of the decoder plugin.
2008-11-10 15:02:26 +01:00
Max Kellermann
863badd91e decoder: no CamelCase
Renamed variables and functions.
2008-11-03 21:43:02 +01:00
Max Kellermann
b3dfcfef52 decoder_api: send song tag in decoder_data()
Before passing the first chunk to the audio output device, send the
current song's tag.
2008-11-03 20:20:09 +01:00
Max Kellermann
ac96022c1d decoder_api: automatically send stream tag
If an input stream provides tags (e.g. from an icecast server), send
them in the decoder_data() and decoder_tag() methods.  Removed the
according code from the mp3 and oggvorbis plugins - decoders shouldn't
have to care about stream tags.

This patch also adds the missing decoder_tag() invocation to the mp3
plugin.
2008-11-03 18:24:01 +01:00
Max Kellermann
b9d456a041 decoder_api: no CamelCase
Renamed variables.
2008-11-03 17:56:41 +01:00
Max Kellermann
020c04e702 decoder_api: added decoder_tag()
Provide an API for submitting additional tags from the stream.
2008-11-02 17:02:28 +01:00
Max Kellermann
c9e15bc418 decoder_api: pass "seekable" flag to decoder_initialized()
Don't pass the "seekable" flag with every decoder_data() invocation.
Since that flag won't change within the file, it is enough to pass it
to decoder_initialized() once per file.
2008-11-02 17:01:51 +01:00
Max Kellermann
8b1f6ff3c8 decoder: replaced music_pipe.audioFormat with dc.out_audio_format
.. and rename dc.audioFormat to dc.in_audio_format.  The music pipe
does not need to know the audio format, and its former "audioFormat"
property indicated the format of the most recently added chunk, which
might be confusing when you are reading the oldest chunks.
2008-11-02 16:55:43 +01:00
Max Kellermann
fd0f195bb7 music_pipe: renamed ob_* functions to music_pipe_*
Rename all functions to the new prefix.
2008-11-02 14:18:34 +01:00
Max Kellermann
767b4c95bd renamed outputBuffer.[ch] to pipe.[ch]
No CamelCase in the file name.  The output_buffer struct is going to
be renamed to music_pipe.  There are so many buffer levels in MPD, and
calling this one "output buffer" is wrong, because it's not the last
buffer before the music reaches the output devices.
2008-11-02 14:12:52 +01:00
Max Kellermann
1a4a3e1f1f decoder: manage decoder list in a static array
Currently, there is no way to dynamically load decoder plugins, thus
we don't need a dynamic list to manage them.
2008-11-01 14:53:30 +01:00
Max Kellermann
62d4fa9306 decoder: use bool for return values and flags
Don't return 0/-1 on success/error, but true/false.  Instead of int,
use bool for storing flags.
2008-10-30 08:38:54 +01:00
Max Kellermann
528b7c3f5e decoder: automatically flush the output buffer after decoder exits
A decoder_flush() invocation was missing in the FLAC plugin, resulting
in casual assertion failures due to a wrong assumption about the last
chunk's audio format.  It's much easier to remove that decoder_flush()
function and make the decoder thread call ob_flush().
2008-10-29 17:29:06 +01:00
Max Kellermann
74c85811af decoder_api: make the audio_format parameter mandatory
There are no callers which pass audio_format==NULL, and it shouldn't
be allowed.
2008-10-29 17:29:03 +01:00