ogl_beamforming

Ultrasound Beamforming Implemented with OpenGL
git clone anongit@rnpnr.xyz:ogl_beamforming.git
Log | Files | Refs | Feed | Submodules | LICENSE

Commit: f8ee00d3562b3f408ecd02bfb3be76f89f11288c
Parent: 95a1d854ee4745a9b11d3bda1109dd9549fcf006
Author: Randy Palamar
Date:   Wed,  2 Oct 2024 14:16:29 -0600

revert most of 12f83e1

This was a bug in the os_unix pipe writing code (fixed here), no
need to waste time closing/opening the pipe and fixing the race it
introduced.

Diffstat:
Mbeamformer.c | 4----
Mhelpers/ogl_beamformer_lib.c | 15++++++++-------
Mos_win32.c | 2+-
3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/beamformer.c b/beamformer.c @@ -408,10 +408,6 @@ do_beamformer(BeamformerCtx *ctx, Arena arena) rf_raw_size, rf_data_buf); } } - /* NOTE: close and reopen the pipe to avoid stale data */ - /* TODO: performance!! */ - os_close_named_pipe(ctx->data_pipe); - ctx->data_pipe = os_open_named_pipe(OS_PIPE_NAME); } /* NOTE: we are starting a volume computation on this frame so make some space */ diff --git a/helpers/ogl_beamformer_lib.c b/helpers/ogl_beamformer_lib.c @@ -49,8 +49,9 @@ os_write_to_pipe(os_pipe p, void *data, size len) { size written = 0, w = 0; do { - written += w; - w = write(p.file, data, len); + if (w != -1) + written += w; + w = write(p.file, data + written, len - written); } while(written != len && w != 0); return written; } @@ -162,10 +163,12 @@ set_beamformer_pipeline(char *shm_name, i32 *stages, i32 stages_count) void send_data(char *pipe_name, char *shm_name, i16 *data, uv2 data_dim) { - g_pipe = os_open_named_pipe(pipe_name); if (g_pipe.file == OS_INVALID_FILE) { - mexErrMsgIdAndTxt("ogl_beamformer:pipe_error", "failed to open pipe"); - return; + g_pipe = os_open_named_pipe(pipe_name); + if (g_pipe.file == OS_INVALID_FILE) { + mexErrMsgIdAndTxt("ogl_beamformer:pipe_error", "failed to open pipe"); + return; + } } check_shared_memory(shm_name); @@ -177,8 +180,6 @@ send_data(char *pipe_name, char *shm_name, i16 *data, uv2 data_dim) mexWarnMsgIdAndTxt("ogl_beamformer:write_error", "failed to write full data to pipe: wrote: %ld", written); g_bp->upload = 1; - - os_close_pipe(g_pipe); } void diff --git a/os_win32.c b/os_win32.c @@ -113,10 +113,10 @@ os_get_file_stats(char *fname) }; } +/* NOTE: win32 doesn't pollute the filesystem so no need to waste the user's time */ static void os_close_named_pipe(os_pipe p) { - CloseHandle(p.file); } static os_pipe