mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-18 09:59:53 -04:00
[input] Buffer full callback should also be made when source reading ends
Otherwise the player will wait infinitely
This commit is contained in:
parent
b9b2874a2e
commit
19ba9d106a
26
src/input.c
26
src/input.c
@ -332,6 +332,16 @@ markers_set(short flags, size_t write_size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
buffer_full_cb(void)
|
||||||
|
{
|
||||||
|
if (!input_buffer.full_cb)
|
||||||
|
return;
|
||||||
|
|
||||||
|
input_buffer.full_cb();
|
||||||
|
input_buffer.full_cb = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------- INPUT SOURCE HANDLING -------------------------- */
|
/* ------------------------- INPUT SOURCE HANDLING -------------------------- */
|
||||||
|
|
||||||
@ -549,6 +559,7 @@ timeout_cb(int fd, short what, void *arg)
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------- Interface towards input backends ------------------ */
|
/* ---------------------- Interface towards input backends ------------------ */
|
||||||
/* Thread: input and spotify */
|
/* Thread: input and spotify */
|
||||||
|
|
||||||
@ -564,15 +575,14 @@ input_write(struct evbuffer *evbuf, struct media_quality *quality, short flags)
|
|||||||
|
|
||||||
read_end = (flags & (INPUT_FLAG_EOF | INPUT_FLAG_ERROR));
|
read_end = (flags & (INPUT_FLAG_EOF | INPUT_FLAG_ERROR));
|
||||||
if (read_end)
|
if (read_end)
|
||||||
|
{
|
||||||
|
buffer_full_cb();
|
||||||
input_now_reading.open = false;
|
input_now_reading.open = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ((evbuffer_get_length(input_buffer.evbuf) > INPUT_BUFFER_THRESHOLD) && evbuf)
|
if ((evbuffer_get_length(input_buffer.evbuf) > INPUT_BUFFER_THRESHOLD) && evbuf)
|
||||||
{
|
{
|
||||||
if (input_buffer.full_cb)
|
buffer_full_cb();
|
||||||
{
|
|
||||||
input_buffer.full_cb();
|
|
||||||
input_buffer.full_cb = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// In case of EOF or error the input is always allowed to write, even if the
|
// In case of EOF or error the input is always allowed to write, even if the
|
||||||
// buffer is full. There is no point in holding back the input in that case.
|
// buffer is full. There is no point in holding back the input in that case.
|
||||||
@ -632,11 +642,7 @@ input_wait(void)
|
|||||||
// Is the buffer full? Then wait for a read or for loop_timeout to elapse
|
// Is the buffer full? Then wait for a read or for loop_timeout to elapse
|
||||||
if (evbuffer_get_length(input_buffer.evbuf) > INPUT_BUFFER_THRESHOLD)
|
if (evbuffer_get_length(input_buffer.evbuf) > INPUT_BUFFER_THRESHOLD)
|
||||||
{
|
{
|
||||||
if (input_buffer.full_cb)
|
buffer_full_cb();
|
||||||
{
|
|
||||||
input_buffer.full_cb();
|
|
||||||
input_buffer.full_cb = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ts = timespec_reltoabs(input_loop_timeout);
|
ts = timespec_reltoabs(input_loop_timeout);
|
||||||
pthread_cond_timedwait(&input_buffer.cond, &input_buffer.mutex, &ts);
|
pthread_cond_timedwait(&input_buffer.cond, &input_buffer.mutex, &ts);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user