API version check?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

API version check?

Jonatan Liljedahl
I use some of the new stuff in the API (midi for example), but I would
like to support older versions of JACK by disabling compilation of parts
of my code.. What is the best way to do this? I'm using autotools but I
don't have much knowledge about it. I would like something like

#ifdef JACK_0_109
...new_midi_stuff
#endif

--
/Jonatan         [ http://kymatica.com ]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: API version check?

juuso.alasuutari (Bugzilla)
Jonatan Liljedahl wrote:
> I use some of the new stuff in the API (midi for example), but I would
> like to support older versions of JACK by disabling compilation of parts
> of my code.. What is the best way to do this? I'm using autotools but I
> don't have much knowledge about it. I would like something like
>
> #ifdef JACK_0_109
> ...new_midi_stuff
> #endif

Here's what I use in Snarl. First, this goes into your configure.in (or
configure.ac):


PKG_CHECK_MODULES(JACK, jack >= 0.99.0, HAVE_JACK="yes", \
  config_error="yes")
if test "x$HAVE_JACK" = xyes
then
   PKG_CHECK_MODULES(STABLE_JACK_MIDI, jack >= 0.105.0,
    HAVE_STABLE_JACK_MIDI="yes", config_error="no")
   if test "x$HAVE_STABLE_JACK_MIDI" = xyes
   then
     AC_DEFINE([HAVE_STABLE_JACK_MIDI], [], \
      [Use the stable MIDI API (0.105.0 and later).])
   else
     PKG_CHECK_MODULES(OLD_JACK_MIDI, jack >= 0.102.27, \
      HAVE_OLD_JACK_MIDI="yes", config_error="no")
     if test "x$HAVE_OLD_JACK_MIDI" = xyes
     then
       AC_DEFINE([HAVE_OLD_JACK_MIDI], [], \
        [Use the old MIDI API (0.102.27 to 0.104.0).])
     else
       PKG_CHECK_MODULES(ANCIENT_JACK_MIDI, jack >= 0.102.0, \
        HAVE_ANCIENT_JACK_MIDI="yes", config_error="yes")
       if test "x$HAVE_ANCIENT_JACK_MIDI" = xyes
       then
         AC_DEFINE([HAVE_ANCIENT_JACK_MIDI], [], \
          [Use the ancient MIDI API (0.102.0 to 0.102.26).])
       fi
     fi
   fi
fi
AC_SUBST(JACK_CFLAGS)
AC_SUBST(JACK_LIBS)


And here are the in-code ifdefs I use:


#ifdef HAVE_STABLE_JACK_MIDI
                jack_midi_event_get (&event, midi_in_buf, i);
#else
                jack_midi_event_get (&event, midi_in_buf, i, nframes);
#endif

...

#ifdef HAVE_STABLE_JACK_MIDI
        event_count = jack_midi_get_event_count (midi_in_buf);
#elif defined HAVE_OLD_JACK_MIDI
        event_count = jack_midi_get_event_count (midi_in_buf, nframes);
#else
        event_count = jack_midi_port_get_info (midi_in_buf,
                                               nframes)->event_count;
#endif


Hope this helps!

Juuso

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: API version check?

Jonatan Liljedahl
Juuso Alasuutari wrote:

> Jonatan Liljedahl wrote:
>> I use some of the new stuff in the API (midi for example), but I would
>> like to support older versions of JACK by disabling compilation of parts
>> of my code.. What is the best way to do this? I'm using autotools but I
>> don't have much knowledge about it. I would like something like
>>
>> #ifdef JACK_0_109
>> ...new_midi_stuff
>> #endif
>
> Here's what I use in Snarl. First, this goes into your configure.in (or
> configure.ac):
...snip...

Thanks, I will try it out!

Btw, in what version was jack_port_set_name() added and actually
working? I have a vague memory of crashes when using it before an
update, but perhaps it was only qjackctl that crashed.

