aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* decode: clear dc.seek_where if we're not seekingEric Wong2008-08-271-2/+1
| | | | | | This way if we previously had a seek error, starting to play a new song will immediately update the status metadata.
* fix output buffer deadlock when daemonizingEric Wong2008-08-191-1/+0
| | | | | | | | | | | 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-463/+203
| | | | | | | | | | | | | 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.
* fix stream URLMax Kellermann2008-06-011-1/+2
| | | | | | | | Streaming was broken, beacuse the stream URL was never copied to path_max_fs. [ew: replaced strcpy with pathcpy_trunc for ease of auditing] git-svn-id: https://svn.musicpd.org/mpd/trunk@7371 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* notify: don't use camelCase in notify.[ch]Max Kellerman2008-06-011-4/+4
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7367 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* assert dc.state == DECODE_STATE_STOPMax Kellerman2008-06-011-1/+2
| | | | | | | During the decoder thread main loop, dc.state must be DECODE_STATE_STOP. Explicitly assigning it after the "dc.stop" check is redundant. git-svn-id: https://svn.musicpd.org/mpd/trunk@7366 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* 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
* const pointers in decode.cMax Kellermann2008-04-151-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7362 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix XFADE_DISABLED=-1Max Kellermann2008-04-151-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7359 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* decode.c: make the crossfade state variable self-documentingEric Wong2008-04-141-15/+18
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7358 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Make the OutputBuffer API more consistentEric Wong2008-04-131-21/+21
| | | | | | | | | | 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-42/+35
| | | | | | | 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-99/+91
| | | | | | | 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
* Get rid of PlayerControl inside the PlayerData structEric Wong2008-04-131-102/+92
| | | | | | | | | | | | 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
* Fix the problem of songs not advancing without client activityEric Wong2008-04-121-0/+1
| | | | | | | | | | | | | The select() in the main event loop blocks now (saving us many unnecessary wakeups). This interacted badly with the threads that were trying to wakeup the main task via pthread_cond_signal() since the main task was not blocked on a condition variable, but on select(). So now if we detect a need to wakeup the player, we write to a pipe which select() is watching instead of blindly calling pthread_cond_signal(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7347 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix several errors/warnings which only appear with -O3Max Kellermann2008-04-121-0/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* pass dc to decoder_task()Max Kellermann2008-04-121-4/+4
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7323 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 pc to player notify functionsMax Kellermann2008-04-121-13/+15
| | | | | Same as the previous patch: less global variables. git-svn-id: https://svn.musicpd.org/mpd/trunk@7317 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* pass DecoderControl object to decoder_sleep()Max Kellermann2008-04-121-15/+12
| | | | | | | | | 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
* remove the local variable "end"Max Kellermann2008-04-121-5/+0
| | | | | | "end" is not being used anymore, since we moved most OutputBuffer struct accesses into methods. git-svn-id: https://svn.musicpd.org/mpd/trunk@7314 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-8/+1
| | | | | | | | 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
* remove buffered_chunks, use cb->sizeMax Kellermann2008-04-121-1/+2
| | | | | | | Second patch to make OutputBuffer self-contained: since OutputBuffer now knows its own size, we do not need the global variable "buffered_chunks" anymore. git-svn-id: https://svn.musicpd.org/mpd/trunk@7311 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* decode: fix some uninitialized variable warningsEric Wong2008-04-121-2/+2
| | | | | They're probably not needed, but less noise => faster debugging git-svn-id: https://svn.musicpd.org/mpd/trunk@7302 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* decode: fix unsigned comparision and add some paranoid assertionsEric Wong2008-04-121-8/+9
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7301 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Fix a few more warnings from -WshadowEric Wong2008-04-121-4/+4
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7300 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* some assertions to check the unsigned changesMax Kellermann2008-04-121-0/+3
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7297 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* yet more unsigned integersMax Kellermann2008-04-121-4/+4
| | | | | | | | | | calculateCrossFadeChunks() still returns int, although the caller uses it as an unsigned value. Since the function body checks for negative values, it is safe to cast to unsigned. crossFade() takes signed parameters, although it callers pass unsigned integers. Change declaration to unsigned. git-svn-id: https://svn.musicpd.org/mpd/trunk@7291 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* use the notify API in the decoderMax Kellermann2008-04-121-6/+8
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7281 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* use break instead of quitDecode()+returnMax Kellermann2008-04-121-6/+3
| | | | | | | | The code paths which return from the functions all have to call quitDecode(). If we simply break instead of calling quitDecode() explicitly, this function gets called in the last line of this function anyway. git-svn-id: https://svn.musicpd.org/mpd/trunk@7278 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* moved expression to audioFormatSizeToTime()Max Kellermann2008-04-121-3/+1
| | | | | | | The multi-line expression which calculates sizeToTime is hard to read, partly because "cb->audioFormat." is too long. Create a separate inline function in audio.h for that. git-svn-id: https://svn.musicpd.org/mpd/trunk@7277 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* let calculateCrossFadeChunks() decideMax Kellermann2008-04-121-14/+12
| | | | | | | Moved the decision whether to cross-fade the current song to calculateCrossFadeChunks(). This simplifies the function decoderParent() and eliminates one layer of indentation. git-svn-id: https://svn.musicpd.org/mpd/trunk@7276 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* moved code to playChunk()Max Kellermann2008-04-121-10/+20
| | | | | | Similar to the crossFade() patch: pass chunk objects to playChunk(), simplify decodeParent() by removing clutter. git-svn-id: https://svn.musicpd.org/mpd/trunk@7275 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* added outputBufferShift()Max Kellermann2008-04-121-4/+1
| | | | | Hiding OutputBuffer internals, yet again. Two more assertions. git-svn-id: https://svn.musicpd.org/mpd/trunk@7274 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* continue main loop instead of nesting loopsMax Kellermann2008-04-121-13/+5
| | | | | | | To unify the decoderParent() main loop some more, use it to wait for the decoder to change the song. Only one single processDecodeInput() caller left after this patch. git-svn-id: https://svn.musicpd.org/mpd/trunk@7273 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* sleep when waiting for cross-fade chunksMax Kellermann2008-04-121-1/+3
| | | | | | | When there are not enough decode cross-fade chunks in the buffer yet, the current code does busy-wait, which will delay the decoder even more. sleep instead, expecting the decoder to wake us up. git-svn-id: https://svn.musicpd.org/mpd/trunk@7272 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* moved code to crossFade()Max Kellermann2008-04-121-15/+20
| | | | | | | Calling crossFade() with the chunk objects is easier than unrolling all the chunk properties manually, and decodeParent() can really use more of these simplifications. git-svn-id: https://svn.musicpd.org/mpd/trunk@7271 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* added struct OutputBufferChunkMax Kellermann2008-04-121-16/+19
| | | | | | 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-4/+2
| | | | | | 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
* removed "quit"Max Kellermann2008-04-121-5/+3
| | | | | | The variable "quit" can be removed, since its only setter can use "break" instead, just like the other code paths. git-svn-id: https://svn.musicpd.org/mpd/trunk@7266 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* do not reset nextChunkMax Kellermann2008-04-121-9/+5
| | | | | | | The variables "nextChunk" and "crossFadeChunks" are only used when doCrossFade==1. This means that we do not have to reset these as long as doCrossFade!=1. git-svn-id: https://svn.musicpd.org/mpd/trunk@7265 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* added outputBufferRelative()Max Kellermann2008-04-121-6/+2
| | | | | | | 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-2/+2
| | | | | | | 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-17/+4
| | | | | | | 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
* make variables more localMax Kellermann2008-04-121-4/+3
| | | | | | | Declare the variables "test" and "fadePosition" in the scope where they are really used. This removes some of the clutter in the function decodeParent(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7261 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* moved the initial buffering code into the big loopMax Kellermann2008-04-121-13/+10
| | | | | | Eliminating some duplicated and. This also decreases the number of lines calling processDecodeInput(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7260 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* some comments in decode.cMax Kellermann2008-04-121-0/+39
| | | | | | | I have spent some time to understand decodeParent(), which does a lot of obfuscated magic... I find it useful to help others to also understand it, so I wrote a few comments. git-svn-id: https://svn.musicpd.org/mpd/trunk@7259 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* integrated macro handleDecodeStart() into callerMax Kellermann2008-04-121-43/+40
| | | | | | | | Another patch indended to improve the CPP macro hell. This enlarges the function decodeParent(), but it cannot be converted into a standalone function easily, because it references so many local variables. git-svn-id: https://svn.musicpd.org/mpd/trunk@7258 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* use clearOutputBuffer()Max Kellermann2008-04-121-4/+2
| | | | | | clearOutputBuffer() also resets currentChunk; this might resolve a theoretical bug. git-svn-id: https://svn.musicpd.org/mpd/trunk@7257 09075e82-0dd4-0310-85a5-a0d7c8717e4f