Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/fake__jack.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class Fake(object):
JackTransportStarting = 3
JackTransportNetStarting = 4

PropertyCreated = 0
PropertyChanged = 1
PropertyDeleted = 2

def dlopen(self, _):
return self

Expand Down
17 changes: 17 additions & 0 deletions examples/chatty_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ def xrun(delay):
print('xrun; delay', delay, 'microseconds')


try:
@client.set_property_change_callback
def property_change(subject, key, changed):
print('subject {}: '.format(subject), end='')
if not key:
assert changed == jack.PROPERTY_DELETED
print('all properties were removed')
return
print('property {!r} was {}'.format(key, {
jack.PROPERTY_CREATED: 'created',
jack.PROPERTY_CHANGED: 'changed',
jack.PROPERTY_DELETED: 'removed',
}[changed]))
except jack.JackError as e:
print(e)


print('activating JACK')
with client:
print('#' * 80)
Expand Down
30 changes: 30 additions & 0 deletions examples/metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3
"""Set/get/remove client/port metadata."""
from pprint import pprint

import jack

client = jack.Client('Metadata-Client')
port = client.inports.register('input')

client.set_property(client, jack.METADATA_PRETTY_NAME, 'Best Client Ever')
print('Client "pretty" name:',
jack.get_property(client, jack.METADATA_PRETTY_NAME))

client.set_property(
port, jack.METADATA_PRETTY_NAME, b'a good port', 'text/plain')
print('Port "pretty" name:',
jack.get_property(port, jack.METADATA_PRETTY_NAME))

print('All client properties:')
pprint(jack.get_properties(client))

print('All port properties:')
pprint(jack.get_properties(port))

print('All properties:')
pprint(jack.get_all_properties())

client.remove_property(port, jack.METADATA_PRETTY_NAME)
client.remove_properties(client)
client.remove_all_properties()
47 changes: 47 additions & 0 deletions jack_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,53 @@
jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size);
int jack_midi_event_write(void* port_buffer, jack_nframes_t time, const jack_midi_data_t* data, size_t data_size);
uint32_t jack_midi_get_lost_event_count(void* port_buffer);

/* session.h */

char* jack_client_get_uuid(jack_client_t* client);

/* uuid.h */

extern int jack_uuid_parse(const char* buf, jack_uuid_t*);

/* metadata.h */

typedef struct {
const char* key;
const char* data;
const char* type;
} jack_property_t;
int jack_set_property(jack_client_t*, jack_uuid_t subject, const char* key, const char* value, const char* type);
int jack_get_property(jack_uuid_t subject, const char* key, char** value, char** type);
typedef struct {
jack_uuid_t subject;
uint32_t property_cnt;
jack_property_t* properties;
uint32_t property_size;
} jack_description_t;
void jack_free_description(jack_description_t* desc, int free_description_itself);
int jack_get_properties(jack_uuid_t subject, jack_description_t* desc);
int jack_get_all_properties(jack_description_t** descs);
int jack_remove_property(jack_client_t* client, jack_uuid_t subject, const char* key);
int jack_remove_properties(jack_client_t* client, jack_uuid_t subject);
int jack_remove_all_properties(jack_client_t* client);
typedef enum {
PropertyCreated,
PropertyChanged,
PropertyDeleted,
} jack_property_change_t;
typedef void (*JackPropertyChangeCallback)(jack_uuid_t subject, const char* key, jack_property_change_t change, void* arg);
int jack_set_property_change_callback(jack_client_t* client, JackPropertyChangeCallback callback, void* arg);
extern const char* JACK_METADATA_CONNECTED;
extern const char* JACK_METADATA_EVENT_TYPES;
extern const char* JACK_METADATA_HARDWARE;
extern const char* JACK_METADATA_ICON_LARGE;
extern const char* JACK_METADATA_ICON_NAME;
extern const char* JACK_METADATA_ICON_SMALL;
extern const char* JACK_METADATA_ORDER;
extern const char* JACK_METADATA_PORT_GROUP;
extern const char* JACK_METADATA_PRETTY_NAME;
extern const char* JACK_METADATA_SIGNAL_TYPE;
""")

# Packed structure
Expand Down
Loading