aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-08-27decode: clear dc.seek_where if we're not seekingEric Wong1-2/+1
This way if we previously had a seek error, starting to play a new song will immediately update the status metadata.
2008-08-19fix output buffer deadlock when daemonizingEric Wong1-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 :<
2008-08-16core rewrite (decode,player,outputBuffer,playlist)Eric Wong1-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.
2008-06-01fix stream URLMax Kellermann1-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
2008-06-01notify: don't use camelCase in notify.[ch]Max Kellerman1-4/+4
git-svn-id: https://svn.musicpd.org/mpd/trunk@7367 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-01assert dc.state == DECODE_STATE_STOPMax Kellerman1-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
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-15const pointers in decode.cMax Kellermann1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@7362 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-15fix XFADE_DISABLED=-1Max Kellermann1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@7359 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-14decode.c: make the crossfade state variable self-documentingEric Wong1-15/+18
git-svn-id: https://svn.musicpd.org/mpd/trunk@7358 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-13Make the OutputBuffer API more consistentEric Wong1-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
2008-04-13Stop passing our single OutputBuffer object everywhereEric Wong1-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
2008-04-13Stop passing our single DecoderControl object everywhereEric Wong1-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
2008-04-13Get rid of PlayerControl inside the PlayerData structEric Wong1-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
2008-04-12Fix the problem of songs not advancing without client activityEric Wong1-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
2008-04-12fix several errors/warnings which only appear with -O3Max Kellermann1-0/+2
git-svn-id: https://svn.musicpd.org/mpd/trunk@7333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12pass dc to decoder_task()Max Kellermann1-4/+4
git-svn-id: https://svn.musicpd.org/mpd/trunk@7323 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 pc to player notify functionsMax Kellermann1-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
2008-04-12pass DecoderControl object to decoder_sleep()Max Kellermann1-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
2008-04-12remove the local variable "end"Max Kellermann1-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
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-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
2008-04-12remove buffered_chunks, use cb->sizeMax Kellermann1-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
2008-04-12decode: fix some uninitialized variable warningsEric Wong1-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
2008-04-12decode: fix unsigned comparision and add some paranoid assertionsEric Wong1-8/+9
git-svn-id: https://svn.musicpd.org/mpd/trunk@7301 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12Fix a few more warnings from -WshadowEric Wong1-4/+4
git-svn-id: https://svn.musicpd.org/mpd/trunk@7300 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12some assertions to check the unsigned changesMax Kellermann1-0/+3
git-svn-id: https://svn.musicpd.org/mpd/trunk@7297 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12yet more unsigned integersMax Kellermann1-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
2008-04-12use the notify API in the decoderMax Kellermann1-6/+8
git-svn-id: https://svn.musicpd.org/mpd/trunk@7281 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12use break instead of quitDecode()+returnMax Kellermann1-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
2008-04-12moved expression to audioFormatSizeToTime()Max Kellermann1-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
2008-04-12let calculateCrossFadeChunks() decideMax Kellermann1-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
2008-04-12moved code to playChunk()Max Kellermann1-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
2008-04-12added outputBufferShift()Max Kellermann1-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
2008-04-12continue main loop instead of nesting loopsMax Kellermann1-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
2008-04-12sleep when waiting for cross-fade chunksMax Kellermann1-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
2008-04-12moved code to crossFade()Max Kellermann1-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
2008-04-12added struct OutputBufferChunkMax Kellermann1-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
2008-04-12added outputBufferChunkData()Max Kellermann1-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
2008-04-12removed "quit"Max Kellermann1-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
2008-04-12do not reset nextChunkMax Kellermann1-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
2008-04-12added outputBufferRelative()Max Kellermann1-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
2008-04-12added outputBufferEmpty()Max Kellermann1-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
2008-04-12moved check to outputBufferAbsolute()Max Kellermann1-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
2008-04-12make variables more localMax Kellermann1-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
2008-04-12moved the initial buffering code into the big loopMax Kellermann1-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
2008-04-12some comments in decode.cMax Kellermann1-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
2008-04-12integrated macro handleDecodeStart() into callerMax Kellermann1-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
2008-04-12use clearOutputBuffer()Max Kellermann1-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