aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_thread.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2009-01-04initialize GError pointersMax Kellermann1-1/+1
GLib mandates that you initialize all GError objects with NULL prior to passing it.
2009-01-04song: allocate the result of song_get_url()Max Kellermann1-8/+11
2009-01-04player_thread: fix cross-fading duplicate chunk bugMax Kellermann1-0/+8
When the decoder of the new song is not fast enough, the player thread has to wait for it for a moment. However the variable "nextChunk" was reset to -1 during that, making the next loop iteration assume that cross-fading has not begun yet. This patch overwrites it with "0" while waiting.
2009-01-03player: emit PLAYLIST event when stream tag changesMax Kellermann1-0/+7
Commit b3e2635a introduced a regression: when a stream tag was changed, the playlist version had to be updated. This was done in syncCurrentPlayerDecodeMetadata(), called by syncPlayerAndPlaylist(). After b3e2635a, this was not called anymore. Fix this by emitting PIPE_EVENT_PLAYLIST.
2009-01-02event_pipe: replaced PIPE_EVENT_SIGNAL with main_notifyMax Kellermann1-1/+2
There is only one location using PIPE_EVENT_SIGNAL: to synchronize player_command() with player_command_finished(). Use the "notify" library instead of the event_pipe here.
2009-01-01event_pipe: added pipe_event enum and callbacksMax Kellermann1-3/+3
Make the event_pipe (formerly main_notify) send/receive a set of events, with a callback for each one. The default event PIPE_EVENT_SIGNAL does not have a callback. It is still there for waking up the main thread, when it is waiting for the player thread.
2009-01-01event_pipe: renamed functions from main_notify_* to event_pipe_*Max Kellermann1-4/+4
Continuing the previous patch.
2009-01-01main_notify: renamed source to event_pipe.cMax Kellermann1-1/+1
We are going to migrate away from the concept of notifying the main thread. There should be events sent to it instead. This patch starts a series to implement that.
2008-12-29player_thread: use GLib loggingMax Kellermann1-8/+10
2008-12-28player_thread: migrate from pthread to glib threadsThomas Jansen1-8/+6
2008-12-28decoder: terminate decoder thread before MPD cleanupMax Kellermann1-0/+1
When MPD exits, it should manually free all resources in use, to allow easy memory leak debugging. Make the decoder thread terminate during that.
2008-11-25player: set elapsed=0 at song changeMarc Pavot1-0/+1
I have found something that looks like a bug in MPD: - When a song is finished, the next one is played and the 'player' event is emitted. - When the client sends the status command just after this event, the songid is the new one but the 'elapsed' time is not reseted to 0. This is problem because I have implemented the solution using a timer on client side to compute the elapsed time but with this bug the elapsed time continues to be incremented on a new song.
2008-11-24player_thread.c: replaced mpd_unused by G_GNUC_UNUSEDThomas Jansen1-1/+3
2008-11-24player: disable music_pipe_check_format()Max Kellermann1-0/+2
The music pipe audio format bugs seem to be fixed (hopefully). Disable music_pipe_check_format() for now, since it consumes a lot of CPU cycles.
2008-11-14player: don't queue song when there are 2 songs in the pipeMax Kellermann1-0/+5
Don't send a "next song" request to the main thread when the current song hasn't started playing yet, i.e. there are already two different songs in the music pipe. This would erase information about the song boundary within the music pipe, and thus triggered an assertion failure. The bug could occur when playing very short songs which fit into the pipe as a whole.
2008-11-14player: wake up decoder before waiting for xfade chunksMax Kellermann1-0/+1
Fix a deadlock: when the decoder waited for buffer space, the player could enter a deadlock situation because it waits for more chunks for crossfading chunks. Signal the decoder before entering notify_wait().
2008-11-13player: chop the tail of the music pipe after CANCELMax Kellermann1-0/+1
When a CANCEL command is received, the player should drop all chunks of the next song. Added new funciton music_pipe_chop() which is used for that.
2008-11-13music_pipe: continuously check the sample format of all chunksMax Kellermann1-0/+6
Provide a debug function which asserts on the sample format of all chunks. Call this function in each iteration of the player main loop.
2008-11-13player: assert that there was no previous "next song chunk"Max Kellermann1-0/+1
When assigning the next_song_chunk variable, it must have been empty. If not, there may be 3 songs overlapping in the music pipe.
2008-11-11player: fix race condition during tag updateMax Kellermann1-2/+4
When a tag is updated, the old tag was freed before the new one was created. Reverse the order to be sure that other threads always see a valid pointer. This still leaves a possible race condition, but it will be addressed later.
2008-11-08decoder: converted dc.error to a dc.state valueMax Kellermann1-2/+2
The player did not care about the exact error value, it only checked whether an error has occured. This could fit well into decoder_control.state - introduce a new state "DECODE_STATE_ERROR".
2008-11-03player: no CamelCaseMax Kellermann1-28/+28
Renamed variables and internal functions. Most of the player_control.h API remains in CamelCase for now.
2008-11-03decoder: no CamelCaseMax Kellermann1-2/+2
Renamed variables and functions.
2008-11-02player: don't play empty chunksMax Kellermann1-0/+3
An empty chunk may happen when it only contains a tag, but no PCM data. Don't call playAudio() then.
2008-11-02player: copy stream tag to the song structMax Kellermann1-5/+19
Non-local songs used to have no tags. If the decoder sends us a tag, we should incorporate it into the song struct. This way, clients can always show the correct song name (if provided by the server).
2008-11-02player: added player.songMax Kellermann1-0/+7
Always remember which song is currently being sent to the audio device.
2008-11-02player: send chunk tag to audio deviceMax Kellermann1-0/+3
If a chunk contains a tag, send it to the audio output device. Few output plugins support this, e.g. shout has support for sending tags.
2008-11-02music_pipe: no CamelCaseMax Kellermann1-4/+4
Rename all variables and struct members.
2008-11-02music_pipe: more wrapper functionsMax Kellermann1-8/+6
Replace all direct music_pipe struct accesses with wrapper functions. The compiled machine code is the same, but this way, we can change struct internals more easily.
2008-11-02decoder: replaced music_pipe.audioFormat with dc.out_audio_formatMax Kellermann1-6/+6
.. and rename dc.audioFormat to dc.in_audio_format. The music pipe does not need to know the audio format, and its former "audioFormat" property indicated the format of the most recently added chunk, which might be confusing when you are reading the oldest chunks.
2008-11-02music_pipe: renamed ob_* functions to music_pipe_*Max Kellermann1-16/+17
Rename all functions to the new prefix.
2008-11-02music_pipe: renamed struct output_buffer to struct music_pipeMax Kellermann1-3/+5
.. and rename ob_chunk to struct music_chunk.
2008-10-30decoder: use bool for return values and flagsMax Kellermann1-4/+4
Don't return 0/-1 on success/error, but true/false. Instead of int, use bool for storing flags.
2008-10-29output: always call cancel() before stop()Max Kellermann1-4/+2
Stopping an audio output device without cancelling its buffer doesn't make sense. Combine the two operations, which saves several cancel calls.
2008-10-29output: use bool for return values and flagsMax Kellermann1-5/+4
Don't return 0/-1 on success/error, but true/false. Instead of int, use bool for storing flags.
2008-10-29player: handle songs shorter than the initial bufferMax Kellermann1-1/+2
When the decoder exited before the buffer has grown big enough ("buffer_before_play"), the player thread waited forever. Add an additional check which disables buffering as soon as the decoder exits.
2008-10-29player: added variable "play_audio_format"Max Kellermann1-2/+4
The local variable "play_audio_format" is updated every time the player starts playing a new song. This way, we always know exactly which audio format is current. The old code broke when a new song had a different format: ob.audio_format is the format of the next song, not of the current one - using this caused breakage for the software volume control.
2008-10-29player: request new song only if there is no pending commandMax Kellermann1-1/+2
Request the next song from the playlist (by clearing pc.next_song) only if the player command is empty. If it is not, the player may be clearing the song that has already been queued, leading to an assertion failure.
2008-10-27player: reset pc.command when decoder startup failsMax Kellermann1-0/+1
When the decoder failed to start, the function do_play() returned, still having pc.command==PLAY. This is because pc.command was reset only when the decoder started up successfully. Add another player_command_finished() call in the error handler.
2008-10-24player: don't clear command before do_play() returnsMax Kellermann1-1/+0
This bug caused the audio output devices to stay open, although MPD wasn't playing: quitDecode() resetted player_control.command, assuming that the command was STOP. This way, player_task() didn't see the CLOSE_AUDIO command, and the device was kept open. Don't clear player_control.command in quitDecode().
2008-10-23player: don't send partial frames of silenceMax Kellermann1-1/+7
Another partial frame fix: the silence buffer was 1020 bytes, which had room for 127.5 24 bit stereo frames. Don't send the partial last frame in this case.
2008-10-21pcm_utils: no CamelCaseMax Kellermann1-2/+2
Renamed all functions which were still in CamelCase.
2008-10-12player: replaced buffered_before_play with buffering flagMax Kellermann1-9/+10
buffered_before_play was copied to struct player because it was used to disable buffering when seeking. Instead of mainaining a copy of this number, move just the flag to the player struct.
2008-10-12player: added commands QUEUE and CANCELMax Kellermann1-29/+48
QUEUE adds a new song to the player's queue. CANCEL clears the queue. These two commands replace the old and complex queueState and queueLockState code.
2008-10-12player: added struct playerMax Kellermann1-48/+75
The player struct holds the local variables which used to be passed to all those helper functions in player_thread.c.
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.