Commit Graph

2501 Commits

Author SHA1 Message Date
Max Kellermann
cd61f6570f music_pipe: moved code to music_chunk_append() 2008-11-02 16:56:49 +01:00
Max Kellermann
e9e9d2bc2d music_pipe: renamed "ob" to "music_pipe"
Last music_pipe rename patch: renamed the global variable (singleton).
2008-11-02 16:56:09 +01:00
Max Kellermann
d430b1dc54 music_pipe: more wrapper functions
Replace all direct music_pipe struct accesses with wrapper functions.
The compiled machine code is the same, but this way, we can change
struct internals more easily.
2008-11-02 16:55:53 +01:00
Max Kellermann
260a0cc33c music_pipe: use GLib instead of utils.h
Eliminate the deprecated utils.h memory allocation functions.
2008-11-02 16:55:48 +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
30fca5e5a9 music_pipe: pass frame size to tail_chunk()
Don't make tail_chunk() calculate the frame size again.
2008-11-02 14:18:34 +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
8964c69a64 music_pipe: renamed struct output_buffer to struct music_pipe
.. and rename ob_chunk to struct music_chunk.
2008-11-02 14:15:47 +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
b48ae8c26f decoder: enable decoders even if they have no init() method
Commit 1a4a3e1f moved decoders into a static array, but failed to
enable those plugins who did not have an init() method at all.
This patch corrects the "enabled" check.
2008-11-02 13:30:26 +01:00
Max Kellermann
4c1b96c307 decoder: make the suffixes and mime_types arrays really const
The strings were constant, but the pointers weren't.  C syntax is
somewhat tricky..
2008-11-01 14:55:23 +01:00
Max Kellermann
0b614fbaae decoder: make all decoder_plugin structs const
All decoder_plugin structs are initialized at compile time, and must
never change.
2008-11-01 14:54:09 +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
5036368f54 decoder: return const decoder_plugin structs
The decoder_plugin structs must never change.  Don't work with
non-const pointers.
2008-11-01 14:51:41 +01:00
Max Kellermann
83f6222ae7 permission: store passwords in GHashTable
Eliminating the deprecated linked list library.
2008-11-01 14:33:25 +01:00
Max Kellermann
aa772ebc02 tag: use GLib instead of utils.h
Don't use the deprecated functions from utils.h.
2008-11-01 14:33:14 +01:00
Max Kellermann
35710a81ea utils: use GUINT32_FROM_LE() instead of readLEuint32()
Eliminate code already provided by GLib.
2008-11-01 14:11:19 +01:00
Max Kellermann
b996108675 tag: don't return const string from fix_utf8()
Return NULL instead of the input value if there is nothing to fix.
This way, the caller doesn't have to use the xfree() hack.
2008-11-01 14:04:15 +01:00
Max Kellermann
aa33422de6 alsa, jack: no const pointers for allocated strings
Make the pointers "device" and "name" non-const, so we don't need the
xfree() hack.  The default value is expressed as NULL.
2008-11-01 14:04:14 +01:00
Max Kellermann
9fdac529b4 path: removed sanitizePathDup()
We don't need to sanitize the path, because the mapper already checks
for malformed paths.
2008-10-31 16:50:51 +01:00
Max Kellermann
f291876772 mapper: check for "." and ".."
Make map_directory_child_fs() refuse the names "." and "..".  This is
currently the interface where an attacker may inject a manipulated
path (through the "update" command).
2008-10-31 16:48:58 +01:00
Max Kellermann
a5f8d4386c update: check return values
Nearly all mapper functions can fail and will then return NULL.  Add
checks to all callers.
2008-10-31 16:47:21 +01:00
Max Kellermann
d8e877e335 path: moved playlist_dir to mapper.c
Added the function map_spl_utf8_to_fs() which replaces
utf8_to_fs_playlist_path().
2008-10-31 16:47:14 +01:00
Max Kellermann
ef54271619 mapper: use g_warning() for logging
g_error() is fatal by default.  Use g_warning() for non-fatal
initialization errors.
2008-10-31 16:46:46 +01:00
Max Kellermann
f098db149e decoder: eliminate gotos in decodeStart()
http://xkcd.com/292/
2008-10-31 16:29:45 +01:00
Max Kellermann
a1ca32168c decoder: don't wake up player when command==NONE
If nobody sent a command, the player isn't waiting for the decoder.
Don't wake it up.
2008-10-31 16:29:39 +01:00
Max Kellermann
63682eb1b8 decoder: notify player after stop
The player should always be woken up when the decoder quits.
2008-10-31 16:29:34 +01:00
Max Kellermann
347e816247 decoder: reset state and command in decoder_task()
Eliminate one goto in decodeStart() by moving some cleanup to
decoder_task().
2008-10-31 16:29:24 +01:00
Max Kellermann
86fbac54fd decoder: introduce switch statement in decoder_task()
switch looks much nicer than if/elseif/... and gcc generates nice
warnings when a new command is added to the enum.
2008-10-31 16:29:22 +01:00
Max Kellermann
78448fe1a5 decoder_api: pass constant path pointers 2008-10-31 15:56:43 +01:00
Max Kellermann
6d6e615825 input_stream: pass const url to input_stream_open() 2008-10-31 15:50:59 +01:00
Max Kellermann
a92903983d client: use bool
Return bool instead of int.
2008-10-31 13:58:00 +01:00
Max Kellermann
6757c17689 removed UTF-8 library, use GLib instead
Removed duplicated code.
2008-10-31 13:57:10 +01:00
Alam Arias
78f60c9c6d removed unneed check for protocol in shout plugin, will assume icecast2 protocol if not exist in config 2008-10-31 12:20:49 +01:00
Max Kellermann
71fe7ad81a path: free GLib error in fs_charset_to_utf8()
g_error_free() was missing in case g_convert() failed.
2008-10-31 12:20:48 +01:00
Max Kellermann
8f9d9cc042 directory: directory_free() frees children
directory_free() should free all of its children (subdirectories and
songs).  This way, db_finish() properly frees all allocated memory.
2008-10-31 09:20:02 +01:00
Max Kellermann
ea515494cb added prefix to header macros
"LOG_H" is a macro which is also used by ffmpeg/log.h.  This is
ffmpeg's fault, because short macros should be reserved for
applications, but since it's always a good idea to choose prefixed
macro names, even for applications, we are going to do that in MPD.
2008-10-31 09:19:53 +01:00
Max Kellermann
5ef17ac1aa client: don't try again after partial write
After a partial write, chances are vanishing that another write() will
succeed.  Don't try immediately.
2008-10-31 09:19:40 +01:00
Max Kellermann
b7ee6febaa removed the sllist library
The "simple singly-linked-list" library has been replaced with GLib's
GList and GQueue.
2008-10-31 09:19:34 +01:00
Max Kellermann
94cbdffb72 client: use GQueue instead of sllist.h for deferred_send
Another custom data structore converted to GLib.
2008-10-31 09:18:11 +01:00
Max Kellermann
90e9079142 client: use GSList instead of struct strnode for command lists
Replace a custom data structure with a GLib one.
2008-10-31 09:17:56 +01:00
Max Kellermann
e5ef2d8a37 client: removed list_cache
The list cache aims to save memory allocations, and complicates the
code a bit.  We should rather use GLib slices later, which are easy to
use.
2008-10-31 09:17:52 +01:00
Max Kellermann
8f37f7c838 ogg: don't include _flac_common.h
The source _ogg_common.c does not need any symbols from
_flac_common.h, but including it leads to compiler errors when libflac
isn't available.
2008-10-31 08:52:09 +01:00
Max Kellermann
d65d6548a3 oggflac: adapt to new API
Again, I forgot to adapt oggflac to the new API (struct input_stream,
bool return values).
2008-10-31 08:52:09 +01:00
Max Kellermann
5024f0b6cc ffmpeg: pass input_stream pointer to decoder_data()
decoder_data() uses wait times to let the input stream continue its
transfer.
2008-10-30 19:09:20 +01:00
Max Kellermann
b15c4cdeb5 ffmpeg: use return value of decoder_data()
decoder_data() always returns the current command.  If we use this, we
can save a lot of decoder_get_command() calls.
2008-10-30 19:03:41 +01:00
Max Kellermann
f3b4a28518 ffmpeg: output buffer size cannot be negative
Converted the runtime check to an assertion.
2008-10-30 19:03:38 +01:00
Max Kellermann
130fc58b36 ffmpeg: break immediately after av_read_frame()
Remove one indent level.
2008-10-30 19:03:31 +01:00
Max Kellermann
5f1df0a927 ffmpeg: moved code to ffmpeg_send_frame()
Move code from ffmpeg_decode_internal() to make it smaller and more
readable.
2008-10-30 19:03:20 +01:00
Max Kellermann
048d62a628 ffmpeg: report seek errors to MPD
The decoder API provides the function decoder_seek_error() to report
seek errors.  Use this function instead of logging the error.
2008-10-30 19:02:38 +01:00
Max Kellermann
cd7a720426 ffmpeg: simplified mpdurl_read()
The function mpdurl_read() is too complicated, and uses the wrong data
types.
2008-10-30 19:02:01 +01:00
Max Kellermann
964442c5ad ffmpeg: call tag_free() instead of free()
tag objects must be freed with tag_free() to ensure that all resources
are freed.
2008-10-30 19:01:36 +01:00
Max Kellermann
25f4efcdb8 ffmpeg: eliminated local variable "tag"
The function ffmpeg_tag() already has the variable base.tag, which can
be used for this.
2008-10-30 19:01:31 +01:00
Max Kellermann
7cbd9821c6 ffmpeg: make ffmpeg_helper() return bool
ffmpeg_try_decode() did not interpret ffmpeg_helper()'s return value
properly; migrate everything to bool to make it consistent.
2008-10-30 19:01:23 +01:00
Max Kellermann
078d83ca13 ffmpeg: removed debug messages
We don't need those anymore, they just fill the log.
2008-10-30 19:01:18 +01:00
Max Kellermann
b180d0b47f ffmpeg: initialize base.decoder
ffmpeg_tag() did not initialize base.decoder, which made valgrind
unhappy, and can lead to a egmentation fault.
2008-10-30 18:08:52 +01:00
Max Kellermann
4d72bda4c3 listen: set file mode 666 on the unix socket
Depending on MPD's umask, the file permissions of the unix socket were
too restrictive, and many clients were not able to connect.  Do a
chmod(0666) on the socket, to allow everybody to connect.
2008-10-30 18:03:18 +01:00
Max Kellermann
9ec695559f pulse: fix segfault without sink name
Commit d692e9 broke configurations without explicit server or sink
configuration.  Check for getBlockParam()==NULL.
2008-10-30 17:46:56 +01:00
Max Kellermann
5f6383d68c mpc: provide 24 bit samples
Similar to libmad, libmpcdec provides samples with higher quality than
16 bit.  Send 24 bit samples to MPD, which allows MPD to apply
dithering just in case the output devices are only 16 bit capable.
2008-10-30 08:45:00 +01:00
Max Kellermann
0db07a920e mpc: moved sample size into a constant
Don't hard-code the "16 bits" or "2 bytes" in multiple locations.
2008-10-30 08:44:51 +01:00
Max Kellermann
6773dea5b0 mpc: renamed variable "s16" to "dest"
The name "s16" implies 16 bit integers.  To make the code more
generic, rename it to "dest".
2008-10-30 08:44:43 +01:00
Max Kellermann
51348d6992 mpc: fix broken integer sample conversion
The conversion of integer samples was completely broken, which
presumably didn't annoy anybody because libmpcdec provides float
samples on most installations.
2008-10-30 08:44:28 +01:00
Max Kellermann
ecd485acbd mpc: fix boolean interpretation of input_stream_seek()
When input_stream_seek() was converted to return a bool, this wasn't
adjusted in the musepack plugin.
2008-10-30 08:42:18 +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
d29bad4410 mp3: make mp3_read() return bool
Its only caller in mp3_decode() just compared its value with
DECODE_BREAK.  Convert that to bool, and return false if the loop
should be ended.  Also eliminate some superfluous command checking
code, which was already done in the preceding while loop.
2008-10-30 06:09:28 +01:00
Max Kellermann
f8722913cf output: removed audio_output.result
Since open() and play() close the device on error, we can simply check
audio_output.open instead of audio_output.result after a call.
2008-10-29 22:34:37 +01:00
Max Kellermann
7da0e005f3 output: delay reopen after device failure
When one of several output devices failed, MPD tried to reopen it
quite often, wasting a lot of resources.  This patch adds a delay:
wait 10 seconds before retrying.  This might be changed to exponential
delays later, but for now, it makes the problem go away.
2008-10-29 22:32:50 +01:00
Max Kellermann
0eae1c55ad output: moved code to audio_output_update()
Moved code from syncAudioDeviceStates() to audio_output_update().
2008-10-29 22:17:44 +01:00
Max Kellermann
678314534a output: always call cancel() before stop()
Stopping an audio output device without cancelling its buffer doesn't
make sense.  Combine the two operations, which saves several cancel
calls.
2008-10-29 22:17:42 +01:00
Max Kellermann
07bb46de88 input_file: refuse to open non-regular files
Don't allow users to open a file which is non-regular (e.g. pipes,
devices).
2008-10-29 21:11:28 +01:00
Max Kellermann
84f7d9c6b3 input_file: check fstat() failure 2008-10-29 21:11:20 +01:00
Max Kellermann
fb08213659 input_file: use GLib for logging 2008-10-29 21:11:04 +01:00
Max Kellermann
8f3d962219 log: don't use utils.h
Prefer GLib over utils.h.
2008-10-29 21:02:22 +01:00
Max Kellermann
cf376b4bc8 output: moved audioDeviceStates to audio_output.enabled 2008-10-29 20:49:51 +01:00
Max Kellermann
2f76db4c78 output: close device on play error
When an output plugin fails to play a chunk, close it.  This replaces
various manual close() calls in nearly all plugins.
2008-10-29 20:40:33 +01:00
Max Kellermann
58c5bee9f0 output: 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-29 20:40:27 +01:00
Max Kellermann
03390d8be1 audio: call closeAudioDevice() on error
Instead of implementing another loop which calls audio_output_close()
on all configured devices, simply call closeAudioDevice().
2008-10-29 20:39:56 +01:00
Max Kellermann
030238bb10 audio: removed variable "audioOpened"
This variable is never read, and can be removed.
2008-10-29 20:39:48 +01:00
Max Kellermann
b967702059 pulse: clear pa_simple pointer in pulse_close()
The pointer becomes invalid due to pa_simple_free(), which may lead to
segmentation faults when the output is reopened later.
2008-10-29 20:38:20 +01:00
Max Kellermann
d692e925a4 pulse: use GLib instead of util.h/log.h
Use GLib allocation and logging functions.
2008-10-29 20:37:36 +01:00
Max Kellermann
38df17546a pulse: no CamelCase 2008-10-29 20:37:15 +01:00
Max Kellermann
2867c8e9b1 player: handle songs shorter than the initial buffer
When the decoder exited before the buffer has grown big enough
("buffer_before_play"), the player thread waited forever.  Add an
additional check which disables buffering as soon as the decoder
exits.
2008-10-29 18:35:10 +01:00
Max Kellermann
5c4dc8d03c oss: check and override audio_format properly
Don't accept 24 bit audio.  Force MPD to use 16 bit if anything other
than 8 or 16 bit is selected.
2008-10-29 18:35:03 +01:00
Max Kellermann
c6714f1755 player: added variable "play_audio_format"
The local variable "play_audio_format" is updated every time the
player starts playing a new song.  This way, we always know exactly
which audio format is current.  The old code broke when a new song had
a different format: ob.audio_format is the format of the next song,
not of the current one - using this caused breakage for the software
volume control.
2008-10-29 17:29:30 +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
Max Kellermann
c042faab42 player: request new song only if there is no pending command
Request the next song from the playlist (by clearing pc.next_song)
only if the player command is empty.  If it is not, the player may be
clearing the song that has already been queued, leading to an
assertion failure.
2008-10-29 17:28:49 +01:00
Max Kellermann
be90199c5a decoder_api: removed decoder_clear()
Call ob_clear() in decoder_command_finished() instead of implementing
that call in every decoder plugin.
2008-10-29 17:28:47 +01:00
Max Kellermann
d6c4441c78 mp3: seek in background
Remember the seek_where argument and call decoder_command_finished()
immediately.  This way, the player thread can continue working, and we
can receive more commands.

