Commit Graph

2925 Commits

Author SHA1 Message Date
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 e4df17f611 ffmpeg: link with libavutil
Since ffmpeg svn r13528, you have to link with libavutil manually.
2008-10-21 08:46:51 +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 7487f9810c configure.ac: use libmikmod-config instead of pkg-config
[mk: use AC_SUBST instead of appending to MPD_CFLAGS / MPD_LIBS]
2008-10-18 18:34:00 +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 90fdf07aa9 Makefile.am: require automake 1.9
With heavy use of conditionals, I broke Makefile.am for the ancient
automake version 1.6.  Instead of supporting this automake version
forever, I'm removing support for it now.  Since automake isn't
required on the build machine, nobody should have a serious problem
with that.
2008-10-18 07:21:04 +02:00
Max Kellermann eace565212 reverted package name to "mpd"
Since mpd-mk has become the "official" MPD, the rename from commit
ba892cbc can be reverted.
2008-10-17 23:59:39 +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