-- Copyright (c) 2010 Philipp Balzarek (p.balzarek@googlemail.com)---- License: MIT; See LICENSE file{-# LANGUAGE ForeignFunctionInterface #-}-- | Low level bindings to the JACK \<jack.h\> functionality---- This is a faithfull representation of the C api. -- For now please refer to the JACK api documentation for a complete -- description of the functionality ---- <http://jackaudio.org/files/docs/html/jack_8h.html>---- A somewhat safer interface can be found at "Sound.Jack.JackMonad" moduleSound.Jack.Bindings(withOpenClient,withOpenClientDefaultServer,Raw.clientOpenWithDefaultServer,Raw.clientOpenWithServerName,Raw.clientClose,Raw.clientNameSize,Raw.getClientName,Raw.internalClientNew,Raw.internalClientClose,Raw.activate,Raw.deactivate,Raw.clientThreadId,Raw.isRealtime,Raw.cycleWait,Raw.cycleSignal,setProcessThread,setThreadInitCallback,setProcessCallback,setFreewheelCallback,setBufferSizeCallback,setSampleRateCallback,setClientRegistrationCallback,setPortRegistrationCallback,setPortConnectCallback,setGraphOrderCallback,setXrunCallback,Raw.setFreewheel,Raw.setBufferSize,Raw.getSampleRate,Raw.getBufferSize,Raw.engineTakeoverTimebase,Raw.cpuLoad,Raw.portRegister,Raw.portUnregister,Raw.portGetBuffer,Raw.portName,Raw.portShortName,Raw.portFlags,Raw.portType,Raw.portIsMine,Raw.portConnected,Raw.portGetConnections,Raw.portGetAllConnections,Raw.jackPortGetLatency,Raw.jackPortGetTotalLatency,Raw.portSetLatency,Raw.recomputeTotalLatencies,Raw.portSetName,Raw.portSetAlias,Raw.portUnsetAlias,Raw.portRequestMonitor,Raw.portRequestMonitorByName,Raw.portEnsureMonitor,Raw.portMonitoringInput,Raw.connect,Raw.disconnect,Raw.portDisconnect,Raw.portNameSize,Raw.portTypeSize,Raw.getPorts,Raw.portByName,Raw.portById,Raw.framesSinceCycleStart,Raw.frameTime,Raw.framesToTime,Raw.timeToFrames,Raw.getTime,Raw.Port,Raw.PortFlags(..),Raw.AudioSample,BufferSizeCallback,ClientRegistrationCallback,FreewheelCallback,GraphOrderCallback,PortConnectCallback,PortRegistrationCallback,ProcessCallback,SampleRateCallback,ThreadCallback,ThreadInitCallback,XRunCallback,Raw.Options(..),Raw.Client-- opaque,Raw.Status(..),Raw.PortID-- opaque,Raw.defaultAudioType,Raw.defaultMidiType,Raw.fromPThread,Raw.NFrames,Raw.PThread,Raw.Time)whereimportqualifiedSound.Jack.RawBindingsasRawimportControl.MonadimportControl.ExceptionimportForeignimportForeign.Cignore=(>>return())-- | Open a Jack client and run the supplied action, handling errors and closing the clientwithOpenClient::String-- ^ server name ->[Raw.Options]-- ^ client options->String-- ^ client name->(Raw.Client->[Raw.Status]->IOa)-- ^ action to be run with the open client->([Raw.Status]->IOa)-- ^ action to be run on error->IOa-- ^withOpenClientserverNameoptionsclientNameactionerrorHandler=bracket(Raw.clientOpenWithServerNameclientNameoptionsserverName)(\(client,flags)->unless(Raw.Failure`elem`flags)(ignore$Raw.clientCloseclient))(\(client,flags)->if(Raw.Failure`elem`flags)thenerrorHandlerflagselseactionclientflags)-- | Open a Jack client on the default server and run the supplied action, -- handling errors and closing the clientwithOpenClientDefaultServer::[Raw.Options]-- ^ client options->String-- ^ The client name ->(Raw.Client->[Raw.Status]->IOa)-- ^ action to be run with the open client->([Raw.Status]->IOa)-- ^ action to be run at error->IOa-- ^withOpenClientDefaultServeroptionsclientNameactionerrorHandler=bracket(Raw.clientOpenWithDefaultServerclientNameoptions)(\(client,flags)->unless(Raw.Failure`elem`flags)(ignore$Raw.clientCloseclient))(\(client,flags)->ifRaw.Failure`elem`flagsthenerrorHandlerflagselseactionclientflags)typeThreadCallback=Ptr()->IO(Ptr())typeBufferSizeCallback=CUInt->Ptr()->IOCInttypeClientRegistrationCallback=PtrCChar->CInt->Ptr()->IO()typeFreewheelCallback=CInt->Ptr()->IO()typeGraphOrderCallback=Ptr()->IOCInttypePortConnectCallback=CUInt->CUInt->CInt->Ptr()->IO()typePortRegistrationCallback=CUInt->CInt->Ptr()->IO()typeProcessCallback=CUInt-- ^ Number of Frames to Process->Ptr()-- ^ User Data->IOCInttypeSampleRateCallback=CUInt->Ptr()->IOCInttypeThreadInitCallback=Ptr()->IO()typeXRunCallback=Ptr()->IOCIntforeignimportccallsafe"wrapper"mkThreadCallback::ThreadCallback->IORaw.ThreadCallbackPtrforeignimportccallsafe"wrapper"mkBufferSizeCallback::BufferSizeCallback->IORaw.BufferSizeCallbackPtrforeignimportccallsafe"wrapper"mkClientRegistrationCallback::ClientRegistrationCallback->IORaw.ClientRegistrationCallbackPtrforeignimportccallsafe"wrapper"mkFreewheelCallback::FreewheelCallback->IORaw.FreewheelCallbackPtrforeignimportccallsafe"wrapper"mkGraphOrderCallback::GraphOrderCallback->IORaw.GraphOrderCallbackPtrforeignimportccallsafe"wrapper"mkPortConnectCallback::PortConnectCallback->IORaw.PortConnectCallbackPtrforeignimportccallsafe"wrapper"mkPortRegistrationCallback::PortRegistrationCallback->IORaw.PortRegistrationCallbackPtrforeignimportccallsafe"wrapper"mkProcessCallback::ProcessCallback->IORaw.ProcessCallbackPtrforeignimportccallsafe"wrapper"mkSampleRateCallback::SampleRateCallback->IORaw.SampleRateCallbackPtrforeignimportccallsafe"wrapper"mkThreadInitCallback::ThreadInitCallback->IORaw.ThreadInitCallbackPtrforeignimportccallsafe"wrapper"mkXRunCallback::XRunCallback->IORaw.XRunCallbackPtrwithFunPtr::(Monadm)=>(t1->ma)->(t->a->t2->mb)->t->t1->t2->mbwithFunPtrmkPtrsetCallbackclientcallbackFunuserData=mkPtrcallbackFun>>=\fPtr->setCallbackclientfPtruserDatasetProcessThread::Raw.Client->ThreadCallback->Ptr()->IOIntsetProcessThread=withFunPtrmkThreadCallbackRaw.setProcessThreadsetThreadInitCallback::Raw.Client->ThreadInitCallback->Ptr()->IOIntsetThreadInitCallback=withFunPtrmkThreadInitCallbackRaw.setThreadInitCallbacksetProcessCallback::Raw.Client->ProcessCallback->Ptr()->IOIntsetProcessCallback=withFunPtrmkProcessCallbackRaw.setProcessCallbacksetFreewheelCallback::Raw.Client->FreewheelCallback->Ptr()->IOIntsetFreewheelCallback=withFunPtrmkFreewheelCallbackRaw.setFreewheelCallbacksetBufferSizeCallback::Raw.Client->BufferSizeCallback->Ptr()->IOIntsetBufferSizeCallback=withFunPtrmkBufferSizeCallbackRaw.setBufferSizeCallbacksetSampleRateCallback::Raw.Client->SampleRateCallback->Ptr()->IOIntsetSampleRateCallback=withFunPtrmkSampleRateCallbackRaw.setSampleRateCallbacksetClientRegistrationCallback::Raw.Client->ClientRegistrationCallback->Ptr()->IOIntsetClientRegistrationCallback=withFunPtrmkClientRegistrationCallbackRaw.setClientRegistrationCallbacksetPortRegistrationCallback::Raw.Client->PortRegistrationCallback->Ptr()->IOIntsetPortRegistrationCallback=withFunPtrmkPortRegistrationCallbackRaw.setPortRegistrationCallbacksetPortConnectCallback::Raw.Client->PortConnectCallback->Ptr()->IOIntsetPortConnectCallback=withFunPtrmkPortConnectCallbackRaw.setPortConnectCallbacksetGraphOrderCallback::Raw.Client->GraphOrderCallback->Ptr()->IOIntsetGraphOrderCallback=withFunPtrmkGraphOrderCallbackRaw.setGraphOrderCallbacksetXrunCallback::Raw.Client->XRunCallback->Ptr()->IOIntsetXrunCallback=withFunPtrmkXRunCallbackRaw.setXrunCallback