This also fixes several issues which resulted in broken frames,
leading to erroneos "elapsed" values: frames weren't parsed properly,
since the code was checking for command!=NONE.
2008-10-29 17:22:56 +01:00
Max Kellermann
de588448df mp3: return from mp3_synth_and_send() on any command
Previously, the function would only return when a STOP was issued.  It
makes more sense to consider all possible commands.
2008-10-29 16:17:21 +01:00
Max Kellermann
6158858f82 mp3: moved code to mp3_synth_and_send()
Break the large function mp3_read() into smaller pieces.
2008-10-29 16:14:08 +01:00
Max Kellermann
e0532ae0a8 mp3: moved code to mp3_send_pcm()
Break the large function mp3_read() into smaller pieces.
2008-10-29 16:14:02 +01:00
Max Kellermann
a6ad0e4047 mp3: moved code to mp3_update_timer_next_frame()
Break the large function mp3_read() into smaller pieces.
2008-10-29 16:13:51 +01:00
Max Kellermann
0d079ee515 mp3: moved code to mp3_this_frame_offset()
Break the large function mp3_read() into smaller pieces.
2008-10-29 16:13:01 +01:00
Max Kellermann
a6f8776c94 mp3: moved code to mp3_time_to_frame()
Break the large function mp3_read() into smaller pieces.
2008-10-29 16:12:26 +01:00
Max Kellermann
ec3083948f mp3: assert that the stream is seekable
dc_seek() won't send a SEEK command to the decoder thread unless the
stream is seekable.  No need to do another check; convert that to an
assertion.
2008-10-29 16:11:16 +01:00
Max Kellermann
78b08f03f2 decoder_api: don't cast need_chunks() to int
need_chunks() returns a decoder_command enum.  Store its return value
as this type.
2008-10-29 16:11:15 +01:00
Max Kellermann
a0b57f3782 mp3: moved code to mp3_filesize_to_song_length()
The function mp3_decode_first_frame() is too large.  Move some code to
separate smaller functions.
2008-10-28 20:44:08 +01:00
Max Kellermann
898978a67d mp3: no "goto"
http://xkcd.com/292/
2008-10-28 20:43:17 +01:00
Max Kellermann
28b47725ff mp3: use GLib allocation functions
This removes the need for util.h.
2008-10-28 20:43:15 +01:00
Max Kellermann
56ebdf1cd1 mp3: use bool
Use the C99 bool data type for boolean values.
2008-10-28 20:42:33 +01:00
Max Kellermann
e4bbc120ac mp3: no CamelCase
Renamed all functions and variables.  Also removed the mp3DecodeData
typedef.
2008-10-28 20:42:01 +01:00
Max Kellermann
1f7c53e619 mp3: remove obsolete comments 2008-10-28 20:41:25 +01:00
Max Kellermann
25f98a41c4 input_file: don't use buffered I/O
Yet another superfluous buffering layer.  input_file was using FILE*,
but we're better off with unbuffered I/O using open(), read(), ...
2008-10-28 20:41:24 +01:00
Max Kellermann
0a61877702 input_stream: convert offset and size to the off_t data type
size_t and long aren't 64 bit safe (i.e. files larger than 2 GB on a
32 bit OS).  Use off_t instead, which is a 64 bit integer if compiled
with large file support.
2008-10-28 20:39:09 +01:00
Max Kellermann
016d996131 utils: use g_str_has_prefix() instead of prefixcmp()
Remove duplicated code from MPD.
2008-10-28 20:33:56 +01:00
Max Kellermann
4a71f66256 player: reset pc.command when decoder startup fails
When the decoder failed to start, the function do_play() returned,
still having pc.command==PLAY.  This is because pc.command was reset
only when the decoder started up successfully.  Add another
player_command_finished() call in the error handler.
2008-10-27 10:10:40 +01:00
Max Kellermann
0d30d51f07 input_file, input_curl: check URL type before attempting to open
Don't attempt to open a HTTP URL as a local file, and don't send a
local path to libcurl.
2008-10-27 10:10:24 +01:00
Max Kellermann
0800c6f4ca output: don't compile plugins which are disabled
Don't compile the sources of disabled output plugins at all.
2008-10-26 21:58:37 +01:00
Max Kellermann
3dac99034a dirvec: fixed GCC shadow warning
On some systems, string.h declares basename().  This emits a shadow
warning.  Change the variable name.
2008-10-26 21:28:16 +01:00
Max Kellermann
5f2384001e curl: read stream name from HTTP response headers
If the server sends the headers "icy-name", "ice-name",
"x-audiocast-name", set the stream title.
2008-10-26 21:20:02 +01:00
Max Kellermann
5d9ef0cd83 input_curl: set input_stream.mime from Content-Type response header 2008-10-26 21:19:32 +01:00
Max Kellermann
1437a56a11 input_curl: added local variable "value"
Replaced the local variable "colon" (which had only temporary meaning)
with the variable "value".  It is a pointer to the first byte of the
header value.
2008-10-26 21:12:56 +01:00
Max Kellermann
d401589edf input_stream: use g_free() in input_stream_close()
g_free() allows passing the NULL pointer.
2008-10-26 21:02:49 +01:00
Max Kellermann
5c19776f2f input_stream: use "bool" instead of "int"
For boolean values and success flags, use bool instead of integer (1/0
for true/false, 0/-1 for success/failure).
2008-10-26 20:56:46 +01:00
Max Kellermann
464b611772 input_stream: input_stream_close() returns void
close() shouldn't fail with read-only streams.
2008-10-26 20:54:52 +01:00
Max Kellermann
f08041f0eb input_stream: added struct input_plugin
Instead of managing a set of method pointers in each input_stream
struct, move these into the new input_plugin struct.  Each
input_stream has only a pointer to the plugin struct.  Pointers to all
implementations are kept in the array "input_plugins".
2008-10-26 20:38:44 +01:00
Max Kellermann
dbc7e9ba2f input_stream: no CamelCase
Renamed all functions and variables.
2008-10-26 20:34:47 +01:00
Max Kellermann
97a9c7a8e0 input_file: removed global constructor
The global constructor is empty, and can be removed.
2008-10-26 20:34:33 +01:00
Max Kellermann
23552f89cc input_file: don't export internal methods
The methods are only used in inputStream_fileOpen(), and should not be
exported.
2008-10-26 20:34:03 +01:00
Max Kellermann
21b8590b53 input_stream: removed the InputStream typedef
Everybody should use struct input_stream.
2008-10-26 19:54:57 +01:00
Max Kellermann
bbaedb17d5 input_stream: renamed sources, no CamelCase
Renamed inputStream.c and inputStream_file.c.
2008-10-26 19:38:50 +01:00
Max Kellermann
3609de8685 http: use libcurl
MPD's HTTP client code has always been broken, no matter how effort
was put into fixing it.  Replace it with libcurl, which is known to be
quite stable.  This adds a fat library dependency, but only for people
who need streaming.
2008-10-26 19:32:43 +01:00
Max Kellermann
6b09e4daef input_stream: added input_stream_global_finish()
The hook input_stream_global_finish() deinitializes global structures
of all input stream implementations.
2008-10-26 19:30:13 +01:00
Max Kellermann
4bc2def15c stored_playlist: fixed signed comparison warning
Cast playlist_max_length to off_t before comparing it to stat.st_size.
2008-10-26 16:26:44 +01:00
Max Kellermann
4fa36a15bf command: removed range check from check_bool()
check_bool() accepts only "0" or "1".  The range check is superfluous.
2008-10-26 16:19:33 +01:00
Max Kellermann
ece8c1347c renamed src/audioOutputs/ to src/output/
Again, no CamelCase in the directory name.
2008-10-26 11:29:44 +01:00
Max Kellermann
e11355f47d renamed src/inputPlugins/ to src/decoder/
These plugins are not input plugins, they are decoder plugins.  No
CamelCase in the directory name.
2008-10-26 11:29:25 +01:00
Max Kellermann
1110a6d410 removed internal copy of libmp4ff
MPD shouldn't integrate sources of other libraries.  Since libmp4ff is
part of libfaad, we should remove the old copy from src/mp4ff and link
with the current version from libfaad instead.
2008-10-25 20:59:36 +02:00
Max Kellermann
a02db57291 pulse: force 16 bit audio sample format
PA_SAMPLE_S16NE is the only sample format which is suported by both
MPD and pulseaudio.  Unfortunately, pulse does not accept 24 bit
samples.

