Subject: [PATCH 2/2] hal_stream: use rtapi_barrier to fix intermittent bugs

From: Jeff Epler <[email-masked]>
Date: Sat, 18 Jul 2015 15:45:17 -0500

---
 src/hal/hal_lib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/hal/hal_lib.c b/src/hal/hal_lib.c
index ee2a306..e5e917f 100644
--- a/src/hal/hal_lib.c
+++ b/src/hal/hal_lib.c
@@ -3568,6 +3568,7 @@ int hal_stream_write(hal_stream_t *stream, union hal_stream_data *buf) {
     union hal_stream_data *dptr = &stream->fifo->data[in * stride];
     memcpy(dptr, buf, sizeof(union hal_stream_data) * num_pins);
     dptr[num_pins].s = ++stream->fifo->this_sample;
+    rtapi_barrier();
     stream->fifo->in = newin;
     return 0;
 }
@@ -3577,6 +3578,7 @@ int hal_stream_read(hal_stream_t *stream, union hal_stream_data *buf, unsigned *
         stream->fifo->num_underruns ++;
         return -ENOSPC;
     }
+    rtapi_barrier();
     int out = stream->fifo->out, newout = hal_stream_advance(stream, out);
     int num_pins = stream->fifo->num_pins;
     int stride = num_pins + 1;
-- 
1.9.1