Skip to content

Commit

Permalink
Fix initialization in test/iodelay.cpp
Browse files Browse the repository at this point in the history
jack_latency_range_t is

struct _jack_latency_range {
    jack_nframes_t min;
    jack_nframes_t max;
};

and jack_nframes_t is

typedef uint32_t        jack_nframes_t;

so it's unsigned. Initialising it with -1 is invalid (at least in C++14). We cannot use {0, 0}, because latency_cb has

   jack_latency_range_t range;
   range.min = range.max = 0;
   if ((range.min != capture_latency.min) || (range.max !=
       capture_latency.max)) {
       capture_latency = range;
   }

so we must not have {0, 0}, otherwise the condition would never be true.

Using UINT32_MAX should be equivalent to the previous -1.
  • Loading branch information
adiknoth committed Jun 11, 2016
1 parent 43efc94 commit ff1ed2c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/iodelay.cpp
Expand Up @@ -20,6 +20,7 @@

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <unistd.h>
#include <jack/jack.h>
Expand Down Expand Up @@ -167,8 +168,8 @@ static jack_client_t *jack_handle;
static jack_port_t *jack_capt;
static jack_port_t *jack_play;

jack_latency_range_t capture_latency = {-1, -1};
jack_latency_range_t playback_latency = {-1, -1};
jack_latency_range_t capture_latency = {UINT32_MAX, UINT32_MAX};
jack_latency_range_t playback_latency = {UINT32_MAX, UINT32_MAX};

void
latency_cb (jack_latency_callback_mode_t mode, void *arg)
Expand Down Expand Up @@ -266,4 +267,4 @@ int main (int ac, char *av [])
return 0;
}

// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------

0 comments on commit ff1ed2c

Please sign in to comment.