Skip to content

Commit

Permalink
Osc: Ensure that copy of markers from oscplots are read properly
Browse files Browse the repository at this point in the history
(Bug fix)
  • Loading branch information
dNechita committed May 28, 2014
1 parent 779c28a commit 9e38de5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ struct _fft_settings {
gfloat fft_pwr_off;
struct _fft_alg_data fft_alg_data;
struct marker_type *markers;
struct marker_type *markers_copy;
struct marker_type **markers_copy;
GMutex *marker_lock;
enum marker_types *marker_type;
};
Expand All @@ -136,7 +136,7 @@ struct _cross_correlation_settings {
fftw_complex *signal_b;
fftw_complex *xcorr_data;
struct marker_type *markers;
struct marker_type *markers_copy;
struct marker_type **markers_copy;
GMutex *marker_lock;
enum marker_types *marker_type;
};
Expand Down
16 changes: 8 additions & 8 deletions osc.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ static void do_fft(Transform *tr)

}
}
if (settings->markers_copy) {
memcpy(settings->markers_copy, settings->markers,
if (*settings->markers_copy) {
memcpy(*settings->markers_copy, settings->markers,
sizeof(struct marker_type) * MAX_MARKERS);
settings->markers_copy = NULL;
*settings->markers_copy = NULL;
g_mutex_unlock(settings->marker_lock);
}
}
Expand Down Expand Up @@ -521,20 +521,20 @@ void cross_correlation_transform_function(Transform *tr, gboolean init_transform
if (!tr->has_the_marker)
return;

if (MAX_MARKERS && marker_type != MARKER_OFF)
if (MAX_MARKERS && marker_type != MARKER_OFF) {
for (j = 0; j <= MAX_MARKERS && markers[j].active; j++)
if (marker_type == MARKER_PEAK) {
markers[j].x = (gfloat)X[maxx[j]];
markers[j].y = (gfloat)out_data[maxx[j]];
markers[j].bin = maxx[j];
}

if (settings->markers_copy) {
memcpy(settings->markers_copy, settings->markers,
if (*settings->markers_copy) {
memcpy(*settings->markers_copy, settings->markers,
sizeof(struct marker_type) * MAX_MARKERS);
settings->markers_copy = NULL;
*settings->markers_copy = NULL;
g_mutex_unlock(settings->marker_lock);
}
}
}

void fft_transform_function(Transform *tr, gboolean init_transform)
Expand Down
4 changes: 2 additions & 2 deletions oscplot.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,12 +871,12 @@ static void add_markers(OscPlot *plot, Transform *transform)
if (priv->active_transform_type == FFT_TRANSFORM ||
priv->active_transform_type == COMPLEX_FFT_TRANSFORM) {
FFT_SETTINGS(transform)->markers = priv->markers;
FFT_SETTINGS(transform)->markers_copy = priv->markers_copy;
FFT_SETTINGS(transform)->markers_copy = &priv->markers_copy;
FFT_SETTINGS(transform)->marker_type = &priv->marker_type;
FFT_SETTINGS(transform)->marker_lock = &priv->g_marker_copy_lock;
} else if (priv->active_transform_type == CROSS_CORRELATION_TRANSFORM) {
XCORR_SETTINGS(transform)->markers = priv->markers;
XCORR_SETTINGS(transform)->markers_copy = priv->markers_copy;
XCORR_SETTINGS(transform)->markers_copy = &priv->markers_copy;
XCORR_SETTINGS(transform)->marker_type = &priv->marker_type;
XCORR_SETTINGS(transform)->marker_lock = &priv->g_marker_copy_lock;
}
Expand Down

0 comments on commit 9e38de5

Please sign in to comment.