Compare commits
	
		
			3 Commits
		
	
	
		
			e0fa019d20
			...
			4ccfad3911
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 4ccfad3911 | |||
| b28d4fbfa6 | |||
| b8d5119d03 | 
@ -1,32 +1,30 @@
 | 
			
		||||
import std/strformat
 | 
			
		||||
 | 
			
		||||
import jacket
 | 
			
		||||
 | 
			
		||||
var client: ClientTPtr
 | 
			
		||||
var jclient: ClientTPtr
 | 
			
		||||
var time: TimeT
 | 
			
		||||
var status: cint
 | 
			
		||||
 | 
			
		||||
client = clientOpen("test_jacket", ord(NullOption), addr status)
 | 
			
		||||
jclient = clientOpen("test_jacket", NullOption.ord, addr status)
 | 
			
		||||
 | 
			
		||||
echo fmt"Server status: {status}"
 | 
			
		||||
echo "Server status: " & $status
 | 
			
		||||
 | 
			
		||||
if client == nil:
 | 
			
		||||
if jclient == nil:
 | 
			
		||||
    echo getJackStatusErrorString(status)
 | 
			
		||||
    quit 1
 | 
			
		||||
 | 
			
		||||
time = getTime()
 | 
			
		||||
var ver = getVersionString()
 | 
			
		||||
echo fmt"JACK version: {ver}"
 | 
			
		||||
var rate = getSampleRate(client)
 | 
			
		||||
echo fmt"Sample rate: {rate}"
 | 
			
		||||
var bufsize = getBufferSize(client)
 | 
			
		||||
echo fmt"Buffer size: {bufsize}"
 | 
			
		||||
var load = cpuLoad(client)
 | 
			
		||||
echo fmt"DSP load: {load}%"
 | 
			
		||||
echo fmt"Server time: {time}"
 | 
			
		||||
var name = getClientName(client)
 | 
			
		||||
echo fmt"Client name: {name}"
 | 
			
		||||
var rt = if isRealtime(client) > 0: "yes" else: "no"
 | 
			
		||||
echo fmt"RT enabled: {rt}"
 | 
			
		||||
let ver = getVersionString()
 | 
			
		||||
echo "JACK version: " & $ver
 | 
			
		||||
let rate = getSampleRate(jclient)
 | 
			
		||||
echo "Sample rate: " & $rate
 | 
			
		||||
let bufsize = getBufferSize(jclient)
 | 
			
		||||
echo "Buffer size: " & $bufsize
 | 
			
		||||
let load = cpuLoad(jclient)
 | 
			
		||||
echo "DSP load: " & $load & "%"
 | 
			
		||||
echo "Server time: " & $time
 | 
			
		||||
let name = getClientName(jclient)
 | 
			
		||||
echo "Client name: " & $name
 | 
			
		||||
let rt = if isRealtime(jclient) > 0: "yes" else: "no"
 | 
			
		||||
echo "RT enabled: " & rt
 | 
			
		||||
 | 
			
		||||
discard clientClose(client)
 | 
			
		||||
discard clientClose(jclient)
 | 
			
		||||
 | 
			
		||||
@ -1,55 +1,53 @@
 | 
			
		||||
import std/[strformat, os]
 | 
			
		||||
 | 
			
		||||
import std/os
 | 
			
		||||
import jacket
 | 
			
		||||
 | 
			
		||||
var client: ClientTPtr
 | 
			
		||||
var jclient: ClientTPtr
 | 
			
		||||
var status: cint
 | 
			
		||||
 | 
			
		||||
proc cleanup() {.noconv.} =
 | 
			
		||||
    echo "Cleaning up..."
 | 
			
		||||
 | 
			
		||||
    if client != nil:
 | 
			
		||||
        discard deactivate(client)
 | 
			
		||||
        discard clientClose(client)
 | 
			
		||||
        client = nil
 | 
			
		||||
    if jclient != nil:
 | 
			
		||||
        discard deactivate(jclient)
 | 
			
		||||
        discard clientClose(jclient)
 | 
			
		||||
        jclient = nil
 | 
			
		||||
 | 
			
		||||
    quit 0
 | 
			
		||||
 | 
			
		||||
