Use new Jack Metadata API to mark CV ports.

By adding metadata key "http://jackaudio.org/metadata/signal-type" value "CV" pair to CV ports, patch bays can discriminate between audio and CV ports (SVN patchage e.g. can already do so).

Metadata API is only implemented in Jack1 for now, this patch will thus have no effect when linked to Jack1/2 without support for metadata.
This commit is contained in:
Hanspeter Portner 2014-05-17 12:11:40 +02:00
parent 467e369cd1
commit 2d43a8abe7
8 changed files with 44 additions and 9 deletions

View File

@ -221,7 +221,7 @@ Controller_Module::mode ( Mode m )
char prefix[512];
snprintf( prefix, sizeof(prefix), "CV-%s", p->name() );
add_aux_audio_input( prefix, 0 );
add_aux_cv_input( prefix, 0 );
chain()->client()->unlock();
}

View File

@ -1270,7 +1270,7 @@ Module::set_latency ( JACK::Port::direction_e dir, nframes_t min, nframes_t max
bool
Module::add_aux_port ( bool input, const char *prefix, int i )
Module::add_aux_port ( bool input, const char *prefix, int i, JACK::Port::type_e type )
{
const char *trackname = chain()->strip()->group()->single() ? NULL : chain()->name();
@ -1278,7 +1278,7 @@ Module::add_aux_port ( bool input, const char *prefix, int i )
char *portname = generate_port_name( prefix, direction, i );
JACK::Port *po = new JACK::Port( chain()->client(), trackname, portname, direction, JACK::Port::Audio );
JACK::Port *po = new JACK::Port( chain()->client(), trackname, portname, direction, type );
free(portname);
@ -1319,7 +1319,7 @@ Module::add_aux_port ( bool input, const char *prefix, int i )
bool
Module::add_aux_audio_output( const char *prefix, int i )
{
bool r = add_aux_port ( false, prefix, i );
bool r = add_aux_port ( false, prefix, i , JACK::Port::Audio);
if ( r )
mixer->maybe_auto_connect_output( &aux_audio_output.back() );
@ -1330,7 +1330,13 @@ Module::add_aux_audio_output( const char *prefix, int i )
bool
Module::add_aux_audio_input( const char *prefix, int i )
{
return add_aux_port ( true, prefix, i );
return add_aux_port ( true, prefix, i , JACK::Port::Audio);
}
bool
Module::add_aux_cv_input( const char *prefix, int i )
{
return add_aux_port ( true, prefix, i , JACK::Port::CV);
}

View File

@ -499,7 +499,7 @@ protected:
virtual void get ( Log_Entry &e ) const;
virtual void set ( Log_Entry &e );
bool add_aux_port ( bool input, const char *prefix, int n );
bool add_aux_port ( bool input, const char *prefix, int n , JACK::Port::type_e type );
public:
nframes_t sample_rate ( void ) const { return Module::_sample_rate; }
@ -513,6 +513,7 @@ public:
bool add_aux_audio_output ( const char *prefix, int n );
bool add_aux_audio_input ( const char *prefix, int n );
bool add_aux_cv_input ( const char *prefix, int n );
static void set_sample_rate ( nframes_t srate ) { _sample_rate = srate; }

View File

@ -21,6 +21,9 @@
#include <jack/jack.h>
#include <jack/midiport.h>
#ifdef HAVE_JACK_METADATA
# include <jack/metadata.h>
#endif
#include <Mutex.H>
typedef jack_nframes_t nframes_t;

View File

@ -71,6 +71,8 @@ namespace JACK
_type = Audio;
if ( strstr( type, "MIDI") )
_type = MIDI;
else if ( strstr( type, "CV)") )
_type = CV;
_client->port_added( this );
@ -190,10 +192,18 @@ namespace JACK
DMESSAGE( "Activating port name %s", jackname );
_port = jack_port_register( _client->jack_client(), jackname,
_type == Audio ? JACK_DEFAULT_AUDIO_TYPE : JACK_DEFAULT_MIDI_TYPE,
( _type == Audio ) || ( _type == CV ) ? JACK_DEFAULT_AUDIO_TYPE : JACK_DEFAULT_MIDI_TYPE,
flags,
0 );
#ifdef HAVE_JACK_METADATA
if ( _type == CV )
{
jack_uuid_t uuid = jack_port_uuid( _port );
jack_set_property( _client->jack_client(), uuid, "http://jackaudio.org/metadata/signal-type", "CV", "text/plain" );
}
#endif
DMESSAGE( "Port = %p", _port );
if ( ! _port )
@ -266,7 +276,16 @@ namespace JACK
Port::deactivate ( void )
{
if ( _port )
{
#ifdef HAVE_JACK_METADATA
if ( _type == CV )
{
jack_uuid_t uuid = jack_port_uuid(_port);
jack_remove_property(_client->jack_client(), uuid, "http://jackaudio.org/metadata/signal-type");
}
#endif
jack_port_unregister( _client->jack_client(), _port );
}
_port = 0;
}

View File

@ -44,7 +44,7 @@ namespace JACK
bool operator < ( const Port & rhs ) const;
enum direction_e { Output, Input };
enum type_e { Audio, MIDI };
enum type_e { Audio, MIDI, CV };
static int max_name ( void );

View File

@ -175,7 +175,7 @@ Control_Sequence::update_port_name ( void )
if ( ! _output )
{
_output = new JACK::Port( engine, track()->name(), s, JACK::Port::Output, JACK::Port::Audio );
_output = new JACK::Port( engine, track()->name(), s, JACK::Port::Output, JACK::Port::CV );
_output->terminal( true );
needs_activation = true;
}

View File

@ -61,6 +61,12 @@ def configure(conf):
define_name='HAVE_JACK_PORT_GET_LATENCY_RANGE',
fragment='#include <jack/jack.h>\nint main (int argc, char**argv) { jack_port_get_latency_range( (jack_port_t*)0, JackCaptureLatency, (jack_latency_range_t *)0 ); }',
mandatory=False);
conf.check(function_name='jack_get_property',
header_name='jack/metadata.h',
define_name='HAVE_JACK_METADATA',
uselib='JACK',
mandatory=False)
conf.check_cfg(package='x11', uselib_store='XLIB',args="--cflags --libs",
mandatory=True)