aboutsummaryrefslogtreecommitdiffstats
path: root/src/outputBuffer.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-10-02Revert "Start using song pointers in core data structures"Eric Wong1-1/+0
This actually opened us up to making lock dependencies more difficult than they needed to be now that we have threaded updates. We would always use the memory anyways, just in the stack instead of bss.
2008-09-29Switch to C99 types (retaining compat with old compilers)Eric Wong1-9/+9
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-28advance to the next song on decoder errorsEric Wong1-1/+2
Fix this regression introduced in the core rewrite so that we now skip to the next song when we encounter an error with the song we tried to decode.
2008-09-02Add missing function prototypesEric Wong1-0/+2
2008-09-02tag: renamed functions, no CamelCaseMax Kellermann1-1/+1
2008-09-02tag: renamed MpdTag and MpdTagItem to struct mpd_tag, struct tag_itemMax Kellermann1-2/+2
Getting rid of CamelCase; not having typedefs also allows us to forward-declare the structures.
2008-09-01Fix shadow warningsEric Wong1-2/+2
2008-08-30clean up CPP includesMax Kellermann1-0/+1
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-30ringbuf: create a new struct rbvec instead of reusing struct iovecEric Wong1-12/+12
Using struct iovec means having to cast iov_base everywhere we want to do pointer arithmetic. Instead, just use rbvec which can be safely casted to iovec whenever we use the readv/writev functions.
2008-08-27Fix software mixerEric Wong1-1/+1
I just forgot to reenable/reinitialize it after the core rewrite.
2008-08-26Reimplement dynamic metadata handlingEric Wong1-7/+29
This has been tested for both playback of streams and outputting to streams, and seems to work fine with minimal locking. This reuses the sequence number infrastructure in OutputBuffer for synchronizing metadata payloads; so (IMNSHO) should be much more understandable than various flags being set here and there.. It could still use some cleanup and much testing, but synchronization issues should be minimal.
2008-08-23outputBuffer: never calculate xfade time if xfade is offEric Wong1-3/+5
We don't assert on xfade_time > 0 inside any of the xfade calculations since we have no lock around xfade_time.
2008-08-23outputBuffer: close audio device on stopEric Wong1-6/+9
2008-08-23outputBuffer: fix buffer_before_play handlingEric Wong1-12/+34
buffer_before_play is a prebuffer; always respecting it is almost as good as having no buffer at all. So we only respect it when we haven't played anything. Bugs that were a side effect of this also got fixed: The player would not stop when we got to the end of the last song on non-repeating playlists. The playlist would continuously show the song in the last few seconds of playback, and never move. Having crossfade enabled would also amplify the above effect. So, as a side effect, crossfade now correctly handles end-of-playlist conditions, as well. It will fade out to silence when we're at the end of a playlist.
2008-08-20outputBuffer: drop buffered audio on new songsEric Wong1-0/+1
Hopefully this fixes the skipping problem Qball reports
2008-08-19Remove ob_wait_sync and cleanup triggering in playlistEric Wong1-28/+17
ob_wait_sync was a gross hack anyways. We are one step closer to being able to trigger actions in our worker threads asynchronously. Just need to make input (file opening) in decoder happen _after_ our decoder returns an ACK.
2008-08-19fix output buffer deadlock when daemonizingEric Wong1-22/+1
We spawned the output buffer thread before daemonizing in initPlayerData(), which is ultra bad because daemonizes forks and threads are not preserved on exit. Since playerData has been stripped bare by this core-rewrite anyways, move this code into the outputBuffer_* group and drop playerData.[ch] completely I completely forgot to test this :<
2008-08-16core rewrite (decode,player,outputBuffer,playlist)Eric Wong1-185/+476
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-15added ob_set_lazy()Max Kellermann1-1/+7
In lazy mode (previously the default), outputBuffer.c only wakes up the player when it was previously empty. That caused a deadlock when the player was waiting for buffered_before_play, since the decoder wouldn't wake up the player when buffered_before_play was reached. In non-lazy mode, always wake up the player when a new chunk was decoded. git-svn-id: https://svn.musicpd.org/mpd/trunk@7364 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-13Make the OutputBuffer API more consistentEric Wong1-65/+65
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-69/+69
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-15/+13
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-12flush after loop in sendDataToOutputBuffer()Max Kellermann1-5/+4
Since tailChunk() automatically flushes full buffers, we do not have to check this in every iteration of sendDataToOutputBuffer(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7343 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12yet another migration to size_tMax Kellermann1-4/+4
We can also get rid of one the two variables. git-svn-id: https://svn.musicpd.org/mpd/trunk@7341 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12check cb->stop in the while loopMax Kellermann1-4/+4
Checking dc->stop in the while condition and again after the while loop costs some CPU cycles we should save. git-svn-id: https://svn.musicpd.org/mpd/trunk@7340 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12eliminate OutputBuffer.currentChunkMax Kellermann1-29/+51
OutputBuffer.currentChunk contains redundant data: it is either -1 when there is no chunk which is currently being written, or it equals "end". If we always keep chunk[end] in a valid state, we can remove OutputBuffer.currentChunk. This patch may look a bit clumsy, especially flushOutputBuffer(), but that will be fixed later with an major OutputBuffer API overhaul. git-svn-id: https://svn.musicpd.org/mpd/trunk@7339 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added output_buffer_expand()Max Kellermann1-13/+22
output_buffer_expand() moves the cb->end to the new position (only its current successor is allowed) and wakes up the player if is waiting for the decoder. This simplifies flushOutputBuffer(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7338 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12initialize all elements in initOutputBuffer()Max Kellermann1-0/+2
The current OutputBuffer object is allocated statically, i.e. it is zeroed. To be safe for other cases in the future, also initialize the other elements. git-svn-id: https://svn.musicpd.org/mpd/trunk@7337 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12wake up player on demandMax Kellermann1-1/+9
The decoder should not wake up the player when it did not produce a flushed chunk. Move the decoder_wakeup_player() call to flushOutputBuffer() and invoke it only if the buffer was previously empty. git-svn-id: https://svn.musicpd.org/mpd/trunk@7336 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12clean up CPP includesMax Kellermann1-5/+0
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-12pass DecoderControl object to decoder_sleep()Max Kellermann1-1/+1
Less global variables: at any invocation of decoder_sleep(), we have a reference to the DecoderControl anyway, so we should pass it. This costs less than having to call getPlayerData() in every tiny function. Maybe some day we will be able to have multiple decoders at the same time... git-svn-id: https://svn.musicpd.org/mpd/trunk@7316 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added output_buffer_free()Max Kellermann1-0/+6
To do proper cleanup before exiting, we have to provide a destructor for OutputBuffer. One day, valgrind will not complain about memory leaks! git-svn-id: https://svn.musicpd.org/mpd/trunk@7315 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12don't use short chunk numbersMax Kellermann1-2/+2
Don't be mean with integer sizes. Although we will probably never have more than 32k buffered chunks, we should use 32 bit integers for addressing them. We do not save very much (some of the saved space is eaten by alignment anyway), but we save at least one assembler instruction for converting short to int. This change requires some more explicit casts, because gcc was less picky when comparing short with a full int. git-svn-id: https://svn.musicpd.org/mpd/trunk@7313 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added output_buffer_skip()Max Kellermann1-0/+6
First patch without camelCase ;) output_buffer_skip() lets us eliminate advanceOutputBufferTo(), and removes yet another external OutputBuffer struct access. git-svn-id: https://svn.musicpd.org/mpd/trunk@7312 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12pass buffered_chunks to initOutputBuffer()Max Kellermann1-14/+17
Try to make OutputBuffer self-contained, without depending on a global variable. git-svn-id: https://svn.musicpd.org/mpd/trunk@7310 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12fix typo in commentMax Kellermann1-3/+3
git-svn-id: https://svn.musicpd.org/mpd/trunk@7305 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12let initOutputBuffer() allocate memoryMax Kellermann1-2/+2
This is the first patch in a series which removes the shared memory, and moves all the playerData objects into the normal libc heap. git-svn-id: https://svn.musicpd.org/mpd/trunk@7304 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added inline function successor()Max Kellermann1-11/+12
The new function successor() can be used to simplify a lot of code lines and saves a lot of "i+>=buffered_chunks" checks. git-svn-id: https://svn.musicpd.org/mpd/trunk@7285 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12moved currentChunk into OutputBufferMax Kellermann1-10/+9
currentChunk is a global variable, which renders the whole output buffer code non-reentrant. Although this is not a real problem since there is only one global output buffer currently, we should move it to the OutputBuffer struct. git-svn-id: https://svn.musicpd.org/mpd/trunk@7284 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added outputBufferShift()Max Kellermann1-0/+10
Hiding OutputBuffer internals, yet again. Two more assertions. git-svn-id: https://svn.musicpd.org/mpd/trunk@7274 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12use sizeof(chunk.data) instead of CHUNK_SIZEMax Kellermann1-2/+2
sizeof() is the more "natural" or "direct" access to the buffer size, instead of a macro happening to be used to the buffer declaration. git-svn-id: https://svn.musicpd.org/mpd/trunk@7270 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added struct OutputBufferChunkMax Kellermann1-17/+15
To make access to OutputBuffer easier, move everything which belongs to a chunk into its own structure, namely OutputBufferChunk. git-svn-id: https://svn.musicpd.org/mpd/trunk@7269 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added outputBufferChunkData()Max Kellermann1-0/+7
Hiding OutputBuffer internals, again. We get an extra assertion in return. git-svn-id: https://svn.musicpd.org/mpd/trunk@7267 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added outputBufferRelative()Max Kellermann1-4/+9
The cross-fade check is still very complicated whenever it uses OutputBuffer internals. Greatly simplify another check by introducing outputBufferRelative(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7264 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added outputBufferEmpty()Max Kellermann1-0/+5
Another "don't use OutputBuffer internals" patch. This ignores the copied "end" value, but I do not think that has ever been a real issue. git-svn-id: https://svn.musicpd.org/mpd/trunk@7263 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12moved check to outputBufferAbsolute()Max Kellermann1-0/+17
decoderParent() uses a lot of OutputBuffer internals to see whether cross-fading should be started. Move these checks to outputBuffer.c, which also simplifies decoderParent(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7262 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12add method availableOutputBuffer()Max Kellermann1-0/+8
The method availableOutputBuffer() calculates how many chunks are in use. This simplifies code which needs this information, and it can run without knowing OutputBuffer internals. The function knows how to calculate this when begin>end; this might have been a bug in decodeParent(), which does not. git-svn-id: https://svn.musicpd.org/mpd/trunk@7250 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12moved code to function tailChunk()Max Kellermann1-33/+58
This patch removes some clutter from decodeParent() by moving some code out. git-svn-id: https://svn.musicpd.org/mpd/trunk@7247 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12use free()+malloc() instead of realloc()Max Kellermann1-1/+3
realloc() has to copy data to the new buffer. Since convBuffer contains temporary data only, we can safely use free() plus a new malloc(), which saves the mempy(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7246 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12outputBuffer: remove unused variableEric Wong1-1/+0
[merged r7185 from branches/ew] git-svn-id: https://svn.musicpd.org/mpd/trunk@7243 09075e82-0dd4-0310-85a5-a0d7c8717e4f