proc portConnected(portA: PortIdT; portB: PortIdT; connect: cint; arg: pointer) {.cdecl.} =
 | 
			
		||||
    let portAPtr = portById(client, portA)
 | 
			
		||||
    let portBPtr = portById(client, portB)
 | 
			
		||||
    let portAPtr = portById(jclient, portA)
 | 
			
		||||
    let portBPtr = portById(jclient, portB)
 | 
			
		||||
    
 | 
			
		||||
    if portAPtr != nil:
 | 
			
		||||
        let portAName = portName(portAPtr)
 | 
			
		||||
        echo fmt"Port A: {portAName}"
 | 
			
		||||
        echo "Port A: " & $portName(portAPtr)
 | 
			
		||||
    else:
 | 
			
		||||
        echo "Port A: <unknown>"
 | 
			
		||||
 | 
			
		||||
    if portAPtr != nil:
 | 
			
		||||
        let portBName = portName(portBPtr)
 | 
			
		||||
        echo fmt"Port B: {portBName}"
 | 
			
		||||
        echo "Port B: " & $portName(portBPtr)
 | 
			
		||||
    else:
 | 
			
		||||
        echo "Port B: <unknown>"
 | 
			
		||||
        
 | 
			
		||||
    let action = if connect > 0: "connect" else: "disconnect"
 | 
			
		||||
    echo fmt"Action: {action}"
 | 
			
		||||
    echo "Action: " & (if connect > 0: "connect" else: "disconnect")
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
client = clientOpen("jacket_port_register", ord(NoStartServer) or ord(UseExactName), addr status)
 | 
			
		||||
jclient = clientOpen("jacket_port_register", NoStartServer.ord, addr status)
 | 
			
		||||
 | 
			
		||||
echo fmt"Server status: {status}"
 | 
			
		||||
echo "Server status: " & $status
 | 
			
		||||
 | 
			
		||||
if client == nil:
 | 
			
		||||
if jclient == nil:
 | 
			
		||||
    echo getJackStatusErrorString(status)
 | 
			
		||||
    quit 1
 | 
			
		||||
 | 
			
		||||
discard portRegister(client, "in_1", JACK_DEFAULT_AUDIO_TYPE, ord(PortIsInput), 0)
 | 
			
		||||
discard portRegister(client, "out_1", JACK_DEFAULT_AUDIO_TYPE, ord(PortIsOutput), 0)
 | 
			
		||||
setControlCHook(cleanup)
 | 
			
		||||
 | 
			
		||||
if setPortConnectCallback(client, portConnected, nil) != 0:
 | 
			
		||||
discard portRegister(jclient, "in_1", JACK_DEFAULT_AUDIO_TYPE, PortIsInput.ord, 0)
 | 
			
		||||
discard portRegister(jclient, "out_1", JACK_DEFAULT_AUDIO_TYPE, PortIsOutput.ord, 0)
 | 
			
		||||
 | 
			
		||||
if setPortConnectCallback(jclient, portConnected, nil) != 0:
 | 
			
		||||
    echo "Error: could not set port connection callback."
 | 
			
		||||
 | 
			
		||||
discard activate(client)
 | 
			
		||||
discard activate(jclient)
 | 
			
		||||
 | 
			
		||||
while true:
 | 
			
		||||
    sleep(50)
 | 
			
		||||
 | 
			
		||||
@ -1,30 +1,31 @@
 | 
			
		||||
import std/[strformat, os]
 | 
			
		||||
 | 
			
		||||
import std/os
 | 
			
		||||
import jacket
 | 
			
		||||
 | 
			
		||||
var client: ClientTPtr
 | 
			
		||||
var jclient: ClientTPtr
 | 
			
		||||
var status: cint
 | 
			
		||||
 | 
			
		||||
proc cleanup() {.noconv.} =
 | 
			
		||||
    echo "Cleaning up..."
 | 
			
		||||
    if client != nil:
 | 
			
		||||
        discard clientClose(client)
 | 
			
		||||
        client = nil
 | 
			
		||||
    
 | 
			
		||||
    if jclient != nil:
 | 
			
		||||
        discard clientClose(jclient)
 | 
			
		||||
        jclient = nil
 | 
			
		||||
    
 | 
			
		||||
    quit 0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
client = clientOpen("jacket_port_register", ord(NoStartServer) or ord(UseExactName), addr status)
 | 
			
		||||
jclient = clientOpen("jacket_port_register", NoStartServer.ord or UseExactName.ord, addr status)
 | 
			
		||||
 | 
			
		||||
echo fmt"Server status: {status}"
 | 
			
		||||
echo "Server status: " & $status
 | 
			
		||||
 | 
			
		||||
if client == nil:
 | 
			
		||||
if jclient == nil:
 | 
			
		||||
    echo getJackStatusErrorString(status)
 | 
			
		||||
    quit 1
 | 
			
		||||
 | 
			
		||||
setControlCHook(cleanup)
 | 
			
		||||
 | 
			
		||||
discard portRegister(client, "in_1", JACK_DEFAULT_AUDIO_TYPE, ord(PortIsInput), 0)
 | 
			
		||||
discard portRegister(client, "out_1", JACK_DEFAULT_AUDIO_TYPE, ord(PortIsOutput), 0)
 | 
			
		||||
discard portRegister(jclient, "in_1", JACK_DEFAULT_AUDIO_TYPE, PortIsInput.ord, 0)
 | 
			
		||||
discard portRegister(jclient, "out_1", JACK_DEFAULT_AUDIO_TYPE, PortIsOutput.ord, 0)
 | 
			
		||||
 | 
			
		||||
