Commit Graph

1796 Commits

Author SHA1 Message Date
Max Kellermann
288a7087f6 allocate playerData_pd from heap instead of shm
git-svn-id: https://svn.musicpd.org/mpd/trunk@7308 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:17:46 +00:00
Max Kellermann
eb5d51c988 fixed another shadow warning
git-svn-id: https://svn.musicpd.org/mpd/trunk@7307 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:17:22 +00:00
Max Kellermann
70ba525144 don't allocate pd.auddioDeviceStates from shm
git-svn-id: https://svn.musicpd.org/mpd/trunk@7306 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:17:12 +00:00
Max Kellermann
4b2a10825d fix typo in comment
git-svn-id: https://svn.musicpd.org/mpd/trunk@7305 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:17:01 +00:00
Max Kellermann
78f606078e let initOutputBuffer() allocate memory
This is the first patch in a series which removes the shared memory,
and moves all the playerData objects into the normal libc heap.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7304 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:16:56 +00:00
Max Kellermann
f0e28ede4d fix deadlock at end of song
Now that we do proper locking and signalling instead of continuous
polling for IPC, a deadlock was found: at the end of a song, the
player thread waits until the main thread sets pc->queueState from
PLAYER_QUEUE_DECODE to PLAYER_QUEUE_PLAY.  He is never woken up, since
syncPlaylistWithQueue() does not activate the notification.  I added
wakeup_player_nb() to setQueueState(), since the player must be
signalled whenever pc->queueState changes.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7303 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:16:50 +00:00
Eric Wong
9cfb4c0390 decode: fix some uninitialized variable warnings
They're probably not needed, but less noise => faster debugging

git-svn-id: https://svn.musicpd.org/mpd/trunk@7302 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:16:44 +00:00
Eric Wong
e566c4c64c decode: fix unsigned comparision and add some paranoid assertions
git-svn-id: https://svn.musicpd.org/mpd/trunk@7301 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:16:37 +00:00
Eric Wong
f275a1a1ab Fix a few more warnings from -Wshadow
git-svn-id: https://svn.musicpd.org/mpd/trunk@7300 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:16:32 +00:00
Eric Wong
4e4441fd32 configure: better CFLAGS checking
needed for compatibility with older gcc.  Also, threw in
some warnings for things I find offensive
(declaration-after-statement, shadow)

git-svn-id: https://svn.musicpd.org/mpd/trunk@7299 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:16:22 +00:00
Max Kellermann
dd20681daa missing const in disabled code path
git-svn-id: https://svn.musicpd.org/mpd/trunk@7298 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:16:18 +00:00
Max Kellermann
ee64bba4d9 some assertions to check the unsigned changes
git-svn-id: https://svn.musicpd.org/mpd/trunk@7297 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:16:13 +00:00
Max Kellermann
1ad2f07a39 use size_t in audio.c
Buffer sizes should be size_t.  This is safe here, at least not
unsafer than without the patch.  I have no idea why audioBufferSize
and audioBufferPos were explicitly declared as signed integer.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7296 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:16:08 +00:00
Max Kellermann
c9d80d6090 use free()/malloc() instead of realloc()
When growing the audioOutput->convBuffer, we can use free()+malloc()
instead of realloc(), which saves a memcpy().

git-svn-id: https://svn.musicpd.org/mpd/trunk@7295 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:16:03 +00:00
Max Kellermann
1d18ca6909 use size_t in audioOutput.c internals
git-svn-id: https://svn.musicpd.org/mpd/trunk@7294 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:15:58 +00:00
Max Kellermann
01bf822896 use size_t and constant pointer in ao plugins
The audio output plugins should get a constant pointer, because they
must not modify the buffer.  Since the size is a non-negative buffer
size in bytes, we should change its type to size_t.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7293 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:15:52 +00:00
Max Kellermann
a2380928db use size_t for pcm_sizeOfConvBuffer() result
In my previous patch set, I forgot to change the
pcm_sizeOfConvBuffer() invocation in convertAudioFormat() to also use
size_t.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7292 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:15:40 +00:00
Max Kellermann
2bd2957a7a yet more unsigned integers
calculateCrossFadeChunks() still returns int, although the caller uses
it as an unsigned value.  Since the function body checks for negative
values, it is safe to cast to unsigned.

