Commit Graph

2494 Commits

Author SHA1 Message Date
Konstantin Sobolev
23b097593e mapper: use the utf8_to_fs_charset() result
In map_directory_child_fs(), the result of utf8_to_fs_charset() was
never used, because it passed the unmodified "name" parameter to
pfx_dir().
2008-11-20 18:10:18 +01:00
Konstantin Sobolev
ddab531b4a path: fix g_convert() argument order
g_convert() wants the destination character set first.  This was mixed
up.
2008-11-20 17:48:11 +01:00
Max Kellermann
1f50146e29 ogg: check the ov_read() return value before the vorbis_info evaluation
The ov_info() return value may be corrupt when ov_read() did not
return a positive value.  First check for success, then check
ov_info().
2008-11-20 12:45:17 +01:00
Max Kellermann
a8f69429b0 input_curl: don't fail when seek to EOF is requested
HTTP servers respond with "416 Requested Range Not Satisfiable" when a
client attempts to seek to the end of the file.  Catch this special
case in input_curl_seek().  This fixes a glitch in the ogg vorbis
decoder plugin.
2008-11-20 12:45:17 +01:00
Max Kellermann
a0dd5b7f2f curl: don't check running_handles for EOF
Since we are using curl_multi_info_read() / CURLMSG_DONE for detecting
end-of-response, we can remove all running_handles==0 checks.  For
some reason, that has never worked correctly.
2008-11-20 12:42:42 +01:00
Max Kellermann
f61904db33 input_curl: always set eof=true on CURLMSG_DONE
curl_multi_info_read() is the authoritative source of the
"end-of-response" information.  Always set c->eof when a CURLMSG_DONE
message is received, and check the result (success/failure) after
that.
2008-11-20 12:41:59 +01:00
Laszlo Ashin
05f4629fa3 wavpack: redo using audio_format_frame_size()
Somehow we lost 600e1322 after renaming some variables in ed6f6046.
2008-11-19 00:02:06 +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
Viliam Mateicka
33b5015469 ffmpeg: read tags from AVFormatContext
The ffmpeg library provides some of the song metadata in the
AVFormatContext struct.  Pass it from there to MPD.
2008-11-18 20:03:00 +01:00
Viliam Mateicka
eac4ed2241 audiofile: fixed misplaced if
[mk: by definition, tag_new() cannot fail - removed check]
2008-11-18 19:54:42 +01:00
Max Kellermann
63272d6888 music_pipe: narrowed assertion on chunk index
The chunk index passed to successor() must be valid, i.e. it must be
smaller than num_chunks.
2008-11-18 19:54:39 +01:00
Max Kellermann
7591403566 input_stream: size==-1 means unknown size
Define the special value "-1" as "unknown size".  Previously, there
was no indicator for streams with unknown size, which might confuse
some decoders.
2008-11-16 20:42:08 +01:00
Max Kellermann
8882f06200 ffmpeg: fixed AVSEEK_SIZE
With whence==AVSEEK_SIZE, the seek function should return the file
size, not the current offset.  Check the return value of
input_stream_seek().
2008-11-16 20:25:31 +01:00
Max Kellermann
9c4e97a61b aac: detect whether to pass "uint32_t*" to NeAACDecInit2()
neaacdec.h declares all arguments as "unsigned long", but internally
expects uint32_t pointers.  This triggers gcc warnings on 64 bit
architectures.  To avoid that, make configure.ac detect whether we're
using Debian's corrected headers or the original libfaad headers.  In
any case, pass a pointer to an uint32_t, conditionally casted to
"unsigned long*".
2008-11-16 20:04:49 +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
Laszlo Ashin
c368a2f91c aac: fix compiler warnings on amd64 2008-11-15 11:54:22 +01:00
Laszlo Ashin
00da7db1e3 aac: don't try to free static buffer
In 432da18e a dynamic buffer was replaced by a static one but some
frees were accidently left there which caused some segfaults.
2008-11-15 11:50:25 +01:00
Max Kellermann
4a1ad61e8e log: check the log threshold in log_func()
The threshold was only checked in the deprecated logging functions
(ERROR(), WARNING(), ...).  Add the check to the GLib logging handler.
2008-11-14 18:27:11 +01:00
Max Kellermann
7720a1195a volume: eliminate alloca() usage
alloca() is not a portable function.  Don't use it.  Using
strncasecmp() is much more efficient anyway, because no memory needs
to be allocated and copied.
2008-11-14 18:15:33 +01:00
Max Kellermann
19131f1eda volume: moved code to oss_mixer_find() 2008-11-14 18:05:13 +01:00
Max Kellermann
eb199ca207 player: don't queue song when there are 2 songs in the pipe
Don't send a "next song" request to the main thread when the current
song hasn't started playing yet, i.e. there are already two different
songs in the music pipe.  This would erase information about the song
boundary within the music pipe, and thus triggered an assertion
failure.  The bug could occur when playing very short songs which fit
into the pipe as a whole.
2008-11-14 17:55:51 +01:00
Max Kellermann
418dac6f94 player: wake up decoder before waiting for xfade chunks
Fix a deadlock: when the decoder waited for buffer space, the player
could enter a deadlock situation because it waits for more chunks for
crossfading chunks.  Signal the decoder before entering notify_wait().
2008-11-14 17:55:45 +01:00
László Áshin
440b1ea3ea wavpack: be more robust if the underlying stream is not seekable
The wavpack open function gives us an option called OPEN_STREAMING. This
provides more robust and error tolerant playback, but it automatically
disables seeking. (More exactly the wavpack lib will not return the
length information.) So, if the stream is already not seekable we can
use this option safely.
2008-11-14 15:23:18 +01:00
László Áshin
c495c6f5af wavpack: tolerate less decoded data than requested
Wavpack plugin doesn't stop decoding if a block couldn't be fully
decoded, rather it tries to go on.
2008-11-14 15:23:13 +01:00
László Áshin
ed6f60460d wavpack: renamed variables and modified coding style slightly 2008-11-14 15:21:44 +01:00
Max Kellermann
7b7340f703 mp3: fix SEEK command check after mp3_synth_and_send()
mp3 seeking was broken, because the command==SEEK check was never
reached.  Swap the command check order (==SEEK before !=NONE) to fix
that.
2008-11-13 14:43:19 +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
709640422c player: chop the tail of the music pipe after CANCEL
When a CANCEL command is received, the player should drop all chunks
of the next song.  Added new funciton music_pipe_chop() which is used
for that.
2008-11-13 02:09:33 +01:00
Max Kellermann
66ce1495f0 music_pipe: continuously check the sample format of all chunks
Provide a debug function which asserts on the sample format of all
chunks.  Call this function in each iteration of the player main loop.
2008-11-13 02:06:58 +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
1178e485cb music_pipe: check for partial frames in appended chunk
Added an additional assertion which checks partial frames in the
existing tail chunk.
2008-11-13 02:06:52 +01:00
Max Kellermann
df09075afc player: assert that there was no previous "next song chunk"
When assigning the next_song_chunk variable, it must have been empty.
If not, there may be 3 songs overlapping in the music pipe.
2008-11-13 01:57:15 +01:00
Max Kellermann
ae9bb92952 playlist: call clearPlayerQueue() only if song is queued II
This patch extends commit 35a16b99, and amends several 2 missing
checks.  It simplifies 2 more checks by merging "if" conditions.
2008-11-12 21:55:13 +01:00
Max Kellermann
93f488f034 wavpack: remove commented debug messages 2008-11-12 21:25:08 +01:00
Max Kellermann
600e132280 wavpack: calculate outsamplesize with audio_format_frame_size() 2008-11-12 21:25:02 +01:00
Max Kellermann
ef80464c0c ogg: revert "use ogg_fopen() instead of ogg_open()"
Unfortunately, ov_fopen() is not supported by libvorbis versions older
than 1.2.
2008-11-12 08:38:04 +01:00
Max Kellermann
b67a8e4d6e aac: shift the input buffer before the full check
When the buffer was full, but everything was already consumed,
fillAacBuffer() would not attempt to flush and refill it.
2008-11-12 08:32:21 +01:00
Max Kellermann
432da18e44 aac: make the input buffer static
Allocate the input buffer within the AacBuffer struct.
2008-11-12 08:29:40 +01:00
Max Kellermann
487e05c67d aac: reject SEEK commands
The aac plugin does not support seeking.  Reject SEEK requests by
calling decoder_seek_error().  Quit the plugin's main loop only when
STOP is received.
2008-11-12 08:25:09 +01:00
Max Kellermann
a9723e661a aac: get decoder command from decoder_data()
Removed a superfluous decoder_get_command() call.
2008-11-12 08:25:06 +01:00
Max Kellermann
35a4ca2421 aac: convert audio_format to temporary variable
The audio_format variable is only used and initialized for
decoder_initialized().  Move it into that block to save some bytes on
the stack.
2008-11-12 08:21:00 +01:00
Max Kellermann
39fa60769c aac: removed method file_decode()
aac_stream_decode() was basically copy+pasted from aac_decode().
Since stream_decode() can also decode files, eliminate aac_decode().
2008-11-12 08:17:50 +01:00
Max Kellermann
e19b53f814 aac: check the buffer length in the ADIF parser
Check whether enough data has been read yet.
2008-11-12 08:16:54 +01:00
Max Kellermann
b30ec73099 aac: use unsigned integers and size_t where appropriate 2008-11-12 08:16:38 +01:00
Max Kellermann
9806355d4c aac: check if the stream is seekable before length check
If the stream is not seekable, don't try to decode all frames to find
out the total song time.
2008-11-12 07:46:01 +01:00
Max Kellermann
f6765c4d8b aac: removed attribute "atEof"
Use input_stream_eof() instead.
2008-11-12 07:41:54 +01:00
Max Kellermann
eff21067f0 mpc: assume the result fo of mpc_decoder_decode() is unsigned
According to the documentation, mpc_decoder_decode() returns an
mpc_uint32_t.  Since the special return value (mpc_uint32_t)-1
translates to a very large long integer, this may cause segmentation
faults if not interpreted properly.
2008-11-12 07:14:18 +01:00
Max Kellermann
0a6f4048d0 mpc: don't assume the stream is stereo
Don't hard-code the factor "2".
2008-11-12 07:07:40 +01:00
Max Kellermann
8d1ffb1684 mpc: get decoder command from decoder_data()
Removed 3 superfluous decoder_get_command() invocations.
2008-11-12 07:07:12 +01:00
Max Kellermann
731e99c26e mpc: moved code to mpc_to_mpd_buffer()
mpc_to_mpd_buffer() converts a whole chunk at a time.  This eliminates
3 local variables in mpc_decode().
2008-11-12 07:06:47 +01:00
Max Kellermann
975d5cd77e mpc: make the buffer large enough for one mpc frame
Don't split the buffer conversion loop.  When libmpcdec returns a
chunk, convert and send the whole chunk at a time.  This moves several
checks out of the loop, and greatly improves performance.
2008-11-12 07:03:44 +01:00
Max Kellermann
865757835e mpc: use GLib instead of utils.h/log.h
Don't use deprecated MPD libraries.
2008-11-12 07:02:29 +01:00
Max Kellermann
1414a3de4c mpc: declare buffer as int32_t[]
The buffer is always casted to int32_t* anyway; declare it as int32_t
array, and remove the cast.
2008-11-12 07:02:06 +01:00
Max Kellermann
06c60888dc mpc: eliminated the local variable "eof"
Since each "eof=true" is followed by "break", the variable is
superfluous.
2008-11-11 21:39:50 +01:00
Max Kellermann
97080b796c ogg: removed stray "}"
Due to an unnoticed merge error, there was a superfluous "}".  Remove
it.
2008-11-11 21:39:31 +01:00
Max Kellermann
53c17db5e9 ogg: use ogg_fopen() instead of ogg_open()
Move the reponsibility for freeing the file handle to libvorbis.
2008-11-11 21:33:10 +01:00
Max Kellermann
448ff32c96 ogg: use GLib instead of utils.h/log.h 2008-11-11 21:33:01 +01:00
Max Kellermann
401e77b258 decoder: fixed typo in assertion
decoder_file_decode() should check for plugin->file_decode, not
plugin->stream_decode().
2008-11-11 21:23:30 +01:00
Max Kellermann
0cba1ae312 ogg: get decoder command from decoder_data()
Eliminate two decoder_get_command() invocations from the main loop.
2008-11-11 21:21:54 +01:00
Max Kellermann
7b575b55c2 ogg: flush buffer after every ov_read() call
Don't let the buffer grow until it is full, flush it whenever there is
data available.
2008-11-11 21:15:01 +01:00
Max Kellermann
67814eddff mp3: support stream tags
Parse ID3 tags, even when they are in the middle of the stream.  Very
few streams provide embedded ID3 tags.  Most of them send only
Shoutcast "icy" tags, which limits the practical usefulness of this
patch.
2008-11-11 20:53:24 +01:00
Max Kellermann
514c37b0cd mp3: eliminated duplicate command check
When a command is received, decode_next_frame_header() and
decodeNextFrame() return DECODE_BREAK.  This is already checked by
both callers, which means that we can eliminate lots of
decoder_get_command() checks.
2008-11-11 20:50:37 +01:00
Max Kellermann
1bfa6a94e2 player: fix race condition during tag update
When a tag is updated, the old tag was freed before the new one was
created.  Reverse the order to be sure that other threads always see a
valid pointer.

This still leaves a possible race condition, but it will be addressed
later.
2008-11-11 20:46:55 +01:00
Max Kellermann
acf0d141be playlist: track song metadata changes
When the tag of the current song changes (e.g. a new tag was sent in
the stream), update the playlist, so clients pick up the new tag.
2008-11-11 20:46:55 +01:00
Max Kellermann
81d2076bcf oggflac: removed the obsolete try_decode() method 2008-11-11 17:17:06 +01:00
Max Kellermann
9eed41911f decoder: return void from decode() methods
The stream_decode() and file_decode() methods returned a boolean,
indicating whether they were able to decode the song.  This is
redundant, since we already know that: if decoder_initialized() has
been called (and dc.state==DECODE), the plugin succeeded.  Change both
methods to return void.
2008-11-11 17:13:44 +01:00
Max Kellermann
05e69ac086 replay_gain: don't include os_compat.h
os_compat.h is deprecated and should be replaced with well-defined
standard headers.
2008-11-11 16:38:33 +01:00
Max Kellermann
bc1999f815 replay_gain: use GLib instead of utils.h/log.h
Eliminated deprecated libraries.
2008-11-11 16:38:26 +01:00
Max Kellermann
8a40e0b495 replay_gain: use pcm_volume() to apply replay gain
The currently replay_gain_apply() implementation duplicates code from
pcm_volume(), except that it uses a floating point scale.  Eliminate
all duplicated code from and make it utilize the pcm_volume() library
function.  This introduces replay gain support for 24 bit audio.
2008-11-11 16:38:12 +01:00
Max Kellermann
cb28487d10 pcm_utils: allow volume levels greater than 100% in pcm_volume()
Allow pcm_volume() to increase volume.
2008-11-11 16:38:10 +01:00
Max Kellermann
edcd45df94 pcm_volume: added constant PCM_VOLUME_1
It may be desirable to change the range of integer volume levels
(e.g. to 1024, which may utilize shifts instead of expensive integer
divisions).  Introduce the constant PCM_VOLUME_1 which describes the
integer value for "100% volume".  This is currently 1000.
2008-11-11 16:32:32 +01:00
Max Kellermann
ad77a3e0ac pcm_utils: added inline function pcm_float_to_volume() 2008-11-11 16:29:02 +01:00
Max Kellermann
5ddde0aac7 replay_gain: converted struct replay_gain_info elements to an array
Having an array instead of individual variables allows the use of the
replay_gain_mode enum as an array index.
2008-11-11 16:24:27 +01:00
Max Kellermann
5e686add91 wavpack: added wavpack_tag_float()
The function simplifies wavpack_replaygain(), because it already
contains the float parser, and it works with a fixed buffer instead of
doing expensive heap allocations.
2008-11-11 16:21:09 +01:00
Max Kellermann
c883d761ab wavpack: make the "key" argument to wavpack_tag() const
This allows us to remove the "static char[]" hack.
2008-11-11 16:19:29 +01:00
Max Kellermann
e2c07dbbbc ogg: ogg_getReplayGainInfo() returns replay_gain_info pointer
Some code simplification.  Avoid pointers to pointers.
2008-11-11 16:19:00 +01:00
Max Kellermann
837cefdb04 replay_gain: converted replay_gain_mode to an enum
Prefer C enums over CPP macros.
2008-11-11 16:18:31 +01:00
Max Kellermann
e9c3497cd2 replay_gain: removed superfluous author name comment
The author's name is already mentioned in the copyright declaration.
2008-11-11 15:55:34 +01:00
Max Kellermann
114b3c1e78 replay_gain: no CamelCase
Renamed functions and variables.
2008-11-11 15:55:34 +01:00
Max Kellermann
54ad08ab37 replay_gain: renamed sources to replay_gain.c, replay_gain.h
No CamelCase file names.
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
ff1acefb21 decoder: removed plugin method try_decode()
Instead of having a seprate try_decode() method, let the
stream_decode() and file_decode() methods decide whether they are able
to decode the song.
2008-11-10 15:07:01 +01:00
Max Kellermann
10eea9d981 decoder: fall back to next plugin
When a plugin is unable to decode a song, try the other plugins.
2008-11-10 15:02:47 +01:00
Max Kellermann
cad37b2e5a decoder: wrapper functions for methods stream_decode() and file_decode()
Added lots of assertions to the wrapper functions.
2008-11-10 15:02:38 +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
23a4ce4444 flac: call flac_process_metadata() for ogg files
The flac plugin wasn't initialized properly when an OGG file was being
decoded.  For some reason, flac_process_metadata() was explicitly not
called for OGG files.  Since that seems to fix the issue, make it
always call flac_process_metadata().
2008-11-10 14:49:34 +01:00
Max Kellermann
0e87f85598 flac: enable the oggflac plugin with older libflac versions
Since decoder_list.c does not include the libflac headers, it cannot
know whether to add the oggflac plugin to the decoder list.  Solve
this by always enabling the oggflac sub-plugin, even with older
libflac versions.  When the libflac API cannot support oggflac,
disable the plugin at runtime by returning "false" from its init()
method.
2008-11-10 14:39:42 +01:00
Max Kellermann
505959f74d flac: enable oggflac with libflac
The "oggflac" plugin was enabled only if HAVE_FLAC_COMMON was
defined.  HAVE_FLAC_COMMON however is only an automake variable, and
is never available in decoder_list.c.  Make decoder_list.c depend on
HAVE_FLAC||HAVE_OGGFLAC instead.
2008-11-10 14:37:37 +01:00
Daniel Schömer
1256f90825 log: properly check log_threshold 2008-11-09 22:27:58 +01:00
Max Kellermann
c9c7dc6e00 decoder: updated API documentation
Updated documentation on the stream_decode() and file_decode() return
values.
2008-11-09 22:10:48 +01:00
Max Kellermann
ab24e203cd wavpack: removed try_decode() method
Wavpack's try_decode() implementation does nothing useful, it only
duplicates code already in stream_decode() / file_decode(), and slows
down MPD.
2008-11-09 22:10:48 +01:00
Max Kellermann
b054ad0ea6 flac: make the init() method check for oggflac support
Disable flac's "oggflac" sub-plugin when libflac does not support
ogg-flac files.
2008-11-09 22:01:47 +01:00
Max Kellermann
72eba30cf4 decoder: converted dc.error to a dc.state value
The player did not care about the exact error value, it only checked
whether an error has occured.  This could fit well into
decoder_control.state - introduce a new state "DECODE_STATE_ERROR".
2008-11-08 15:48:00 +01:00
Max Kellermann
8cbdc2667e decoder: removed "plugin" from the decoder struct
decoder.plugin was a write-only attribute.
2008-11-08 13:33:44 +01:00
Laszlo Ashin
343a8a20e3 wavpack: make 24-bit samples available for mpd
This patch makes 24-bit samples available for mpd. I tested with the
WavPack Test Suite found on wavpack.com:

 http://www.rarewares.org/wavpack/test_suite.zip

Every test file worked fine.
2008-11-08 13:11:10 +01:00
Laszlo Ashin
3e338da871 wavpack: check last_byte in push_back_byte() method
At this moment the wavpack lib doesn't use the return value of the
push_back function, which has an equivalent meaning of the return
value of ungetc().  This is a lucky situation, because so far it
simply returned with 1 as a hard coded value.  From now on the
function will return EOF on error.  (This function makes exactly one
byte pushable back.)
2008-11-08 13:10:15 +01:00
Laszlo Ashin
cfd55b29bd wavpack: wrapper for converting void* to struct wavpack_input*
A new function has been added to do a cast and a little check in the
wavpack-mpd input stream wrapper.
2008-11-08 13:09:07 +01:00
Laszlo Ashin
2b4a410bb0 wavpack: put braces around one line code blocks
I think this makes the code more easily modifiable and prevents some
annoying mistakes.
2008-11-08 13:08:21 +01:00