while true:
 | 
			
		||||
    sleep(50)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										58
									
								
								jacket.nim
									
									
									
									
									
								
							
							
						
						
									
										58
									
								
								jacket.nim
									
									
									
									
									
								
							@ -457,37 +457,33 @@ proc setInfoFunction*(infoCallback: JackInfoCallback) {.importc: "jack_set_info_
 | 
			
		||||
 | 
			
		||||
proc getJackStatusErrorString*(status: cint): string =
 | 
			
		||||
    # Get JACK error status as string.
 | 
			
		||||
    if status == ord(Success):
 | 
			
		||||
    if status == Success.ord:
 | 
			
		||||
        return ""
 | 
			
		||||
 | 
			
		||||
    var errorString = ""
 | 
			
		||||
 | 
			
		||||
    if status == ord(Failure):
 | 
			
		||||
    if status == Failure.ord:
 | 
			
		||||
        # Only include this generic message if no other error status is set
 | 
			
		||||
        errorString = "Overall operation failed"
 | 
			
		||||
    if (status and ord(InvalidOption)) > 0:
 | 
			
		||||
        errorString &= "\nThe operation contained an invalid and unsupported option"
 | 
			
		||||
    if (status and ord(NameNotUnique)) > 0:
 | 
			
		||||
        errorString &= "\nThe desired client name was not unique"
 | 
			
		||||
    if (status and ord(ServerStarted)) > 0:
 | 
			
		||||
        errorString &= "\nThe JACK server was started as a result of this operation"
 | 
			
		||||
    if (status and ord(ServerFailed)) > 0:
 | 
			
		||||
        errorString &= "\nUnable to connect to the JACK server"
 | 
			
		||||
    if (status and ord(ServerError)) > 0:
 | 
			
		||||
        errorString &= "\nCommunication error with the JACK server"
 | 
			
		||||
    if (status and ord(NoSuchClient)) > 0:
 | 
			
		||||
        errorString &= "\nRequested client does not exist"
 | 
			
		||||
    if (status and ord(LoadFailure)) > 0:
 | 
			
		||||
        errorString &= "\nUnable to load internal client"
 | 
			
		||||
    if (status and ord(InitFailure)) > 0:
 | 
			
		||||
        errorString &= "\nUnable to initialize client"
 | 
			
		||||
    if (status and ord(ShmFailure)) > 0:
 | 
			
		||||
        errorString &= "\nUnable to access shared memory"
 | 
			
		||||
    if (status and ord(VersionError)) > 0:
 | 
			
		||||
        errorString &= "\nClient's protocol version does not match"
 | 
			
		||||
    if (status and ord(BackendError)) > 0:
 | 
			
		||||
        errorString &= "\nBackend Error"
 | 
			
		||||
    if (status and ord(ClientZombie)) > 0:
 | 
			
		||||
        errorString &= "\nClient is being shutdown against its will"
 | 
			
		||||
 | 
			
		||||
    return errorString
 | 
			
		||||
        result = "Overall operation failed"
 | 
			
		||||
    if (status and InvalidOption.ord) > 0:
 | 
			
		||||
        result.add("\nThe operation contained an invalid and unsupported option")
 | 
			
		||||
    if (status and NameNotUnique.ord) > 0:
 | 
			
		||||
        result.add("\nThe desired client name was not unique")
 | 
			
		||||
    if (status and ServerStarted.ord) > 0:
 | 
			
		||||
        result.add("\nThe JACK server was started as a result of this operation")
 | 
			
		||||
    if (status and ServerFailed.ord) > 0:
 | 
			
		||||
        result.add("\nUnable to connect to the JACK server")
 | 
			
		||||
    if (status and ServerError.ord) > 0:
 | 
			
		||||
        result.add("\nCommunication error with the JACK server")
 | 
			
		||||
    if (status and NoSuchClient.ord) > 0:
 | 
			
		||||
        result.add("\nRequested client does not exist")
 | 
			
		||||
    if (status and LoadFailure.ord) > 0:
 | 
			
		||||
        result.add("\nUnable to load internal client")
 | 
			
		||||
    if (status and InitFailure.ord) > 0:
 | 
			
		||||
        result.add("\nUnable to initialize client")
 | 
			
		||||
    if (status and ShmFailure.ord) > 0:
 | 
			
		||||
        result.add("\nUnable to access shared memory")
 | 
			
		||||
    if (status and VersionError.ord) > 0:
 | 
			
		||||
        result.add("\nClient's protocol version does not match")
 | 
			
		||||
    if (status and BackendError.ord) > 0:
 | 
			
		||||
        result.add("\nBackend Error")
 | 
			
		||||
    if (status and ClientZombie.ord) > 0:
 | 
			
		||||
        result.add("\nClient is being shutdown against its will")
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user