crossFade() takes signed parameters, although it callers pass unsigned
integers.  Change declaration to unsigned.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7291 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:15:35 +00:00
Max Kellermann
f7e97c9a89 constant pointers
There were some const pointers missing in the previous const-cleanup
patch.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7290 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:15:30 +00:00
Max Kellermann
05c41a80ed fix parameter types in the faad calls
libfaad wants uint32_t pointers.  Passing a long pointer is bugged on
amd64.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7289 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:15:24 +00:00
Max Kellermann
2ede0780f6 fix compilation error in wavpack plugin
The patch "Start using song pointers in core data structures" removed
dc->utf8url, and the adaption for wavpack_plugin.c was missing.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7288 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:15:16 +00:00
Max Kellermann
a5aa5a0258 yet more unsigned integers
git-svn-id: https://svn.musicpd.org/mpd/trunk@7287 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:15:10 +00:00
Max Kellermann
4e0891337a whitespace cleanup
git-svn-id: https://svn.musicpd.org/mpd/trunk@7286 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:15:00 +00:00
Max Kellermann
7503518bac added inline function successor()
The new function successor() can be used to simplify a lot of code
lines and saves a lot of "i+>=buffered_chunks" checks.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7285 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:14:55 +00:00
Max Kellermann
079f13bc7d moved currentChunk into OutputBuffer
currentChunk is a global variable, which renders the whole output
buffer code non-reentrant.  Although this is not a real problem since
there is only one global output buffer currently, we should move it to
the OutputBuffer struct.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7284 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:14:50 +00:00
Max Kellermann
4ee8396f41 use the notify API in the main thread
git-svn-id: https://svn.musicpd.org/mpd/trunk@7283 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:14:45 +00:00
Max Kellermann
b7ac3fab46 use the notify API in the player
git-svn-id: https://svn.musicpd.org/mpd/trunk@7282 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:14:38 +00:00
Max Kellermann
701cf6884c use the notify API in the decoder
git-svn-id: https://svn.musicpd.org/mpd/trunk@7281 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:14:32 +00:00
Max Kellermann
0146fbe3ce use the pthread API in notify.c
This patch rewrites notify.c to use the pthread API, namely
pthread_mutex and pthread_cond.  This is a lot cheaper and easier than
the pipe() hack.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7280 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:14:25 +00:00
Max Kellermann
38e0dafc4c rename the notify.c methods
Use "notify" as a prefix rather than suffix.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7279 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:14:19 +00:00
Max Kellermann
00a16b49ba use break instead of quitDecode()+return
The code paths which return from the functions all have to call
quitDecode().  If we simply break instead of calling quitDecode()
explicitly, this function gets called in the last line of this
function anyway.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7278 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:14:14 +00:00
Max Kellermann
646260b19e moved expression to audioFormatSizeToTime()
The multi-line expression which calculates sizeToTime is hard to read,
partly because "cb->audioFormat." is too long.  Create a separate
inline function in audio.h for that.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7277 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:14:09 +00:00
Max Kellermann
dc55e13ca1 let calculateCrossFadeChunks() decide
Moved the decision whether to cross-fade the current song to
calculateCrossFadeChunks().  This simplifies the function
decoderParent() and eliminates one layer of indentation.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7276 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:14:01 +00:00
Max Kellermann
b009b2a437 moved code to playChunk()
Similar to the crossFade() patch: pass chunk objects to playChunk(),
simplify decodeParent() by removing clutter.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7275 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:56 +00:00
Max Kellermann
2e648b57f3 added outputBufferShift()
Hiding OutputBuffer internals, yet again.  Two more assertions.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7274 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:51 +00:00
Max Kellermann
11a5728e1d continue main loop instead of nesting loops
To unify the decoderParent() main loop some more, use it to wait for
the decoder to change the song.  Only one single processDecodeInput()
caller left after this patch.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7273 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:45 +00:00
Max Kellermann
f25ff42639 sleep when waiting for cross-fade chunks
When there are not enough decode cross-fade chunks in the buffer yet,
the current code does busy-wait, which will delay the decoder even
more.  sleep instead, expecting the decoder to wake us up.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7272 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:41 +00:00
Max Kellermann
9760325ee6 moved code to crossFade()
Calling crossFade() with the chunk objects is easier than unrolling
all the chunk properties manually, and decodeParent() can really use
more of these simplifications.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7271 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:36 +00:00
Max Kellermann
bc20b64302 use sizeof(chunk.data) instead of CHUNK_SIZE
sizeof() is the more "natural" or "direct" access to the buffer size,
instead of a macro happening to be used to the buffer declaration.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7270 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:30 +00:00
Max Kellermann
74910df0f3 added struct OutputBufferChunk
To make access to OutputBuffer easier, move everything which belongs
to a chunk into its own structure, namely OutputBufferChunk.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7269 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:24 +00:00
Max Kellermann
68a625b5b8 moved CHUNK_SIZE to outputBuffer.h
The chunk size should be in outputBuffer.h since the output buffer
code is its primary user.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7268 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:17 +00:00
Max Kellermann
7a6c31ae06 added outputBufferChunkData()
Hiding OutputBuffer internals, again.  We get an extra assertion in
return.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7267 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:11 +00:00
Max Kellermann
71b24e0950 removed "quit"
The variable "quit" can be removed, since its only setter can use
"break" instead, just like the other code paths.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7266 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:05 +00:00
Max Kellermann
e9b7aae3f0 do not reset nextChunk
The variables "nextChunk" and "crossFadeChunks" are only used when
doCrossFade==1.  This means that we do not have to reset these as long
as doCrossFade!=1.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7265 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:13:00 +00:00
Max Kellermann
4e60343e55 added outputBufferRelative()
The cross-fade check is still very complicated whenever it uses
OutputBuffer internals.  Greatly simplify another check by introducing
outputBufferRelative().

