aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins (follow)
Commit message (Collapse)AuthorAgeFilesLines
* removed internal copy of libmp4ffMax Kellermann2008-10-251-1/+1
| | | | | | 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.
* mp3: send 24 bit PCM dataMax Kellermann2008-10-231-63/+24
| | | | | | | 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.
* mp3: use sizeof(sample) instead of hard-coded "2"Max Kellermann2008-10-231-2/+3
| | | | | We are going to convert the code to 24 bit; don't hard-code a sample size of 2 bytes.
* ffmpeg: don't pass pointer as hexadecimal stringMax Kellermann2008-10-211-20/+27
| | | | | | | | | | | | | | 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).
* ffmpeg: detect which ffmpeg headers should be includedMax Kellermann2008-10-211-0/+6
| | | | | | | | | 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.
* ffmpeg: make internal functions staticMax Kellermann2008-10-181-22/+12
| | | | | The mpdurl_* code is internal, don't expose them. Also don't initialize struct members with NULL.
* ffmpeg: new decoder pluginViliam Mateicka2008-10-171-0/+416
| | | | | | [mk: fixed indent, changed copyright statement, added autoconf test, fixed includes paths, fixed 2 gcc warnings, don't close input stream twice]
* Makefile.am: don't compile disabled decoder pluginsMax Kellermann2008-10-1714-143/+17
| | | | | Don't compile the sources of disabled decoder plugins at all, and don't attempt to register these.
* input_stream: removed nmemb argumentMax Kellermann2008-10-171-1/+1
| | | | | The nmemb argument isn't actually useful, and one of nmemb and size was always passed as 1. Remove it.
* mp3: dither an arbitrary number of channelsMax Kellermann2008-10-101-6/+3
| | | | | | | | 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.
* mp3: hard-code dithering to 16 bitsMax Kellermann2008-10-101-8/+6
| | | | | | The dithering function audio_linear_dither() worked for signed 16 bits only anyway, having a variable "bits" just disables important gcc optimizations.
* audio_format: renamed sampleRate to sample_rateMax Kellermann2008-10-1011-52/+51
| | | | | The last bit of CamelCase in audio_format.h. Additionally, rename a bunch of local variables.
* use the "bool" data type instead of "int"Max Kellermann2008-10-085-18/+18
| | | | "bool" should be used in C99 programs for boolean values.
* don't include os_compat.hMax Kellermann2008-10-084-0/+5
| | | | | When there are standardized headers, use these instead of the bloated os_compat.h.
* use C99 struct initializersMax Kellermann2008-09-2910-100/+65
| | | | | | The old struct initializers are error prone and don't allow moving elements around. Since we are going to overhaul some of the APIs soon, it's easier to have all implementations use C99 initializers.
* decoder: renamed plugin methodsMax Kellermann2008-09-291-3/+3
| | | | | Why have a "_func" prefix on all method names? Also don't typedef the methods, there is no advantage in that.
* switch to C99 types, part IIMax Kellermann2008-09-293-11/+11
| | | | | Do full C99 integer type conversion in all modules which were not touched by Eric's merged patch.
* Switch to C99 types (retaining compat with old compilers)Eric Wong2008-09-293-8/+8
| | | | | | | | | | | | | | | Seeing the "mpd_" prefix _everywhere_ is mind-numbing as the mind needs to retrain itself to skip over the first 4 tokens of a type to get to its meaning. So avoid having extra characters on my terminal to make it easier to follow code at 2:30 am in the morning. Please report any new issues you may come across on Free toolchains. I realize how difficult it can be to build/maintain cross-compiling toolchains and I have no intention of forcing people to upgrade their toolchains to build mpd. Tested with gcc 2.95.4 and and gcc 4.3.1 on x86-32.
* flac: removed FlacData.chunk_lengthMax Kellermann2008-09-232-8/+2
| | | | | chunk_length can be converted to a local variable, because it is always reset to 0 after it was used.
* flac: merged flacSendChunk() into flac_common_write()Max Kellermann2008-09-231-17/+16
| | | | | | | Since flacSendChunk() is a trivial function and is only used in one location, move the code there. The advantage is that calling decoder_data() directly returns the decoder_command value, so we can eliminate one decoder_get_command() call.
* flac: removed generic sample size supportMax Kellermann2008-09-231-32/+26
| | | | | | | | Support for bit rates except 16 bits (and 8 bits on little endian) has always been broken. Since we added optimized functions for 8, 16, 24/32 bits, we can remove the generic flac_convert() function. Instead of removing it, convert it to a wrapper function for flac_convert_*().
* flac: added special functions for 8 and 32 bitMax Kellermann2008-09-231-0/+37
| | | | | Same optimization for 8 and 32 bit files, like the previous patch for 16 bit. Along the way, this patch adds 24 bit FLAC support!
* flac: added optimized converter for 16 bitMax Kellermann2008-09-231-0/+17
| | | | | | flac_convert_16() runs a lot faster than the generic (and quite buggy) function flac_convert(). flac_convert_16() is only used for non-stereo files, since there is already flac_convert_stereo16().
* flac: use signed integers in flac_convert_stereo16()Max Kellermann2008-09-231-6/+4
| | | | | | By mistake, I casted the sample value to uint16_t, which is wrong. This patch simplifies the code by using a int16_t pointer instead of casting to int16_t* every time.
* flac: moved code from flacWrite() to _flac_common.cMax Kellermann2008-09-234-129/+97
| | | | | | | There is still a lot of duplicated code in flac_plugin.c and oggflac_plugin.c. Move code from flac_plugin.c to _flac_common.c, and use the new function flac_common_write() also in oggflac_plugin.c, porting lots of optimizations over to it.
* flac: assume the buffer is empty in flacWrite() IIMax Kellermann2008-09-231-7/+2
| | | | | The previous patch on this topic was incomplete: it still added data->chunk_length when calling flac_convert(). Remove this, too.
* audio_format: added audio_format_sample_size()Max Kellermann2008-09-232-3/+4
| | | | | | The inline function audio_format_sample_size() calculates how many bytes each sample consumes. This function already takes into account that 24 bit samples are 4 bytes long, not 3.
* start using prefixcmp()Eric Wong2008-09-231-1/+1
| | | | | LOC reduction and less noise makes things easier for tired old folks to follow.
* mp3: fix long line, I can't read past 80 colsEric Wong2008-09-231-1/+2
|
* mp3: fix buffer overflow when max_frames is too largeMax Kellermann2008-09-171-0/+5
| | | | | | | The function decodeFirstFrame() allocates memory based on data from the mp3 header. This can make the buffer size allocation overflow, or lead to a DoS attack with a very large buffer. Cap this buffer at 8 million frames, which should really be enough for reasonable files.
* mp4: fix potential integer overflow bug in the mp4_decode() functionTerry2008-09-121-0/+7
| | | | | | | | | | A crafted mp4 file could cause an integer overflow in mp4_decode function in src/inputPlugins/mp4_plugin.c. mp4ff_num_samples() function returns some tainted value. sizeof(float) * numSamples is an integer overflow operation if numSamples is too huge, so xmalloc will allocate a small memory region. I constructe a mp4 file, and use faad2 to open the file. mp4ff_num_samples() returns -1. So I think mpd bears from the same problem.
* audio_format: converted typedef AudioFormat to struct audio_formatMax Kellermann2008-09-079-11/+11
| | | | | Get rid of CamelCase, and don't use a typedef, so we can forward-declare it, and unclutter the include dependencies.
* fix -Wcast-qual -Wwrite-strings warningsMax Kellermann2008-09-072-8/+21
| | | | | | | | | The previous patch enabled these warnings. In Eric's branch, they were worked around with a generic deconst_ptr() function. There are several places where we can add "const" to pointers, and in others, libraries want non-const strings. In the latter, convert string literals to "static char[]" variables - this takes the same space, and seems safer than deconsting a string literal.
* oggflac: fix GCC warningsMax Kellermann2008-08-291-9/+9
| | | | | | Fix lots of "unused parameter" warnings in the OggFLAC decoder plugin. Not sure if anybody uses it anymore, since newer libflac obsoletes it.
* tag: fix the shout and oggflac pluginsMax Kellermann2008-08-291-2/+4
| | | | | | During the tag library refactoring, the shout plugin was disabled, and I forgot about adapting it to the new API. Apply the same fixes to the oggflac decoder plugin.
* wavpack: tag_new() cannot failMax Kellermann2008-08-291-5/+0
| | | | | Since tag_new() uses xmalloc(), it cannot fail - if we're really out of memory, the process will abort.
* tag: renamed functions, no CamelCaseMax Kellermann2008-08-2910-58/+57
|
* tag: renamed MpdTag and MpdTagItem to struct tag, struct mpd_tag_itemMax Kellermann2008-08-2911-43/+43
| | | | | Getting rid of CamelCase; not having typedefs also allows us to forward-declare the structures.
* moved global variable "ob" to outputBuffer.hMax Kellermann2008-08-262-0/+6
| | | | | | | This releases several include file dependencies. As a side effect, "CHUNK_SIZE" isn't defined by decoder_api.h anymore, so we have to define it directly in the plugins which need it. It just isn't worth it to add it to the decoder plugin API.
* flac: decoder command means EOFMax Kellermann2008-08-262-11/+9
| | | | | | | It was possible for the decoder thread to go into an endless loop (flac and oggflac decoders): when a "STOP" command arrived, the Read() callback would return 0, but the EOF() callback returned false. Fix: when decoder_get_command()!=NONE, return EOF==true.
* mp3, flac: check for seek command after decoder_read()Max Kellermann2008-08-262-4/+16
| | | | | | | When we introduced decoder_read(), we added code which aborts the read operation when a decoder command arrives. Several plugins however did not expect that when they were converted to decoder_read(). Add proper checks to the mp3 and flac decoder plugins.
* check decoder_command!=NONE instead of decoder_command==STOPMax Kellermann2008-08-265-13/+14
| | | | | | The code said "decoder_command==STOP" because that was a conversion from the old "dc->stop" test. As we can now check for all commands in one test, we can simply rewrite that to decoder_command!=NONE.
* mp3: converted the MUTEFRAME_ macros to an enumMax Kellermann2008-08-261-9/+12
| | | | Also introduce MUTEFRAME_NONE; previously, the code used "0".
* mp3: converted the DECODE_ constants to an enumMax Kellermann2008-08-261-8/+13
|
* wavpack: don't use "isp" before initializationMax Kellermann2008-08-261-4/+1
| | | | | | The old code called can_seek() with the uninitialized pointer "isp.is". Has this ever worked? Anyway, initialize "isp" first, then call can_seek(&isp).
* wavpack: moved code to wavpack_open_wvc()Max Kellermann2008-08-261-79/+66
| | | | | | Move everything related to finding and initializing the WVC stream to wavpack_open_wvc(). This greatly simplifies its error handling and the function wavpack_streamdecode().
* simplified code in the ogg decoder pluginMax Kellermann2008-08-261-25/+25
| | | | | Return early when the player thread sent us a command. This saves one level of indentation.
* added decoder_read()Max Kellermann2008-08-268-66/+17
| | | | | | | | | On our way to stabilize the decoder API, we will one day remove the input stream functions. The most basic function, read() will be provided by decoder_api.h with this patch. It already contains a loop (still with manual polling), error/eof handling and decoder command checks. This kind of code used to be duplicated in all decoder plugins.
* wavpack: added InputStreamPlus.decoderMax Kellermann2008-08-261-4/+7
| | | | The "decoder" object reference will be used by another patch.
* oggvorbis: don't detect OGG header if stream is not seekableMax Kellermann2008-08-262-0/+10
| | | | | | | | | If the input stream is not seekable, the try_decode() function consumes valuable data, which is not available to the decode() function anymore. This means that the decode() function does not parse the header correctly. Better skip the detection if we cannot seek. Or implement better buffering, something like unread() or buffered rewind().