--
/Jonatan         [ http://kymatica.com ]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: API version check?

juuso.alasuutari (Bugzilla)
Jonatan Liljedahl wrote:
> Btw, in what version was jack_port_set_name() added and actually
> working? I have a vague memory of crashes when using it before an
> update, but perhaps it was only qjackctl that crashed.

I don't know about the port name stuff, haven't used it myself.

Juuso

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: API version check?

Jonatan Liljedahl
Juuso Alasuutari wrote:
> Jonatan Liljedahl wrote:
>> Btw, in what version was jack_port_set_name() added and actually
>> working? I have a vague memory of crashes when using it before an
>> update, but perhaps it was only qjackctl that crashed.
>
> I don't know about the port name stuff, haven't used it myself.

I had an old 0.103.0 that I tested against, and with your version tests
it compiled fine! So I guess it was only qjackctl that didn't handle
changing port names.

Thanks.
--
/Jonatan         [ http://kymatica.com ]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: API version check?

Jonatan Liljedahl
In reply to this post by juuso.alasuutari (Bugzilla)
Juuso Alasuutari wrote:

> Jonatan Liljedahl wrote:
>> I use some of the new stuff in the API (midi for example), but I would
>> like to support older versions of JACK by disabling compilation of parts
>> of my code.. What is the best way to do this? I'm using autotools but I
>> don't have much knowledge about it. I would like something like
>>
>> #ifdef JACK_0_109
>> ...new_midi_stuff
>> #endif
>
> Here's what I use in Snarl. First, this goes into your configure.in (or
> configure.ac):
>
> PKG_CHECK_MODULES(JACK, jack >= 0.99.0, HAVE_JACK="yes", \
>   config_error="yes")
> if test "x$HAVE_JACK" = xyes
> then
>    PKG_CHECK_MODULES(STABLE_JACK_MIDI, jack >= 0.105.0,
>     HAVE_STABLE_JACK_MIDI="yes", config_error="no")
>    if test "x$HAVE_STABLE_JACK_MIDI" = xyes
>    then
>      AC_DEFINE([HAVE_STABLE_JACK_MIDI], [], \
>       [Use the stable MIDI API (0.105.0 and later).])
>    else
>      PKG_CHECK_MODULES(OLD_JACK_MIDI, jack >= 0.102.27, \
>       HAVE_OLD_JACK_MIDI="yes", config_error="no")
>      if test "x$HAVE_OLD_JACK_MIDI" = xyes
>      then
>        AC_DEFINE([HAVE_OLD_JACK_MIDI], [], \
>         [Use the old MIDI API (0.102.27 to 0.104.0).])
>      else
>        PKG_CHECK_MODULES(ANCIENT_JACK_MIDI, jack >= 0.102.0, \
>         HAVE_ANCIENT_JACK_MIDI="yes", config_error="yes")
>        if test "x$HAVE_ANCIENT_JACK_MIDI" = xyes
>        then
>          AC_DEFINE([HAVE_ANCIENT_JACK_MIDI], [], \
>           [Use the ancient MIDI API (0.102.0 to 0.102.26).])
>        fi
>      fi
>    fi
> fi
> AC_SUBST(JACK_CFLAGS)
> AC_SUBST(JACK_LIBS)

Any idea how this could be done on Mac OS X (with MacPorts) if Jack is a
Framework?

Maybe it would be possible to skip pkg-config and instead check for
certain functions/headers to determine the version? But how would one
check the function signature (nframes or not to the midi stuff)??

--
/Jonatan         [ http://kymatica.com ]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: API version check?

juuso.alasuutari (Bugzilla)
Jonatan Liljedahl wrote:

> Juuso Alasuutari wrote:
>> PKG_CHECK_MODULES(JACK, jack >= 0.99.0, HAVE_JACK="yes", \
>>   config_error="yes")
>> if test "x$HAVE_JACK" = xyes
>> then
>>    PKG_CHECK_MODULES(STABLE_JACK_MIDI, jack >= 0.105.0,
>>     HAVE_STABLE_JACK_MIDI="yes", config_error="no")
>>    if test "x$HAVE_STABLE_JACK_MIDI" = xyes
>>    then
>>      AC_DEFINE([HAVE_STABLE_JACK_MIDI], [], \
>>       [Use the stable MIDI API (0.105.0 and later).])
>>    else
>>      PKG_CHECK_MODULES(OLD_JACK_MIDI, jack >= 0.102.27, \
>>       HAVE_OLD_JACK_MIDI="yes", config_error="no")
>>      if test "x$HAVE_OLD_JACK_MIDI" = xyes
>>      then
>>        AC_DEFINE([HAVE_OLD_JACK_MIDI], [], \
>>         [Use the old MIDI API (0.102.27 to 0.104.0).])
>>      else
>>        PKG_CHECK_MODULES(ANCIENT_JACK_MIDI, jack >= 0.102.0, \
>>         HAVE_ANCIENT_JACK_MIDI="yes", config_error="yes")
>>        if test "x$HAVE_ANCIENT_JACK_MIDI" = xyes
>>        then
>>          AC_DEFINE([HAVE_ANCIENT_JACK_MIDI], [], \
>>           [Use the ancient MIDI API (0.102.0 to 0.102.26).])
>>        fi
>>      fi
>>    fi
>> fi
>> AC_SUBST(JACK_CFLAGS)
>> AC_SUBST(JACK_LIBS)
>
> Any idea how this could be done on Mac OS X (with MacPorts) if Jack is a
> Framework?
>
> Maybe it would be possible to skip pkg-config and instead check for
> certain functions/headers to determine the version? But how would one
> check the function signature (nframes or not to the midi stuff)??

I don't use OS X myself so I don't know how this is done there. Maybe
St├ęphane does?

Juuso


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel