aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* moved code to player_thread.cMax Kellermann2008-08-261-394/+0
| | | | | Move code which runs in the player thread to player_thread.c. Having a lot of player thread code in decode.c isn't easy to understand.
* moved code to crossfade.cMax Kellermann2008-08-261-49/+10
| | | | | | decode.c should be a lot smaller; start by moving all code which handles cross-fading to crossfade.c. Also includes camelCase conversion.
* added inline function audio_format_time_to_size()Max Kellermann2008-08-261-1/+1
| | | | | Make the code more readable by hiding big formulas in an inline function with a nice name.
* pass max_chunks to calculateCrossFadeChunks()Max Kellermann2008-08-261-7/+8
| | | | | Make calculateCrossFadeChunks() more generic and portable by eliminating global variable access.
* renamed functions in decoder_list.hMax Kellermann2008-08-261-4/+4
| | | | InputPlugin to decoder_plugin, and no camelCase.
* no camel case in struct decoder_pluginMax Kellermann2008-08-261-20/+22
|
* renamed InputPlugin to struct decoder_pluginMax Kellermann2008-08-261-1/+1
| | | | | | "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.
* added PlayerControl.commandMax Kellermann2008-08-261-21/+26
| | | | | | | PlayerControl.command replaces the old attributes play, stop, pause, closeAudio, lockQueue, unlockQueue, seek. The main thread waits for each command synchronously, so there can only be one command enabled at a time anyway.
* added decoder_command_finished() to decoder_api.hMax Kellermann2008-08-261-8/+0
| | | | | | | 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().
* moved struct AudioFormat to audio_format.hMax Kellermann2008-08-261-0/+1
| | | | | We want to expose the AudioFormat structure to plugins; remove some clutter by moving its declaration to a separate header file.
* do not sleep after openAudioDevice()Max Kellermann2008-08-261-3/+0
| | | | | | After the decoder has been initialized and the audio device has been opened, don't sleep. The decoder plugin won't do anything special nor will it care to wake us up for some reason.
* added struct decoderMax Kellermann2008-08-261-5/+13
| | | | | | 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.
* invoke the notify API directlyMax Kellermann2008-08-261-38/+17
| | | | | | Don't use wrappers like player_wakeup_decoder_nb(). These have been wrappers calling notify.c functions, for compatibility with the existing code when we migrated to notify.c.
* removed "else"Max Kellermann2008-08-261-2/+3
| | | | | The "if" block breaked out of the loop. That means we can move the code out of the "else" block.
* added dc_command_finished()Max Kellermann2008-08-261-2/+9
| | | | | | | | 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.
* don't busy wait for the decoder threadMax Kellermann2008-08-261-3/+7
| | | | | | | Busy wait loops are a bad thing, especially when the response time can be very long - busy waits eat a lot of CPU, and thus slow down the other thread. Since the other thread will notify us when it's ready, we can use notify_wait() instead.
* merged start, stop, seek into DecoderControl.commandMax Kellermann2008-08-261-22/+32
| | | | | | | 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.
* don't set pc->errored_song in decodeStart()Max Kellermann2008-08-261-1/+0
| | | | | pc->errored_song is already set by decodeParent() in the player thread when we set dc->error; no need to set it in the decoder thread.
* added dc.next_song, renamed pc.current_songMax Kellermann2008-08-261-11/+14
| | | | | | | | | Since pc->current_song denotes the song which the decoder should use next, we should move it to DecoderControl. This removes one internal PlayerControl struct access from the decoder code. Also add pc.next_song, which is manipulated by the playlist code, and gets copied to dc.next_song as soon as the decoder is started.
* 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