jack: update to new latency range API as the old one has been deprecated.

Message ID 1339449311-31170-2-git-send-email-gseanmcg@gmail.com
State Superseded, archived
Headers show

Commit Message

Sean McGovern June 11, 2012, 9:15 p.m.
Fixes Bugzilla #279
---
 configure                |    3 ++-
 libavdevice/jack_audio.c |    6 ++++++
 2 files changed, 8 insertions(+), 1 deletions(-)

Comments

Mans Rullgard June 11, 2012, 9:43 p.m. | #1
Sean McGovern <gseanmcg@gmail.com> writes:

> Fixes Bugzilla #279
> ---
>  configure                |    3 ++-
>  libavdevice/jack_audio.c |    6 ++++++
>  2 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index fbb71b6..20643e0 100755
> --- a/configure
> +++ b/configure
> @@ -1087,6 +1087,7 @@ HAVE_LIST="
>      inet_aton
>      inline_asm
>      isatty
> +    jack_new_latency_api
>      ldbrx
>      libdc1394_1
>      libdc1394_2
> @@ -2982,7 +2983,7 @@ check_header soundcard.h
>
>  enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
>
> -enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
> +enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_func jack_port_get_latency_range && enable jack_new_latency_api

Why the extra config symbol?  You can use HAVE_JACK_PORT_GET_LATENCY_RANGE
directly like we do for a bunch of other functions.
Sean McGovern June 11, 2012, 9:47 p.m. | #2
On Mon, Jun 11, 2012 at 5:43 PM, Måns Rullgård <mans@mansr.com> wrote:
> Sean McGovern <gseanmcg@gmail.com> writes:
>
>> Fixes Bugzilla #279
>> ---
>>  configure                |    3 ++-
>>  libavdevice/jack_audio.c |    6 ++++++
>>  2 files changed, 8 insertions(+), 1 deletions(-)
>>
>> diff --git a/configure b/configure
>> index fbb71b6..20643e0 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1087,6 +1087,7 @@ HAVE_LIST="
>>      inet_aton
>>      inline_asm
>>      isatty
>> +    jack_new_latency_api
>>      ldbrx
>>      libdc1394_1
>>      libdc1394_2
>> @@ -2982,7 +2983,7 @@ check_header soundcard.h
>>
>>  enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
>>
>> -enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
>> +enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_func jack_port_get_latency_range && enable jack_new_latency_api
>
> Why the extra config symbol?  You can use HAVE_JACK_PORT_GET_LATENCY_RANGE
> directly like we do for a bunch of other functions.
>

I guess I didn't read configure properly -- OK I will do that and re-submit.

-- Sean McG.
Sean McGovern June 11, 2012, 10:20 p.m. | #3
On Mon, Jun 11, 2012 at 5:43 PM, Måns Rullgård <mans@mansr.com> wrote:
> Sean McGovern <gseanmcg@gmail.com> writes:
>
>> Fixes Bugzilla #279
>> ---
>>  configure                |    3 ++-
>>  libavdevice/jack_audio.c |    6 ++++++
>>  2 files changed, 8 insertions(+), 1 deletions(-)
>>
>> diff --git a/configure b/configure
>> index fbb71b6..20643e0 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1087,6 +1087,7 @@ HAVE_LIST="
>>      inet_aton
>>      inline_asm
>>      isatty
>> +    jack_new_latency_api
>>      ldbrx
>>      libdc1394_1
>>      libdc1394_2
>> @@ -2982,7 +2983,7 @@ check_header soundcard.h
>>
>>  enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
>>
>> -enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
>> +enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_func jack_port_get_latency_range && enable jack_new_latency_api
>
> Why the extra config symbol?  You can use HAVE_JACK_PORT_GET_LATENCY_RANGE
> directly like we do for a bunch of other functions.
>

The define never makes it in to config.h unless it's in HAVE_LIST.

-- Sean McG.

Patch

diff --git a/configure b/configure
index fbb71b6..20643e0 100755
--- a/configure
+++ b/configure
@@ -1087,6 +1087,7 @@  HAVE_LIST="
     inet_aton
     inline_asm
     isatty
+    jack_new_latency_api
     ldbrx
     libdc1394_1
     libdc1394_2
@@ -2982,7 +2983,7 @@  check_header soundcard.h
 
 enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
 
-enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
+enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_func jack_port_get_latency_range && enable jack_new_latency_api
 
 enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
 
diff --git a/libavdevice/jack_audio.c b/libavdevice/jack_audio.c
index 9f1bb23..2800d8b 100644
--- a/libavdevice/jack_audio.c
+++ b/libavdevice/jack_audio.c
@@ -91,7 +91,13 @@  static int process_callback(jack_nframes_t nframes, void *arg)
 
     /* Copy and interleave audio data from the JACK buffer into the packet */
     for (i = 0; i < self->nports; i++) {
+    #if HAVE_JACK_NEW_LATENCY_API
+        jack_latency_range_t range;
+        jack_port_get_latency_range(self->ports[i], JackCaptureLatency, &range);
+        latency += range.max;
+    #else
         latency += jack_port_get_total_latency(self->client, self->ports[i]);
+    #endif
         buffer = jack_port_get_buffer(self->ports[i], self->buffer_size);
         for (j = 0; j < self->buffer_size; j++)
             pkt_data[j * self->nports + i] = buffer[j];