aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/mp3_plugin.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-10-30decoder: use bool for return values and flagsMax Kellermann1-14/+14
Don't return 0/-1 on success/error, but true/false. Instead of int, use bool for storing flags.
2008-10-30mp3: make mp3_read() return boolMax Kellermann1-19/+7
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-29decoder: automatically flush the output buffer after decoder exitsMax Kellermann1-2/+0
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-29decoder_api: removed decoder_clear()Max Kellermann1-5/+1
Call ob_clear() in decoder_command_finished() instead of implementing that call in every decoder plugin.
2008-10-29mp3: seek in backgroundMax Kellermann1-5/+7
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-29mp3: return from mp3_synth_and_send() on any commandMax Kellermann1-2/+2
Previously, the function would only return when a STOP was issued. It makes more sense to consider all possible commands.
2008-10-29mp3: moved code to mp3_synth_and_send()Max Kellermann1-60/+74
Break the large function mp3_read() into smaller pieces.
2008-10-29mp3: moved code to mp3_send_pcm()Max Kellermann1-29/+48
Break the large function mp3_read() into smaller pieces.
2008-10-29mp3: moved code to mp3_update_timer_next_frame()Max Kellermann1-16/+28
Break the large function mp3_read() into smaller pieces.
2008-10-29mp3: moved code to mp3_this_frame_offset()Max Kellermann1-10/+10
Break the large function mp3_read() into smaller pieces.
2008-10-29mp3: moved code to mp3_time_to_frame()Max Kellermann1-11/+21
Break the large function mp3_read() into smaller pieces.
2008-10-29mp3: assert that the stream is seekableMax Kellermann1-5/+5
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-28mp3: moved code to mp3_filesize_to_song_length()Max Kellermann1-23/+42
The function mp3_decode_first_frame() is too large. Move some code to separate smaller functions.
2008-10-28mp3: no "goto"Max Kellermann1-19/+36
http://xkcd.com/292/
2008-10-28mp3: use GLib allocation functionsMax Kellermann1-11/+9
This removes the need for util.h.
2008-10-28mp3: use boolMax Kellermann1-50/+51
Use the C99 bool data type for boolean values.
2008-10-28mp3: no CamelCaseMax Kellermann1-255/+254
Renamed all functions and variables. Also removed the mp3DecodeData typedef.
2008-10-28mp3: remove obsolete commentsMax Kellermann1-4/+0
2008-10-28input_stream: convert offset and size to the off_t data typeMax Kellermann1-1/+1
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-28utils: use g_str_has_prefix() instead of prefixcmp()Max Kellermann1-1/+2
Remove duplicated code from MPD.
2008-10-26input_stream: use "bool" instead of "int"Max Kellermann1-3/+2
For boolean values and success flags, use bool instead of integer (1/0 for true/false, 0/-1 for success/failure).
2008-10-26input_stream: no CamelCaseMax Kellermann1-20/+20
Renamed all functions and variables.
2008-10-26input_stream: removed the InputStream typedefMax Kellermann1-7/+9
Everybody should use struct input_stream.
2008-10-26renamed src/inputPlugins/ to src/decoder/Max Kellermann1-0/+0
These plugins are not input plugins, they are decoder plugins. No CamelCase in the directory name.
2008-10-23mp3: send 24 bit PCM dataMax Kellermann1-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.
2008-10-23mp3: use sizeof(sample) instead of hard-coded "2"Max Kellermann1-2/+3
We are going to convert the code to 24 bit; don't hard-code a sample size of 2 bytes.
2008-10-17Makefile.am: don't compile disabled decoder pluginsMax Kellermann1-11/+3
Don't compile the sources of disabled decoder plugins at all, and don't attempt to register these.
2008-10-10mp3: dither an arbitrary number of channelsMax Kellermann1-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.
2008-10-10mp3: hard-code dithering to 16 bitsMax Kellermann1-8/+6
The dithering function audio_linear_dither() worked for signed 16 bits only anyway, having a variable "bits" just disables important gcc optimizations.
2008-10-10audio_format: renamed sampleRate to sample_rateMax Kellermann1-1/+1
The last bit of CamelCase in audio_format.h. Additionally, rename a bunch of local variables.
2008-09-29use C99 struct initializersMax Kellermann1-10/+7
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.
2008-09-29Switch to C99 types (retaining compat with old compilers)Eric Wong1-5/+5
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.
2008-09-23start using prefixcmp()Eric Wong1-1/+1
LOC reduction and less noise makes things easier for tired old folks to follow.
2008-09-23mp3: fix long line, I can't read past 80 colsEric Wong1-1/+2
2008-09-17mp3: fix buffer overflow when max_frames is too largeMax Kellermann1-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.
2008-09-07audio_format: converted typedef AudioFormat to struct audio_formatMax Kellermann1-2/+2
Get rid of CamelCase, and don't use a typedef, so we can forward-declare it, and unclutter the include dependencies.
2008-08-29tag: renamed functions, no CamelCaseMax Kellermann1-22/+21
2008-08-29tag: renamed MpdTag and MpdTagItem to struct tag, struct mpd_tag_itemMax Kellermann1-9/+9
Getting rid of CamelCase; not having typedefs also allows us to forward-declare the structures.
2008-08-26mp3, flac: check for seek command after decoder_read()Max Kellermann1-1/+10
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.
2008-08-26check decoder_command!=NONE instead of decoder_command==STOPMax Kellermann1-7/+7
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.
2008-08-26mp3: converted the MUTEFRAME_ macros to an enumMax Kellermann1-9/+12
Also introduce MUTEFRAME_NONE; previously, the code used "0".
2008-08-26mp3: converted the DECODE_ constants to an enumMax Kellermann1-8/+13
2008-08-26added decoder_read()Max Kellermann1-14/+6
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.
2008-08-26mp3: added mp3DecodeData.decoderMax Kellermann1-9/+13
We need the decoder object at several places in the mp3 plugin. Add it to mp3DecodeData, so we don't have to pass it around in every function.
2008-08-26mp3: audio_linear_dither() returns mpd_sint16Max Kellermann1-11/+9
The return value of audio_linear_dither() is always casted to mpd_sint16. Returning long does not make sense, and consumed 8 bytes on a 64 bit platform.
2008-08-26mp3: changed outputBuffer's type to mpd_sint16[]Max Kellermann1-3/+3
The output buffer always contains mpd_sint16; declaring it with that type saves several casts.
2008-08-26mp3: moved num_samples calculation out of the loopMax Kellermann1-5/+7
The previous patch removed all loop specific dependencies from the num_samples formula; we can now calculate it before entering the loop.
2008-08-26mp3: eliminated outputPtrMax Kellermann1-14/+3
The output buffer is always flushed after being appended to, which allows us to assume it is always empty. Always start writing at outputBuffer, don't remember outputPtr.
2008-08-26mp3: don't do a second flush in mp3_decode()Max Kellermann1-17/+1
The previous patch made mp3Read() flush the output buffer in every iteration, which means we can eliminate the flush check after invoking mp3Read().
2008-08-26mp3: always flush directly after decoding/ditheringMax Kellermann1-15/+13
Since we try to fill the buffer in every iteration, we assume that we should flush the output buffer at the end of each iteration.