aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_utils.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Switch to C99 types (retaining compat with old compilers)Eric Wong2008-09-291-32/+32
| | | | | | | | | | | | | | | 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.
* pcm_utils: added pcm_range()Max Kellermann2008-09-281-10/+18
| | | | | | | Make the code more readable by moving the range checks to pcm_range(). gcc does quite a good job at optimizing it: the resulting binary is exactly the same, although it contains a parametrized shift instead of hard-coded boundaries.
* pcm_utils: added inline function pcm_dither()Max Kellermann2008-09-281-8/+10
| | | | | Merge some code into an inline function, so we can optimize it later only once.
* audio_format: converted typedef AudioFormat to struct audio_formatMax Kellermann2008-09-071-7/+10
| | | | | 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-071-9/+10
| | | | | | | | | 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.
* enable -Wpointer-arith, -Wstrict-prototypesMax Kellermann2008-08-261-2/+4
| | | | | | Also enable -Wunused-parameter - this forces us to add the gcc "unused" attribute to a lot of parameters (mostly library callback functions), but it's worth it during code refactorizations.
* more const pointers in pcm_utils.[ch]Max Kellermann2008-04-151-3/+4
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7360 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* decode: fix some uninitialized variable warningsEric Wong2008-04-121-1/+1
| | | | | They're probably not needed, but less noise => faster debugging git-svn-id: https://svn.musicpd.org/mpd/trunk@7302 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* missing const in disabled code pathMax Kellermann2008-04-121-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7298 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* constant pointersMax Kellermann2008-04-121-5/+5
| | | | | | There were some const pointers missing in the previous const-cleanup patch. git-svn-id: https://svn.musicpd.org/mpd/trunk@7290 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* use constant pointers when possibleMax Kellermann2008-04-121-13/+12
| | | | | | It is a good practice to constify pointers when their dereferenced data is not modified within the functions or its descendants. git-svn-id: https://svn.musicpd.org/mpd/trunk@7234 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* use size_tMax Kellermann2008-03-261-1/+1
| | | | | | | | When dealing with in-memory lengths, the standard type "size_t" should be used. Missing one can be quite dangerous, because an attacker could provoke an integer under-/overflow, which may provide an attack vector. git-svn-id: https://svn.musicpd.org/mpd/trunk@7205 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Cleanup #includes of standard system headers and put them in one placeEric Wong2008-01-031-4/+1
| | | | | | | | | | | | | This will make refactoring features easier, especially now that pthreads support and larger refactorings are on the horizon. Hopefully, this will make porting to other platforms (even non-UNIX-like ones for masochists) easier, too. os_compat.h will house all the #includes for system headers considered to be the "core" of MPD. Headers for optional features will be left to individual source files. git-svn-id: https://svn.musicpd.org/mpd/trunk@7130 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* pcm_utils: gcc 2.95 compile fix (extra semi-colon)Eric Wong2007-09-101-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6872 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Changing all calls to ERROR() followed by exit(EXIT_FAILURE) with a singleJ. Alexander Treuman2007-05-261-8/+4
| | | | | call to FATAL(). git-svn-id: https://svn.musicpd.org/mpd/trunk@6276 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Cleaning up pcm_getSampleRateConverter.J. Alexander Treuman2007-05-261-23/+27
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6275 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Exit with an error if channel count isn't 1 or 2.J. Alexander Treuman2007-05-261-0/+4
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6274 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Make pcm_convertAudioFormat return the buffer size. This is necessaryJ. Alexander Treuman2007-05-261-17/+20
| | | | | | | | because lsr may return less than the input buffer size, and the rest of the audio code needs to know the new size. This fixes the clicking that was introduced with recent changes to the lsr code. A huge thanks to remiss for figuring this out. git-svn-id: https://svn.musicpd.org/mpd/trunk@6273 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Reverting to the full lsr API. Turns out the simple API needs all of theJ. Alexander Treuman2007-05-241-29/+52
| | | | | | | | audio at once, so it won't work for us. The old full API code was still heavily broken, as each call to pcm_convertSampleRate() used the same state, even if it was processing two streams of audio. The new code keeps a separate state for each audio stream that's being converted. git-svn-id: https://svn.musicpd.org/mpd/trunk@6255 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Tidying up pcm_utils.c a bit more.J. Alexander Treuman2007-05-231-8/+9
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6230 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Switching to the lsr simple API. The problem with the full API is that theJ. Alexander Treuman2007-05-231-19/+7
| | | | | | | | | | | number of channels is specified when the converter state is created. Previously this was only done once, thus breaking horribly when the input audio suddenly had a different channel count. A new state could be created every time the number of channels changes, but this could happen many times a second if resampling to two different formats at once. The simple API doesn't have this problem, as channel count is an argument to the conversion function itself. git-svn-id: https://svn.musicpd.org/mpd/trunk@6229 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Split pcm_convertAudioFormat into separate functions for bitrate, channel,J. Alexander Treuman2007-05-221-168/+207
| | | | | | and samplerate conversion. This makes the code much easier to read, and fixes a few bugs that were previously there. git-svn-id: https://svn.musicpd.org/mpd/trunk@6224 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Cleaning up/correcting some comments.J. Alexander Treuman2007-05-221-10/+7
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6200 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* ReindentingJ. Alexander Treuman2007-05-221-10/+12
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6199 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* The massive copyright updateAvuton Olrich2007-04-051-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5834 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* pcm_utils: fix libsamplerate compilation with non-C99 compilersEric Wong2007-02-191-4/+12
| | | | | | | | | | | | Mixing code and declarations is ugly, anyways. We could probably get away with using alloca(), but I'm not sure how good compiler support is for that, either. It's probably more supported than mixed declarations and code. Nevertheless; we'll trigger memory checkers on exit because we don't free the buffers; but we won't actually leak because we reuse those buffers (just like the non-SRC code path). git-svn-id: https://svn.musicpd.org/mpd/trunk@5397 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Fixing some weird floating point comparison issue. Not exactly sure whyJ. Alexander Treuman2007-02-131-2/+3
| | | | | this fixes it though. git-svn-id: https://svn.musicpd.org/mpd/trunk@5338 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Add libsamplerate support, old resampling is still an option, but this ↵Avuton Olrich2007-02-021-10/+99
| | | | | sounds much better for those who need it and don't want to use pulseaudio. Reviewed by shank/avuton. git-svn-id: https://svn.musicpd.org/mpd/trunk@5316 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Don't initialize globals to zero (or NULL)Eric Wong2007-01-141-4/+4
| | | | | | | | Some compilers and linkers aren't smart enough to optimize this, as global variables are implictly initialized to zero. As a result, binaries are a bit smaller as more goes in the .bss and less in the text section. git-svn-id: https://svn.musicpd.org/mpd/trunk@5254 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Replace strdup and {c,re,m}alloc with x* variants to check for OOM errorsEric Wong2006-08-261-3/+4
| | | | | | | | | | | | | | | | | | | I'm checking for zero-size allocations and assert()-ing them, so we can more easily get backtraces and debug problems, but we'll also allow -DNDEBUG people to live on the edge if they wish. We do not rely on errno when checking for OOM errors because some implementations of malloc do not set it, and malloc is commonly overridden by userspace wrappers. I've spent some time looking through the source and didn't find any obvious places where we would explicitly allocate 0 bytes, so we shouldn't trip any of those assertions. We also avoid allocating zero bytes because C libraries don't handle this consistently (some return NULL, some not); and it's dangerous either way. git-svn-id: https://svn.musicpd.org/mpd/trunk@4690 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Add mpd-indent.shAvuton Olrich2006-07-201-115/+124
| | | | | | Indent the entire tree, hopefully we can keep it indented. git-svn-id: https://svn.musicpd.org/mpd/trunk@4410 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* [CLEANUP] Remove unused functionAvuton Olrich2006-07-141-39/+24
| | | | | Cleanup whitespace->tabs git-svn-id: https://svn.musicpd.org/mpd/trunk@4338 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Change shank's email addressJ. Alexander Treuman2006-07-141-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Huge header update, update the copyright and addAvuton Olrich2006-07-131-1/+1
| | | | | the GPL header where necessary git-svn-id: https://svn.musicpd.org/mpd/trunk@4317 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* wee found the audioFormatConversion bug, was actually a bug in shout pluginWarren Dukes2004-10-231-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2311 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* ok, resampling and converting to mono no worksWarren Dukes2004-10-231-27/+41
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2309 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* configure shout encoding quality and audio formatWarren Dukes2004-10-231-26/+49
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2307 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* todo updateWarren Dukes2004-06-061-2/+0
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@1352 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* trash XMMS resampling, use ESD's instead, don't understand it, but it worksWarren Dukes2004-05-101-34/+22
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@979 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* some debug codeWarren Dukes2004-05-101-2/+9
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@978 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* ???Warren Dukes2004-05-101-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@977 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix a bug in channel conversionWarren Dukes2004-05-101-2/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@975 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix computation of conversion buffer sizeWarren Dukes2004-05-101-7/+26
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@974 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* format conversion for 8->16 bis and mono->stereoWarren Dukes2004-05-101-12/+75
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@973 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* resampling code blatantly ripped from xmms, needs testing and need toWarren Dukes2004-05-101-3/+55
| | | | | right conversion routines for bit conversion and channel conversion git-svn-id: https://svn.musicpd.org/mpd/trunk@971 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* more little bits of code in prep for resample/audioFormat conversion,Warren Dukes2004-05-101-1/+18
| | | | | now to just write the actual audioFormat conversion code! git-svn-id: https://svn.musicpd.org/mpd/trunk@970 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* add vim shiznit to end of all source filesWarren Dukes2004-04-141-0/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@750 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* adjust scaling of software volumeWarren Dukes2004-04-111-8/+8
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@681 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* use EXIT_SUCCESS and EXIT_FAILUREWarren Dukes2004-04-021-2/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@591 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* obotomize mixing a bitWarren Dukes2004-03-051-6/+8
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@198 09075e82-0dd4-0310-85a5-a0d7c8717e4f