Remove python jacksesison stuff
This commit is contained in:
parent
e318abc1a9
commit
4f8708f321
|
@ -13,8 +13,8 @@ dist-check-doxygen:
|
|||
@false
|
||||
endif
|
||||
|
||||
SUBDIRS = jack libjack jackd drivers example-clients tools config $(DOC_DIR) man python
|
||||
DIST_SUBDIRS = config jack libjack jackd drivers example-clients tools doc man python
|
||||
SUBDIRS = jack libjack jackd drivers example-clients tools config $(DOC_DIR) man
|
||||
DIST_SUBDIRS = config jack libjack jackd drivers example-clients tools doc man
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = jack.pc
|
||||
|
|
|
@ -1042,7 +1042,6 @@ jack/version.h
|
|||
jackd/Makefile
|
||||
jackd/jackd.1
|
||||
libjack/Makefile
|
||||
python/Makefile
|
||||
)
|
||||
|
||||
dnl
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
noinst_SCRIPTS = jackd.py
|
||||
EXTRA_DIST = jackd.py jackctl.py mygetopt.py reserve_audio.py
|
||||
|
|
@ -1,242 +0,0 @@
|
|||
|
||||
from ctypes import *
|
||||
|
||||
libj = cdll.LoadLibrary( "libjack.so" )
|
||||
libjs = cdll.LoadLibrary( "libjackserver.so" )
|
||||
|
||||
|
||||
class jackctl_parameter_value( Union ):
|
||||
_fields_ = [ ( "ui", c_uint ),
|
||||
( "i", c_int ),
|
||||
( "c", c_char ),
|
||||
( "ss", c_char * 128 ),
|
||||
( "b", c_bool ) ]
|
||||
|
||||
def get_str( self ):
|
||||
return buffer(self.ss)
|
||||
|
||||
def set_str( self, sss ):
|
||||
self.ss = sss
|
||||
|
||||
str = property( get_str, set_str )
|
||||
|
||||
class jackctl_server_t( Structure ):
|
||||
pass
|
||||
|
||||
class jackctl_driver_t( Structure ):
|
||||
pass
|
||||
|
||||
class jackctl_internal_t( Structure ):
|
||||
pass
|
||||
|
||||
class jackctl_parameter_t( Structure ):
|
||||
pass
|
||||
|
||||
class JSList( Structure ):
|
||||
pass
|
||||
|
||||
JSList._fields_ = [ ("data", c_void_p), ("next", POINTER(JSList)) ]
|
||||
|
||||
class JSIter:
|
||||
def __init__(self, ptr, typ=c_void_p):
|
||||
self.ptr = ptr
|
||||
self.typ = typ
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def next( self ):
|
||||
if not self.ptr:
|
||||
raise StopIteration
|
||||
|
||||
retval = self.ptr.contents.data
|
||||
self.ptr = self.ptr.contents.next
|
||||
|
||||
return cast( retval, self.typ )
|
||||
|
||||
DeviceAcquireFunc = CFUNCTYPE( c_int, c_char_p )
|
||||
DeviceReleaseFunc = CFUNCTYPE( None, c_char_p )
|
||||
|
||||
jackctl_server_start = libjs.jackctl_server_start
|
||||
jackctl_server_start.argtypes = [ POINTER(jackctl_server_t), POINTER(jackctl_driver_t) ]
|
||||
jackctl_server_start.restype = c_bool
|
||||
|
||||
jackctl_server_stop = libjs.jackctl_server_stop
|
||||
jackctl_server_stop.argtypes = [ POINTER(jackctl_server_t) ]
|
||||
jackctl_server_stop.restype = c_bool
|
||||
|
||||
jackctl_server_create = libjs.jackctl_server_create
|
||||
jackctl_server_create.argtypes = [ DeviceAcquireFunc, DeviceReleaseFunc ]
|
||||
jackctl_server_create.restype = POINTER(jackctl_server_t)
|
||||
|
||||
jackctl_server_get_drivers_list = libjs.jackctl_server_get_drivers_list
|
||||
jackctl_server_get_drivers_list.argtypes = [ POINTER(jackctl_server_t) ]
|
||||
jackctl_server_get_drivers_list.restype = POINTER(JSList)
|
||||
|
||||
jackctl_server_get_parameters = libjs.jackctl_server_get_parameters
|
||||
jackctl_server_get_parameters.argtypes = [ POINTER(jackctl_server_t) ]
|
||||
jackctl_server_get_parameters.restype = POINTER(JSList)
|
||||
|
||||
jackctl_driver_get_parameters = libjs.jackctl_driver_get_parameters
|
||||
jackctl_driver_get_parameters.argtypes = [ POINTER(jackctl_driver_t) ]
|
||||
jackctl_driver_get_parameters.restype = POINTER(JSList)
|
||||
|
||||
jackctl_driver_get_name = libjs.jackctl_driver_get_name
|
||||
jackctl_driver_get_name.argtypes = [ POINTER(jackctl_driver_t) ]
|
||||
jackctl_driver_get_name.restype = c_char_p
|
||||
|
||||
jackctl_parameter_get_name = libjs.jackctl_parameter_get_name
|
||||
jackctl_parameter_get_name.argtypes = [ POINTER(jackctl_parameter_t) ]
|
||||
jackctl_parameter_get_name.restype = c_char_p
|
||||
|
||||
jackctl_parameter_get_short_description = libjs.jackctl_parameter_get_short_description
|
||||
jackctl_parameter_get_short_description.argtypes = [ POINTER(jackctl_parameter_t) ]
|
||||
jackctl_parameter_get_short_description.restype = c_char_p
|
||||
|
||||
jackctl_parameter_get_type = libjs.jackctl_parameter_get_type
|
||||
jackctl_parameter_get_type.argtypes = [ POINTER(jackctl_parameter_t) ]
|
||||
jackctl_parameter_get_type.restype = c_uint
|
||||
|
||||
jackctl_parameter_set_value = libjs.jackctl_parameter_set_value
|
||||
jackctl_parameter_set_value.argtypes = [ POINTER(jackctl_parameter_t), POINTER(jackctl_parameter_value) ]
|
||||
jackctl_parameter_set_value.restype = c_bool
|
||||
|
||||
jackctl_parameter_get_value = libjs.jackctl_parameter_get_value
|
||||
jackctl_parameter_get_value.argtypes = [ POINTER(jackctl_parameter_t) ]
|
||||
jackctl_parameter_get_value.restype = jackctl_parameter_value
|
||||
|
||||
jackctl_parameter_get_id = libjs.jackctl_parameter_get_id
|
||||
jackctl_parameter_get_id.argtypes = [ POINTER(jackctl_parameter_t) ]
|
||||
jackctl_parameter_get_id.restype = c_char
|
||||
|
||||
jackctl_server_switch_master = libjs.jackctl_server_switch_master
|
||||
jackctl_server_switch_master.argtypes = [ POINTER(jackctl_server_t), POINTER(jackctl_driver_t) ]
|
||||
jackctl_server_switch_master.restype = c_bool
|
||||
|
||||
|
||||
class Parameter(object):
|
||||
def __init__( self, param_ptr ):
|
||||
self.param_ptr = param_ptr
|
||||
self.param_type = jackctl_parameter_get_type( self.param_ptr )
|
||||
|
||||
def get_short_desc( self ):
|
||||
return jackctl_parameter_get_short_description( self.param_ptr )
|
||||
|
||||
short_desc = property( get_short_desc )
|
||||
|
||||
def get_name( self ):
|
||||
return jackctl_parameter_get_name( self.param_ptr )
|
||||
|
||||
name = property( get_name )
|
||||
|
||||
def get_id( self ):
|
||||
return jackctl_parameter_get_id( self.param_ptr )
|
||||
|
||||
id = property( get_id )
|
||||
|
||||
def set_value( self, val ):
|
||||
param_v = jackctl_parameter_value()
|
||||
if self.param_type == 1:
|
||||
# int
|
||||
param_v.i = int(val)
|
||||
elif self.param_type == 2:
|
||||
# uint
|
||||
param_v.ui = int(val)
|
||||
elif self.param_type == 3:
|
||||
# char
|
||||
assert( (type(val) == str) and len(val)==1 )
|
||||
param_v.c = val
|
||||
elif self.param_type == 4:
|
||||
# string
|
||||
assert( type(val) == str )
|
||||
param_v.ss = val
|
||||
elif self.param_type == 5:
|
||||
# bool
|
||||
assert( type(val) == bool )
|
||||
param_v.b = val
|
||||
|
||||
jackctl_parameter_set_value( self.param_ptr, pointer(param_v) )
|
||||
|
||||
def get_value( self ):
|
||||
param_v = jackctl_parameter_get_value( self.param_ptr )
|
||||
|
||||
if self.param_type == 1:
|
||||
# int
|
||||
return param_v.i
|
||||
elif self.param_type == 2:
|
||||
# uint
|
||||
return param_v.ui
|
||||
elif self.param_type == 3:
|
||||
# char
|
||||
return param_v.c
|
||||
elif self.param_type == 4:
|
||||
# string
|
||||
return param_v.ss
|
||||
elif self.param_type == 5:
|
||||
# bool
|
||||
return param_v.b
|
||||
|
||||
value = property( get_value, set_value )
|
||||
|
||||
class Driver(object):
|
||||
def __init__( self, drv_ptr ):
|
||||
self.drv_ptr = drv_ptr
|
||||
|
||||
params_jslist = jackctl_driver_get_parameters( self.drv_ptr )
|
||||
|
||||
self.params = {}
|
||||
for i in JSIter( params_jslist, POINTER(jackctl_parameter_t) ):
|
||||
self.params[ jackctl_parameter_get_name( i ) ] = Parameter(i)
|
||||
|
||||
def get_name( self ):
|
||||
return jackctl_driver_get_name( self.drv_ptr )
|
||||
|
||||
name = property( get_name )
|
||||
|
||||
|
||||
class Server(object):
|
||||
def __init__( self ):
|
||||
self.dacqd = DeviceAcquireFunc(self.acquire_card)
|
||||
self.reled = DeviceReleaseFunc(self.release_card)
|
||||
self.srv_ptr = jackctl_server_create( self.dacqd, self.reled )
|
||||
|
||||
self.acquire_card_cb = None
|
||||
self.release_card_cb = None
|
||||
|
||||
driver_jslist = jackctl_server_get_drivers_list( self.srv_ptr )
|
||||
|
||||
self.drivers = {}
|
||||
for i in JSIter( driver_jslist, POINTER(jackctl_driver_t) ):
|
||||
self.drivers[ jackctl_driver_get_name( i ) ] = Driver(i)
|
||||
|
||||
params_jslist = jackctl_server_get_parameters( self.srv_ptr )
|
||||
|
||||
self.params = {}
|
||||
for i in JSIter( params_jslist, POINTER(jackctl_parameter_t) ):
|
||||
self.params[ jackctl_parameter_get_name( i ) ] = Parameter(i)
|
||||
|
||||
def __del__( self ):
|
||||
pass
|
||||
|
||||
def start( self, driver ):
|
||||
return jackctl_server_start( self.srv_ptr, driver.drv_ptr )
|
||||
|
||||
def switch_master( self, driver ):
|
||||
return jackctl_server_switch_master( self.srv_ptr, driver.drv_ptr )
|
||||
|
||||
def stop( self ):
|
||||
return jackctl_server_stop( self.srv_ptr )
|
||||
|
||||
|
||||
def acquire_card( self, cardname ):
|
||||
if self.acquire_card_cb:
|
||||
return self.acquire_card_cb(cardname)
|
||||
else:
|
||||
return True
|
||||
|
||||
def release_card( self, cardname ):
|
||||
if self.release_card_cb:
|
||||
self.release_card_cb(cardname)
|
||||
|
||||
|
||||
|
137
python/jackd.py
137
python/jackd.py
|
@ -1,137 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
from pyjackd.mygetopt import my_getopt
|
||||
from pyjackd import jackctl
|
||||
import readline
|
||||
import time
|
||||
|
||||
import reserve_audio
|
||||
|
||||
argv = sys.argv[1:]
|
||||
|
||||
|
||||
|
||||
def server_parse_ags( srv, argv ):
|
||||
shortopts = ""
|
||||
longopts = []
|
||||
shortmap = {}
|
||||
driver = None
|
||||
|
||||
for param in srv.params:
|
||||
p = srv.params[param]
|
||||
shortopts += p.id
|
||||
if p.param_type != 5:
|
||||
shortopts += ":"
|
||||
longopts.append (p.name + "=")
|
||||
else:
|
||||
longopts.append (p.name)
|
||||
|
||||
shortmap[p.id] = p
|
||||
|
||||
while not driver:
|
||||
opts, argv = my_getopt( argv, shortopts+"d:" )
|
||||
if not opts:
|
||||
break
|
||||
for opt,optarg in opts:
|
||||
if opt == "-d":
|
||||
driver = srv.drivers[optarg]
|
||||
elif opt.startswith("--"):
|
||||
pass
|
||||
elif opt.startswith("-"):
|
||||
p = shortmap[opt[1]]
|
||||
if p.param_type == 5:
|
||||
p.value = True
|
||||
else:
|
||||
p.value = optarg
|
||||
|
||||
return driver, argv
|
||||
|
||||
def driver_parse_args( drv, argv ):
|
||||
shortopts = ""
|
||||
longopts = []
|
||||
shortmap = {}
|
||||
|
||||
for param in drv.params:
|
||||
p = drv.params[param]
|
||||
shortopts += p.id
|
||||
if p.param_type != 5:
|
||||
shortopts += ":"
|
||||
longopts.append (p.name + "=")
|
||||
else:
|
||||
longopts.append (p.name)
|
||||
|
||||
shortmap[p.id] = p
|
||||
|
||||
while True:
|
||||
opts, argv = my_getopt( argv, shortopts+"d:" )
|
||||
if not opts:
|
||||
break
|
||||
for opt,optarg in opts:
|
||||
if opt.startswith("--"):
|
||||
pass
|
||||
elif opt.startswith("-"):
|
||||
p = shortmap[opt[1]]
|
||||
if p.param_type == 5:
|
||||
p.value = True
|
||||
else:
|
||||
p.value = optarg
|
||||
|
||||
def acquire_dev(cardname):
|
||||
reserve_audio.reserve_dev(cardname,20,None)
|
||||
time.sleep(0.1)
|
||||
return True
|
||||
|
||||
def release_dev(cardname):
|
||||
reserve_audio.rr.unreserve()
|
||||
reserve_audio.rr = None
|
||||
|
||||
srv = jackctl.Server()
|
||||
srv.acquire_card_cb = acquire_dev
|
||||
srv.release_card_cb = release_dev
|
||||
|
||||
drv, argv = server_parse_ags( srv, argv )
|
||||
driver_parse_args( drv, argv )
|
||||
|
||||
#for p in srv.params.values():
|
||||
# print p.name, "-> ", p.value
|
||||
#
|
||||
#print "----------------"
|
||||
#print "driver ", drv.name
|
||||
#
|
||||
#for p in drv.params.values():
|
||||
# print p.name, "-> ", p.value
|
||||
|
||||
started = srv.start( drv )
|
||||
|
||||
if not started:
|
||||
print "failed to start with driver " + drv.name
|
||||
print "trying to start with dummy driver, switch to the right master yourself"
|
||||
|
||||
started = srv.start( srv.drivers["dummy"] )
|
||||
|
||||
if not started:
|
||||
sys.exit(20)
|
||||
|
||||
quit = False
|
||||
while not quit:
|
||||
try:
|
||||
cmd = raw_input("jack> ")
|
||||
except EOFError:
|
||||
break
|
||||
|
||||
cmdv = cmd.split()
|
||||
|
||||
if len(cmdv) == 0:
|
||||
continue
|
||||
|
||||
if cmdv[0] == "quit":
|
||||
quit = True
|
||||
elif cmdv[0] == "switch":
|
||||
if len(cmdv) > 1:
|
||||
drv = srv.drivers[cmdv[1]]
|
||||
driver_parse_args( drv, cmdv[2:] )
|
||||
srv.switch_master( drv )
|
||||
|
||||
print "\nshutting down"
|
||||
srv.stop()
|
|
@ -1,48 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import getopt
|
||||
|
||||
def my_getopt(args, shortopts, longopts = []):
|
||||
"""getopt(args, options[, long_options]) -> opts, args
|
||||
|
||||
Parses command line options and parameter list. args is the
|
||||
argument list to be parsed, without the leading reference to the
|
||||
running program. Typically, this means "sys.argv[1:]". shortopts
|
||||
is the string of option letters that the script wants to
|
||||
recognize, with options that require an argument followed by a
|
||||
colon (i.e., the same format that Unix getopt() uses). If
|
||||
specified, longopts is a list of strings with the names of the
|
||||
long options which should be supported. The leading '--'
|
||||
characters should not be included in the option name. Options
|
||||
which require an argument should be followed by an equal sign
|
||||
('=').
|
||||
|
||||
The return value consists of two elements: the first is a list of
|
||||
(option, value) pairs; the second is the list of program arguments
|
||||
left after the option list was stripped (this is a trailing slice
|
||||
of the first argument). Each option-and-value pair returned has
|
||||
the option as its first element, prefixed with a hyphen (e.g.,
|
||||
'-x'), and the option argument as its second element, or an empty
|
||||
string if the option has no argument. The options occur in the
|
||||
list in the same order in which they were found, thus allowing
|
||||
multiple occurrences. Long and short options may be mixed.
|
||||
|
||||
"""
|
||||
|
||||
opts = []
|
||||
if type(longopts) == type(""):
|
||||
longopts = [longopts]
|
||||
else:
|
||||
longopts = list(longopts)
|
||||
if args and args[0].startswith('-') and args[0] != '-':
|
||||
if args[0] == '--':
|
||||
args = args[1:]
|
||||
if args[0].startswith('--'):
|
||||
opts, args = getopt.do_longs(opts, args[0][2:], longopts, args[1:])
|
||||
else:
|
||||
opts, args = getopt.do_shorts(opts, args[0][1:], shortopts, args[1:])
|
||||
|
||||
return opts, args
|
||||
else:
|
||||
return None, args
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
|
||||
import dbus.service
|
||||
import gobject
|
||||
import dbus.mainloop.glib
|
||||
|
||||
rr = None
|
||||
|
||||
class reservation_t( dbus.service.Object ):
|
||||
def __init__( self, device_name, prio, override_cb=None ):
|
||||
|
||||
self.dev_name = device_name
|
||||
self.prio = prio
|
||||
self.override_cb = override_cb
|
||||
|
||||
self.bus = dbus.SessionBus()
|
||||
|
||||
dbus.service.Object.__init__( self, None,
|
||||
"/org/freedesktop/ReserveDevice1/" + self.dev_name,
|
||||
dbus.service.BusName( "org.freedesktop.ReserveDevice1." + self.dev_name, bus=self.bus, allow_replacement=True, replace_existing=True, do_not_queue=True ) )
|
||||
|
||||
@dbus.service.method( dbus_interface="org.freedesktop.ReserveDevice1", in_signature="i", out_signature="b" )
|
||||
def RequestRelease( self, prio ):
|
||||
if prio < self.prio:
|
||||
return False
|
||||
|
||||
if self.override_cb:
|
||||
if self.override_cb( self.device_name ):
|
||||
self.connection.release_name( 'org.freedesktop.ReserveDevice1.' + self.dev_name )
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def unreserve (self):
|
||||
self.connection.release_name( 'org.freedesktop.ReserveDevice1.' + self.dev_name )
|
||||
rr.remove_from_connection()
|
||||
|
||||
|
||||
def reserve_dev( dev_name, prio, override_cb ):
|
||||
global rr
|
||||
try:
|
||||
session_bus = dbus.SessionBus()
|
||||
except Exception:
|
||||
return
|
||||
|
||||
try:
|
||||
r_proxy = session_bus.get_object( "org.freedesktop.ReserveDevice1." + dev_name, "/org/freedesktop/ReserveDevice1/" + dev_name )
|
||||
r_iface = dbus.Interface( r_proxy, "org.freedesktop.ReserveDevice1" )
|
||||
except Exception:
|
||||
print "no other reservation exists. taking the name"
|
||||
rr = reservation_t( dev_name, prio, override_cb )
|
||||
return
|
||||
|
||||
if not r_iface.RequestRelease( prio ):
|
||||
raise Exception
|
||||
|
||||
rr = reservation_t( dev_name, prio, override_cb )
|
||||
|
||||
|
||||
|
||||
dbus.mainloop.glib.threads_init()
|
||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||
|
||||
def run_main():
|
||||
loop = gobject.MainLoop()
|
||||
loop.run()
|
||||
|
||||
|
Loading…
Reference in New Issue