From 06c22c25821e1652433a2e80e4fd1a8c661e6d71 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Wed, 14 Jun 2017 23:38:34 -0400
Subject: [PATCH] port from Pd Vanilla: readsf fix for short soundfiles if the
 entire soundfile fits into the fifo, then [readsf~] will start to loop the
 file, since the 'drained' test in d_soundfile.c:1937 does not trigger. the
 fix is to properly set the fifohead (in the read thread) to the new position,
 even if the read() returned '0' (indicating EOF)

commit 057cb3ee6cc58597a1b74a00a7880c2cfd0a466a
---
 pd/src/d_soundfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pd/src/d_soundfile.c b/pd/src/d_soundfile.c
index 4e1ab4a30..e7abcce67 100644
--- a/pd/src/d_soundfile.c
+++ b/pd/src/d_soundfile.c
@@ -1802,13 +1802,13 @@ static void *readsf_child_main(void *zz)
                 {
                     x->x_fifohead += sysrtn;
                     x->x_bytelimit -= sysrtn;
+                    if (x->x_fifohead == fifosize)
+                        x->x_fifohead = 0;
                     if (x->x_bytelimit <= 0)
                     {
                         x->x_eof = 1;
                         break;
                     }
-                    if (x->x_fifohead == fifosize)
-                        x->x_fifohead = 0;
                 }
 #ifdef DEBUG_SOUNDFILE
                 sprintf(boo, "after: head %d, tail %d\n", 
-- 
GitLab