Instead of bailing out with an error message, we should tell the MPD
core to convert all samples to 16 bit for pulse.
2008-10-25 20:41:28 +02:00
Max Kellermann
ee499cb42f player: don't clear command before do_play() returns
This bug caused the audio output devices to stay open, although MPD
wasn't playing: quitDecode() resetted player_control.command, assuming
that the command was STOP.  This way, player_task() didn't see the
CLOSE_AUDIO command, and the device was kept open.

Don't clear player_control.command in quitDecode().
2008-10-24 17:50:24 +02:00
Max Kellermann
18c6ebb023 remove unused sources
These are results from failed merges which I didn't notice.
2008-10-24 17:41:13 +02:00
Max Kellermann
f4e6bb2815 jack: support for 24 bit samples
When the audio source provides 24 bit samples, don't bother to convert
(lossily) them to 16 bit before jack's floating point conversion - go
directly from 24 bit to float.
2008-10-24 17:36:11 +02:00
Max Kellermann
b1adfaae43 jack: moved code to jack_write_samples_16()
Move sample format dependent code to a separate function.
2008-10-24 17:34:47 +02:00
Max Kellermann
03a077e8a4 jack: eliminated CamelCase
Renamed all variables and functions.  Add the prefix "mpd_jack_" to
function names.
2008-10-24 17:29:37 +02:00
Max Kellermann
e19f0a8dbc jack: added assertions against partial frames
We must never pass partial frames.  Added assertions to debug this.
2008-10-24 16:56:10 +02:00
Max Kellermann
e7cd237674 jack: optimize local variables
Merge the variables "avail_data" and "avail_frames" into "available".
Both variables are never used at the same time.
2008-10-24 16:56:08 +02:00
Max Kellermann
0a6704420b jack: lockless data transfer to jack thread
The JACK documentation postulates that the process() callback must not
block, therefore locking is forbidden.  Anyway, the old code was racy.

