aboutsummaryrefslogtreecommitdiffstats
path: root/src (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-02-05fix -Wconst warningsMax Kellermann37-197/+223
[ew: cleaned up the dirty union hack a bit] Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7180 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-29storedPlaylist: faster, but less accurate check for maximum sizesEric Wong1-7/+7
There are still other ways to run the mpd server out of disk-space, so permissions are still recommended to protect against malicious users. git-svn-id: https://svn.musicpd.org/mpd/trunk@7179 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-27interface: abort if we expire while processing linesEric Wong1-0/+2
If we keep processing expired interfaces in a loop, we'll eventually close it and get fd < 0, causing assertions to fail. git-svn-id: https://svn.musicpd.org/mpd/trunk@7168 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-27gcc.h: fix compilation with !(gcc >= 3)Eric Wong1-0/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@7167 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26Revert the queue implementation and commandsEric Wong5-259/+1
It's too ugly and broken (both technically and usability-wise) to be worth supporting in any stable release. In one sentence: The queue is a very crippled version of the playlist that takes precedence over the normal playlist. How is it crippled? * The "queueid" command only allows the queuing of songs ALREADY IN THE PLAYLIST! This promotes having the entire mpd database of songs in the playlist, which is a stupid practice to begin with. * It doesn't allow for meaningful rearranging and movement of songs within the queue. To move a song, you'd need to dequeue and requeue it (and other songs on the list). Why? The playlist already allows _all_ these features and shows everything a client needs to know about the ordering of songs in a _single_ command! * Random was a stupid idea to begin with and unfortunately we're stuck supporting it since we've always had it. Users should learn to use "shuffle" instead and not look at their playlists. Implementing queue because we have the problem of random is just a bandage fix and digging ourselves a new hole. This protocol addition was never in a stable release of mpd, so reverting it will only break things for people following trunk; which I'm not too worried about. I am however worried about long-term support of this misfeature, so I'm removing it. Additionally, there are other points: * It's trivially DoS-able: (while true; do echo queueid $song_id; done) | nc $MPD_HOST $MPD_PORT The above commands would cause the queue to become infinitely expanding, taking up all available memory in the system. The mpd playlist was implemented as an array with a fixed (but configurable) size limit for this reason. * It's not backwards-compatible. All clients would require upgrades (and additional complexity) to even know what the next song in the playlist is. mpd is a shared architecture, and we should not violate the principle of least astonishment here. This removes the following commands: queueid, dequeue, queueinfo Additionally, the status field of "playlistqueue: " is removed from the status command. While this DoS is trivial to fix, the design is simply too broken to ever support in a real release. The overloading of the "addid" command and the allowing of negative numbers to be used as offsets is far more flexible. This improved "addid" is completely backwards-compatible with all clients, and does not require clients to have UI changes or run additional commands to display the queue. git-svn-id: https://svn.musicpd.org/mpd/trunk@7155 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26storedPlaylist: prevent potential DoS from stored playlist commandsEric Wong3-2/+18
While mpd has always protected against the infinite expansion of the main playlist by limiting its size in memory, however the new storedPlaylist code has never checked for this limit. Malicious (or clumsy) users could repeatedly append songs to stored playlists, causing files to grow increasingly large on disk. Attempting to load extremely large files into memory will require mpd to slurp that all into memory, and ultimately the file would be unusable by mpd because of the configurable playlist size limit. Now we limit stored playlists to the max_playlist_length configuration variable set by the user (default is 16384). We will refuse to append to playlist files if they hit that limit; and also refuse to load more than the specified amount of songs into memory. git-svn-id: https://svn.musicpd.org/mpd/trunk@7154 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26playlist: don't allow no-op/senseless movement of songsEric Wong1-8/+14
This disables moving the bonkered moving of the current song to a (negative) offset of itself (introduced in the last commit). This also short circuits no-op moves when (from == to) and avoid needless increasing of the playlist version and causes clients to issue pointless no-op plchanges commands. git-svn-id: https://svn.musicpd.org/mpd/trunk@7153 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26playlist: allow move to specify offset from current songEric Wong1-1/+10
If (and only if) there is a current song in the playlist, (player could be stopped), allow the move destination argument to be specified as a negative number. This means moving any song (besides the current one) to the -1 position will allow it to be moved to the next song in the playlist. Moving any song to position -2 will move it to the song after the next, and so forth. Moving a song to -playlist.length will move it to the song _before_ the current song on the playlist; so this will work for repeating playlists, too. git-svn-id: https://svn.musicpd.org/mpd/trunk@7152 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26command: allow "addid" command to take an optional second argument, positionEric Wong1-2/+14
This will allow "addid \"song_url\" <pos>" to atomically insert a song at any given playlist position. If the add succeeds, but the actual movement fails (due to invalid position), then the song_id will be deleted before the command returns back to the client, and the client will get an error response. git-svn-id: https://svn.musicpd.org/mpd/trunk@7151 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26command: cleanup integer argument validation for commandsEric Wong1-214/+106
git-svn-id: https://svn.musicpd.org/mpd/trunk@7150 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26addToPlaylist/addSongToPlaylist: printId argument changed to added_idEric Wong4-13/+19
Instead of printing out the Id from playlist.c, instead set the integer that added_id poitns to if added_id is non-NULL. This makes the API cleaner and will allow us to use additional commands to manipulate the newly-added song_id. Callers (handleAddId) that relied on printId to print it to the given fd have now been modified to print the ID at a higher-level; making playlist.c less-dependent on protocol details. git-svn-id: https://svn.musicpd.org/mpd/trunk@7149 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26gcc.h: support mpd_fprintf__, with arguments shifted even further rightEric Wong1-0/+1
This will be used to check errors in command.c git-svn-id: https://svn.musicpd.org/mpd/trunk@7148 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26Cleanup checking for tests in src/ when building in separate dirEric Wong1-1/+2
git-svn-id: https://svn.musicpd.org/mpd/trunk@7147 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26fixed "comparison between signed and unsigned"Max Kellermann5-10/+10
Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7146 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26fix -Waggregate-returnMax Kellermann3-10/+10
Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7145 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26assume old flac api when FLAC_API_VERSION_CURRENT is not definedMax Kellermann1-1/+1
the code is inconsistent when FLAC_API_VERSION_CURRENT is not defined: sometimes version > 7 is assumed, and sometimes version <= 7. solve this by assuming the version is old when FLAC_API_VERSION_CURRENT is not defined. Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7144 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26fixed -Wshadow warningsMax Kellermann20-183/+185
Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7143 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26fixed invalid C prototypesMax Kellermann7-8/+8
Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7142 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03ioops: make this zero-impact when compiling w/o zeroconf as wellEric Wong4-49/+106
This reduces the text size of the binary slightly when zeroconf support is not built, and keeps the interface code cleaner as well. git-svn-id: https://svn.musicpd.org/mpd/trunk@7133 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03zeroconf: reformat (with mpd-indent.sh + manual tweaks)Eric Wong4-232/+266
Also, lower the impact of compiling this w/o zeroconf by making the init/teardown functions static no-ops. Eventually, we should separate the Bonjour and Avahi code into separate files and have callbacks registered for each one, avoiding the #ifdef mess we have now... git-svn-id: https://svn.musicpd.org/mpd/trunk@7132 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03directory: allow db_file to reside on / once againEric Wong1-0/+2
Oops!, I went back and documented the change going to parent_path(), but forgot to change the code that was affected by it. git-svn-id: https://svn.musicpd.org/mpd/trunk@7131 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03Cleanup #includes of standard system headers and put them in one placeEric Wong93-477/+167
This will make refactoring features easier, especially now that pthreads support and larger refactorings are on the horizon. Hopefully, this will make porting to other platforms (even non-UNIX-like ones for masochists) easier, too. os_compat.h will house all the #includes for system headers considered to be the "core" of MPD. Headers for optional features will be left to individual source files. git-svn-id: https://svn.musicpd.org/mpd/trunk@7130 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03directory.c: get rid of the horrid dirname(3) and libgen.h dependencyEric Wong1-13/+3
Ok, so basename(3) is even more brain-damaged, inconsistent and/or broken than dirname(3) on most systems, but there are broken implementations of it out there. Just use our already existing internal parent_path() function instead and get rid of the only place where we look for libgen.h. git-svn-id: https://svn.musicpd.org/mpd/trunk@7129 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03document parent_path()Eric Wong2-3/+20
git-svn-id: https://svn.musicpd.org/mpd/trunk@7128 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03playerCloseAudio() is staticEric Wong2-3/+3
git-svn-id: https://svn.musicpd.org/mpd/trunk@7127 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03player.c: introduce set_current_song to avoid needless repetitionEric Wong1-27/+13
git-svn-id: https://svn.musicpd.org/mpd/trunk@7126 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01song: updateSongInfo: left out charset conversion when going thread-safeEric Wong1-2/+4
git-svn-id: https://svn.musicpd.org/mpd/trunk@7124 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01silence is constant, as is the buffer we pass to playAudioEric Wong3-5/+3
git-svn-id: https://svn.musicpd.org/mpd/trunk@7123 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01Simplify decode cleanup logic a bitEric Wong11-126/+21
DECODE_STATE_STOP is always set as dc->state, and dc->stop is always cleared. So handle it in decodeStart once rather than doing it in every plugin. While we're at it, fix a long-standing (but difficult to trigger) bug in mpc_decode where we failed to return if mpc_decoder_initialize() fails. git-svn-id: https://svn.musicpd.org/mpd/trunk@7122 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01charConv: tie the buffer size for iconv() to our PATH_MAX constantEric Wong1-1/+2
Although most PATH_MAX is higher than the 1k buffer we set, some implementations will set a 256 (or even 64) byte PATH_MAX, so we should be prepared for that. git-svn-id: https://svn.musicpd.org/mpd/trunk@7121 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01storedPlaylist: remove the needless StoredPlaylist struct and just use ListEric Wong3-90/+60
Abstractions should reduce the amount of code and make things easier to follow. The StoredPlaylist struct did not do that, so get rid of it and just use our standard linked list implementation instead. diffstat agrees with me that the abstraction is pointless: 3 files changed, 60 insertions(+), 90 deletions(-) git-svn-id: https://svn.musicpd.org/mpd/trunk@7120 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01storedPlaylist: cleanup API and avoid needless heap allocations + error checksEric Wong3-108/+69
git-svn-id: https://svn.musicpd.org/mpd/trunk@7119 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01storedPlaylist: cleanup load functionEric Wong1-72/+16
* stop supporting unused parentlen block, I have no idea how it was ever usable, but playlists don't work in subdirectories... * myFgets is far easier to use than fgetc loops. * Since we're using myFgets, we'll just skip lines that are too long, rather than error out and bitch and moan about things... git-svn-id: https://svn.musicpd.org/mpd/trunk@7118 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01playlist: cleanup pathname generation for the "rm" command, tooEric Wong1-15/+5
git-svn-id: https://svn.musicpd.org/mpd/trunk@7117 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01playlist: avoid the use of newStoredPlaylist for saving active playlistsEric Wong3-29/+54
It was a nice way to double the memory needed to write the playlist to a file. git-svn-id: https://svn.musicpd.org/mpd/trunk@7116 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01Make utf8_to_fs_playlist_path universally accessibleEric Wong3-12/+15
git-svn-id: https://svn.musicpd.org/mpd/trunk@7115 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01storedPlaylist: fix compile warning (last-second internal API change)Eric Wong1-2/+0
git-svn-id: https://svn.musicpd.org/mpd/trunk@7114 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01mpc_plugin: break out if a missed error branchEric Wong1-0/+2
We shouldn't try to continue if mpc_decoder_initialize() fails. git-svn-id: https://svn.musicpd.org/mpd/trunk@7113 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01Revert r7111 and begin to properly fix storedPlaylist codeEric Wong2-90/+73
git-svn-id: https://svn.musicpd.org/mpd/trunk@7112 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-31Don't let xstrdup(s) crash crash when s is NULL, but return Null in steadQball Cow1-1/+5
git-svn-id: https://svn.musicpd.org/mpd/trunk@7111 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-31ogg_common: fix indent screwupEric Wong1-14/+5
git-svn-id: https://svn.musicpd.org/mpd/trunk@7109 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-31fix builds that only have FLAC >= 1.1.3 but not Ogg-VorbisEric Wong3-9/+9
git-svn-id: https://svn.musicpd.org/mpd/trunk@7108 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-28Merge branches/ew r7104Eric Wong28-429/+405
thread-safety work in preparation for rewrite to use pthreads Expect no regressions against trunk (r7078), possibly minor performance improvements in update (due to fewer heap allocations), but increased stack usage. Applied the following patches: * maxpath_str for reentrancy (temporary fix, reverted) * path: start working on thread-safe variants of these methods * Re-entrancy work on path/character-set conversions * directory.c: exploreDirectory() use reentrant functions here * directory/update: more use of reentrant functions + cleanups * string_toupper: a strdup-less version of strDupToUpper * get_song_url: a static-variable-free version of getSongUrl() * Use reentrant/thread-safe get_song_url everywhere * replace rmp2amp with the reentrant version, rmp2amp_r * Get rid of the non-reentrant/non-thread-safe rpp2app, too. * buffer2array: assert strdup() returns a usable value in unit tests * replace utf8ToFsCharset and fsCharsetToUtf8 with thread-safe variants * fix storing playlists w/o absolute paths * parent_path(), a reentrant version of parentPath() * parentPath => parent_path for reentrancy and thread-safety * allow "make test" to automatically run embedded unit tests * remove convStrDup() and maxpath_str() * use MPD_PATH_MAX everywhere instead of MAXPATHLEN * path: get rid of appendSlash, pfx_path and just use pfx_dir * get_song_url: fix the ability to play songs in the top-level music_directory git-svn-id: https://svn.musicpd.org/mpd/trunk@7106 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-27If clearing stored playlist fails, don't return error + OK. but only the error.Qball Cow1-2/+1
this was caused by always having the handleStoredPlaylist function return 0. git-svn-id: https://svn.musicpd.org/mpd/trunk@7105 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-16Know about SND_PCM_STATE_RUNNING, might fix some bugsQball Cow1-0/+4
git-svn-id: https://svn.musicpd.org/mpd/trunk@7077 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-10Fix possible wrong 'addition'Qball Cow1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@7076 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-06Fix replaygain for latest flac version.Qball Cow1-0/+9
The updated initialize method did not tell the libFLAC to look for the tag containing the replay information. git-svn-id: https://svn.musicpd.org/mpd/trunk@7075 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-11-28Re-enable seeking in http streams.Qball Cow2-7/+4
Fixing stopping mpd from block when trying to stop a ogg stream that is buffering. git-svn-id: https://svn.musicpd.org/mpd/trunk@7053 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-11-28Don't try to forever to get data when the sockets winds up in "temporaryQball Cow1-8/+21
unavailable" when streaming music. But give up after 100 times. This is atm better then waiting until the connection gets back, because mpd blocks on this. git-svn-id: https://svn.musicpd.org/mpd/trunk@7052 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-11-21A better way to do the last patch (extremely minor patch)Avuton Olrich1-4/+2
git-svn-id: https://svn.musicpd.org/mpd/trunk@7042 09075e82-0dd4-0310-85a5-a0d7c8717e4f