Commit Graph

1344 Commits

Author SHA1 Message Date
Max Kellermann
c9e6201df5 fix strtok() related segmentation fault
strtok() may return NULL if the input is an empty string.  The
playlist parser did not check for that.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7200 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-03-26 10:37:40 +00:00
Max Kellermann
c5b524e376 eliminated duplicate initialization
Local variables which are never read before the first assignment don't
need initialization.  Saves a few bytes of text.  Also don't reset
variables which are never read until function return.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7199 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-03-26 10:37:36 +00:00
Max Kellermann
54b544c2f4 parse/initialize with the correct data type
When we expect an integer as result, why would we use the double
precision floating point parser?  strtol() is a better match, although
we should probably check for overflows...

git-svn-id: https://svn.musicpd.org/mpd/trunk@7198 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-03-26 10:37:27 +00:00
Max Kellermann
b546bcfec6 fix "unreachable code" warning
There is unreachable code at several positions, e.g. after an
#if/#end, or after an endless loop.  Remove that.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7197 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-03-26 10:37:23 +00:00
Max Kellermann
66fe580642 explicitly downcast
Tools like "sparse" check for missing downcasts, since implicit cast
may be dangerous.  Although that does not change the compiler result,
it may make the code more readable (IMHO), because you always see when
there may be data cut off.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7196 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-03-26 10:37:17 +00:00
Max Kellermann
13c17c3d94 check the result of fopen() in all code paths
The while() loop only checks for interrupted system calls (which woudl
never happen if the signal mask were set up properly), but nobody
checks if the fopen() actually succeeds.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7195 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-03-26 10:37:10 +00:00
Max Kellermann
33e88ff8f9 zero is a valid file descriptor
Although it may not happen in mpd code, it is perfectly possible for a
newly allocated file descriptor to be zero.  For theoretical
correctness, allow 0.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7194 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-03-26 10:37:06 +00:00
Max Kellermann
c6ceceae8a moved handlePendingSignals() check into while() condition
For code unification: for me, it looks ugly to do a break in the
command in a while() block.  This belongs into the while condition.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7193 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-03-26 10:37:02 +00:00
Eric Wong
7c69161913 inputPlugins: add .oga suffix support for Ogg containers
From <http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions>:
> .oga - audio/ogg
>
>    * Ogg Audio Profile (audio in Ogg container)
>    * Applications supporting .oga, .ogv SHOULD support decoding
>      from muxed Ogg streams
>    * Covers Ogg FLAC, Ghost, and OggPCM
>    * Although they share the same MIME type, Vorbis and Speex
>      use different file extensions.
>    * SHOULD contain a Skeleton logical bitstream.
>    * Vorbis and Speex may use .oga, but it is not the
>      prefered(sic) method of distributing these files because of
>      backwards-compatibility issues.