Remove all locks, and don't wait for more data to become available -
just send to the port what is already in the buffer.
2008-10-24 16:55:51 +02:00
Max Kellermann
4ecdaabbb0 jack: partial writes to ring buffer
Don't wait until there is room for the full data chunk passed to
jack_playAudio().  Try to incrementally send as much as possible into
the ring buffer.
2008-10-24 16:39:43 +02:00
Max Kellermann
91ad576aad jack: added constant "frame_size"
Don't hard-code a frame size of "4" (16 bit stereo), calculate the
sample size from sizeof(*buffer), and create the constant
"frame_size".
2008-10-24 15:47:52 +02:00
Max Kellermann
9d6651d8b2 jack: fix indentation
Indent with tabs.
2008-10-24 08:44:40 +02:00
Max Kellermann
8b4829c2fe pcm_resample: support for libsamplerate < 0.1.3
libsamplerate 0.1.2 didn't have the 32 bit <-> float conversion
routines.  Emulate them in case they aren't supported.
2008-10-24 08:41:34 +02:00
Max Kellermann
5fefa954a3 player: don't send partial frames of silence
Another partial frame fix: the silence buffer was 1020 bytes, which
had room for 127.5 24 bit stereo frames.  Don't send the partial last
frame in this case.
2008-10-23 20:54:52 +02:00
Max Kellermann
4eadb0f7aa pcm_utils: added 24 bit conversion functions
24 bit output is as important as 16 bit output.  Provide a
pcm_convert() implementation which can convert to 24 bit with as
little quality loss as possible.
2008-10-23 20:11:37 +02:00
Max Kellermann
ec37633f1c pcm_utils: generic pcm_convert_size() implementation
The old pcm_convert_size() ignored most of the destination format,
e.g. it did not check its sample size, and assumed it is 16 bit.
Simplify and universalize it by using audio_format_frame_size().
2008-10-23 20:11:28 +02:00
Max Kellermann
98e4817548 pcm_utils: moved code to pcm_convert_16()
pcm_convert() converted only to 16 bit.  To be able to support other
sample sizes, move that 16 bit specific code to a separate function.
2008-10-23 20:11:24 +02:00
Max Kellermann
8489e90c1e pcm_channels: added 24 bit implementations
The 24 bit implementation is mostly copy'n'paste of the 16 bit
version, except that the data type is int32_t instead of int16_t.
2008-10-23 20:04:37 +02:00
Max Kellermann
a0bcbb37f4 pcm_utils: moved channel conversion functions to pcm_channels.c
Separate code from pcm_utils.c to keep it small and simple.
2008-10-23 20:03:14 +02:00
Max Kellermann
af7cb932fb pcm_resample: implemented 24 bit resampling
Similar to pcm_resample_16(), implement pcm_resample_24().  The 24 bit
implementation is very similar, but it uses src_int_to_float_array()
instead of src_short_to_float_array() before sending data to
libsamplerate.
2008-10-23 20:02:51 +02:00
Max Kellermann
5bbcbfb7ce pcm_resample: moved code to pcm_resample_set()
A future patch will implement a 24 bit resampler.  To unify code, move
code which can be shared to a separate function.
2008-10-23 20:02:09 +02:00
Max Kellermann
1dcb946fb0 pcm_resample: eliminated "sample" local variables
Copy from source to destination buffer directly, don't use the
temporary variables "lsample" and "rsample".
2008-10-23 20:01:37 +02:00
Max Kellermann
124f79a2a6 pcm_resample: don't resample partial samples
Added assertions which ensure that there are no partial samples in the
source buffer.
2008-10-23 20:01:12 +02:00
Max Kellermann
b13d656f81 pcm_resample: don't hard-code sample size
Use sizeof(sample) instead of hard-coding "2".  Although we're in 16
bit right now, this will make code sharing easier when we support
other sample sizes.
2008-10-23 20:01:08 +02:00
Max Kellermann
6b1c54ef96 pcm_utils: moved code to pcm_resample.c
Separate the resampling code from the rest of pcm_utils.c.  Create two
sub-libraries: pcm_resample_libsamplerate.c and
pcm_resample_fallback.c.
2008-10-23 20:00:51 +02:00
Max Kellermann
098991f8e8 command: fix boolean value parser
Due to a logic error, no value was valid for the boolean value
parser.  Replace "||" with "&&".
2008-10-23 18:06:05 +02:00
Max Kellermann
2cc2420f8c mp3: send 24 bit PCM data
libmad produces samples of more than 24 bit.  Rounding that down to 16
bits using dithering makes those people lose quality who have a 24 bit
capable sound device.  Send 24 bit PCM data, and let the receiver
decide whether to apply 16 bit dithering.
2008-10-23 16:58:38 +02:00
Max Kellermann
bf5774edbd mp3: use sizeof(sample) instead of hard-coded "2"
We are going to convert the code to 24 bit; don't hard-code a sample
size of 2 bytes.
2008-10-23 16:58:14 +02:00
Max Kellermann
0078837a97 pcm_dither: added generic 24 to 16 bit dithering
Copied and adapted code from the mp3 decoder plugin.  This library now
replaces the old and low-quality function pcm_convert_24_to_16().
2008-10-23 16:58:07 +02:00
Max Kellermann
80603cf6f1 audio: allow 24 and 8 bit output
I added 24 bit support a while ago, but it wasn't possible to force 24
bit output.  Add 24 and 8 bit to the list of allowed sample sizes.
Although 8 bit audio isn't as widely used as 24 bit, there is no
reason to exclude it.
2008-10-23 16:57:58 +02:00
Max Kellermann
980f2ca56d output_buffer: don't split frames
Splitting a frame between two buffer chunks causes distortion in the
output.  MPD used to assume that the chunk size 1020 would never cause
splitted frames, but that isn't the case for 24 bit stereo (127.5
frames), and even less for files with even more channels.
2008-10-23 16:48:49 +02:00
Max Kellermann
4f807b3aaa stored_playlist: don't map files outside the database
Don't attempt to map paths which are already absolute with
map_song_fs(): check with song_in_database() instead of
song_is_file().
2008-10-23 09:54:42 +02:00
Max Kellermann
fdc9a4cc5a stored_playlist: emit idle event on delete
The "rm" command did not send notifications to idle clients.  Add it.
2008-10-23 09:54:39 +02:00
Max Kellermann
93598e28f4 stored_playlist: renamed and moved spl_delete() to stored_playlist.c
The function deletePlaylist() shouldn't be in playlist.c.
2008-10-23 09:54:32 +02:00
Max Kellermann
39f0c41fbf stored_playlist: spl_load() returns GPtrArray
Don't use our deprecated linked list library, use GLib's GPtrArray
instead.
2008-10-23 09:54:28 +02:00
Max Kellermann
e172874cc6 command: check over/underflows in check_int()
The "long" result of strtol() was implicitly casted down to a 32 bit
integer.  Add some range checking instead.
2008-10-23 09:54:10 +02:00
Max Kellermann
95ae1d9e9e command: added check_unsigned() / check_bool()
Many command arguments must not be negative; add a separate
parser/checker function for that.  For the same reason, add
check_bool().  This eliminates two strange special cases handlers from
check_int().
2008-10-23 09:53:35 +02:00
Max Kellermann
3958457256 stored_playlist: unsigned index arguments
Pass index arguments as unsigned integers.  They must not be negative,
and even if some caller accidently passes -1, it won't pass the bound
checks (since it's now 2**32-1).
2008-10-23 09:53:34 +02:00
Max Kellermann
bc938603f6 playlist: unsigned integers
There are some integers which have a "magic" -1 value which means
"undefined" or "nothing".  All others can be converted to unsigned,
since they must not contain a negative number.
2008-10-23 07:19:46 +02:00
Max Kellermann
890b067346 command: use the bool datatype instead of int
Instead of returning 0 for success and -1 for failure, return true or
false.  This seems more natural.
2008-10-22 21:41:54 +02:00
Max Kellermann
d4f3c09081 command: converted COMMAND_RETURN_* macros to enum
Also add names for "error" and "ok".  I don't like passing anonymous
integer codes around.

This is not yet complete: lots of functions (e.g. in playlist.c)
follow the same convention of -1/0, and these have to be adapted, too.
2008-10-22 21:41:49 +02:00
Max Kellermann
d11ee6580c command: replaced "goto" with "break"
http://xkcd.com/292/
2008-10-22 21:40:58 +02:00
Max Kellermann
51a6ee88f7 command: no CamelCase
Eliminate CamelCase in all public and static functions.
2008-10-22 21:40:44 +02:00
Max Kellermann
69c563b511 command: removed CommandHandlerFunction typedef
The typedef CommandHandlerFunction is only used once.  Move its type
into the command struct.
2008-10-22 21:40:36 +02:00
Max Kellermann
d0a9dcdcf5 ack: converted ACK_ERROR_* macros to enum 2008-10-22 21:40:32 +02:00
Max Kellermann
7aca4cd194 stored_playlist: send timestamps
Send last modification timestamps to the client.  This allows the
client to see when another client modifies a stored playlist.
2008-10-22 19:18:39 +02:00
Max Kellermann
9c983c442c command: added command "listplaylists"
"listplaylists" returns a list of all stored playlists.  This command
seems more elaborate than listing them below "lsinfo".
2008-10-22 19:16:56 +02:00
Max Kellermann
f8e586402d command: added print_spl_list()
The function print_spl_list() replaces the old function lsPlaylists()
from ls.c.
2008-10-22 19:16:35 +02:00
Max Kellermann
a65e20b50e stored_playlist: added spl_list()
spl_list() provides an interface for enumerating all stored playlists.
This separates the internal playlist logic from the protocol specific
function lsPlaylists().
2008-10-22 19:15:50 +02:00
Max Kellermann
3a164ef8e6 stored_playlist: spl_append_uri() returns enum playlist_result
The return value of spl_append_uri() was somewhat buggy: some branches
returned ACK_* values, and some an enum playlist_result.  Unify this.
2008-10-22 17:24:40 +02:00
Max Kellermann
d2606baa79 stored_playlist: de-CamelCase moved function
Rename addToStoredPlaylist() to spl_append_uri(), and remove the
clearStoredPlaylist() macro.
2008-10-22 17:23:58 +02:00
Max Kellermann
1da921f03c stored_playlist: moved functions from playlist.c
The two functions clearStoredPlaylist() and addToStoredPlaylist()
don't belong into playlist.c.  clearStoredPlaylist() was a wrapper for
spl_clear(), and is converted into a CPP macro for now.
2008-10-22 17:23:11 +02:00
Max Kellermann
ac853b6165 stored_playlist: no CamelCase
Renamed all public functions, prefix is "spl_".
2008-10-22 17:21:59 +02:00
Max Kellermann
a4def81313 renamed storedPlaylist.c to stored_playlist.c
No CamelCase in file names.
2008-10-22 17:21:57 +02:00
Max Kellermann
1c62e2cd62 command: added "commands" array instead of registering manually
The list of commands is known at compile time.  Instead of creating a
linked list on startup, we can just register all commands in a static
sorted array.
2008-10-22 10:08:14 +02:00
Max Kellermann
84d0f56eaf command: make command pointers constant
The command pointers which are passed around aren't being modified -
in fact, no command pointer must be modified once it has been added to
the commandList.
2008-10-22 09:59:01 +02:00
Max Kellermann
4b4f7df933 command: renamed CommandEntry to struct command
No CamelCase and no struct typedefs.
2008-10-22 09:58:13 +02:00
Max Kellermann
e6d90d4e83 pcm_utils: added pcm_convert_init()
Instead of manually calling memset(0) on the pcm_convert_state struct,
client code should use a library function from pcm_utils.c.  This way,
we can change the semantics of the struct easily.
2008-10-21 22:53:16 +02:00
Max Kellermann
ca6e613a7f pcm_utils: no CamelCase
Renamed all functions which were still in CamelCase.
2008-10-21 22:53:13 +02:00
Max Kellermann
fb416964d6 pcm_utils: renamed ConvState to struct pcm_convert_state
No CamelCase, and a struct instead of a typedef.
2008-10-21 21:59:43 +02:00
Max Kellermann
a7888c4998 ffmpeg: don't pass pointer as hexadecimal string
Casting a pointer to some sort of integer and formatting it into a
string isn't valid.  A pointer derived from this hex string won't work
reliably.  Since ffmpeg doesn't provide a nice API for passing our
pointer, we have to think of a different hack: ffmpeg passes the exact
URL pointer to mpdurl_open(), and we can make this string part of a
struct.  This reduces the problem to casting the string back to the
struct.

This is still a workaround, but this is "sort of portable", unless the
ffmpeg people start messing with the URL pointer (which would be valid
according to the API definition).
2008-10-21 18:12:56 +02:00
Max Kellermann
def97411f2 ffmpeg: detect which ffmpeg headers should be included
Since ffmpeg svn r12865, you have to include libavcodec/avcodec.h
instead of avcodec.h.  This cannot be checked at compile time, instead
we have to add a check to configure.ac.  Viliam's original ffmpeg
plugin was based on the newer ffmpeg library, while my Debian
installation had the older version.  My attempt to correct his include
statements wasn't correct after all.
2008-10-21 08:34:19 +02:00
Eric Wong
d52437d43f update: fix multiple deletes from *vec iterators
{song,dir}vec_for_each each failed to gracefully handle deleted
files when iterating through.  While we were thread-safe, we
were not safe within the calling thread.  If a callback we
passed caused sv->nr to shring, our index would still increment;
causing files to stay in the database.

A way to test this is to remove 10 or so contiguous songs from a
>10 song directory.
2008-10-21 01:35:11 +02:00
Eric Wong
9aeacdef56 dirvec: introduce locking for all iterators
Like the songvec nr_lock, only one lock is used for all
traversals since they're rarely changed.  This only
projects traversals, but not the individual structures
themselves.
2008-10-21 01:34:36 +02:00
Eric Wong
686a6df3a5 {dir,song}vec: these structs are const
We definitely don't modify them here.
2008-10-21 01:31:36 +02:00
Eric Wong
f2525e3efb dirvec: add dirvec_for_each iterator
This will make it easier to introduce locking
2008-10-21 01:30:30 +02:00
Max Kellermann
1d385190a0 path: removed pathcpy_trunc()
There was only one user of pathcpy_trunc(), which can be eliminated.
2008-10-20 22:18:42 +02:00
Max Kellermann
49260e6db2 path: replaced parent_path() with g_path_get_dirname()
Again, GLib's version is more robust than ours.
2008-10-20 22:18:40 +02:00
Max Kellermann
ba96920a52 path: replaced mpd_basename() with g_path_get_basename()
GLib's g_path_get_basename() is much more reliable than
mpd_basename().  The latter could be tricked into an assertion
failure.
2008-10-20 22:18:12 +02:00
Max Kellermann
99e82a2ef2 signal_check.c: don't use leading underscores
Identifiers with two leading underscores are reserved for the C
compiler's internal use.  Don't use them in the source.
2008-10-20 22:18:03 +02:00
Max Kellermann
57f5e8731d mapper: don't return database path with leading slash
Due to an off-by-one bug in map_fs_to_utf8(), the function returned
database paths with a leading slash.
2008-10-19 00:05:39 +02:00
Andrzej Rybczak
52123c1de8 listen: fix "struct ucred" check
The macro name is HAVE_STRUCT_UCRED, not HAVE_UCRED.
2008-10-18 18:21:49 +02:00
Max Kellermann
98f7177f4a input_stream: don't declare method typedefs
The typedefs aren't using by anybody but struct input_stream.  Remove
them and declare the method type within struct input_stream.
2008-10-18 08:17:55 +02:00
Max Kellermann
1dfe92057e ffmpeg: make internal functions static
The mpdurl_* code is internal, don't expose them.  Also don't
initialize struct members with NULL.
2008-10-18 08:08:13 +02:00
Max Kellermann
02a2a407c1 client: converted permissions to unsigned
client->permission is a bit set, and should be unsigned.
2008-10-17 23:53:28 +02:00
Max Kellermann
f8d5b74071 client: eliminate variable "left" in client_write()
Reduce two temporary variables to only one.
2008-10-17 23:53:16 +02:00
Max Kellermann
bdbccc633d client: fixed send buffer
There is no sense in using the kernel's send buffer size (SO_SNDBUF)
for MPD's send buffer.  Convert it into a static buffer of 4 kB.
2008-10-17 23:52:47 +02:00
Max Kellermann
48c11c52ac client: removed CLIENT_MAX_BUFFER_LENGTH
Use a literal in the struct declaration, and sizeof(client->buffer)
everywhere else.  Also shrink the buffer from 40 kB to 4 kB.  The
buffer must only be large enough to hold one line of input, and 4 kB
is still more than enough.
2008-10-17 23:52:40 +02:00
Max Kellermann
3689d5e4ed client: added assertions on the buffer pointers
The buffer pointers must not exceed the buffer size.
2008-10-17 23:29:41 +02:00
Max Kellermann
d691577a96 client: read() return value is ssize_t
Use ssize_t instead of int.
2008-10-17 23:26:40 +02:00
Max Kellermann
79459d08d9 client: handle partial lines correctly
Commit 6eb62e47 didn't obey partial lines correctly: when a line
wasn't finished in one read, the first part was ignored when the rest
arrived.
2008-10-17 23:23:54 +02:00
Viliam Mateicka
11ad997141 ffmpeg: new decoder plugin
[mk: fixed indent, changed copyright statement, added autoconf test,
fixed includes paths, fixed 2 gcc warnings, don't close input stream
twice]
2008-10-17 22:27:33 +02:00
Max Kellermann
4ee8da2e69 Makefile.am: don't compile disabled decoder plugins
Don't compile the sources of disabled decoder plugins at all, and
don't attempt to register these.
2008-10-17 21:57:09 +02:00
Max Kellermann
25b5d90e44 Makefile.am: don't compile disabled sources
If a feature is disabled, don't compile the source file at all,
disable it completely in Makefile.am instead.
2008-10-17 21:13:23 +02:00
Max Kellermann
4984639b72 input_stream: removed nmemb argument
The nmemb argument isn't actually useful, and one of nmemb and size
was always passed as 1.  Remove it.
2008-10-17 17:53:59 +02:00
Max Kellermann
b73ecbb073 input: declare struct input_stream
Provide a struct type which can be forward-declared.  The typedef
InputStream is deprecated now.
2008-10-17 17:53:48 +02:00
Max Kellermann
bae98f777b decoder: notify player after entering decodeStart()
Wake up the player as soon as the decoder thread has entered its loop.
This fixes a dead lock when the input is blocking.
2008-10-17 17:53:44 +02:00
Max Kellermann
7ca19736c9 command: expect "file:///" url for local files
When adding a local file, clients have to use the "file" URI schema
described in RFC 1738 3.10.  By adding this schema to "urlhandlers", a
client can detect whether this feature is available.
2008-10-17 17:53:43 +02:00
Max Kellermann
f548216ead listen: fixed unused variable warning without HAVE_UCRED
The local variable "passcred" was only used by ucred code.
2008-10-17 17:40:28 +02:00
Max Kellermann
9b5ce27c3b configure.ac: check if "struct ucred" is available
By default, glibc 2.8 hides struct ucred behind the _GNU_SOURCE
macro.  I don't want to enable that globally, because it may encourage
the use of non-portable functions.  Test if "struct ucred" is
available, and enable _GNU_SOURCE if required.

For details about that issue, see glib's bug database:

 http://sources.redhat.com/bugzilla/show_bug.cgi?id=6545
2008-10-16 14:59:26 +02:00
Max Kellermann
b53365949a configure.ac: find more libraries with pkg-config
Detect the following libraries with pkg-config: libshout, libid3tag,
libmad.
2008-10-16 08:33:29 +02:00
Max Kellermann
beec15ddaa command: special case for "add /"
The undocumented command "add /" adds the full music database to the
playlist.  Don't interpret this special path as a local file path.
2008-10-16 07:40:34 +02:00
Max Kellermann
f9222fdabe playlist: also allow world-readable local files
Allow a local user to not only add his own files, but also all
world-readable files (mode 0444).
2008-10-15 23:10:05 +02:00
Max Kellermann
f1ab4d2c1b song: check file type in song_file_update()
Don't load non-regular files.
2008-10-15 22:43:24 +02:00
Max Kellermann
8c0060fae4 playlist: added support for adding songs not in the music database
Clients which have authenticated via unix socket may add local files
to the MPD playlist, provided that they own the file.
2008-10-15 22:35:13 +02:00
Max Kellermann
0b44cad2ce command: print error message on "addid" failure
Returning the playlist_result value from a command handler does not
make sense.  Call print_playlist_result() there, and forward its
return value.
2008-10-15 22:35:04 +02:00
Max Kellermann
961a349f15 playlist: moved code to song_by_url()
Replace some complicated checks from addToPlaylist() to the simpler
function song_by_url().
2008-10-15 22:35:00 +02:00
Max Kellermann
6d3488c8b3 song: added song_in_database()
Some functions assume that a song is not in the database when it is a
remote song.  Based on that, they decide whether they are responsible
for freeing the song struct.  Add a special function which checks
whether a song is in the database (currently equal to song_is_file()).
2008-10-15 22:34:47 +02:00
Max Kellermann
4a7ad5b618 listen, client: enable SO_PASSCRED, get client's uid
Enable authentication over unix sockets.  Store the client's uid in
the client struct.
2008-10-15 22:34:21 +02:00
Max Kellermann
fa56ff3d52 update: don't skip hidden files
Skip only the special directory entries "." and "..", don't skip all
other "hidden" files.
2008-10-15 20:51:01 +02:00
Max Kellermann
92513c3309 shout: check for vorbisenc library
The switch from ogg.m4 to pkg-config intentionally disabled
libvorbisenc.  Enable it when shout_ogg is used.
2008-10-15 20:40:04 +02:00
Enrico Weigelt
30cd345581 fixing several imports to work via pkg-config
This patch fixes several imports to use pkg-config instead of certain
esoteric tests.
2008-10-15 20:39:46 +02:00
Max Kellermann
047043d2a8 locate: use g_utf8_casefold() instead of string_toupper()
string_toupper() and strDupToUpper() were not able to deal with
character sets other than US-ASCII.  Use GLib's g_utf8_casefold()
for strings.
2008-10-15 19:36:37 +02:00
Max Kellermann
7366191f0d mapper: moved musicDir initialization from path.c
Moved the musicDir variable and its initialization code from path.c to
mapper.c.
2008-10-15 19:36:33 +02:00
Max Kellermann
76779f0fbe path: allow starting MPD with non-existing music directory
When the music directory is not mounted yet, let MPD start anyway.
2008-10-15 19:36:31 +02:00
Max Kellermann
8746a58ab9 path, tag_id3: use g_convert() instead of charConv.c
GLib provides an easier API for character set conversion than iconv().
Use g_convert() / g_convert_with_fallback() for all character
conversions.  We should optimize the path.h API later to return a
newly allocated buffer, so we can just pass GLib's return value.
2008-10-15 19:36:30 +02:00
Max Kellermann
e89599eaad use GLib
GLib is a nice and portable utility library.  We are going to use it
from now on, and eliminate a lot of duplicated code from MPD.  Why
invent the wheel again and again?
2008-10-15 19:35:04 +02:00
Max Kellermann
2a47e90cf5 tag_id3: fix indentation
Indentation was broken in tag_id3.c: it used 4 spaces instead of tabs.
2008-10-15 19:29:46 +02:00
Max Kellermann
cf7ed8c5df idle: client command "noidle" aborts idle 2008-10-15 18:21:57 +02:00
Max Kellermann
6eb62e4761 client: optimized client_input_received()
Use memchr() instead of manually traversing the input buffer.  Update
the client's properties after all commands have been processed.  Check
for buffer overflow once.
2008-10-15 18:21:45 +02:00
Max Kellermann
62ee702877 listen: pass protocol family to establishListen()
The caller already knows the protocol family, and we can eliminate the
complicated switch statement in establishListen() if we just pass this
information.  This seems more robust.
2008-10-15 07:30:24 +02:00
Max Kellermann
ba594cfec0 listen: use getaddrinfo() instead of gethostbyname()
getaddrinfo() is more robust and has proper IPv6 support.  The new
code tries to bind to all IP addresses returned by getaddrinfo().
2008-10-15 07:20:53 +02:00
Max Kellermann
a3e3d2c950 command: added command "idle"
"idle" waits until something noteworthy happens on the server,
e.g. song change, playlist modified, database updated.  This allows
clients to keep up to date without polling.
2008-10-14 22:38:14 +02:00
Max Kellermann
30c86d8ae6 alsa: added #ifdefs around SND_PCM_NO_AUTO_xxx
These macros are not available in older libasound versions (1.0.13
fails, 1.0.16 is ok).  Ignore the configuration if the constants are
not defined.
2008-10-14 22:37:27 +02:00
Max Kellermann
da1c0cd6d7 playlist: don't use uninitialized local variable (typo)
Instead of the uninitialized local variable "s", I should have used
"uri".
2008-10-14 17:23:24 +02:00
Max Kellermann
c4a43f8a9d oss: use unsigned integer for ioctl constants
The OSS constants overflow a signed integer, use unsigned instead.
2008-10-14 17:21:57 +02:00
Max Kellermann
f01a08d5c2 oss: convert several macros to enum
C enums are nicer than CPP macros.
2008-10-14 17:21:53 +02:00
Max Kellermann
86782faa18 alsa: optionally disable resampling and others
Added mpd.conf options for disabling automatic resamling, sample
format and channel conversion.  This way, users may choose to override
ALSA's automatic resampling, and use libsamplerate instead.
2008-10-14 17:21:49 +02:00
Max Kellermann
ba892cbcb0 changed package name to "mpd-mk", updated version number
This git branch has become a real MPD fork now.  Time to change the
package name to the code name "mpd-mk".  Set the version number to
"0.14~git" to mark this as a non-released version.
2008-10-14 17:21:27 +02:00
Max Kellermann
197caee151 update: don't follow relative symlinks
Don't follow relative symlinks which point into the music directory.
This allows you to organize music with symbolic links, without MPD
managing separate copies of each song.
2008-10-14 11:10:54 +02:00
Max Kellermann
f521c12d20 ls: removed myStat(), isFile(), isDir()
The mapper code has replaced these functions.
2008-10-14 11:10:51 +02:00
Max Kellermann
5b71d5f6f7 mapper: new song-to-filesystem mapper library
The mapper library maps directory and song objects to file system
paths.  With this central library, the code mixture in path.c should
be cleaned up, and we will be able to add neat features like aliasing.
2008-10-14 11:10:49 +02:00
Max Kellermann
a52a9fc1fc playlist: moved code to playlist_save.c
playlist_print_song() and playlist_print_uri() handle charset
conversion and (optional) music directory prefixing.
2008-10-14 11:10:47 +02:00
Max Kellermann
308bc230b2 song: pass const song pointer to song_get_url()
song_get_url() doesn't modify the song object.
2008-10-14 11:10:44 +02:00
Eric Wong
06c8a9ed0b {dir,song}vec: fix off-by-one errors in {dir,song}vec_delete
Found by Valgrind while looking for another bug...

Hmm.. I should really just make this code generic since
they're duplicated...
2008-10-14 11:10:00 +02:00
Max Kellermann
f71ac4d479 song: stat file in song_file_update(), don't use isMusic()
isMusic() used to be a very inefficient function: with every
invocation, it did another stat() on the specified file.  There is
only one caller, do the stat() there manually and use hasMusicSuffix()
instead of isMusic().
2008-10-13 16:56:00 +02:00
Max Kellermann
94a5a5a985 update: always look up parent directory in updatePath()
By always creating the parent directory, we can use delete_name_in()
without further lookups.  The parents which may non exist will be
pruned later.  An update request for a non-existing or empty directory
should be quite unusual, so this doesn't add any measurable overhead.
2008-10-13 16:55:55 +02:00
Max Kellermann
a52343732b update: pass base file name to updateInDirectory()
In order to optimize buffer usage, pass only the base file name to
updateInDirectory().  This way, updateInDirectory() may choose when to
allocate a larger buffer for the full path.
2008-10-13 16:55:54 +02:00
Max Kellermann
270a6ebd69 update: moved code to make_subdir() 2008-10-13 16:46:51 +02:00
Max Kellermann
3e9ed15e76 update: added delete_name_in()
delete_name_in() is similar to delete_path(), but it does not need to
look up the parent directory.
2008-10-13 16:46:32 +02:00
Max Kellermann
69617438a9 dirvec: dirvec_find() compares basename
It is invalid to pass a path with the wrong dirname to dirvec_find().
To be able to find a subdirectory only by its basename, compare only
the basename of both paths.
2008-10-13 16:33:04 +02:00
Max Kellermann
3b6ff84393 directory: added directory_get_name()
directory_get_name() returns the base name of the directory.
2008-10-13 16:32:39 +02:00
Max Kellermann
bc85e92a72 playlist: don't use isPlaylist() in deletePlaylist()
The only caller of deletePlaylist() appends PLAYLIST_FILE_SUFFIX, so
we can be sure it's already there.  We don't need to stat the file,
since unlink() does all the checking.
2008-10-13 16:30:44 +02:00
Max Kellermann
07c9b62764 audio: don't clear input_audio_format on openAudioDevice(NULL)
Commit 80a2c937 broke resume after pause: it cleared the
input_audio_format when it attempted to simplify a complicated
expression.  Don't clear it, just assign input_audio_format if a new
format was specified.
2008-10-13 14:31:18 +02:00
Max Kellermann
5ea2e198f9 directory: pass const pointers to inline functions
The inline functions directory_is_empty() and directory_get_path()
don't modify the object - pass constant object pointers to them.
2008-10-13 09:56:57 +02:00
Eric Wong
313405edb6 songvec: avoid holding nr_lock during free(3)
We only need to lock sv->nr changes to prevent traversals ( why
it's called "nr_lock").  free(3) is a "slow" function on my
system; so we can avoid unnecessarily holding a lock long for
longer than needed.
2008-10-13 09:55:07 +02:00
Eric Wong
3035a3303d update: allow music_root updates to be queued
Previously only updates with subdirectories being
specified could be queued.  No harm in queueing
full updates.
2008-10-13 09:55:03 +02:00
Eric Wong
8d907fb9fa directory: use mpd_sizeof_str_flex_array for path, too
This way we avoid unnecessary heap allocations.
2008-10-13 09:55:00 +02:00
Eric Wong
8867bd554c tag_item: avoid wasting space when struct is unpackable
Not all compilers support struct packing, and those that don't
shouldn't be punished for it.
2008-10-13 09:40:14 +02:00
Eric Wong
c641aabe33 song: song_get_url: fix "/" prefix for songs in music_root 2008-10-13 09:39:02 +02:00
Aaron McEwan
2139d8bba8 shout: make the protocol configurable
Added configuration parameter "protocol" which lets the user choose
from 3 shout protocols.  This adds support for real shoutcast servers.
2008-10-12 12:14:51 +02:00
Max Kellermann
ff69f12259 shout: use strcmp() instead of strncasecmp()
Case insensitivity isn't helpful, and comparing only the first 3 bytes
of a configured value may encourage users to supply wrong or
misleading values.
2008-10-12 12:13:27 +02:00
Max Kellermann
ffed2fdca7 alsa: fall back to 16 bit output
If the sample format isn't supported by the device (i.e. 24 bit on
low-end sound chips), fall back to 16 bit output.  There is code in
pcm_utils.c which converts PCM data to 16 bit.
2008-10-12 12:02:55 +02:00
Max Kellermann
9b0693d8ef pcm_utils: support any number of channels in pcm_sizeOfConvBuffer()
When calculating the conversion buffer size, don't hard-code the
formulas for only mono<->stereo.
2008-10-12 12:02:54 +02:00
Max Kellermann
c0ecce5498 pcm_utils: support converting N channels to stereo
Convert any number of channels to stereo.  In fact, this isn't really
stereo, it's rater mono blown up to stereo.  This patch should only
make it possible to play 5.1 files at all; "real" conversion to stereo
should be implemented, but for now, this is better than nothing.
2008-10-12 12:02:52 +02:00
Max Kellermann
52949453df pcm_utils: pass output channel count to pcm_convertChannels()
In order to be able to deal with non-trivial conversions,
pcm_convertChannels() needs to know both the input and the output
channel count.  Simplify buffer allocation in that function.
2008-10-12 11:51:19 +02:00
Max Kellermann
a7924d141d pcm_utils: moved code from pcm_convertChannels() to separate functions
Moved code from pcm_convertChannels() to pcm_convert_channels_1_to_2()
and pcm_convert_channels_2_to_1().  Improved the quality of
pcm_convert_channels_2_to_1() by calculating the arithmetic mean value
of both samples.
2008-10-12 11:47:42 +02:00
Max Kellermann
1a74d7be41 alsa: moved code to alsa_configure()
Move code which loads configuration to alsa_configure().  This removes
one indent level.
2008-10-12 11:47:33 +02:00
Max Kellermann
0d3a6ff669 pcm_utils: pass int16_t* where appropriate
Pass int16_t pointers instead of char pointers to functions which can
deal with 16 bit audio only.
2008-10-12 11:28:37 +02:00
Max Kellermann
08210af23a player: replaced buffered_before_play with buffering flag
buffered_before_play was copied to struct player because it was used
to disable buffering when seeking.  Instead of mainaining a copy of
this number, move just the flag to the player struct.
2008-10-12 01:21:35 +02:00
Max Kellermann
80a2c937c4 audio: renamed the audio_format variables
Renamed audio_configFormat to configured_audio_format.  Renamed
audio_buffer.format to input_audio_format.  Simplified its
initialization in openAudioDevice().
2008-10-12 01:00:00 +02:00
Max Kellermann
336b193097 audio: removed enum ad_state
All what's left from ad_state is a simple boolean flag (ENABLE /
DISABLE).  Convert it to a C99 bool.
2008-10-12 00:48:59 +02:00
Max Kellermann
c297c8555f audio: removed audio_buffer.buffer
audio.c maintained one of MPD's many layers of audio buffers.  It was
without any benefit, since playAudio() can simply send the source
buffer directly to the audio output plugin.
2008-10-12 00:42:33 +02:00
Max Kellermann
ea25688e46 output_buffer: converted ob_is_empty() to inline
The function ob_is_empty() is called very often.  It's worth it to
convert it to an inline function.
2008-10-12 00:42:22 +02:00
Max Kellermann
35a939e3e7 player: added commands QUEUE and CANCEL
QUEUE adds a new song to the player's queue.  CANCEL clears the queue.
These two commands replace the old and complex queueState and
queueLockState code.
2008-10-12 00:07:54 +02:00
Max Kellermann
35a16b9923 playlist: call clearPlayerQueue() only if song is queued
Simplify and merge several if clauses before the clearPlayerQueue()
invocation.  Call clearPlayerQueue() only if a song is actually
queued; add an assertion for that in clearPlayerQueue().
2008-10-12 00:03:27 +02:00
Max Kellermann
9d51bd392b player: added struct player
The player struct holds the local variables which used to be passed to
all those helper functions in player_thread.c.
2008-10-12 00:02:23 +02:00
Max Kellermann
2fcbabf4d1 player: removed set_current_song()
set_current_song() is an internal function and consists of only one
assignment.  Eliminate it.
2008-10-11 12:52:57 +02:00
Max Kellermann
42409a35e2 player: removed player_control.fileTime
This variable is superfluous, it is only used to copy its value to
player_control.totalTime.  Since the original source of this value
(song->tag->time) will still be available at this point, we can safely
remove fileTime.
2008-10-11 12:52:51 +02:00
Max Kellermann
dd7711d86c alsa: don't override libasound's buffer_time and period_time
ALSA does a good job measuring its buffer_time and period_time.  Don't
override its defaults, unless the user demands it.
2008-10-11 12:52:48 +02:00
Max Kellermann
bcc443a8aa alsa: re-enable blocking mode
Revert e4f5d6bd "re-enable-nonblocking, but sleep if busy".
Non-blocking mode with manual sleeping doesn't help at all (by the
way, the patch should have used snd_pcm_wait() instead of
my_usleep()).  ALSA knows much more about the hardware quirks, so we
just let it do the job.
2008-10-11 12:47:20 +02:00
Max Kellermann
215d8aa8f6 oss: fix opening default OSS device
Leftover from the output API changes: oss_open_default() was changed
to return a void*, but it still returned "0" to report success.
Report the OssData pointer instead.
2008-10-11 12:40:48 +02:00
Max Kellermann
17d9c1708b player: don't wake up decoder after every frame
The decoder was woken up after each chunk which had been played.  That
caused a lot of superfluous context switches.  Wake up the decoder
only when a certain amount of the buffer has been consumed.  This
formula is somewhat arbitrary, and has to be proven experimentally.
2008-10-10 16:47:57 +02:00
Max Kellermann
f41fe1e0b5 mp3: dither an arbitrary number of channels
The mp3 plugin did not use the MAD_NCHANNELS() value correctly: when a
stream was not stereo, it was assumed to be mono, although the correct
number was passed to MPD.  libmad doesn't support more than 2
channels, but this change allows gcc to optimize its inlining
strategy.
2008-10-10 16:40:48 +02:00
Max Kellermann
bac136608d mp3: hard-code dithering to 16 bits
The dithering function audio_linear_dither() worked for signed 16 bits
only anyway, having a variable "bits" just disables important gcc
optimizations.
2008-10-10 16:34:52 +02:00
Max Kellermann
5de7521900 player: added player_get_audio_format()
player_get_audio_format() replaces getPlayerSampleRate(),
getPlayerBits(), getPlayerChannels().
2008-10-10 14:51:22 +02:00
Max Kellermann
0b4dfae22e player: added player_control.audio_format
This replaces the attributes bits, channels, sampleRate.
2008-10-10 14:47:58 +02:00
Max Kellermann
8c33b64847 mvp: unsinged integers
Fix some gcc warnings by using unsigned where appropriate.  Declare
numfrequencies as "const", and replaced the magic number 12 with a
sizeof.
2008-10-10 14:47:58 +02:00
Max Kellermann
cec9264d24 mvp: adapt to the new output device API 2008-10-10 14:47:56 +02:00
Max Kellermann
7d9bedc3aa mvp: missing includes
Again, a plugin which was disabled in my test environment and suffered
from compilation errors.
2008-10-10 14:47:54 +02:00
Max Kellermann
8fc6b93afc oss: added OssData.audio_format
This replaces the separate properties channels, sampleRate, bits.
2008-10-10 14:42:30 +02:00