aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_thread.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-10-11player: removed player_control.fileTimeMax Kellermann1-1/+2
This variable is superfluous, it is only used to copy its value to player_control.totalTime. Since the original source of this value (song->tag->time) will still be available at this point, we can safely remove fileTime.
2008-10-10player: don't wake up decoder after every frameMax Kellermann1-1/+7
The decoder was woken up after each chunk which had been played. That caused a lot of superfluous context switches. Wake up the decoder only when a certain amount of the buffer has been consumed. This formula is somewhat arbitrary, and has to be proven experimentally.
2008-10-10player: added player_control.audio_formatMax Kellermann1-6/+2
This replaces the attributes bits, channels, sampleRate.
2008-10-10audio_format: renamed sampleRate to sample_rateMax Kellermann1-1/+1
The last bit of CamelCase in audio_format.h. Additionally, rename a bunch of local variables.
2008-10-08song: removed CamelCaseMax Kellermann1-2/+2
CamelCase is ugly... rename all functions.
2008-10-08use the "bool" data type instead of "int"Max Kellermann1-4/+4
"bool" should be used in C99 programs for boolean values.
2008-10-08song: converted typedef Song to struct songMax Kellermann1-0/+1
Again, a data type which can be forward-declared.
2008-09-29audio_output: added method pause()Max Kellermann1-1/+1
pause() puts the audio output into pause mode: if supported, it may perform a special action, which keeps the device open, but does not play anything. Output plugins like "shout" might want to play silence during pause, so their clients won't be disconnected. Plugins which do not support pausing will simply be closed, and have to be reopened when unpaused. This pach includes an implementation for the shout plugin, which sends silence chunks.
2008-09-26notify: protect notify->pending with the mutexMax Kellermann1-2/+0
There was a known deadlocking bug in the notify library: when the other thread set notify->pending after the according check in notify_wait(), the latter thread was deadlocked. Resolve this by synchronizing all accesses to notify->pending with the notify object's mutex. Since notify_signal_sync() was never used, we can remove it. As a consequence, we don't need notify_enter() and notify_leave() anymore; eliminate them, too.
2008-09-07audio_format: converted typedef AudioFormat to struct audio_formatMax Kellermann1-1/+1
Get rid of CamelCase, and don't use a typedef, so we can forward-declare it, and unclutter the include dependencies.
2008-08-26moved player_command_finished() to player_thread.cMax Kellermann1-0/+8
2008-08-26moved code to pc_init(), dc_init()Max Kellermann1-3/+2
2008-08-26renamed player.c to player_control.cMax Kellermann1-1/+1
Give player.c a better name, meaning that the code is used to control the player thread.
2008-08-26renamed decode.h to decoder_control.hMax Kellermann1-1/+1
2008-08-26moved global variable "pc" to player.hMax Kellermann1-0/+1
This is the last of the three variables. Now we don't need playerData.h anymore in most sources.
2008-08-26moved variable "dc" to decode.hMax Kellermann1-6/+7
Now that "dc" is available here, we don't have to pass it to decoder_is_idle() and decoder_is_starting() anymore.
2008-08-26player_thread: removed decode(), renamed decodeParent()Max Kellermann1-15/+4
decode() is a trivial wrapper for decodeParent(). Merge both and rename them to do_play().
2008-08-26hide DecoderControl accesses in inline functionsMax Kellermann1-10/+6
Unfortunately, we have to pass the DecoderControl pointer to these inline functions, because the global variable "dc" may not be available here. This will be fixed later.
2008-08-26check for decoder error before state!=STARTMax Kellermann1-9/+8
When dc->error!=NOERROR, we do not need to check state!=START. Simplify the checks by moving the error check to the top.
2008-08-26don't reset dc->command in quitDecode()Max Kellermann1-1/+0
The decoder thread is responsible for resetting dc->command after a command was executed. As a consequence, we can assume that dc->command is already NONE after decoder_stop().
2008-08-26added decoder_control.cMax Kellermann1-50/+17
The source "decoder_control.c" provides an API for controlling the decoder. This replaces various direct accesses to the DecoderControl struct.
2008-08-26fix a comment regarding the player queueMax Kellermann1-1/+1
2008-08-26rewrote playerKill()Max Kellermann1-0/+8
playerKill() was marked as deprecated, but it seems like a good idea to do proper cleanup in all threads (e.g. for usable valgrind results). Introduce the command "EXIT" which makes the player thread exit cleanly.
2008-08-26player: don't call STOP before CLOSE_AUDIOMax Kellermann1-1/+2
playerWait() stops the player thread (twice!) and closes the output device. It should be well enough to just send CLOSE_AUDIO, without STOP. This requires a tiny change to the player thread code: make it break when CLOSE_AUDIO is sent.
2008-08-26assert song->url != NULLMax Kellermann1-0/+4
2008-08-26don't call quitDecode() in waitOnDecode()Max Kellermann1-2/+3
To make the code more consistent, call quitDecode() only at the end of decodeParent().
2008-08-26moved code to player_thread.cMax Kellermann1-165/+54
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.
2008-08-26moved code to crossfade.cMax Kellermann1-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.
2008-08-26added inline function audio_format_time_to_size()Max Kellermann1-1/+1
Make the code more readable by hiding big formulas in an inline function with a nice name.
2008-08-26pass max_chunks to calculateCrossFadeChunks()Max Kellermann1-7/+8
Make calculateCrossFadeChunks() more generic and portable by eliminating global variable access.
2008-08-26renamed functions in decoder_list.hMax Kellermann1-4/+4
InputPlugin to decoder_plugin, and no camelCase.
2008-08-26no camel case in struct decoder_pluginMax Kellermann1-20/+22
2008-08-26renamed InputPlugin to struct decoder_pluginMax Kellermann1-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.
2008-08-26added PlayerControl.commandMax Kellermann1-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.
2008-08-26added decoder_command_finished() to decoder_api.hMax Kellermann1-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().
2008-08-26moved struct AudioFormat to audio_format.hMax Kellermann1-0/+1
We want to expose the AudioFormat structure to plugins; remove some clutter by moving its declaration to a separate header file.
2008-08-26do not sleep after openAudioDevice()Max Kellermann1-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.
2008-08-26added struct decoderMax Kellermann1-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.
2008-08-26invoke the notify API directlyMax Kellermann1-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.
2008-08-26removed "else"Max Kellermann1-2/+3
The "if" block breaked out of the loop. That means we can move the code out of the "else" block.
2008-08-26added dc_command_finished()Max Kellermann1-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.
2008-08-26don't busy wait for the decoder threadMax Kellermann1-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.
2008-08-26merged start, stop, seek into DecoderControl.commandMax Kellermann1-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.
2008-08-26don't set pc->errored_song in decodeStart()Max Kellermann1-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.
2008-08-26added dc.next_song, renamed pc.current_songMax Kellermann1-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.
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