aboutsummaryrefslogtreecommitdiffstats
path: root/src (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-08-27playlist: fix deleting the last song in a playlistEric Wong1-1/+2
unK reported a bug in which explicitly calling "delete" on each song would cause mpd to lock up. This is actually triggered when the only song on the mpd playlist is deleted. Additionally, add an extra assertion to ensure we play a valid, non-NULL song in play_order_num().
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-27tagTracker: locks around {get,remove}TagItemStringEric Wong1-2/+13
Hopefully this fixes a segfault I experienced inside freeMpdTag earlier with the metadata_pipe. I could not reproduce the segfault again, however. Regardless, if multiple threads rely on this, we need to atomically increment/decrement these counters.
2008-08-27metadata_pipe: remove highly unlikely memory leakEric Wong1-0/+1
When we send metadata, there's a remote chance that our pipe is full and our tag will be silently discarded. If that happens, the readers will never have a chance to free the tag, so ensure we free it before returning to the caller.
2008-08-27Fix software mixerEric Wong2-1/+2
I just forgot to reenable/reinitialize it after the core rewrite.
2008-08-26Reimplement dynamic metadata handlingEric Wong12-35/+287
This has been tested for both playback of streams and outputting to streams, and seems to work fine with minimal locking. This reuses the sequence number infrastructure in OutputBuffer for synchronizing metadata payloads; so (IMNSHO) should be much more understandable than various flags being set here and there.. It could still use some cleanup and much testing, but synchronization issues should be minimal.
2008-08-25playlist: fix "currentsong" after song deletionEric Wong1-0/+2
When deleting previous songs, we forgot to update the playlist.queue value, causing syncPlaylistWithQueue to trigger a false sync and screw with the playlist.current pointer; causing the currentsong command to return an incorrect song. Thanks to unK to reporting this bug!
2008-08-25playlist: fix "currentsong" after song movementEric Wong1-1/+4
When moving songs around, we forgot to update the playlist.queue value, causing syncPlaylistWithQueue to trigger a false sync and screw with the playlist.current pointer; causing the currentsong command to return an incorrect song.
2008-08-23xfade: gracefully fail on very short xfade timesEric Wong1-1/+2
It's possible to calculate an impossibly small value that we don't have a chance to xfade. Don't die if we can't find the boundary to start crossfading on
2008-08-23xfade: copy xfade_time locally to avoid race conditionsEric Wong1-2/+5
ob.xfade_time can be changed by the main process without locking, so copy the float value into a local variable and recheck the local variable for zero before continuing.
2008-08-23outputBuffer: never calculate xfade time if xfade is offEric Wong1-3/+5
We don't assert on xfade_time > 0 inside any of the xfade calculations since we have no lock around xfade_time.
2008-08-23don't crossfade different audio formatsEric Wong1-2/+4
It sounds nasty and we didn't do it before the core-rewrite
2008-08-23outputBuffer: close audio device on stopEric Wong2-15/+9
2008-08-23outputBuffer_audio: eliminate the hacky audio_opened variableEric Wong1-10/+3
It's redundant, we already track that stuff elsewhere.
2008-08-23playlist: queue songs after adding themEric Wong1-0/+6
This fixes the case where we wouldn't start playing a newly added song if we're near the end of the playlist and done decoding the last song (but still playing from the buffer).
2008-08-23outputBuffer: fix buffer_before_play handlingEric Wong3-38/+55
buffer_before_play is a prebuffer; always respecting it is almost as good as having no buffer at all. So we only respect it when we haven't played anything. Bugs that were a side effect of this also got fixed: The player would not stop when we got to the end of the last song on non-repeating playlists. The playlist would continuously show the song in the last few seconds of playback, and never move. Having crossfade enabled would also amplify the above effect. So, as a side effect, crossfade now correctly handles end-of-playlist conditions, as well. It will fade out to silence when we're at the end of a playlist.
2008-08-23change queueNextSongInPlaylist assertion to checkEric Wong1-1/+2
There are still some places where we try to call this function without the playlist being stopped. It's really harmless, to call it and just break out immediately, so change the assertion.
2008-08-20mp3_plugin: fix assertion during seekingEric Wong1-3/+3
data->muteFrame won't necessarily get cleared when it enters that block of code, so we don't signal the action as complete until it is actually cleared.
2008-08-20outputBuffer: drop buffered audio on new songsEric Wong1-0/+1
Hopefully this fixes the skipping problem Qball reports
2008-08-19Remove ob_wait_sync and cleanup triggering in playlistEric Wong3-72/+46
ob_wait_sync was a gross hack anyways. We are one step closer to being able to trigger actions in our worker threads asynchronously. Just need to make input (file opening) in decoder happen _after_ our decoder returns an ACK.
2008-08-19fix output buffer deadlock when daemonizingEric Wong12-90/+48
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-19log.c: thread-safety for warning logEric Wong1-4/+12
I'm really no fan of the warning log, it's too complex for how little it gets used; but fixing it is another problem.
2008-08-16core rewrite (decode,player,outputBuffer,playlist)Eric Wong47-2199/+1951
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-30http: hopefully allow seeking to work on static filesEric Wong1-1/+2
git-svn-id: https://svn.musicpd.org/mpd/trunk@7398 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30don't call seekInputStream(0) if r==0Max Kellermann1-1/+2
If nothing has been read from the input stream, we don't have to rewind it. git-svn-id: https://svn.musicpd.org/mpd/trunk@7397 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30eliminated local variable "to_read"Max Kellermann1-4/+3
The variable "to_read" is never modified except in the last iteration of the while loop. This means the while condition will never become false, as the body will break before that may be checked. git-svn-id: https://svn.musicpd.org/mpd/trunk@7396 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30introduce struct condition as a more correct version of NotifyEric Wong4-64/+191
Start using it in the HTTP code git-svn-id: https://svn.musicpd.org/mpd/trunk@7395 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30utils: pthread_{mutex,cond}_init can fail, so check for itEric Wong2-0/+18
git-svn-id: https://svn.musicpd.org/mpd/trunk@7394 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30http: initial rewrite using ringbuffer + pthreadsEric Wong2-562/+799
This institutes the usage of a separate thread to buffer HTTP input. It is basically practice code for using the ringbuffer code which I plan on reusing for the OutputBuffer as well as further input buffering for disk (networked filesystems over WAN, laptops on battery, etc). Each readFromInputStream() call on an HTTP stream can take several seconds to complete, short reads are avoided. A single-threaded solution for systems supporting large enough SO_RCVBUF values should also be possible and will likely be done in the future; but this lock-free(except when full/empty) ringbuffer is cool :) git-svn-id: https://svn.musicpd.org/mpd/trunk@7393 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30http: fix some small memory leaks when hitting redirectsEric Wong1-0/+6
git-svn-id: https://svn.musicpd.org/mpd/trunk@7392 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30utils: add new unforgiving utility functionsEric Wong2-0/+30
We'll be using pipes when waiting for I/O, and condition variables at other times. git-svn-id: https://svn.musicpd.org/mpd/trunk@7391 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30ringbuf: add thread-safe, thread-specific reset functionsEric Wong2-0/+30
This will allow both the reader and writer threads to reset the ringbuffer in a thread-safe fashion. git-svn-id: https://svn.musicpd.org/mpd/trunk@7390 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30ringbuf: get_{write,read}_vector returns total bytes in both vec eltsEric Wong2-5/+9
This will eliminate unnecessary calls to ringbuf_{read,write}_space git-svn-id: https://svn.musicpd.org/mpd/trunk@7389 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30http: split out logic around getaddrinfo() and connect()Eric Wong1-40/+42
Makes code easier to read and modularize git-svn-id: https://svn.musicpd.org/mpd/trunk@7388 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30http: split out auth code since it's mostly uninteresting for nowEric Wong3-75/+103
The auth code also has some ugly usages of string generation which I will eventually replace with something nicer... git-svn-id: https://svn.musicpd.org/mpd/trunk@7387 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30Add a generic ring buffer implementationEric Wong3-0/+503
This piece of code is from the JACK Audio Connection Kit (trimmed down a bit for better readability). The vector functions now reuse the common iovec struct used by writev/readv instead of reinventing an identical but differently-named struct. From the comments: > ISO/POSIX C version of Paul Davis's lock free ringbuffer C++ code. > This is safe for the case of one read thread and one write thread. License is LGPL 2.1 or later git-svn-id: https://svn.musicpd.org/mpd/trunk@7386 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-30os_compat.h: add sys/uio.h for writev/readvEric Wong1-0/+1
vectored I/O will be useful with our ring buffer lib git-svn-id: https://svn.musicpd.org/mpd/trunk@7385 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-13jack: initialize audioOutput->dataMax Kellermann1-1/+3
Initialize audioOutput->data with NULL in jack_initDriver(). Previously, this was never initialized, although the other functions relied on it being NULL prior to jack_openDevice(). This patch addresses bug 0001641[1]. In contrast to the patch provided by the bug reporter, it moves the initialization before the "!param" check. [1] - http://musicpd.org/mantis/view.php?id=1641 git-svn-id: https://svn.musicpd.org/mpd/trunk@7375 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-13mod: fix crashing on modtracker filesHans de Goede1-1/+1
This patch was taken from http://bugzilla.livna.org/show_bug.cgi?id=1987 and addresses bug 0001693[1] [1] - http://musicpd.org/mantis/view.php?id=1693 git-svn-id: https://svn.musicpd.org/mpd/trunk@7374 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-02audio.c: avoid magic numbers even if they have comments :)Eric Wong1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@7373 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-02remove audioDeviceStates from playerData and getPlayerDataEric Wong5-40/+14
git-svn-id: https://svn.musicpd.org/mpd/trunk@7372 09075e82-0dd4-0310-85a5-a0d7c8717e4f
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-01oggflac_plugin: fix build with libOggFLAC lib (libFLAC <= 7)Eric Wong1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@7370 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-01make DecoderControl.state an enumMax Kellerman1-4/+6
git-svn-id: https://svn.musicpd.org/mpd/trunk@7369 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-06-01notify: don't use camelCase in notify.[ch]Max Kellerman5-26/+26
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-17fix race condition in main_notify.cMax Kellermann1-1/+6
The function wait_main_task() is racy: if the function wakeup_via_cond() sees the mutex is locked just before wait_main_task() executes pthread_cond_wait(), the main thread blocks forever. Work around this issue by adding a "pending" flag just like in my notify.c code. A standards-compliant solution should be implemented later. git-svn-id: https://svn.musicpd.org/mpd/trunk@7365 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-15added ob_set_lazy()Max Kellermann3-2/+26
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-15use dc.current_song instead of pc.current_songMax Kellermann1-1/+1
When we are in an input plugin, dc.current_song should already be set. Use it instead of pc.current_song. git-svn-id: https://svn.musicpd.org/mpd/trunk@7363 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