diff options
author | Adrian Knoth <adi@drcomp.erfurt.thur.de> | 2017-03-12 20:56:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-12 20:56:08 +0100 |
commit | d1df7524a29d7db3c2c6660c72327f157cb590e6 (patch) | |
tree | f384d2e3659fd86686eb83027900ffb00374fe51 | |
parent | 701f74fa2059621effd6a1a904198fca28f8aabe (diff) | |
parent | 2ea3a56d77e0697d832eb0a7f6075bdb8189985c (diff) | |
download | jack2-d1df7524a29d7db3c2c6660c72327f157cb590e6.tar.gz |
Merge pull request #215 from jmendeth/alsa-correction
alsa_in/out: Convert between sample rates when necessary
alsa_in and alsa_out set the playback latency of their ports to the target delay. The problem is the target delay is in terms of the ALSA sample rate, so it should be converted to JACK's sample rate.
Example: Imagine JACK is running at 48 kHz, and alsa_out is invoked like:
alsa_out -r 96000 -t 512
Currently, alsa_out will report 512 frames of playback latency. After the fix, it converts to 48kHz and correctly reports 256.
Also converts the result of jack_frames_since_cycle_start to ALSA sample rate.
-rw-r--r-- | example-clients/alsa_in.c | 4 | ||||
-rw-r--r-- | example-clients/alsa_out.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/example-clients/alsa_in.c b/example-clients/alsa_in.c index 1a8c0332..29e9bf3b 100644 --- a/example-clients/alsa_in.c +++ b/example-clients/alsa_in.c @@ -353,7 +353,7 @@ int process (jack_nframes_t nframes, void *arg) { delay = snd_pcm_avail( alsa_handle ); - delay -= jack_frames_since_cycle_start( client ); + delay -= round( jack_frames_since_cycle_start( client ) / static_resample_factor ); // Do it the hard way. // this is for compensating xruns etc... @@ -510,7 +510,7 @@ latency_cb (jack_latency_callback_mode_t mode, void *arg) jack_latency_range_t range; JSList *node; - range.min = range.max = target_delay; + range.min = range.max = round(target_delay * static_resample_factor); if (mode == JackCaptureLatency) { for (node = capture_ports; node; node = jack_slist_next (node)) { diff --git a/example-clients/alsa_out.c b/example-clients/alsa_out.c index d5fd2680..fbfc3dd0 100644 --- a/example-clients/alsa_out.c +++ b/example-clients/alsa_out.c @@ -357,7 +357,7 @@ int process (jack_nframes_t nframes, void *arg) { delay = (num_periods*period_size)-snd_pcm_avail( alsa_handle ) ; - delay -= jack_frames_since_cycle_start( client ); + delay -= round( jack_frames_since_cycle_start( client ) * static_resample_factor ); // Do it the hard way. // this is for compensating xruns etc... @@ -513,7 +513,7 @@ latency_cb (jack_latency_callback_mode_t mode, void *arg) jack_latency_range_t range; JSList *node; - range.min = range.max = target_delay; + range.min = range.max = round(target_delay / static_resample_factor); if (mode == JackCaptureLatency) { for (node = capture_ports; node; node = jack_slist_next (node)) { |