Skip to content

Commit

Permalink
feat: always decode returned c_char_p to str using default encoding
Browse files Browse the repository at this point in the history
Used encoding can be set with encoding keyword param, when `None`, un-decoded `bytes` is returened

Signed-off-by: Christopher Arndt <[email protected]>
  • Loading branch information
SpotlightKid committed Mar 27, 2022
1 parent 70c2f7d commit 7c4cc4b
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions jacklib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ class jack_description_t(Structure):


# JACK2 only:
def get_version_string():
def get_version_string(encoding=ENCODING):
if jlib.jack_get_version_string:
return jlib.jack_get_version_string()
return _d(jlib.jack_get_version_string(), encoding)

return None

Expand All @@ -416,9 +416,10 @@ def client_open(client_name, options, status, uuid=""):
return None


def client_rename(client, new_name):
# JACK1 < 0.126:
def client_rename(client, new_name, encoding=ENCODING):
if jlib.jack_client_rename:
return jlib.jack_client_rename(client, _e(new_name))
return _d(jlib.jack_client_rename(client, _e(new_name)), encoding)

return None

Expand All @@ -437,9 +438,9 @@ def client_name_size():
return 0


def get_client_name(client):
def get_client_name(client, encoding=ENCODING):
if jlib.jack_get_client_name:
return jlib.jack_get_client_name(client)
return _d(jlib.jack_get_client_name(client), encoding)

return None

Expand Down Expand Up @@ -965,12 +966,12 @@ def port_get_buffer(port, nframes):
return jlib.jack_port_get_buffer(port, nframes)


def port_name(port):
return _d(jlib.jack_port_name(port))
def port_name(port, encoding=ENCODING):
return _d(jlib.jack_port_name(port), encoding)


def port_short_name(port):
return _d(jlib.jack_port_short_name(port))
def port_short_name(port, encoding=ENCODING):
return _d(jlib.jack_port_short_name(port), encoding)


def port_flags(port):
Expand Down Expand Up @@ -1544,9 +1545,9 @@ def session_event_free(event):
jlib.jack_session_event_free(event)


def client_get_uuid(client):
def client_get_uuid(client, encoding=ENCODING):
if jlib.jack_client_get_uuid:
return _d(jlib.jack_client_get_uuid(client))
return _d(jlib.jack_client_get_uuid(client), encoding)

return None

Expand All @@ -1563,16 +1564,16 @@ def session_commands_free(cmds):
jlib.jack_session_commands_free(cmds)


def get_uuid_for_client_name(client, client_name):
def get_uuid_for_client_name(client, client_name, encoding=ENCODING):
if jlib.jack_get_uuid_for_client_name:
return jlib.jack_get_uuid_for_client_name(client, _e(client_name))
return _d(jlib.jack_get_uuid_for_client_name(client, _e(client_name)), encoding)

return None


def get_client_name_by_uuid(client, client_uuid):
def get_client_name_by_uuid(client, client_uuid, encoding=ENCODING):
if jlib.jack_get_client_name_by_uuid:
return jlib.jack_get_client_name_by_uuid(client, _e(client_uuid))
return _d(jlib.jack_get_client_name_by_uuid(client, _e(client_uuid)), encoding)

return None

Expand Down

0 comments on commit 7c4cc4b

Please sign in to comment.