| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
Hiding OutputBuffer internals, yet again. Two more assertions.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7274 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
The method availableOutputBuffer() calculates how many chunks are in
use. This simplifies code which needs this information, and it can
run without knowing OutputBuffer internals. The function knows how to
calculate this when begin>end; this might have been a bug in
decodeParent(), which does not.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7250 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@7245 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
|
|
|
| |
It is way more complicated than it should be; and
locking it for thread-safety is too difficult.
[merged r7183 from branches/ew]
git-svn-id: https://svn.musicpd.org/mpd/trunk@7241 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I initially started to do a heavy rewrite that changed the way processes
communicated, but that was too much to do at once. So this change only
focuses on replacing the player and decode processes with threads and
using condition variables instead of polling in loops; so the changeset
itself is quiet small.
* The shared output buffer variables will still need locking
to guard against race conditions. So in this effect, we're probably
just as buggy as before. The reduced context-switching overhead of
using threads instead of processes may even make bugs show up more or
less often...
* Basic functionality appears to be working for playing local (and NFS)
audio, including:
play, pause, stop, seek, previous, next, and main playlist editing
* I haven't tested HTTP streams yet, they should work.
* I've only tested ALSA and Icecast. ALSA works fine, Icecast
metadata seems to get screwy at times and breaks song
advancement in the playlist at times.
* state file loading works, too (after some last-minute hacks with
non-blocking wakeup functions)
* The non-blocking (*_nb) variants of the task management functions are
probably overused. They're more lenient and easier to use because
much of our code is still based on our previous polling-based system.
* It currently segfaults on exit. I haven't paid much attention
to the exit/signal-handling routines other than ensuring it
compiles. At least the state file seems to work. We don't
do any cleanups of the threads on exit, yet.
* Update is still done in a child process and not in a thread.
To do this in a thread, we'll need to ensure it does proper
locking and communication with the main thread; but should
require less memory in the end because we'll be updating
the database "in-place" rather than updating a copy and
then bulk-loading when done.
* We're more sensitive to bugs in 3rd party libraries now.
My plan is to eventually use a master process which forks()
and restarts the child when it dies:
locking and communication with the main thread; but should
require less memory in the end because we'll be updating
the database "in-place" rather than updating a copy and
then bulk-loading when done.
* We're more sensitive to bugs in 3rd party libraries now.
My plan is to eventually use a master process which forks()
and restarts the child when it dies:
master - just does waitpid() + fork() in a loop
\- main thread
\- decoder thread
\- player thread
At the beginning of every song, the main thread will set
a dirty flag and update the state file. This way, if we
encounter a song that triggers a segfault killing the
main thread, the master will start the replacement main
on the next song.
* The main thread still wakes up every second on select()
to check for signals; which affects power management.
[merged r7138 from branches/ew]
git-svn-id: https://svn.musicpd.org/mpd/trunk@7240 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
| |
The chunk index cannot be negative.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7231 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When the decoder process is faster than the player process, all
decodedd buffers are full at some point in time. The decoder has to
wait for buffers to become free (finished playing). It used to do
this by polling the buffer status 100 times a second.
This generates a lot of unnecessary CPU wakeups. This patch adds a
way for the player process to notify the decoder process that it may
continue its work.
We could use pthread_cond for that, unfortunately inter-process
mutexes/conds are not supported by some kernels (Linux), so we cannot
use this light-weight method until mpd moves to using threads instead
of processes. The other method would be semaphores, which
historically are global resources with a unique name; this historic
API is cumbersome, and I wanted to avoid it.
I came up with a quite naive solution for now: I create an anonymous
pipe with pipe(), and the decoder process reads on that pipe. Until
the player process sends data on it as a signal, the decoder process
blocks.
This can be optimized in a number of ways:
- if the decoder process is still working (instead of waiting for
buffers), we could save the write() system call, since there is
nobody waiting for the notification.
[ew: I tried this using a counter in shared memory, didn't help]
- the pipe buffer will be full at some point, when the decoder thread
is too slow. For this reason, the writer side of the pipe is
non-blocking, and mpd can ignore the resulting EWOULDBLOCK.
- since we have shared memory, we could check whether somebody is
actually waiting without a context switch, and we could just not
write the notification byte.
[ew: tried same method/result as first point above]
- if there is already a notification in the pipe, we could also not
write another one.
[ew: tried same method/result as first/third points above]
- the decoder will only consume 64 bytes at a time. If the pipe
buffer is full, this will result in a lot of read() invocations.
This does not hurt badly, but on a heavily loaded system, this might
add a little bit more load. The preceding optimizations however
are able eliminate the this.
- finally, we should use another method for inter process
notifications - maybe kill() or just make mpd use threads, finally.
In spite of all these possibilities to optimize this code further,
this pipe notification trick is faster than the 100 Hz poll. On my
machine, it reduced the number of wakeups to less than 30%.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7215 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
|
|
| |
This patch moves code which initializes the OutputBuffer struct to
outputBuffer.c. Although this is generally a good idea, it prepares
the following patch.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7206 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
|
|
|
| |
When dealing with in-memory lengths, the standard type "size_t" should
be used. Missing one can be quite dangerous, because an attacker
could provoke an integer under-/overflow, which may provide an attack
vector.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7205 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
|
|
|
| |
audio at once, so it won't work for us. The old full API code was still
heavily broken, as each call to pcm_convertSampleRate() used the same
state, even if it was processing two streams of audio. The new code keeps
a separate state for each audio stream that's being converted.
git-svn-id: https://svn.musicpd.org/mpd/trunk@6255 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@5834 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
|
| |
Indent the entire tree, hopefully we can keep
it indented.
git-svn-id: https://svn.musicpd.org/mpd/trunk@4410 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
| |
void * rather than "x char *"
git-svn-id: https://svn.musicpd.org/mpd/trunk@4408 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@4333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
| |
the GPL header where necessary
git-svn-id: https://svn.musicpd.org/mpd/trunk@4317 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@2482 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@1439 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
|
| |
create a race condition (but hasn't happened in the last 10 months since
this code was written)
git-svn-id: https://svn.musicpd.org/mpd/trunk@1397 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@1362 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@1361 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
|
|
| |
vorbis comments are updated on the fly for streams
need to decode icy metadata
buffering of metadata needs to be hardened, to ensure that player has already read a particular metachunk or passed over it
git-svn-id: https://svn.musicpd.org/mpd/trunk@1358 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@1352 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@1239 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@1225 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@1125 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
| |
be gentle
git-svn-id: https://svn.musicpd.org/mpd/trunk@1051 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@968 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
|
|
|
| |
to interface. Also, use outputBuffer abstraction for ogg
git-svn-id: https://svn.musicpd.org/mpd/trunk@941 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|
|
implement in other decoders
git-svn-id: https://svn.musicpd.org/mpd/trunk@940 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|