aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/flac_plugin.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-09-29flac: removed FlacData.chunk_lengthMax Kellermann1-1/+0
chunk_length can be converted to a local variable, because it is always reset to 0 after it was used.
2008-09-29flac: moved code from flacWrite() to _flac_common.cMax Kellermann1-68/+1
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.
2008-09-29flac: assume the buffer is empty in flacWrite() IIMax Kellermann1-6/+2
The previous patch on this topic was incomplete: it still added data->chunk_length when calling flac_convert(). Remove this, too.
2008-09-02tag: renamed functions, no CamelCaseMax Kellermann1-4/+4
2008-09-02tag: renamed MpdTag and MpdTagItem to struct mpd_tag, struct tag_itemMax Kellermann1-7/+7
Getting rid of CamelCase; not having typedefs also allows us to forward-declare the structures.
2008-08-30clean up CPP includesMax Kellermann1-6/+0
Include only headers which are really required. This speeds up compilation and helps detect cross-layer accesses. [ew: minor fixups to not break on new core]
2008-08-30enable -Wpointer-arith, -Wstrict-prototypesMax Kellermann1-7/+7
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.
2008-08-16core rewrite (decode,player,outputBuffer,playlist)Eric Wong1-28/+25
This is a huge refactoring of the core mpd process. The queueing/buffering mechanism is heavily reworked. The player.c code has been merged into outputBuffer (the actual ring buffering logic is handled by ringbuf.c); and decode.c actually handles decoding stuff. The end result is several hundreds of lines shorter, even though we still have a lot of DEBUG statements left in there for tracing and a lot of assertions, too.
2008-04-13Make the OutputBuffer API more consistentEric Wong1-2/+2
We had functions names varied between outputBufferFoo, fooOutputBuffer, and output_buffer_foo That was too confusing for my little brain to handle. And the global variable was somehow named 'cb' instead of the more obvious 'ob'... git-svn-id: https://svn.musicpd.org/mpd/trunk@7355 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-13Stop passing our single OutputBuffer object everywhereEric Wong1-9/+8
All of our main singleton data structures are implicitly shared, so there's no reason to keep passing them around and around in the stack and making our internal API harder to deal with. git-svn-id: https://svn.musicpd.org/mpd/trunk@7354 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-13Stop passing our single DecoderControl object everywhereEric Wong1-23/+20
This at least makes the argument list to a lot of our plugin functions shorter and removes a good amount of line nois^W^Wcode, hopefully making things easier to read and follow. git-svn-id: https://svn.musicpd.org/mpd/trunk@7353 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12replaced assertion with checkMax Kellermann1-2/+1
During my tests, it happened that data->position>newPosition. I have not yet fully understood why this can happen; for now, replace this with a run-time check. git-svn-id: https://svn.musicpd.org/mpd/trunk@7334 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12multiply num_samples with bytes_per_channelMax Kellermann1-1/+1
The patch "convert blocks until the buffer is full" did not update data->chunk_length correctly: it added the number of samples, not the number of bytes. Multiply that with bytes_per_channel git-svn-id: https://svn.musicpd.org/mpd/trunk@7332 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12missing num_channels check in previous patchMax Kellermann1-1/+1
In the patch "special optimized case for 16bit stereo", the check for "num_channels==2" was missing. git-svn-id: https://svn.musicpd.org/mpd/trunk@7331 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12special optimized case for 16bit stereoMax Kellermann1-3/+20
Not having to loop for every sample byte (depending on a variable unknown at compile time) saves a lot of CPU cycles. We could consider reimplementing this function with liboil... git-svn-id: https://svn.musicpd.org/mpd/trunk@7330 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12read num_channels onceMax Kellermann1-3/+4
Read frame->header.channels once, and pass only this integer to flac_convert(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7329 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12assume the buffer is empty in flacWrite()Max Kellermann1-4/+3
flacWrite() is the only function which sets data->chunk_length. If we flush the buffer before we return, we can assume that it is always empty upon entering flacWrite(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7328 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12convert blocks until the buffer is fullMax Kellermann1-23/+43
Move the inner loop which converts samples to flac_convert(). There it is isolated and easier to optimize. This function does not have to worry about buffer boundaries; the caller (i.e. flacWrite()) calculates how much is left and is responsible for flushing. That saves a lot of superfluous range checks within the loop. git-svn-id: https://svn.musicpd.org/mpd/trunk@7327 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12calculate bytes_per_channel, check for buffer flush onceMax Kellermann1-11/+14
Check for flushing the chunk buffer only once per sample, before iterating over channels and bytes. This saves another 5% CPU cycles. git-svn-id: https://svn.musicpd.org/mpd/trunk@7326 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12don't calculate bytes per sample within the loopMax Kellermann1-1/+2
AudioFormat.bits is volatile, and to read it, 3 pointers had to be deferenced. Calculate this value once. This speeds up this function by 5%. git-svn-id: https://svn.musicpd.org/mpd/trunk@7325 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12use unsigned integers and size_t in the flac pluginMax Kellermann1-2/+7
git-svn-id: https://svn.musicpd.org/mpd/trunk@7324 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12Initial cut of fork() => pthreads() for decoder and playerEric Wong1-0/+1
I initially started to do a heavy rewrite that changed the way processes communicated, but that was too much to do at once. So this change only focuses on replacing the player and decode processes with threads and using condition variables instead of polling in loops; so the changeset itself is quiet small. * The shared output buffer variables will still need locking to guard against race conditions. So in this effect, we're probably just as buggy as before. The reduced context-switching overhead of using threads instead of processes may even make bugs show up more or less often... * Basic functionality appears to be working for playing local (and NFS) audio, including: play, pause, stop, seek, previous, next, and main playlist editing * I haven't tested HTTP streams yet, they should work. * I've only tested ALSA and Icecast. ALSA works fine, Icecast metadata seems to get screwy at times and breaks song advancement in the playlist at times. * state file loading works, too (after some last-minute hacks with non-blocking wakeup functions) * The non-blocking (*_nb) variants of the task management functions are probably overused. They're more lenient and easier to use because much of our code is still based on our previous polling-based system. * It currently segfaults on exit. I haven't paid much attention to the exit/signal-handling routines other than ensuring it compiles. At least the state file seems to work. We don't do any cleanups of the threads on exit, yet. * Update is still done in a child process and not in a thread. To do this in a thread, we'll need to ensure it does proper locking and communication with the main thread; but should require less memory in the end because we'll be updating the database "in-place" rather than updating a copy and then bulk-loading when done. * We're more sensitive to bugs in 3rd party libraries now. My plan is to eventually use a master process which forks() and restarts the child when it dies: locking and communication with the main thread; but should require less memory in the end because we'll be updating the database "in-place" rather than updating a copy and then bulk-loading when done. * We're more sensitive to bugs in 3rd party libraries now. My plan is to eventually use a master process which forks() and restarts the child when it dies: master - just does waitpid() + fork() in a loop \- main thread \- decoder thread \- player thread At the beginning of every song, the main thread will set a dirty flag and update the state file. This way, if we encounter a song that triggers a segfault killing the main thread, the master will start the replacement main on the next song. * The main thread still wakes up every second on select() to check for signals; which affects power management. [merged r7138 from branches/ew] git-svn-id: https://svn.musicpd.org/mpd/trunk@7240 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12use unsigned integers in the flac pluginMax Kellermann1-1/+1
The counter variables c_samp and c_chan begin at zero and can never be negative. git-svn-id: https://svn.musicpd.org/mpd/trunk@7228 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12removed unused variableMax Kellermann1-3/+3
The local variable d_samp is initialized, but never actually used. git-svn-id: https://svn.musicpd.org/mpd/trunk@7227 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-02-05fix -Wconst warningsMax Kellermann1-9/+9
[ew: cleaned up the dirty union hack a bit] Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7180 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26assume old flac api when FLAC_API_VERSION_CURRENT is not definedMax Kellermann1-1/+1
the code is inconsistent when FLAC_API_VERSION_CURRENT is not defined: sometimes version > 7 is assumed, and sometimes version <= 7. solve this by assuming the version is old when FLAC_API_VERSION_CURRENT is not defined. Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7144 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03Cleanup #includes of standard system headers and put them in one placeEric Wong1-5/+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
2008-01-01Simplify decode cleanup logic a bitEric Wong1-10/+0
DECODE_STATE_STOP is always set as dc->state, and dc->stop is always cleared. So handle it in decodeStart once rather than doing it in every plugin. While we're at it, fix a long-standing (but difficult to trigger) bug in mpc_decode where we failed to return if mpc_decoder_initialize() fails. git-svn-id: https://svn.musicpd.org/mpd/trunk@7122 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-06Fix replaygain for latest flac version.Qball Cow1-0/+9
The updated initialize method did not tell the libFLAC to look for the tag containing the replay information. git-svn-id: https://svn.musicpd.org/mpd/trunk@7075 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-14Add oga extension for flac-1.2.1Avuton Olrich1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@6888 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-28inputPlugins/flac: improve error messagesEric Wong1-12/+13
For the default: case, just use the error message that libFLAC provides instead of using something ambiguous. Also, this gets rid of long lines in the code, making it easier to digest. Of course, we save ~100 bytes of text space in the process :) git-svn-id: https://svn.musicpd.org/mpd/trunk@6830 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-04-05The massive copyright updateAvuton Olrich1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@5834 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-01-14flac: workaround for type inconsistency between new/old read callbackEric Wong1-1/+1
size_t (1.1.3) makes a lot more sense, but older flac used unsigned here... git-svn-id: https://svn.musicpd.org/mpd/trunk@5258 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-01-14Don't initialize globals to zero (or NULL)Eric Wong1-12/+1
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
2007-01-14flac/ogg/oggflac: keep old mime-types in addition to the new onesEric Wong1-2/+7
We'll be dealing with legacy server configurations for a long time to come. git-svn-id: https://svn.musicpd.org/mpd/trunk@5253 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-01-14flac: sparse: mismatched enum type for seekEric Wong1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@5244 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-01-06Fix the mime types for flac & oggflac, see mantis bug #1423 for more informationAvuton Olrich1-2/+2
git-svn-id: https://svn.musicpd.org/mpd/trunk@5222 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-12-04Add OggFLAC support when using the new 1.1.3 FLAC libraryEric Wong1-18/+105
This means that when using libFLAC as a shared object, OggFLAC support is dependent on the compile-time options of the libFLAC library loaded. git-svn-id: https://svn.musicpd.org/mpd/trunk@5112 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-12-04Introduce backwards compatibility with pre-1.1.3 FLACEric Wong1-56/+106
git-svn-id: https://svn.musicpd.org/mpd/trunk@5111 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-12-04inputPlugins/flac_plugin: switch to the new (1.1.3) APIEric Wong1-106/+60
We will restore compatibility with the old API in the next few commits; along with OggFLAC support. git-svn-id: https://svn.musicpd.org/mpd/trunk@5110 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-12-04inputPlugins/flac_plugin: cleanup static declarationsEric Wong1-149/+122
move flac_decode to the bottom, so we don't have to declare all of our static functions. git-svn-id: https://svn.musicpd.org/mpd/trunk@5109 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-08-20trivial: labels should be on the left-most column, no tabbingEric Wong1-1/+1
Unfortunately there doesn't seem to be an indent switch for this, but we have find + perl: find src -name '*.[ch]' | xargs perl -i -p -e \ 's/^\s+(\w+):/$1:/g unless /^\s+default:/' This is a followup to r4605, and there are no actual code changes in this. git-svn-id: https://svn.musicpd.org/mpd/trunk@4661 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-20Add mpd-indent.shAvuton Olrich1-2/+2
Add a few new options for indent to try to make things a bit cleaner git-svn-id: https://svn.musicpd.org/mpd/trunk@4411 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-20Add mpd-indent.shAvuton Olrich1-188/+231
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
2006-07-17inputPlugins/*_plugin.c: static-ficationEric Wong1-23/+23
Nothing here is ever exported for linkage besides the InputPlugin structure, so mark them static to save a few bytes. git-svn-id: https://svn.musicpd.org/mpd/trunk@4382 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-17sparse: fix a enum type mismatch in flac_pluginEric Wong1-1/+1
Both values are compiled to zero, but this is more correct since we're using the correct enum (in the unlikely case that the FLAC library breaks compatibility). git-svn-id: https://svn.musicpd.org/mpd/trunk@4379 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-14Change shank's email addressJ. Alexander Treuman1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@4333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-13Huge header update, update the copyright and addAvuton Olrich1-1/+1
the GPL header where necessary git-svn-id: https://svn.musicpd.org/mpd/trunk@4317 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-03-16merge with mpd/trunk up to r3925Eric Wong1-226/+32
git-svn-id: https://svn.musicpd.org/mpd/trunk@3926 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2005-12-31flac_plugin: revert the performance optimization we did a while agoEric Wong1-23/+19
the performance optimization was broken for big-endian architectures. mpd-uclinux is doing using a slightly different optimization to flacWrite() that we may end up using here in the future. git-svn-id: https://svn.musicpd.org/mpd/trunk@3753 09075e82-0dd4-0310-85a5-a0d7c8717e4f