Thanks to Qball and Rasi for the patch.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7191 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-03-20 05:27:04 +00:00
Eric Wong
5915fe55c0 listen.c: fix shadow warning here
git-svn-id: https://svn.musicpd.org/mpd/trunk@7182 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-02-05 10:20:46 +00:00
Eric Wong
77e3283973 compress.c: fix skips/distortion introduced in r7146
We need to ensure we're working with signed types when assigning
them.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7181 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-02-05 10:17:45 +00:00
Max Kellermann
6fbdc721d9 fix -Wconst warnings
[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-02-05 10:17:33 +00:00
Eric Wong
22efbd5eca storedPlaylist: faster, but less accurate check for maximum sizes
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-29 09:26:39 +00:00
Eric Wong
b1cbe333a6 interface: abort if we expire while processing lines
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-27 23:10:45 +00:00
Eric Wong
2fcd63feb1 gcc.h: fix compilation with !(gcc >= 3)
git-svn-id: https://svn.musicpd.org/mpd/trunk@7167 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-27 23:10:41 +00:00
Eric Wong
688289b295 Revert the queue implementation and commands
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-26 20:21:07 +00:00
Eric Wong
29df70366c storedPlaylist: prevent potential DoS from stored playlist commands
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-26 20:20:59 +00:00
Eric Wong
3a1b3e3807 playlist: don't allow no-op/senseless movement of songs
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-26 12:47:04 +00:00
Eric Wong
e213ca4f8b playlist: allow move to specify offset from current song
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-26 12:47:00 +00:00
Eric Wong
9eee1a81cf command: allow "addid" command to take an optional second argument, position
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-26 12:46:56 +00:00
Eric Wong
2889b576eb command: cleanup integer argument validation for commands
git-svn-id: https://svn.musicpd.org/mpd/trunk@7150 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26 12:46:53 +00:00
Eric Wong
2f0e5bfd85 addToPlaylist/addSongToPlaylist: printId argument changed to added_id
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-26 12:46:49 +00:00
Eric Wong
2dafd9cd56 gcc.h: support mpd_fprintf__, with arguments shifted even further right
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-26 12:46:44 +00:00
Eric Wong
262e515bee Cleanup checking for tests in src/ when building in separate dir
git-svn-id: https://svn.musicpd.org/mpd/trunk@7147 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26 12:46:41 +00:00
Max Kellermann
c3ba1bb956 fixed "comparison between signed and unsigned"
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-26 12:46:37 +00:00
Max Kellermann
0659d35951 fix -Waggregate-return
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-26 12:46:30 +00:00
Max Kellermann
07eaad301a assume old flac api when FLAC_API_VERSION_CURRENT is not defined
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-26 12:46:26 +00:00
Max Kellermann
07adb14e3c fixed -Wshadow warnings
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-26 12:46:21 +00:00
Max Kellermann
28008e6977 fixed invalid C prototypes
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-26 12:46:09 +00:00
Eric Wong
7d66859277 ioops: make this zero-impact when compiling w/o zeroconf as well
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-03 10:03:34 +00:00
Eric Wong
a9b581f6c5 zeroconf: reformat (with mpd-indent.sh + manual tweaks)
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-03 10:03:28 +00:00
Eric Wong
776ccc89ad directory: allow db_file to reside on / once again
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-03 07:32:59 +00:00
Eric Wong
cb8f1af3bd Cleanup #includes of standard system headers and put them in one place
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-03 07:29:49 +00:00
Eric Wong
790e70cf25 directory.c: get rid of the horrid dirname(3) and libgen.h dependency
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-03 07:22:22 +00:00
Eric Wong
b1cdf8dadf document parent_path()
git-svn-id: https://svn.musicpd.org/mpd/trunk@7128 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03 07:22:18 +00:00
Eric Wong
b70912031d playerCloseAudio() is static
git-svn-id: https://svn.musicpd.org/mpd/trunk@7127 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03 07:22:13 +00:00
Eric Wong
7de5f9cef1 player.c: introduce set_current_song to avoid needless repetition
git-svn-id: https://svn.musicpd.org/mpd/trunk@7126 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03 07:22:08 +00:00
Eric Wong
00e0224996 song: updateSongInfo: left out charset conversion when going thread-safe
git-svn-id: https://svn.musicpd.org/mpd/trunk@7124 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01 10:10:08 +00:00
Eric Wong
4c88ef34bb silence is constant, as is the buffer we pass to playAudio
git-svn-id: https://svn.musicpd.org/mpd/trunk@7123 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01 10:10:02 +00:00
Eric Wong
2cc59816a6 Simplify decode cleanup logic a bit
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-01 10:09:56 +00:00
Eric Wong
5e7367c580 charConv: tie the buffer size for iconv() to our PATH_MAX constant
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-01 10:09:43 +00:00
Eric Wong
1b4de32706 storedPlaylist: remove the needless StoredPlaylist struct and just use List
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-01 10:09:36 +00:00
Eric Wong
09936358fa storedPlaylist: cleanup API and avoid needless heap allocations + error checks
git-svn-id: https://svn.musicpd.org/mpd/trunk@7119 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01 10:09:31 +00:00
Eric Wong
390ed29740 storedPlaylist: cleanup load function
* 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-01 10:09:26 +00:00
Eric Wong
24c58132ec playlist: cleanup pathname generation for the "rm" command, too
git-svn-id: https://svn.musicpd.org/mpd/trunk@7117 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01 10:09:23 +00:00
Eric Wong
68b9f41381 playlist: avoid the use of newStoredPlaylist for saving active playlists
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-01 10:09:18 +00:00
Eric Wong
47efe42321 Make utf8_to_fs_playlist_path universally accessible
git-svn-id: https://svn.musicpd.org/mpd/trunk@7115 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01 10:07:34 +00:00
Eric Wong
49f8660f35 storedPlaylist: fix compile warning (last-second internal API change)
git-svn-id: https://svn.musicpd.org/mpd/trunk@7114 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01 03:06:01 +00:00
Eric Wong
c3a47fe364 mpc_plugin: break out if a missed error branch
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-01 03:01:58 +00:00
Eric Wong
6fbbc642dd Revert r7111 and begin to properly fix storedPlaylist code
git-svn-id: https://svn.musicpd.org/mpd/trunk@7112 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-01 03:01:24 +00:00
Qball Cow
c75d33752a Don't let xstrdup(s) crash crash when s is NULL, but return Null in stead
git-svn-id: https://svn.musicpd.org/mpd/trunk@7111 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-31 18:41:08 +00:00
Eric Wong
a4ed0a8358 ogg_common: fix indent screwup
git-svn-id: https://svn.musicpd.org/mpd/trunk@7109 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-31 00:54:38 +00:00
Eric Wong
0d1a3539ad fix builds that only have FLAC >= 1.1.3 but not Ogg-Vorbis
git-svn-id: https://svn.musicpd.org/mpd/trunk@7108 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-31 00:54:32 +00:00
Eric Wong
b79f6b882a Merge branches/ew r7104
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-28 02:56:25 +00:00
Qball Cow
0d26248a0d If clearing stored playlist fails, don't return error + OK. but only the error.
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-27 00:03:49 +00:00
Qball Cow
fd75619c3b Know about SND_PCM_STATE_RUNNING, might fix some bugs
git-svn-id: https://svn.musicpd.org/mpd/trunk@7077 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-16 15:46:54 +00:00
Qball Cow
704daecbf2 Fix possible wrong 'addition'
git-svn-id: https://svn.musicpd.org/mpd/trunk@7076 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-12-10 13:51:25 +00:00
Qball Cow
ba48dc18fd Fix replaygain for latest flac version.
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-12-06 23:01:28 +00:00
Qball Cow
e1571cc705 Re-enable seeking in http streams.
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-28 14:06:03 +00:00
Qball Cow
4447ce5065 Don't try to forever to get data when the sockets winds up in "temporary
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-28 14:00:56 +00:00
Avuton Olrich
5e085751f5 A better way to do the last patch (extremely minor patch)
git-svn-id: https://svn.musicpd.org/mpd/trunk@7042 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-11-21 14:02:03 +00:00
Avuton Olrich
6f11941e5e Fix Sun C 5.9 / C99 compatiblity
git-svn-id: https://svn.musicpd.org/mpd/trunk@7041 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-11-21 13:43:37 +00:00
Qball Cow
6050541d97 When parsing id3_frames take in account that there are different frames
and with different field types.
This fixes comments for id3v1 and id3v2


git-svn-id: https://svn.musicpd.org/mpd/trunk@7040 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-11-21 12:15:00 +00:00
Qball Cow
b8dfe42342 Disable seeking on streams, because of bug 1611. When playing ogg, the decoder seeks through the file then starts to play. This does not mix well with streams from websites. Stopping playback of an oggstream that is trying to stream will result in mpd hanging.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7039 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-11-18 19:15:10 +00:00
Qball Cow
ec49c1d3d9 Fix wavpack endian issues, tested to work for 16bit. (after blowing my ears off with white noise)
git-svn-id: https://svn.musicpd.org/mpd/trunk@6952 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-10-03 16:11:01 +00:00
Qball Cow
cb9d1b3d27 Playlist queue patch (http://musicpd.org/mantis/view.php?id=1478) version 11.
This adds the following commands:
* queueid <id>		Add song <id> to the queue.
* dequeue <pos>		Remove song from <pos> from the queue
* queueinfo			List the queue

To the statusfield it adds the following entry:
playlistqueue:	<uid>		UID can be used by clients to track changes in the playlist queue.



git-svn-id: https://svn.musicpd.org/mpd/trunk@6927 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-26 08:25:35 +00:00
Eric Wong
3a03b89b48 inputPlugins/_ogg_common.c: fixup includes for new (1.1.4+ FLAC)
ogg_stream_type_detect may not be compiled correctly
when compiling FLAC (1.1.4+) without Vorbis

git-svn-id: https://svn.musicpd.org/mpd/trunk@6896 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-17 11:30:37 +00:00
Avuton Olrich
1337f33c62 Add oga extension for flac-1.2.1
git-svn-id: https://svn.musicpd.org/mpd/trunk@6888 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-14 22:15:38 +00:00
Eric Wong
34f3abd357 conf.c: remove extra semi-colon here, too
git-svn-id: https://svn.musicpd.org/mpd/trunk@6874 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-10 07:15:58 +00:00
Eric Wong
8b141ae54e buffer input while waiting for outputBuffer space in mp4 and (ogg)flac
Both mp4 and (ogg)flac inputPlugins got HTTP inputStream support
later in the game, so their calls to sendDataToOutputBuffer()
didn't get updated to support buffering while the outputBuffer
was full.  This fixes it.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6873 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-10 07:12:42 +00:00
Eric Wong
54339dfbc2 pcm_utils: gcc 2.95 compile fix (extra semi-colon)
git-svn-id: https://svn.musicpd.org/mpd/trunk@6872 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-10 07:12:37 +00:00
Eric Wong
38de8d0808 playerInit() is static
git-svn-id: https://svn.musicpd.org/mpd/trunk@6868 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-08 03:29:13 +00:00
Eric Wong
30ed6bcf22 inputStream_http: signal the server to close after all requests
We want the partial content goodies of HTTP/1.1 without
requiring persistent connections.  Persistent connections across
multiple HTTP requests don't really help in the case of MPD,
either, because our content is usually big and heavy.

Note: this puts MPD at the hands of the server to correctly
close() the TCP connection we're using.  If we connect to a
rogue server that keeps the connection alive even when request
not to, we'll spin :(  However, encountering such a server
is very unlikely...

git-svn-id: https://svn.musicpd.org/mpd/trunk@6867 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-08 01:06:29 +00:00
Eric Wong
251216a552 decode: fix seek when paused
We need to SIGCONT the decoder process to allow for seeking
while paused.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6864 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-07 01:17:09 +00:00
Eric Wong
45c9989849 get rid of unused DECODE_SUFFIX_* #defines
These haven't been used for several years

git-svn-id: https://svn.musicpd.org/mpd/trunk@6863 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-07 00:59:29 +00:00
Eric Wong
56274fd016 Once again get rid of busy waiting and use SIGSTOP for pause
The problems I had were related to the OSS driver and USB
device I was using.  The problems existed even with the old
busy-waiting scheme enabled.

OSS  - Bithead USB     => bad
ALSA - Bithead USB     => OK
OSS  - Onboard i8x0    => OK
ALSA - Onboard i8x0    => OK

bad - slow shutdown, pauses, dropped audio after pause/resume

git-svn-id: https://svn.musicpd.org/mpd/trunk@6861 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-06 01:07:49 +00:00
Eric Wong
7024700cc5 return to busy-waiting on pause for now..
Until we can fix it properly (or replace it with a cleaner event
system), I don't want this in trunk.  Currently there are
strange pauses when queueing and during shutdown that I can't
seem to figure out right away.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6860 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-06 00:45:34 +00:00
Eric Wong
fe584bb11c send SIGCONT to the player process whenever we need to busy wait on it
This fixes the problem of playlist moving/changnig while we're paused

Followup to r6822

git-svn-id: https://svn.musicpd.org/mpd/trunk@6859 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-06 00:19:33 +00:00
Eric Wong
b2ae8da509 conf: use getBoolBlockParam for block params, too
git-svn-id: https://svn.musicpd.org/mpd/trunk@6858 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-05 23:59:36 +00:00
Eric Wong
4a2122eaf4 conf: improved boolean config parameter handling from -ke
the force flag will issue FATAL() if an invalid value is
specified

git-svn-id: https://svn.musicpd.org/mpd/trunk@6857 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-05 23:59:33 +00:00
Eric Wong
ac58dce7df Redirect stdin *before* we establish a listen socket
This way we'll avoid listening on fd=0 and have a better
chance of having fd=0 as /dev/null

git-svn-id: https://svn.musicpd.org/mpd/trunk@6852 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-05 01:19:37 +00:00
Eric Wong
7992ff37d0 log: oops, fix a syntax error
(yes, it helps to actually compile code before committing it)

git-svn-id: https://svn.musicpd.org/mpd/trunk@6851 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-04 21:08:35 +00:00
Eric Wong
146485d0cb log: better bug avoidance for libraries incorrectly handling fd=0
We redirect stdin to /dev/null to work around a libao bug, but
this bug has been fixed in libao since 2003 (according to jat).

However, there are likely other bugs in other libraries (and
even our code!) that handle fd=0 incorrectly and I'd rather not
take the risk[1].  So So it's easiest to just keep
fd=0==/dev/null for now...

[1] - I've seen several of these myself...

git-svn-id: https://svn.musicpd.org/mpd/trunk@6849 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-04 19:45:24 +00:00
Eric Wong
203a5ed26d zeroconf: avoid passing NULLs to Avahi *_free() routines
This should fix Debian bug #428551
(mpd crashes when restarting the dbus daemon)

git-svn-id: https://svn.musicpd.org/mpd/trunk@6844 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-02 02:18:09 +00:00
Eric Wong
bbe8b0efd8 Fix endless loop when mpd is launched from a non-interactive shell.
Thanks to _noth_ for the patch, this fixes Mantis bug #1534

_noth_ wrote:
> When MPD is launched from a non-interactive shell, it enters an endless
> loop, filling up its error log file with "error accept()'ing" messages.
> This is caused by the fact that stdin is already closed when mpd starts
> up.  listenOnPort() opens up the first of its sockets as fd 0 (the first
> empty fd table position). Then, setup_log_output()->redirect_stdin()
> overwrites fd0 (fd=open("/dev/null",...); dup2(fd, STDIN_FILENO);)
> without checking if it corresponds to the actual standard input (or if
> it is open in the first place).  This means that listenSockets[0].fd now
> is a fd for /dev/null, thus doIOForInterfaces()->getConnections() can't
> accept(2) on it and fails with the above error. The attached patch fixes
> this for me.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6843 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-02 01:11:28 +00:00
Eric Wong
c2e742106f interface: fix IPV6 hostname buffer deallocation from automatics
The host buffer that hostname pointed to is no longer on the
stack by the time the SECURE() message is printed.  So make it
static and thus accessible to all.  We won't be calling this
stuff in the middle of a child process/thread/task, so there's
no

Also, hostname is a constant string we shouldn't modify, so mark
it as const char *.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6842 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-09-01 12:20:49 +00:00
Eric Wong
c5c8548ba2 inputPlugins/flac: improve error messages
For the default: case, just use the error message that libFLAC
provides instead of using something ambiguous.  Also, this gets
rid of long lines in the code, making it easier to digest.

Of course, we save ~100 bytes of text space in the process :)

git-svn-id: https://svn.musicpd.org/mpd/trunk@6830 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-28 05:01:19 +00:00
Eric Wong
cd6e584c35 log: cleanup: avoid "magic" numbers
We used a bare '15' in several places and it's not immediately
obvious where it came from.  This makes it more obvious

git-svn-id: https://svn.musicpd.org/mpd/trunk@6829 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-28 05:01:16 +00:00
J. Alexander Treuman
1b045d0672 removing debug messages from signal handlers
As unfortunate as it is to remove such useful debugging messages, it's
necessary to fix a potential deadlock with signal handling.  A bunch of
functions the debug functions call aren't safe to call from a signal
handler.  There are some alternate solutions, but they're neither pretty
nor simple.  So just remove them entirely for now.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6828 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-27 21:18:35 +00:00
J. Alexander Treuman
752bf24b74 interface: print whole debug message at once
Using SECURE once without a \n, and again with one, results in a timestamp
mid-line.  Let's not do that.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6827 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-27 21:10:44 +00:00
J. Alexander Treuman
8d89add8e7 adding \n to a bunch of error message strings
git-svn-id: https://svn.musicpd.org/mpd/trunk@6826 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-27 21:03:22 +00:00
Eric Wong
f18e524176 send SIGSTOP to player and decoder processes on pause, too
as with the stop command, this will cause the player and decoder
to suspend and not wake up hundreds of times a second to poll
a variable for wakeup.  This will reduce power consumption
on some CPUs while mpd is paused and not playing.

tests:

pause && unpause => OK

pause && stop && play => OK

pause && exit && restart w/statefile && unpause => OK

pause && block sound device && \
unpause => failed to open sound device \
=> still paused and suspended => unblock sound device &&
unpause => OK (playing)

In all cases, the player process releases the audio device
when paused before going into the suspended state.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6822 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-27 09:36:11 +00:00
Eric Wong
0f2e9ee662 export FATAL() with noreturn attribute
This attribute was set in log.c, but not exported to other
modules in log.h

This allows us to remove some unneccessary variable
initializations that were added in r6277.  I did
audioOutput_shout.c a bit differently, to avoid some
jumps.

before:
$ size src/mpd
text    data     bss     dec     hex filename
225546    4040   14600  244186   3b9da src/mpd

after:
$ size src/mpd
text    data     bss     dec     hex filename
224698    4040   14600  243338   3b68a src/mpd

git-svn-id: https://svn.musicpd.org/mpd/trunk@6821 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-27 08:05:55 +00:00
J. Alexander Treuman
fe4b16ed96 inputPlugins/mp3_plugin: parse LAME tags for ReplayGain info
Parse ReplayGain info in LAME tags and use it if no ID3v2 ReplayGain tags
are found.  This is currently a bit unsafe, as apparently some LAME tags
have bogus ReplayGain values.  But I'm finding a lot of MP3s with valid
LAME tags that fail the LAME tag CRC check.  So until I figure out why
that's happening, it's an unreliable method for checking if the LAME tag is
valid.

A big thanks to tmz for writing the original patch.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6798 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-22 16:42:08 +00:00
J. Alexander Treuman
5e1deab05f decode: close audio device after initial open if paused
Currently, if we start decoding while the pause flag is set, we open the
audio device and leave it opened, blocking other apps from using it.  The
obvious thing to do is to not open the audio device if the pause flag is
set, but the open call also sets the audio format.  Therefore I'm leaving
the open call in, and just closing it immediately afterwards if the pause
flag is set.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6745 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-12 19:23:48 +00:00
J. Alexander Treuman
d286294805 decode: reformatting for better readability
git-svn-id: https://svn.musicpd.org/mpd/trunk@6742 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-12 19:15:06 +00:00
J. Alexander Treuman
3fedc4d806 audioOutputs/audioOutput_shout: adding timers back
The shout plugin will now feign playback until the connect timeout is hit,
preventing connection attempts from blocking playback on local outputs.
Note that this patch is very different from remiss' original one.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6738 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-11 21:36:23 +00:00
Qball Cow
e195fb8100 Cleanup a outcommented debug statement
git-svn-id: https://svn.musicpd.org/mpd/trunk@6736 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-08-11 11:36:13 +00:00
Qball Cow
4811eadb4a Extra debug output
git-svn-id: https://svn.musicpd.org/mpd/trunk@6689 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-07-16 20:31:37 +00:00
J. Alexander Treuman
54e6b27989 log: flush the warning log after redirecting stderr to the log files
Previously, the warning log was only flushed if creating the db or logging
to stdout.  This meant that under normal circumstances (no db creation,
logging to files) the warning log was never flushed.  This caused a bug
when a warning was printed for each call to the status command where the
warning buffer would grow endlessly, eventually using more and more CPU to
reallocate it.

git-svn-id: https://svn.musicpd.org/mpd/trunk@6660 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-06-29 18:41:02 +00:00