aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-08-26renamed InputPlugin to struct decoder_pluginMax Kellermann10-21/+21
"decoder plugin" is a better name than "input plugin", since the plugin does not actually do the input - InputStream does. Also don't use typedef, so we can forward-declare it if required.
2008-08-26eliminate OUTPUT_BUFFER_DC_STOP, OUTPUT_BUFFER_DC_SEEKMax Kellermann2-4/+5
(Ab)use the decoder_command enumeration, which has nearly the same values and the same meaning.
2008-08-26added decoder_get_url()Max Kellermann1-1/+1
The wavpack decoder plugin implements a hack, and it needs the song URL for that. This API (and the hack) should be revised later, but add that function for now.
2008-08-26don't set dc->seekable in wavpack pluginMax Kellermann1-2/+0
dc->seekable is already set by decodeStart().
2008-08-26use a local "initialized" flag instead of dc->stateMax Kellermann3-5/+11
Since we want to hide mpd internals from the decoder plugins, the plugins should not check dc->state whether they have already called decoder_initialized(). Use a local variable to track that.
2008-08-26added decoder_seek_where() and decoder_seek_error()Max Kellermann10-40/+40
Provide access to seeking for the decoder plugins; they have to know where to seek, and they need a way to tell us that seeking has failed.
2008-08-26added decoder_command_finished() to decoder_api.hMax Kellermann10-15/+15
Some decoder commands are implemented in the decoder plugins, thus they need to have an API call to signal that their current command has been finished. Let them use the new decoder_command_finished() instead of the internal dc_command_finished().
2008-08-26added decoder_get_command()Max Kellermann11-59/+67
Another big patch which hides internal mpd APIs from decoder plugins: decoder plugins regularly poll dc->command; expose it with a decoder_api.h function.
2008-08-26moved InputPlugin to decoder_api.hMax Kellermann4-4/+3
InputPlugin is the API which is implemented by a decoder plugin. This belongs to the public API/ABI, so move it to decoder_api.h. It will later be renamed to something like "decoder_plugin".
2008-08-26remove one indent level from audiofile pluginMax Kellermann1-30/+25
Anonymous code blocks just to declare variables look ugly. Move the variable declarations up and disband the code block.
2008-08-26use break instead of local variable "eof"Max Kellermann1-16/+12
Similar to previous patch: eliminate one variable by using "break". This also simplifies the code since we can remove one level of indent.
2008-08-26removed local variable "eof" because it is unusedMax Kellermann2-19/+9
"break" is so much easier than "eof=1; continue;", when "!eof" is the loop condition.
2008-08-26simplify several dc->command checksMax Kellermann1-7/+3
Since we have merged dc->stop, dc->seek into one variable, we don't have to check both conditions at a time; we can replace "!stop && !seek" with "none".
2008-08-26added parameter total_time to decoder_initialized()Max Kellermann12-27/+25
Similar to the previous patch: pass total_time instead of manipulating dc->totalTime directly.
2008-08-26added audio_format parameter to decoder_initialized()Max Kellermann12-81/+78
dc->audioFormat is set once by the decoder plugins before invoking decoder_initialized(); hide dc->audioFormat and let the decoder pass an AudioFormat pointer to decoder_initialized().
2008-08-26added decoder_clear() and decoder_flush()Max Kellermann10-22/+21
We are now beginning to remove direct structure accesses from the decoder plugins. decoder_clear() and decoder_flush() mask two very common buffer functions.
2008-08-26added decoder_data()Max Kellermann9-59/+58
Moved all of the player-waiting code to decoder_data(), to make OutputBuffer more generic.
2008-08-26added decoder_initialized()Max Kellermann11-31/+28
decoder_initialized() sets the state to DECODE_STATE_DECODE and wakes up the player thread. It is called by the decoder plugin after its internal initialization is finished. More arguments will be added later to prevent direct accesses to the DecoderControl struct.
2008-08-26added struct decoderMax Kellermann12-23/+35
The decoder struct should later be made opaque to the decoder plugin, because maintaining a stable struct ABI is quite difficult. The ABI should only consist of a small number of stable functions.
2008-08-26added dc_command_finished()Max Kellermann10-30/+15
dc_command_finished() is invoked by the decoder thread when it has finished a command (sent by the player thread). It resets dc.command and wakes up the player thread. This combination was used at a lot of places, and by introducing this function, the code will be more readable.
2008-08-26merged start, stop, seek into DecoderControl.commandMax Kellermann11-80/+95
Much of the existing code queries all three variables sequentially. Since only one of them can be set at a time, this can be optimized and unified by merging all of them into one enum variable. Later, the "command" checks can be expressed in a "switch" statement.
2008-08-26clean up CPP includesMax Kellermann13-64/+0
Include only headers which are really required. This speeds up compilation and helps detect cross-layer accesses.
2008-08-26enable -Wpointer-arith, -Wstrict-prototypesMax Kellermann4-10/+11
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-06-30don't call seekInputStream(0) if r==0Max Kellermann1-1/+2
If nothing has been read from the input stream, we don't have to rewind it. git-svn-id: https://svn.musicpd.org/mpd/trunk@7397 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30eliminated local variable "to_read"Max Kellermann1-4/+3
The variable "to_read" is never modified except in the last iteration of the while loop. This means the while condition will never become false, as the body will break before that may be checked. git-svn-id: https://svn.musicpd.org/mpd/trunk@7396 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-13mod: fix crashing on modtracker filesHans de Goede1-1/+1
This patch was taken from http://bugzilla.livna.org/show_bug.cgi?id=1987 and addresses bug 0001693[1] [1] - http://musicpd.org/mantis/view.php?id=1693 git-svn-id: https://svn.musicpd.org/mpd/trunk@7374 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-01oggflac_plugin: fix build with libOggFLAC lib (libFLAC <= 7)Eric Wong1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@7370 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-15use dc.current_song instead of pc.current_songMax Kellermann1-1/+1
When we are in an input plugin, dc.current_song should already be set. Use it instead of pc.current_song. git-svn-id: https://svn.musicpd.org/mpd/trunk@7363 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-13Make the OutputBuffer API more consistentEric Wong12-42/+42
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 Wong12-86/+77
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 Wong12-244/+222
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-13Get rid of PlayerControl inside the PlayerData structEric Wong1-1/+1
It actually increases our image size a small bit and may even hurt performance a very small bit, but makes the code less verbose and easier to manage. I don't see a reason for mpd to ever support playing multiple files at the same time (users can run multiple instances of mpd if they really want to play Zaireeka, but that's such an edge case it's not worth ever supporting in our code). git-svn-id: https://svn.musicpd.org/mpd/trunk@7352 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 Kellermann2-4/+9
git-svn-id: https://svn.musicpd.org/mpd/trunk@7324 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12clean up CPP includesMax Kellermann1-0/+1
Try to only include headers which are really needed. We should particularly check all "headers including other headers". The long-term goal is to have a manageable, small API for plugins (decoders, output) without so many mpd internals cluttering the namespace. git-svn-id: https://svn.musicpd.org/mpd/trunk@7319 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12Fix a few more warnings from -WshadowEric Wong3-27/+29
git-svn-id: https://svn.musicpd.org/mpd/trunk@7300 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12constant pointersMax Kellermann2-4/+4
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
2008-04-12fix parameter types in the faad callsMax Kellermann2-3/+3
libfaad wants uint32_t pointers. Passing a long pointer is bugged on amd64. git-svn-id: https://svn.musicpd.org/mpd/trunk@7289 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12fix compilation error in wavpack pluginMax Kellermann1-3/+6
The patch "Start using song pointers in core data structures" removed dc->utf8url, and the adaption for wavpack_plugin.c was missing. git-svn-id: https://svn.musicpd.org/mpd/trunk@7288 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12yet more unsigned integersMax Kellermann2-5/+5
git-svn-id: https://svn.musicpd.org/mpd/trunk@7287 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12Drop metadata updates from HTTP for now (input HTTP, and shout)Eric Wong2-6/+0
It is way more complicated than it should be; and locking it for thread-safety is too difficult. [merged r7183 from branches/ew] git-svn-id: https://svn.musicpd.org/mpd/trunk@7241 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12Initial cut of fork() => pthreads() for decoder and playerEric Wong10-0/+15
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