aboutsummaryrefslogtreecommitdiffstats
path: root/src/outputBuffer.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Start using song pointers in core data structures"Eric Wong2008-10-021-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.
* Switch to C99 types (retaining compat with old compilers)Eric Wong2008-09-291-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.
* advance to the next song on decoder errorsEric Wong2008-09-281-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.
* Merge branch 'mk/tag'Eric Wong2008-09-031-3/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * mk/tag: (22 commits) tag: fix segfault on update utf8.h: Fix build (broken os_compat.h #include) tag: optimize tag_dup(), copy item references tag: fix the shout and oggflac plugins const pointers tag: static directory name tag: try not to reallocate tag.items in every add() call song: don't export newNullSong() tag: try not to duplicate the input string tag: pass length to fix_utf8() added "length" parameter to validUtf8String() assert value!=NULL in fix_utf8() tag: converted macro fixUtf8() to an inline function tag: added a pool for tag items tag: converted tag_item.value to a char array removed tree.c tag: converted MpdTag.items to a pointer list tag: moved code to tag_id3.c wavpack: tag_new() cannot fail tag: converted tag_add_item() to an inline function ...
| * tag: renamed functions, no CamelCaseMax Kellermann2008-09-021-1/+1
| |
| * tag: renamed MpdTag and MpdTagItem to struct mpd_tag, struct tag_itemMax Kellermann2008-09-021-2/+2
| | | | | | | | | | Getting rid of CamelCase; not having typedefs also allows us to forward-declare the structures.
* | Add missing function prototypesEric Wong2008-09-021-0/+2
|/
* Merge branch 'mk/cleanups'Eric Wong2008-09-011-12/+13
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * mk/cleanups: (60 commits) pass constant pointers const pointers unsigned integers and size_t oggflac: fix GCC warnings include cleanup protect locate.h from double inclusion playlist: eliminate unused fd parameters jack: made "sample_size" static const moved jack configuration to the JackData struct jack: removed unused macros jack: don't set audioOutput->data=NULL jack: initialize JackData in jack_initDriver() jack: added freeJackClient() jack: initialize jd->client after !jd check jack: eliminate superfluous freeJackData() calls mp3: converted the MUTEFRAME_ macros to an enum mp3: converted the DECODE_ constants to an enum wavpack: don't use "isp" before initialization wavpack: moved code to wavpack_open_wvc() simplified code in the ogg decoder plugin ...
| * clean up CPP includesMax Kellermann2008-08-301-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]
| * ringbuf: create a new struct rbvec instead of reusing struct iovecEric Wong2008-08-301-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.
* | Fix shadow warningsEric Wong2008-09-011-2/+2
|/
* Fix software mixerEric Wong2008-08-271-1/+1
| | | | I just forgot to reenable/reinitialize it after the core rewrite.
* Reimplement dynamic metadata handlingEric Wong2008-08-261-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.
* outputBuffer: never calculate xfade time if xfade is offEric Wong2008-08-231-3/+5
| | | | | We don't assert on xfade_time > 0 inside any of the xfade calculations since we have no lock around xfade_time.
* outputBuffer: close audio device on stopEric Wong2008-08-231-6/+9
|
* outputBuffer: fix buffer_before_play handlingEric Wong2008-08-231-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.
* outputBuffer: drop buffered audio on new songsEric Wong2008-08-201-0/+1
| | | | Hopefully this fixes the skipping problem Qball reports
* Remove ob_wait_sync and cleanup triggering in playlistEric Wong2008-08-191-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.
* fix output buffer deadlock when daemonizingEric Wong2008-08-191-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 :<
* core rewrite (decode,player,outputBuffer,playlist)Eric Wong2008-08-161-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.
* added ob_set_lazy()Max Kellermann2008-04-151-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
* Make the OutputBuffer API more consistentEric Wong2008-04-131-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
* Stop passing our single OutputBuffer object everywhereEric Wong2008-04-131-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
* Stop passing our single DecoderControl object everywhereEric Wong2008-04-131-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
* flush after loop in sendDataToOutputBuffer()Max Kellermann2008-04-121-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
* yet another migration to size_tMax Kellermann2008-04-121-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
* check cb->stop in the while loopMax Kellermann2008-04-121-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
* eliminate OutputBuffer.currentChunkMax Kellermann2008-04-121-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
* added output_buffer_expand()Max Kellermann2008-04-121-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
* initialize all elements in initOutputBuffer()Max Kellermann2008-04-121-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
* wake up player on demandMax Kellermann2008-04-121-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
* clean up CPP includesMax Kellermann2008-04-121-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
* pass DecoderControl object to decoder_sleep()Max Kellermann2008-04-121-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
* added output_buffer_free()Max Kellermann2008-04-121-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
* don't use short chunk numbersMax Kellermann2008-04-121-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
* added output_buffer_skip()Max Kellermann2008-04-121-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
* pass buffered_chunks to initOutputBuffer()Max Kellermann2008-04-121-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
* fix typo in commentMax Kellermann2008-04-121-3/+3
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7305 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* let initOutputBuffer() allocate memoryMax Kellermann2008-04-121-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
* added inline function successor()Max Kellermann2008-04-121-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
* moved currentChunk into OutputBufferMax Kellermann2008-04-121-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
* added outputBufferShift()Max Kellermann2008-04-121-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
* use sizeof(chunk.data) instead of CHUNK_SIZEMax Kellermann2008-04-121-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
* added struct OutputBufferChunkMax Kellermann2008-04-121-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
* added outputBufferChunkData()Max Kellermann2008-04-121-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
* added outputBufferRelative()Max Kellermann2008-04-121-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
* added outputBufferEmpty()Max Kellermann2008-04-121-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
* moved check to outputBufferAbsolute()Max Kellermann2008-04-121-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
* add method availableOutputBuffer()Max Kellermann2008-04-121-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
* moved code to function tailChunk()Max Kellermann2008-04-121-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