Commit 98a83487 authored by Martin Steghöfer's avatar Martin Steghöfer Committed by Thomas Daede

Fix ogg123 freeze when interrupting at End-Of-Stream.

Bug-Debian: https://bugs.debian.org/307325
Forwarded: https://trac.xiph.org/ticket/1956#comment:3

When arriving at the end of the input file, the main thread waits for
the output thread to finish up the current buffer. If a cancellation
signal arrives at that stage, this signal of an empty buffer never
arrives because the output thread bails out before actually emptying
the buffer.

Fix:
1.) Make sure the output thread wakes up the main thread when bailing
out, so the main thread can go on, too.
2.) When the main thread wakes up while waiting for an empty buffer,
make sure it understands the situation (that there won't be an empty
buffer because the replay has been cancelled) and doesn't go back to
sleep.
parent 6d670e7c
......@@ -213,8 +213,16 @@ void *buffer_thread_func (void *arg)
LOCK_MUTEX (buf->mutex);
DEBUG("Check for cancelation");
if (buf->cancel_flag || sig_request.cancel)
if (buf->cancel_flag || sig_request.cancel) {
/* signal empty buffer space, so the main
thread can wake up to die in peace */
DEBUG("Abort: Wake up the writer thread");
COND_SIGNAL(buf->write_cond);
/* abort this thread, too */
UNLOCK_MUTEX(buf->mutex);
break;
}
DEBUG("Check for something to play");
/* Block until we can play something */
......@@ -227,8 +235,16 @@ void *buffer_thread_func (void *arg)
}
DEBUG("Check for cancelation");
if (buf->cancel_flag || sig_request.cancel)
if (buf->cancel_flag || sig_request.cancel) {
/* signal empty buffer space, so the main
thread can wake up to die in peace */
DEBUG("Abort: Wake up the writer thread");
COND_SIGNAL(buf->write_cond);
/* abort this thread, too */
UNLOCK_MUTEX(buf->mutex);
break;
}
DEBUG("Ready to play");
......@@ -760,7 +776,7 @@ void buffer_wait_for_empty (buf_t *buf)
pthread_cleanup_push(buffer_mutex_unlock, buf);
LOCK_MUTEX(buf->mutex);
while (!empty && !buf->abort_write) {
while (!empty && !buf->abort_write && !buf->cancel_flag && !sig_request.cancel) {
if (buf->curfill > 0) {
DEBUG1("Buffer curfill = %ld, going back to sleep.", buf->curfill);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment