Commit 84c1c568e989c73adbe8c479e3890ff4e5d3c172

tokyovania 2022-08-09T16:34:53

add PA_terminate to close the lib

diff --git a/lib/portaudio/output.c b/lib/portaudio/output.c
index 73a8e11..e525e99 100644
--- a/lib/portaudio/output.c
+++ b/lib/portaudio/output.c
@@ -76,6 +76,7 @@ int rtbuf_portaudio_output_stop (s_rtbuf *rtb)
     Pa_StopStream(data->reserved.stream);
     Pa_CloseStream(data->reserved.stream);
     data->reserved.stream = 0;
+    Pa_Terminate();
   }
   return 0;
 }
diff --git a/librtbuf/rtbuf.c b/librtbuf/rtbuf.c
index 5b53224..37ad446 100644
--- a/librtbuf/rtbuf.c
+++ b/librtbuf/rtbuf.c
@@ -444,7 +444,11 @@ int rtbuf_run ()
   if (g_rtbuf_sort)
     rtbuf_sort();
   while (i < g_rtbuf_sorted_n) {
-    s_rtbuf *rtb = &g_rtbuf[g_rtbuf_sorted[i]];
+    unsigned int rtb_i;
+    s_rtbuf *rtb;
+    rtb_i = g_rtbuf_sorted[i];
+    assert(rtb_i < g_rtbuf_alloc.max);
+    rtb = &g_rtbuf[rtb_i];
     /* printf(" rtbuf_run %i ", i);
        rtbuf_print(g_rtbuf_sorted[i]);
        printf("\n"); */