qi: Fix 'rootdir' value, include post-install from proper location
[dragora.git] / patches / vorbis-tools / 0007-Fix-ogg123-freeze-when-interrupting-at-End-Of-Stream.patch
blob67f8eaabc6a2bf0a99f4a17375cdabec574181f2
1 From: =?utf-8?q?Martin_Stegh=C3=B6fer?= <martin@steghoefer.eu>
2 Date: Tue, 28 Oct 2014 23:04:19 +0100
3 Subject: Fix ogg123 freeze when interrupting at End-Of-Stream.
5 Bug-Debian: https://bugs.debian.org/307325
6 Forwarded: https://trac.xiph.org/ticket/1956#comment:3
8 When arriving at the end of the input file, the main thread waits for
9 the output thread to finish up the current buffer. If a cancellation
10 signal arrives at that stage, this signal of an empty buffer never
11 arrives because the output thread bails out before actually emptying
12 the buffer.
14 Fix:
15 1.) Make sure the output thread wakes up the main thread when bailing
16 out, so the main thread can go on, too.
17 2.) When the main thread wakes up while waiting for an empty buffer,
18 make sure it understands the situation (that there won't be an empty
19 buffer because the replay has been cancelled) and doesn't go back to
20 sleep.
21 ---
22 ogg123/buffer.c | 26 +++++++++++++++++++++++---
23 1 file changed, 23 insertions(+), 3 deletions(-)
25 diff --git a/ogg123/buffer.c b/ogg123/buffer.c
26 index b09c9c9..c7111d2 100644
27 --- a/ogg123/buffer.c
28 +++ b/ogg123/buffer.c
29 @@ -209,8 +209,18 @@ void *buffer_thread_func (void *arg)
30 never be unset. */
31 while ( !(buf->eos && buf->curfill == 0) && !buf->abort_write) {
33 - if (buf->cancel_flag || sig_request.cancel)
34 + if (buf->cancel_flag || sig_request.cancel) {
35 + /* signal empty buffer space, so the main
36 + thread can wake up to die in peace */
38 + DEBUG("Abort: Wake up the writer thread");
39 + LOCK_MUTEX(buf->mutex);
40 + COND_SIGNAL(buf->write_cond);
41 + UNLOCK_MUTEX(buf->mutex);
43 + /* abort this thread, too */
44 break;
45 + }
47 DEBUG("Check for something to play");
48 /* Block until we can play something */
49 @@ -227,8 +237,18 @@ void *buffer_thread_func (void *arg)
51 UNLOCK_MUTEX(buf->mutex);
53 - if (buf->cancel_flag || sig_request.cancel)
54 + if (buf->cancel_flag || sig_request.cancel) {
55 + /* signal empty buffer space, so the main
56 + thread can wake up to die in peace */
58 + DEBUG("Abort: Wake up the writer thread");
59 + LOCK_MUTEX(buf->mutex);
60 + COND_SIGNAL(buf->write_cond);
61 + UNLOCK_MUTEX(buf->mutex);
63 + /* abort this thread, too */
64 break;
65 + }
67 /* Don't need to lock buffer while running actions since position
68 won't change. We clear out any actions before we compute the
69 @@ -756,7 +776,7 @@ void buffer_wait_for_empty (buf_t *buf)
70 pthread_cleanup_push(buffer_mutex_unlock, buf);
72 LOCK_MUTEX(buf->mutex);
73 - while (!empty && !buf->abort_write) {
74 + while (!empty && !buf->abort_write && !buf->cancel_flag && !sig_request.cancel) {
76 if (buf->curfill > 0) {
77 DEBUG1("Buffer curfill = %ld, going back to sleep.", buf->curfill);