Commit Graph

2537 Commits

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