Expand Up
@@ -16,15 +16,15 @@
#
# For a full copy of the GNU General Public License see the COPYING file
# ------------------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# Try Import jacklib
try :
import jacklib
except ImportError :
jacklib = None
from __future__ import absolute_import , print_function , unicode_literals
# ------------------------------------------------------------------------------------------------------------
from . import jacklib
# -------------------------------------------------------------------------------------------------
# Get JACK error status as string
def get_jack_status_error_string (cStatus ):
Expand All
@@ -33,41 +33,43 @@ def get_jack_status_error_string(cStatus):
if status == 0x0 :
return ""
errorString = ""
errorString = []
if status & jacklib .JackFailure :
errorString += "Overall operation failed;\n "
if status == jacklib .JackFailure :
# Only include this generic message if no other error status is set
errorString .append ("Overall operation failed" )
if status & jacklib .JackInvalidOption :
errorString += "The operation contained an invalid or unsupported option; \n "
errorString . append ( "The operation contained an invalid or unsupported option" )
if status & jacklib .JackNameNotUnique :
errorString += "The desired client name was not unique; \n "
errorString . append ( "The desired client name was not unique" )
if status & jacklib .JackServerStarted :
errorString += "The JACK server was started as a result of this operation; \n "
errorString . append ( "The JACK server was started as a result of this operation" )
if status & jacklib .JackServerFailed :
errorString += "Unable to connect to the JACK server; \n "
errorString . append ( "Unable to connect to the JACK server" )
if status & jacklib .JackServerError :
errorString += "Communication error with the JACK server; \n "
errorString . append ( "Communication error with the JACK server" )
if status & jacklib .JackNoSuchClient :
errorString += "Requested client does not exist; \n "
errorString . append ( "Requested client does not exist" )
if status & jacklib .JackLoadFailure :
errorString += "Unable to load internal client; \n "
errorString . append ( "Unable to load internal client" )
if status & jacklib .JackInitFailure :
errorString += "Unable to initialize client; \n "
errorString . append ( "Unable to initialize client" )
if status & jacklib .JackShmFailure :
errorString += "Unable to access shared memory; \n "
errorString . append ( "Unable to access shared memory" )
if status & jacklib .JackVersionError :
errorString += "Client's protocol version does not match; \n "
errorString . append ( "Client's protocol version does not match" )
if status & jacklib .JackBackendError :
errorString += "Backend Error; \n "
errorString . append ( "Backend Error" )
if status & jacklib .JackClientZombie :
errorString += "Client is being shutdown against its will; \n "
errorString . append ( "Client is being shutdown against its will" )
return errorString . strip (). rsplit ( ";" , 1 )[ 0 ] + "."
return "; \n " . join ( errorString ) + "."
# ------------------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# Convert C char** -> Python list
def c_char_p_p_to_list (c_char_p_p ):
def c_char_p_p_to_list (c_char_p_p , encoding = jacklib . ENCODING , errors = 'ignore' ):
i = 0
retList = []
Expand All
@@ -76,30 +78,33 @@ def c_char_p_p_to_list(c_char_p_p):
while True :
new_char_p = c_char_p_p [i ]
if new_char_p :
retList .append (str (new_char_p , encoding = "utf-8" ))
i += 1
else :
if not new_char_p :
break
retList .append (new_char_p .decode (encoding = encoding , errors = errors ))
i += 1
jacklib .free (c_char_p_p )
return retList
# ------------------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# Convert C void* -> string
def voidptr2str (void_p ):
char_p = jacklib .cast (void_p , jacklib .c_char_p )
string = str (char_p .value , encoding = "utf-8" )
return string
# ------------------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# Convert C void* -> jack_default_audio_sample_t*
def translate_audio_port_buffer (void_p ):
return jacklib .cast (void_p , jacklib .POINTER (jacklib .jack_default_audio_sample_t ))
# ------------------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# Convert a JACK midi buffer into a python variable-size list
def translate_midi_event_buffer (void_p , size ):
Expand Down