git-svn-id: https://svn.musicpd.org/mpd/trunk@7264 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:12:53 +00:00
Max Kellermann
50dc380f23 added outputBufferEmpty()
Another "don't use OutputBuffer internals" patch.  This ignores the
copied "end" value, but I do not think that has ever been a real
issue.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7263 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:12:47 +00:00
Max Kellermann
e626028b41 moved check to outputBufferAbsolute()
decoderParent() uses a lot of OutputBuffer internals to see whether
cross-fading should be started.  Move these checks to outputBuffer.c,
which also simplifies decoderParent().

git-svn-id: https://svn.musicpd.org/mpd/trunk@7262 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:12:42 +00:00
Max Kellermann
a546428263 make variables more local
Declare the variables "test" and "fadePosition" in the scope where
they are really used.  This removes some of the clutter in the
function decodeParent().

git-svn-id: https://svn.musicpd.org/mpd/trunk@7261 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:12:36 +00:00
Max Kellermann
b89b019723 moved the initial buffering code into the big loop
Eliminating some duplicated and.  This also decreases the number of
lines calling processDecodeInput().

git-svn-id: https://svn.musicpd.org/mpd/trunk@7260 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:12:31 +00:00
Max Kellermann
aaebd9ef2b some comments in decode.c
I have spent some time to understand decodeParent(), which does a lot
of obfuscated magic...  I find it useful to help others to also
understand it, so I wrote a few comments.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7259 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12 04:12:26 +00:00