| 1 | #cxx . . $ `<file>/external/portaudio/pa_jack.c`/if defined (UNIXcxx . . $ `<built-in>:413:9`!) && defined (JACKcxx . . $ `<built-in>:417:9`!) |
| 2 | /* |
| 3 | * $Id$ |
| 4 | * PortAudio Portable Real-Time Audio Library |
| 5 | * Latest Version at: http://www.portaudio.com |
| 6 | * JACK Implementation by Joshua Haberman |
| 7 | * |
| 8 | * Copyright (c) 2004 Stefan Westerfeld <[email protected]> |
| 9 | * Copyright (c) 2004 Arve Knudsen <[email protected]> |
| 10 | * Copyright (c) 2002 Joshua Haberman <[email protected]> |
| 11 | * |
| 12 | * Based on the Open Source API proposed by Ross Bencina |
| 13 | * Copyright (c) 1999-2002 Ross Bencina, Phil Burk |
| 14 | * |
| 15 | * Permission is hereby granted, free of charge, to any person obtaining |
| 16 | * a copy of this software and associated documentation files |
| 17 | * (the "Software"), to deal in the Software without restriction, |
| 18 | * including without limitation the rights to use, copy, modify, merge, |
| 19 | * publish, distribute, sublicense, and/or sell copies of the Software, |
| 20 | * and to permit persons to whom the Software is furnished to do so, |
| 21 | * subject to the following conditions: |
| 22 | * |
| 23 | * The above copyright notice and this permission notice shall be |
| 24 | * included in all copies or substantial portions of the Software. |
| 25 | * |
| 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 27 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 29 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR |
| 30 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 31 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 32 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 33 | */ |
| 34 | |
| 35 | /* |
| 36 | * The text above constitutes the entire PortAudio license; however, |
| 37 | * the PortAudio community also makes the following non-binding requests: |
| 38 | * |
| 39 | * Any person wishing to distribute modifications to the Software is |
| 40 | * requested to send the modifications to the original developer so that |
| 41 | * they can be incorporated into the canonical version. It is also |
| 42 | * requested that these non-binding requests be included along with the |
| 43 | * license above. |
| 44 | */ |
| 45 | |
| 46 | /** |
| 47 | @file |
| 48 | @ingroup hostapi_src |
| 49 | */ |
| 50 | |
| 51 | #include <string.h> |
| 52 | #include <regex.h> |
| 53 | #include <stdlib.h> |
| 54 | #include <stdio.h> |
| 55 | #include <assert.h> |
| 56 | #include <sys/types.h> |
| 57 | #include <unistd.h> |
| 58 | #include <errno.h> /* EBUSY */ |
| 59 | #include <signal.h> /* sig_atomic_t */ |
| 60 | #include <math.h> |
| 61 | #include <semaphore.h> |
| 62 | |
| 63 | #include <jack/types.h> |
| 64 | #include <jack/jack.h> |
| 65 | |
| 66 | #include "pa_util.h"cxx . . $ `<file>/external/portaudio/pa_util.h`/ |
| 67 | #include "pa_hostapi.h"cxx . . $ `<file>/external/portaudio/pa_hostapi.h`/ |
| 68 | #include "pa_stream.h"cxx . . $ `<file>/external/portaudio/pa_stream.h`/ |
| 69 | #include "pa_process.h"cxx . . $ `<file>/external/portaudio/pa_process.h`/ |
| 70 | #include "pa_allocation.h"cxx . . $ `<file>/external/portaudio/pa_allocation.h`/ |
| 71 | #include "pa_cpuload.h"cxx . . $ `<file>/external/portaudio/pa_cpuload.h`/ |
| 72 | #include "pa_ringbuffer.h"cxx . . $ `<file>/external/portaudio/pa_ringbuffer.h`/ |
| 73 | #include "pa_debugprint.h"cxx . . $ `<file>/external/portaudio/pa_debugprint.h`/ |
| 74 | |
| 75 | #include "pa_jack.h"cxx . . $ `<file>/external/portaudio/pa_jack.h`/ |
| 76 | |
| 77 | static pthread_tcxx . . $ pthread_t# mainThread_cxx . . $ mainThread_.; |
| 78 | static char *jackErr_cxx . . $ jackErr_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 79 | static const char* clientName_cxx . . $ clientName_. = "PortAudio"; |
| 80 | static const char* port_regex_suffixcxx . . $ port_regex_suffix. = ":.*"; |
| 81 | |
| 82 | #define STRINGIZE_HELPERcxx . . $ `external/portaudio/pa_jack.c:82:9`!(expr) #expr |
| 83 | #define STRINGIZEcxx . . $ `external/portaudio/pa_jack.c:83:9`!(expr) STRINGIZE_HELPERcxx . . $ `external/portaudio/pa_jack.c:82:9`!(expr) |
| 84 | |
| 85 | /* Check PaError */ |
| 86 | #define ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!(expr) \ |
| 87 | do { \ |
| 88 | PaError paErr; \ |
| 89 | if( (paErr = (expr)) < paNoError ) \ |
| 90 | { \ |
| 91 | if( (paErr) == paUnanticipatedHostError && pthread_self() == mainThread_ ) \ |
| 92 | { \ |
| 93 | const char *err = jackErr_; \ |
| 94 | if (! err ) err = "unknown error"; \ |
| 95 | PaUtil_SetLastHostErrorInfo( paJACK, -1, err ); \ |
| 96 | } \ |
| 97 | PaUtil_DebugPrint(( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZEcxx . . $ `external/portaudio/pa_jack.c:83:9`!( __LINE__ ) "\n" )); \ |
| 98 | result = paErr; \ |
| 99 | goto error; \ |
| 100 | } \ |
| 101 | } while( 0 ) |
| 102 | |
| 103 | #define UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!(expr, code) \ |
| 104 | do { \ |
| 105 | if( (expr) == 0 ) \ |
| 106 | { \ |
| 107 | if( (code) == paUnanticipatedHostError && pthread_self() == mainThread_ ) \ |
| 108 | { \ |
| 109 | const char *err = jackErr_; \ |
| 110 | if (!err) err = "unknown error"; \ |
| 111 | PaUtil_SetLastHostErrorInfo( paJACK, -1, err ); \ |
| 112 | } \ |
| 113 | PaUtil_DebugPrint(( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZEcxx . . $ `external/portaudio/pa_jack.c:83:9`!( __LINE__ ) "\n" )); \ |
| 114 | result = (code); \ |
| 115 | goto error; \ |
| 116 | } \ |
| 117 | } while( 0 ) |
| 118 | |
| 119 | #define ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!(expr, success) \ |
| 120 | do { \ |
| 121 | int err = (expr); \ |
| 122 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( err == success ); \ |
| 123 | } while( 0 ) |
| 124 | |
| 125 | /* |
| 126 | * Functions that directly map to the PortAudio stream interface |
| 127 | */ |
| 128 | |
| 129 | static void Terminatecxx . . $ Terminate(79277cf7c6a25a16).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi ); |
| 130 | static PaErrorcxx . . $ PaError# IsFormatSupportedcxx . . $ IsFormatSupported(dbae6b543f13ee5).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, |
| 131 | const PaStreamParameterscxx . . $ PaStreamParameters# *inputParameters, |
| 132 | const PaStreamParameterscxx . . $ PaStreamParameters# *outputParameters, |
| 133 | double sampleRate ); |
| 134 | static PaErrorcxx . . $ PaError# OpenStreamcxx . . $ OpenStream(dd932161c061c960).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, |
| 135 | PaStreamcxx . . $ PaStream#** s, |
| 136 | const PaStreamParameterscxx . . $ PaStreamParameters# *inputParameters, |
| 137 | const PaStreamParameterscxx . . $ PaStreamParameters# *outputParameters, |
| 138 | double sampleRate, |
| 139 | unsigned long framesPerBuffer, |
| 140 | PaStreamFlagscxx . . $ PaStreamFlags# streamFlags, |
| 141 | PaStreamCallbackcxx . . $ PaStreamCallback# *streamCallback, |
| 142 | void *userData ); |
| 143 | static PaErrorcxx . . $ PaError# CloseStreamcxx . . $ CloseStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream#* stream ); |
| 144 | static PaErrorcxx . . $ PaError# StartStreamcxx . . $ StartStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *stream ); |
| 145 | static PaErrorcxx . . $ PaError# StopStreamcxx . . $ StopStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *stream ); |
| 146 | static PaErrorcxx . . $ PaError# AbortStreamcxx . . $ AbortStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *stream ); |
| 147 | static PaErrorcxx . . $ PaError# IsStreamStoppedcxx . . $ IsStreamStopped(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ); |
| 148 | static PaErrorcxx . . $ PaError# IsStreamActivecxx . . $ IsStreamActive(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *stream ); |
| 149 | /*static PaTime GetStreamInputLatency( PaStream *stream );*/ |
| 150 | /*static PaTime GetStreamOutputLatency( PaStream *stream );*/ |
| 151 | static PaTimecxx . . $ PaTime# GetStreamTimecxx . . $ GetStreamTime(a405b17f82753acc).( PaStreamcxx . . $ PaStream# *stream ); |
| 152 | static double GetStreamCpuLoadcxx . . $ GetStreamCpuLoad(a405b17f82753acc).( PaStreamcxx . . $ PaStream#* stream ); |
| 153 | |
| 154 | |
| 155 | /* |
| 156 | * Data specific to this API |
| 157 | */ |
| 158 | |
| 159 | struct PaJackStreamcxx . . $ PaJackStream#; |
| 160 | |
| 161 | typedef structcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0# |
| 162 | { |
| 163 | PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# commonHostApiRepcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#commonHostApiRep.; |
| 164 | PaUtilStreamInterfacecxx . . $ PaUtilStreamInterface# callbackStreamInterfacecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#callbackStreamInterface.; |
| 165 | PaUtilStreamInterfacecxx . . $ PaUtilStreamInterface# blockingStreamInterfacecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#blockingStreamInterface.; |
| 166 | |
| 167 | PaUtilAllocationGroupcxx . . $ PaUtilAllocationGroup# *deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory.; |
| 168 | |
| 169 | jack_client_tcxx . . $ jack_client_t# *jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client.; |
| 170 | int jack_buffer_sizecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_buffer_size.; |
| 171 | PaHostApiIndexcxx . . $ PaHostApiIndex# hostApiIndexcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#hostApiIndex.; |
| 172 | |
| 173 | pthread_mutex_tcxx . . $ pthread_mutex_t# mtxcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#mtx.; |
| 174 | pthread_cond_tcxx . . $ pthread_cond_t# condcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#cond.; |
| 175 | unsigned long inputBasecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#inputBase., outputBasecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#outputBase.; |
| 176 | |
| 177 | /* For dealing with the process thread */ |
| 178 | volatile int xruncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#xrun.; /* Received xrun notification from JACK? */ |
| 179 | struct PaJackStreamcxx . . $ PaJackStream# * volatile toAddcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toAdd., * volatile toRemovecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toRemove.; |
| 180 | struct PaJackStreamcxx . . $ PaJackStream# *processQueuecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#processQueue.; |
| 181 | volatile sig_atomic_tcxx . . $ sig_atomic_t# jackIsDowncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jackIsDown.; |
| 182 | } |
| 183 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation#; |
| 184 | |
| 185 | /* PaJackStream - a stream data structure specifically for this implementation */ |
| 186 | |
| 187 | typedef struct PaJackStreamcxx . . $ PaJackStream# |
| 188 | { |
| 189 | PaUtilStreamRepresentationcxx . . $ PaUtilStreamRepresentation# streamRepresentationcxx . . $ PaJackStream#streamRepresentation.; |
| 190 | PaUtilBufferProcessorcxx . . $ PaUtilBufferProcessor# bufferProcessorcxx . . $ PaJackStream#bufferProcessor.; |
| 191 | PaUtilCpuLoadMeasurercxx . . $ PaUtilCpuLoadMeasurer# cpuLoadMeasurercxx . . $ PaJackStream#cpuLoadMeasurer.; |
| 192 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *hostApicxx . . $ PaJackStream#hostApi.; |
| 193 | |
| 194 | /* our input and output ports */ |
| 195 | jack_port_tcxx . . $ jack_port_t# **local_input_portscxx . . $ PaJackStream#local_input_ports.; |
| 196 | jack_port_tcxx . . $ jack_port_t# **local_output_portscxx . . $ PaJackStream#local_output_ports.; |
| 197 | |
| 198 | /* the input and output ports of the client we are connecting to */ |
| 199 | jack_port_tcxx . . $ jack_port_t# **remote_input_portscxx . . $ PaJackStream#remote_input_ports.; |
| 200 | jack_port_tcxx . . $ jack_port_t# **remote_output_portscxx . . $ PaJackStream#remote_output_ports.; |
| 201 | |
| 202 | int num_incoming_connectionscxx . . $ PaJackStream#num_incoming_connections.; |
| 203 | int num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections.; |
| 204 | |
| 205 | jack_client_tcxx . . $ jack_client_t# *jack_clientcxx . . $ PaJackStream#jack_client.; |
| 206 | |
| 207 | /* The stream is running if it's still producing samples. |
| 208 | * The stream is active if samples it produced are still being heard. |
| 209 | */ |
| 210 | volatile sig_atomic_tcxx . . $ sig_atomic_t# is_runningcxx . . $ PaJackStream#is_running.; |
| 211 | volatile sig_atomic_tcxx . . $ sig_atomic_t# is_activecxx . . $ PaJackStream#is_active.; |
| 212 | /* Used to signal processing thread that stream should start or stop, respectively */ |
| 213 | volatile sig_atomic_tcxx . . $ sig_atomic_t# doStartcxx . . $ PaJackStream#doStart., doStopcxx . . $ PaJackStream#doStop., doAbortcxx . . $ PaJackStream#doAbort.; |
| 214 | |
| 215 | jack_nframes_tcxx . . $ jack_nframes_t# t0cxx . . $ PaJackStream#t0.; |
| 216 | |
| 217 | PaUtilAllocationGroupcxx . . $ PaUtilAllocationGroup# *stream_memorycxx . . $ PaJackStream#stream_memory.; |
| 218 | |
| 219 | /* These are useful in the process callback */ |
| 220 | |
| 221 | int callbackResultcxx . . $ PaJackStream#callbackResult.; |
| 222 | int isSilencedcxx . . $ PaJackStream#isSilenced.; |
| 223 | int xruncxx . . $ PaJackStream#xrun.; |
| 224 | |
| 225 | /* These are useful for the blocking API */ |
| 226 | |
| 227 | int isBlockingStreamcxx . . $ PaJackStream#isBlockingStream.; |
| 228 | PaUtilRingBuffercxx . . $ PaUtilRingBuffer# inFIFOcxx . . $ PaJackStream#inFIFO.; |
| 229 | PaUtilRingBuffercxx . . $ PaUtilRingBuffer# outFIFOcxx . . $ PaJackStream#outFIFO.; |
| 230 | volatile sig_atomic_tcxx . . $ sig_atomic_t# data_availablecxx . . $ PaJackStream#data_available.; |
| 231 | sem_tcxx . . $ sem_t# data_semaphorecxx . . $ PaJackStream#data_semaphore.; |
| 232 | int bytesPerFramecxx . . $ PaJackStream#bytesPerFrame.; |
| 233 | int samplesPerFramecxx . . $ PaJackStream#samplesPerFrame.; |
| 234 | |
| 235 | struct PaJackStreamcxx . . $ PaJackStream# *nextcxx . . $ PaJackStream#next.; |
| 236 | } |
| 237 | PaJackStreamcxx . . $ PaJackStream#; |
| 238 | |
| 239 | /* In calls to jack_get_ports() this filter expression is used instead of "" |
| 240 | * to prevent any other types (eg Midi ports etc) being listed */ |
| 241 | #define JACK_PORT_TYPE_FILTERcxx . . $ `external/portaudio/pa_jack.c:241:9`! "audio" |
| 242 | |
| 243 | #define TRUEcxx . . $ `external/portaudio/pa_jack.c:243:9`! 1 |
| 244 | #define FALSEcxx . . $ `external/portaudio/pa_jack.c:244:9`! 0 |
| 245 | |
| 246 | /* |
| 247 | * Functions specific to this API |
| 248 | */ |
| 249 | |
| 250 | static int JackCallbackcxx . . $ JackCallback(3a1320329ebf51c9).( jack_nframes_tcxx . . $ jack_nframes_t# frames, void *userData ); |
| 251 | |
| 252 | |
| 253 | /* |
| 254 | * |
| 255 | * Implementation |
| 256 | * |
| 257 | */ |
| 258 | |
| 259 | /* ---- blocking emulation layer ---- */ |
| 260 | |
| 261 | /* Allocate buffer. */ |
| 262 | static PaErrorcxx . . $ PaError# BlockingInitFIFOcxx . . $ BlockingInitFIFO(f58fe52af2ddcbe6).( PaUtilRingBuffercxx . . $ PaUtilRingBuffer# *rbuf, long numFrames, long bytesPerFrame ) |
| 263 | { |
| 264 | long numBytes = numFrames * bytesPerFrame; |
| 265 | char *buffer = (char *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64).( numBytes ); |
| 266 | if( buffer == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) return paInsufficientMemorycxx . . $ paInsufficientMemory.; |
| 267 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( buffer, 0, numBytes ); |
| 268 | return (PaErrorcxx . . $ PaError#) PaUtil_InitializeRingBuffercxx . . $ PaUtil_InitializeRingBuffer(ecfe1861a9e38811).( rbuf, 1, numBytes, buffer ); |
| 269 | } |
| 270 | |
| 271 | /* Free buffer. */ |
| 272 | static PaErrorcxx . . $ PaError# BlockingTermFIFOcxx . . $ BlockingTermFIFO(27859d36c95e5309).( PaUtilRingBuffercxx . . $ PaUtilRingBuffer# *rbuf ) |
| 273 | { |
| 274 | if( rbuf->buffercxx . . $ PaUtilRingBuffer#buffer. ) freecxx . . $ free(5d22bdacc48458e8).( rbuf->buffercxx . . $ PaUtilRingBuffer#buffer. ); |
| 275 | rbuf->buffercxx . . $ PaUtilRingBuffer#buffer. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 276 | return paNoErrorcxx . . $ paNoError.; |
| 277 | } |
| 278 | |
| 279 | static int |
| 280 | BlockingCallbackcxx . . $ BlockingCallback(fb4a53f6a51faeed).( const void *inputBuffer, |
| 281 | void *outputBuffer, |
| 282 | unsigned long framesPerBuffer, |
| 283 | const PaStreamCallbackTimeInfocxx . . $ PaStreamCallbackTimeInfo#* timeInfo, |
| 284 | PaStreamCallbackFlagscxx . . $ PaStreamCallbackFlags# statusFlags, |
| 285 | void *userData ) |
| 286 | { |
| 287 | struct PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream# *)userData; |
| 288 | long numBytes = stream->bytesPerFramecxx . . $ PaJackStream#bytesPerFrame. * framesPerBuffer; |
| 289 | |
| 290 | /* This may get called with NULL inputBuffer during initial setup. */ |
| 291 | if( inputBuffer != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 292 | { |
| 293 | PaUtil_WriteRingBuffercxx . . $ PaUtil_WriteRingBuffer(63d341022bae197b).( &stream->inFIFOcxx . . $ PaJackStream#inFIFO., inputBuffer, numBytes ); |
| 294 | } |
| 295 | if( outputBuffer != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 296 | { |
| 297 | int numRead = PaUtil_ReadRingBuffercxx . . $ PaUtil_ReadRingBuffer(5284866c5272b37b).( &stream->outFIFOcxx . . $ PaJackStream#outFIFO., outputBuffer, numBytes ); |
| 298 | /* Zero out remainder of buffer if we run out of data. */ |
| 299 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( (char *)outputBuffer + numRead, 0, numBytes - numRead ); |
| 300 | } |
| 301 | |
| 302 | if( !stream->data_availablecxx . . $ PaJackStream#data_available. ) |
| 303 | { |
| 304 | stream->data_availablecxx . . $ PaJackStream#data_available. = 1; |
| 305 | sem_postcxx . . $ sem_post(2e1de0073772a87a).( &stream->data_semaphorecxx . . $ PaJackStream#data_semaphore. ); |
| 306 | } |
| 307 | return paContinuecxx . . $ paContinue.; |
| 308 | } |
| 309 | |
| 310 | static PaErrorcxx . . $ PaError# |
| 311 | BlockingBegincxx . . $ BlockingBegin(6179de1e636293a).( PaJackStreamcxx . . $ PaJackStream# *stream, int minimum_buffer_size ) |
| 312 | { |
| 313 | long doRead = 0; |
| 314 | long doWrite = 0; |
| 315 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 316 | long numFrames; |
| 317 | |
| 318 | doRead = stream->local_input_portscxx . . $ PaJackStream#local_input_ports. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 319 | doWrite = stream->local_output_portscxx . . $ PaJackStream#local_output_ports. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 320 | /* <FIXME> */ |
| 321 | stream->samplesPerFramecxx . . $ PaJackStream#samplesPerFrame. = 2; |
| 322 | stream->bytesPerFramecxx . . $ PaJackStream#bytesPerFrame. = sizeof(float) * stream->samplesPerFramecxx . . $ PaJackStream#samplesPerFrame.; |
| 323 | /* </FIXME> */ |
| 324 | numFrames = 32; |
| 325 | while (numFrames < minimum_buffer_size) |
| 326 | numFrames *= 2; |
| 327 | |
| 328 | if( doRead ) |
| 329 | { |
| 330 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( BlockingInitFIFO( &stream->inFIFO, numFrames, stream->bytesPerFrame ) ); |
| 331 | } |
| 332 | if( doWrite ) |
| 333 | { |
| 334 | long numBytes; |
| 335 | |
| 336 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( BlockingInitFIFO( &stream->outFIFO, numFrames, stream->bytesPerFrame ) ); |
| 337 | |
| 338 | /* Make Write FIFO appear full initially. */ |
| 339 | numBytes = PaUtil_GetRingBufferWriteAvailablecxx . . $ PaUtil_GetRingBufferWriteAvailable(fd6925ed6a291f27).( &stream->outFIFOcxx . . $ PaJackStream#outFIFO. ); |
| 340 | PaUtil_AdvanceRingBufferWriteIndexcxx . . $ PaUtil_AdvanceRingBufferWriteIndex(ea1a431c84d9e284).( &stream->outFIFOcxx . . $ PaJackStream#outFIFO., numBytes ); |
| 341 | } |
| 342 | |
| 343 | stream->data_availablecxx . . $ PaJackStream#data_available. = 0; |
| 344 | sem_initcxx . . $ sem_init(43542eaff42295b0).( &stream->data_semaphorecxx . . $ PaJackStream#data_semaphore., 0, 0 ); |
| 345 | |
| 346 | error: |
| 347 | return result; |
| 348 | } |
| 349 | |
| 350 | static void |
| 351 | BlockingEndcxx . . $ BlockingEnd(ece44e1ba60f6043).( PaJackStreamcxx . . $ PaJackStream# *stream ) |
| 352 | { |
| 353 | BlockingTermFIFOcxx . . $ BlockingTermFIFO(27859d36c95e5309).( &stream->inFIFOcxx . . $ PaJackStream#inFIFO. ); |
| 354 | BlockingTermFIFOcxx . . $ BlockingTermFIFO(27859d36c95e5309).( &stream->outFIFOcxx . . $ PaJackStream#outFIFO. ); |
| 355 | |
| 356 | sem_destroycxx . . $ sem_destroy(2e1de0073772a87a).( &stream->data_semaphorecxx . . $ PaJackStream#data_semaphore. ); |
| 357 | } |
| 358 | |
| 359 | static PaErrorcxx . . $ PaError# BlockingReadStreamcxx . . $ BlockingReadStream(c5040b39c98d43dd).( PaStreamcxx . . $ PaStream#* s, void *data, unsigned long numFrames ) |
| 360 | { |
| 361 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 362 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream# *)s; |
| 363 | |
| 364 | long bytesRead; |
| 365 | char *p = (char *) data; |
| 366 | long numBytes = stream->bytesPerFramecxx . . $ PaJackStream#bytesPerFrame. * numFrames; |
| 367 | while( numBytes > 0 ) |
| 368 | { |
| 369 | bytesRead = PaUtil_ReadRingBuffercxx . . $ PaUtil_ReadRingBuffer(5284866c5272b37b).( &stream->inFIFOcxx . . $ PaJackStream#inFIFO., p, numBytes ); |
| 370 | numBytes -= bytesRead; |
| 371 | p += bytesRead; |
| 372 | if( numBytes > 0 ) |
| 373 | { |
| 374 | /* see write for an explanation */ |
| 375 | if( stream->data_availablecxx . . $ PaJackStream#data_available. ) |
| 376 | stream->data_availablecxx . . $ PaJackStream#data_available. = 0; |
| 377 | else |
| 378 | sem_waitcxx . . $ sem_wait(2e1de0073772a87a).( &stream->data_semaphorecxx . . $ PaJackStream#data_semaphore. ); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | return result; |
| 383 | } |
| 384 | |
| 385 | static PaErrorcxx . . $ PaError# BlockingWriteStreamcxx . . $ BlockingWriteStream(72e086fd9bc8337a).( PaStreamcxx . . $ PaStream#* s, const void *data, unsigned long numFrames ) |
| 386 | { |
| 387 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 388 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream# *)s; |
| 389 | long bytesWritten; |
| 390 | char *p = (char *) data; |
| 391 | long numBytes = stream->bytesPerFramecxx . . $ PaJackStream#bytesPerFrame. * numFrames; |
| 392 | while( numBytes > 0 ) |
| 393 | { |
| 394 | bytesWritten = PaUtil_WriteRingBuffercxx . . $ PaUtil_WriteRingBuffer(63d341022bae197b).( &stream->outFIFOcxx . . $ PaJackStream#outFIFO., p, numBytes ); |
| 395 | numBytes -= bytesWritten; |
| 396 | p += bytesWritten; |
| 397 | if( numBytes > 0 ) |
| 398 | { |
| 399 | /* we use the following algorithm: |
| 400 | * (1) write data |
| 401 | * (2) if some data didn't fit into the ringbuffer, set data_available to 0 |
| 402 | * to indicate to the audio that if space becomes available, we want to know |
| 403 | * (3) retry to write data (because it might be that between (1) and (2) |
| 404 | * new space in the buffer became available) |
| 405 | * (4) if this failed, we are sure that the buffer is really empty and |
| 406 | * we will definitely receive a notification when it becomes available |
| 407 | * thus we can safely sleep |
| 408 | * |
| 409 | * if the algorithm bailed out in step (3) before, it leaks a count of 1 |
| 410 | * on the semaphore; however, it doesn't matter, because if we block in (4), |
| 411 | * we also do it in a loop |
| 412 | */ |
| 413 | if( stream->data_availablecxx . . $ PaJackStream#data_available. ) |
| 414 | stream->data_availablecxx . . $ PaJackStream#data_available. = 0; |
| 415 | else |
| 416 | sem_waitcxx . . $ sem_wait(2e1de0073772a87a).( &stream->data_semaphorecxx . . $ PaJackStream#data_semaphore. ); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | return result; |
| 421 | } |
| 422 | |
| 423 | static signed long |
| 424 | BlockingGetStreamReadAvailablecxx . . $ BlockingGetStreamReadAvailable(72c1818a5177f981).( PaStreamcxx . . $ PaStream#* s ) |
| 425 | { |
| 426 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream# *)s; |
| 427 | |
| 428 | int bytesFull = PaUtil_GetRingBufferReadAvailablecxx . . $ PaUtil_GetRingBufferReadAvailable(fd6925ed6a291f27).( &stream->inFIFOcxx . . $ PaJackStream#inFIFO. ); |
| 429 | return bytesFull / stream->bytesPerFramecxx . . $ PaJackStream#bytesPerFrame.; |
| 430 | } |
| 431 | |
| 432 | static signed long |
| 433 | BlockingGetStreamWriteAvailablecxx . . $ BlockingGetStreamWriteAvailable(72c1818a5177f981).( PaStreamcxx . . $ PaStream#* s ) |
| 434 | { |
| 435 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream# *)s; |
| 436 | |
| 437 | int bytesEmpty = PaUtil_GetRingBufferWriteAvailablecxx . . $ PaUtil_GetRingBufferWriteAvailable(fd6925ed6a291f27).( &stream->outFIFOcxx . . $ PaJackStream#outFIFO. ); |
| 438 | return bytesEmpty / stream->bytesPerFramecxx . . $ PaJackStream#bytesPerFrame.; |
| 439 | } |
| 440 | |
| 441 | static PaErrorcxx . . $ PaError# |
| 442 | BlockingWaitEmptycxx . . $ BlockingWaitEmpty(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 443 | { |
| 444 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream# *)s; |
| 445 | |
| 446 | while( PaUtil_GetRingBufferReadAvailablecxx . . $ PaUtil_GetRingBufferReadAvailable(fd6925ed6a291f27).( &stream->outFIFOcxx . . $ PaJackStream#outFIFO. ) > 0 ) |
| 447 | { |
| 448 | stream->data_availablecxx . . $ PaJackStream#data_available. = 0; |
| 449 | sem_waitcxx . . $ sem_wait(2e1de0073772a87a).( &stream->data_semaphorecxx . . $ PaJackStream#data_semaphore. ); |
| 450 | } |
| 451 | return 0; |
| 452 | } |
| 453 | |
| 454 | /* ---- jack driver ---- */ |
| 455 | |
| 456 | /* copy null terminated string source to destination, escaping regex characters with '\\' in the process */ |
| 457 | static void copy_string_and_escape_regex_charscxx . . $ copy_string_and_escape_regex_chars(584917e90c1c156b).( char *destination, const char *source, size_t destbuffersize ) |
| 458 | { |
| 459 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( destination != source ); |
| 460 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( destbuffersize > 0 ); |
| 461 | |
| 462 | char *dest = destination; |
| 463 | /* dest_stop is the last location that we can null-terminate the string */ |
| 464 | char *dest_stop = destination + (destbuffersize - 1); |
| 465 | |
| 466 | const char *src = source; |
| 467 | |
| 468 | while ( *src != '\0' && dest != dest_stop ) |
| 469 | { |
| 470 | const char c = *src; |
| 471 | if ( strchrcxx . . $ strchr(2050848944e00d54).( "\\()[]{}*+?|$^.", c ) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 472 | { |
| 473 | if( (dest + 1) == dest_stop ) |
| 474 | break; /* only proceed if we can write both c and the escape */ |
| 475 | |
| 476 | *dest = '\\'; |
| 477 | dest++; |
| 478 | } |
| 479 | *dest = c; |
| 480 | dest++; |
| 481 | |
| 482 | src++; |
| 483 | } |
| 484 | |
| 485 | *dest = '\0'; |
| 486 | } |
| 487 | |
| 488 | /* BuildDeviceList(): |
| 489 | * |
| 490 | * The process of determining a list of PortAudio "devices" from |
| 491 | * JACK's client/port system is fairly involved, so it is separated |
| 492 | * into its own routine. |
| 493 | */ |
| 494 | |
| 495 | static PaErrorcxx . . $ PaError# BuildDeviceListcxx . . $ BuildDeviceList(f6fafa200cd34369).( PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *jackApi ) |
| 496 | { |
| 497 | /* Utility macros for the repetitive process of allocating memory */ |
| 498 | |
| 499 | /* JACK has no concept of a device. To JACK, there are clients |
| 500 | * which have an arbitrary number of ports. To make this |
| 501 | * intelligible to PortAudio clients, we will group each JACK client |
| 502 | * into a device, and make each port of that client a channel */ |
| 503 | |
| 504 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 505 | PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *commonApi = &jackApi->commonHostApiRepcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#commonHostApiRep.; |
| 506 | |
| 507 | const char **jack_ports = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 508 | char **client_names = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 509 | char *port_regex_string = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 510 | // In the worst case scenario, every character would be escaped, doubling the string size. |
| 511 | // Add 1 for null terminator. |
| 512 | size_t device_name_regex_escaped_size = jack_client_name_sizecxx . . $ jack_client_name_size(b126dc7c1de90089).() * 2 + 1; |
| 513 | size_t port_regex_size = device_name_regex_escaped_size + strlencxx . . $ strlen(751346f8406fd082).(port_regex_suffixcxx . . $ port_regex_suffix.); |
| 514 | int port_index, client_index, i; |
| 515 | double globalSampleRate; |
| 516 | regex_tcxx . . $ regex_t# port_regex; |
| 517 | unsigned long numClients = 0, numPorts = 0; |
| 518 | char *tmp_client_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 519 | |
| 520 | commonApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultInputDevicecxx . . $ PaHostApiInfo#defaultInputDevice. = paNoDevicecxx . . $ `external/portaudio/portaudio.h:220:9`!; |
| 521 | commonApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultOutputDevicecxx . . $ PaHostApiInfo#defaultOutputDevice. = paNoDevicecxx . . $ `external/portaudio/portaudio.h:220:9`!; |
| 522 | commonApi->infocxx . . $ PaUtilHostApiRepresentation#info..deviceCountcxx . . $ PaHostApiInfo#deviceCount. = 0; |
| 523 | |
| 524 | /* Parse the list of ports, using a regex to grab the client names */ |
| 525 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( regcomp( &port_regex, "^[^:]*", REG_EXTENDEDcxx . . $ `<external>/18190116149591951179/regex.h:310:9`! ), 0 ); |
| 526 | |
| 527 | /* since we are rebuilding the list of devices, free all memory |
| 528 | * associated with the previous list */ |
| 529 | PaUtil_FreeAllAllocationscxx . . $ PaUtil_FreeAllAllocations(312b3fcc9bc2c5fe).( jackApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory. ); |
| 530 | |
| 531 | port_regex_string = PaUtil_GroupAllocateMemorycxx . . $ PaUtil_GroupAllocateMemory(1657cd93bd8e98c5).( jackApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory., port_regex_size ); |
| 532 | tmp_client_name = PaUtil_GroupAllocateMemorycxx . . $ PaUtil_GroupAllocateMemory(1657cd93bd8e98c5).( jackApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory., jack_client_name_sizecxx . . $ jack_client_name_size(b126dc7c1de90089).() ); |
| 533 | |
| 534 | /* We can only retrieve the list of clients indirectly, by first |
| 535 | * asking for a list of all ports, then parsing the port names |
| 536 | * according to the client_name:port_name convention (which is |
| 537 | * enforced by jackd) |
| 538 | * A: If jack_get_ports returns NULL, there's nothing for us to do */ |
| 539 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( (jack_ports = jack_get_ports( jackApi->jack_client, "", JACK_PORT_TYPE_FILTERcxx . . $ `external/portaudio/pa_jack.c:241:9`!, 0 )) && jack_ports[0], paNoError ); |
| 540 | /* Find number of ports */ |
| 541 | while( jack_ports[numPorts] ) |
| 542 | ++numPorts; |
| 543 | /* At least there will be one port per client :) */ |
| 544 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( client_names = PaUtil_GroupAllocateMemory( jackApi->deviceInfoMemory, numPorts * |
| 545 | sizeof (char *) ), paInsufficientMemory ); |
| 546 | |
| 547 | /* Build a list of clients from the list of ports */ |
| 548 | for( numClients = 0, port_index = 0; jack_ports[port_index] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; port_index++ ) |
| 549 | { |
| 550 | int client_seen = FALSEcxx . . $ `external/portaudio/pa_jack.c:244:9`!; |
| 551 | regmatch_tcxx . . $ regmatch_t# match_info; |
| 552 | const char *port = jack_ports[port_index]; |
| 553 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "JACK port found: %s\n", port )); |
| 554 | |
| 555 | /* extract the client name from the port name, using a regex |
| 556 | * that parses the clientname:portname syntax */ |
| 557 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !regexec( &port_regex, port, 1, &match_info, 0 ), paInternalError ); |
| 558 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(match_info.rm_eo - match_info.rm_so < jack_client_name_size()); |
| 559 | memcpycxx . . $ memcpy(cc817cb175f282d).( tmp_client_name, port + match_info.rm_socxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_so., |
| 560 | match_info.rm_eocxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_eo. - match_info.rm_socxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_so. ); |
| 561 | tmp_client_name[match_info.rm_eocxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_eo. - match_info.rm_socxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_so.] = '\0'; |
| 562 | |
| 563 | /* do we know about this port's client yet? */ |
| 564 | for( i = 0; i < numClients; i++ ) |
| 565 | { |
| 566 | if( strcmpcxx . . $ strcmp(5ae29d726ae57f88).( tmp_client_name, client_names[i] ) == 0 ) |
| 567 | client_seen = TRUEcxx . . $ `external/portaudio/pa_jack.c:243:9`!; |
| 568 | } |
| 569 | |
| 570 | if (client_seen) |
| 571 | continue; /* A: Nothing to see here, move along */ |
| 572 | |
| 573 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( client_names[numClients] = (char*)PaUtil_GroupAllocateMemory( jackApi->deviceInfoMemory, |
| 574 | strlen(tmp_client_name) + 1), paInsufficientMemory ); |
| 575 | |
| 576 | /* The alsa_pcm client should go in spot 0. If this |
| 577 | * is the alsa_pcm client AND we are NOT about to put |
| 578 | * it in spot 0 put it in spot 0 and move whatever |
| 579 | * was already in spot 0 to the end. */ |
| 580 | if( strcmpcxx . . $ strcmp(5ae29d726ae57f88).( "alsa_pcm", tmp_client_name ) == 0 && numClients > 0 ) |
| 581 | { |
| 582 | /* alsa_pcm goes in spot 0 */ |
| 583 | strcpycxx . . $ strcpy(b7b3a83273496486).( client_names[ numClients ], client_names[0] ); |
| 584 | strcpycxx . . $ strcpy(b7b3a83273496486).( client_names[0], tmp_client_name ); |
| 585 | } |
| 586 | else |
| 587 | { |
| 588 | /* put the new client at the end of the client list */ |
| 589 | strcpycxx . . $ strcpy(b7b3a83273496486).( client_names[ numClients ], tmp_client_name ); |
| 590 | } |
| 591 | ++numClients; |
| 592 | } |
| 593 | |
| 594 | /* Now we have a list of clients, which will become the list of |
| 595 | * PortAudio devices. */ |
| 596 | |
| 597 | /* there is one global sample rate all clients must conform to */ |
| 598 | |
| 599 | globalSampleRate = jack_get_sample_ratecxx . . $ jack_get_sample_rate(c09b6173c6c1729d).( jackApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. ); |
| 600 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( commonApi->deviceInfos = (PaDeviceInfo**)PaUtil_GroupAllocateMemory( jackApi->deviceInfoMemory, |
| 601 | sizeof(PaDeviceInfo*) * numClients ), paInsufficientMemory ); |
| 602 | |
| 603 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( commonApi->info.deviceCount == 0 ); |
| 604 | |
| 605 | /* Create a PaDeviceInfo structure for every client */ |
| 606 | for( client_index = 0; client_index < numClients; client_index++ ) |
| 607 | { |
| 608 | PaDeviceInfocxx . . $ PaDeviceInfo# *curDevInfo; |
| 609 | const char **clientPorts = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 610 | |
| 611 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( curDevInfo = (PaDeviceInfo*)PaUtil_GroupAllocateMemory( jackApi->deviceInfoMemory, |
| 612 | sizeof(PaDeviceInfo) ), paInsufficientMemory ); |
| 613 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( curDevInfo->name = (char*)PaUtil_GroupAllocateMemory( jackApi->deviceInfoMemory, |
| 614 | strlen(client_names[client_index]) + 1 ), paInsufficientMemory ); |
| 615 | strcpycxx . . $ strcpy(b7b3a83273496486).( (char *)curDevInfo->namecxx . . $ PaDeviceInfo#name., client_names[client_index] ); |
| 616 | |
| 617 | curDevInfo->structVersioncxx . . $ PaDeviceInfo#structVersion. = 2; |
| 618 | curDevInfo->hostApicxx . . $ PaDeviceInfo#hostApi. = jackApi->hostApiIndexcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#hostApiIndex.; |
| 619 | |
| 620 | /* JACK is very inflexible: there is one sample rate the whole |
| 621 | * system must run at, and all clients must speak IEEE float. */ |
| 622 | curDevInfo->defaultSampleRatecxx . . $ PaDeviceInfo#defaultSampleRate. = globalSampleRate; |
| 623 | |
| 624 | /* To determine how many input and output channels are available, |
| 625 | * we re-query jackd with more specific parameters. */ |
| 626 | copy_string_and_escape_regex_charscxx . . $ copy_string_and_escape_regex_chars(584917e90c1c156b).( port_regex_string, |
| 627 | client_names[client_index], |
| 628 | device_name_regex_escaped_size ); |
| 629 | strncatcxx . . $ strncat(255158a415b673b0).( port_regex_string, port_regex_suffixcxx . . $ port_regex_suffix., port_regex_size ); |
| 630 | |
| 631 | /* ... what are your output ports (that we could input from)? */ |
| 632 | clientPorts = jack_get_portscxx . . $ jack_get_ports(ad0468aa12990071).( jackApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client., port_regex_string, |
| 633 | JACK_PORT_TYPE_FILTERcxx . . $ `external/portaudio/pa_jack.c:241:9`!, JackPortIsOutputcxx . . $ JackPortIsOutput.); |
| 634 | curDevInfo->maxInputChannelscxx . . $ PaDeviceInfo#maxInputChannels. = 0; |
| 635 | curDevInfo->defaultLowInputLatencycxx . . $ PaDeviceInfo#defaultLowInputLatency. = 0.; |
| 636 | curDevInfo->defaultHighInputLatencycxx . . $ PaDeviceInfo#defaultHighInputLatency. = 0.; |
| 637 | if( clientPorts ) |
| 638 | { |
| 639 | jack_port_tcxx . . $ jack_port_t# *p = jack_port_by_namecxx . . $ jack_port_by_name(4f48ea04666fdaa3).( jackApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client., clientPorts[0] ); |
| 640 | curDevInfo->defaultLowInputLatencycxx . . $ PaDeviceInfo#defaultLowInputLatency. = curDevInfo->defaultHighInputLatencycxx . . $ PaDeviceInfo#defaultHighInputLatency. = |
| 641 | jack_port_get_latencycxx . . $ jack_port_get_latency(d53b401d5aad02b0).( p ) / globalSampleRate; |
| 642 | |
| 643 | for( i = 0; clientPorts[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; i++) |
| 644 | { |
| 645 | /* The number of ports returned is the number of output channels. |
| 646 | * We don't care what they are, we just care how many */ |
| 647 | curDevInfo->maxInputChannelscxx . . $ PaDeviceInfo#maxInputChannels.++; |
| 648 | } |
| 649 | freecxx . . $ free(5d22bdacc48458e8).(clientPorts); |
| 650 | } |
| 651 | |
| 652 | /* ... what are your input ports (that we could output to)? */ |
| 653 | clientPorts = jack_get_portscxx . . $ jack_get_ports(ad0468aa12990071).( jackApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client., port_regex_string, |
| 654 | JACK_PORT_TYPE_FILTERcxx . . $ `external/portaudio/pa_jack.c:241:9`!, JackPortIsInputcxx . . $ JackPortIsInput.); |
| 655 | curDevInfo->maxOutputChannelscxx . . $ PaDeviceInfo#maxOutputChannels. = 0; |
| 656 | curDevInfo->defaultLowOutputLatencycxx . . $ PaDeviceInfo#defaultLowOutputLatency. = 0.; |
| 657 | curDevInfo->defaultHighOutputLatencycxx . . $ PaDeviceInfo#defaultHighOutputLatency. = 0.; |
| 658 | if( clientPorts ) |
| 659 | { |
| 660 | jack_port_tcxx . . $ jack_port_t# *p = jack_port_by_namecxx . . $ jack_port_by_name(4f48ea04666fdaa3).( jackApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client., clientPorts[0] ); |
| 661 | curDevInfo->defaultLowOutputLatencycxx . . $ PaDeviceInfo#defaultLowOutputLatency. = curDevInfo->defaultHighOutputLatencycxx . . $ PaDeviceInfo#defaultHighOutputLatency. = |
| 662 | jack_port_get_latencycxx . . $ jack_port_get_latency(d53b401d5aad02b0).( p ) / globalSampleRate; |
| 663 | |
| 664 | for( i = 0; clientPorts[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; i++) |
| 665 | { |
| 666 | /* The number of ports returned is the number of input channels. |
| 667 | * We don't care what they are, we just care how many */ |
| 668 | curDevInfo->maxOutputChannelscxx . . $ PaDeviceInfo#maxOutputChannels.++; |
| 669 | } |
| 670 | freecxx . . $ free(5d22bdacc48458e8).(clientPorts); |
| 671 | } |
| 672 | |
| 673 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "Adding JACK device %s with %d input channels and %d output channels\n", |
| 674 | client_names[client_index], |
| 675 | curDevInfo->maxInputChannels, |
| 676 | curDevInfo->maxOutputChannels )); |
| 677 | |
| 678 | /* Add this client to the list of devices */ |
| 679 | commonApi->deviceInfoscxx . . $ PaUtilHostApiRepresentation#deviceInfos.[client_index] = curDevInfo; |
| 680 | ++commonApi->infocxx . . $ PaUtilHostApiRepresentation#info..deviceCountcxx . . $ PaHostApiInfo#deviceCount.; |
| 681 | if( commonApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultInputDevicecxx . . $ PaHostApiInfo#defaultInputDevice. == paNoDevicecxx . . $ `external/portaudio/portaudio.h:220:9`! && curDevInfo->maxInputChannelscxx . . $ PaDeviceInfo#maxInputChannels. > 0 ) |
| 682 | commonApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultInputDevicecxx . . $ PaHostApiInfo#defaultInputDevice. = client_index; |
| 683 | if( commonApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultOutputDevicecxx . . $ PaHostApiInfo#defaultOutputDevice. == paNoDevicecxx . . $ `external/portaudio/portaudio.h:220:9`! && curDevInfo->maxOutputChannelscxx . . $ PaDeviceInfo#maxOutputChannels. > 0 ) |
| 684 | commonApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultOutputDevicecxx . . $ PaHostApiInfo#defaultOutputDevice. = client_index; |
| 685 | } |
| 686 | |
| 687 | error: |
| 688 | regfreecxx . . $ regfree(b1814a8fd6af504b).( &port_regex ); |
| 689 | freecxx . . $ free(5d22bdacc48458e8).( jack_ports ); |
| 690 | return result; |
| 691 | } |
| 692 | |
| 693 | static void UpdateSampleRatecxx . . $ UpdateSampleRate(a14b1df557c35d95).( PaJackStreamcxx . . $ PaJackStream# *stream, double sampleRate ) |
| 694 | { |
| 695 | /* XXX: Maybe not the cleanest way of going about this? */ |
| 696 | stream->cpuLoadMeasurercxx . . $ PaJackStream#cpuLoadMeasurer..samplingPeriodcxx . . $ $anonymous_type_b8cdcef88d4fa6e4_0#samplingPeriod. = stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor..samplePeriodcxx . . $ $anonymous_type_33f8fe5f0a49cfa7_1#samplePeriod. = 1. / sampleRate; |
| 697 | stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..sampleRatecxx . . $ PaStreamInfo#sampleRate. = sampleRate; |
| 698 | } |
| 699 | |
| 700 | static void JackErrorCallbackcxx . . $ JackErrorCallback(85c52e162fed56f9).( const char *msg ) |
| 701 | { |
| 702 | if( pthread_selfcxx . . $ pthread_self(f708dce9a8856c70).() == mainThread_cxx . . $ mainThread_. ) |
| 703 | { |
| 704 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( msg ); |
| 705 | jackErr_cxx . . $ jackErr_. = realloccxx . . $ realloc(417ab160f6baadc6).( jackErr_cxx . . $ jackErr_., strlencxx . . $ strlen(751346f8406fd082).( msg ) + 1 ); |
| 706 | strcpycxx . . $ strcpy(b7b3a83273496486).( jackErr_cxx . . $ jackErr_., msg ); |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | static void JackOnShutdowncxx . . $ JackOnShutdown(5d22bdacc48458e8).( void *arg ) |
| 711 | { |
| 712 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *jackApi = (PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *)arg; |
| 713 | PaJackStreamcxx . . $ PaJackStream# *stream = jackApi->processQueuecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#processQueue.; |
| 714 | |
| 715 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: JACK server is shutting down\n", __FUNCTION__ )); |
| 716 | for( ; stream; stream = stream->nextcxx . . $ PaJackStream#next. ) |
| 717 | { |
| 718 | stream->is_activecxx . . $ PaJackStream#is_active. = 0; |
| 719 | } |
| 720 | |
| 721 | /* Make sure that the main thread doesn't get stuck waiting on the condition */ |
| 722 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_lock( &jackApi->mtx ), 0 ); |
| 723 | jackApi->jackIsDowncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jackIsDown. = 1; |
| 724 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_cond_signal( &jackApi->cond ), 0 ); |
| 725 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_unlock( &jackApi->mtx ), 0 ); |
| 726 | |
| 727 | } |
| 728 | |
| 729 | static int JackSrCbcxx . . $ JackSrCb(3a1320329ebf51c9).( jack_nframes_tcxx . . $ jack_nframes_t# nframes, void *arg ) |
| 730 | { |
| 731 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *jackApi = (PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *)arg; |
| 732 | double sampleRate = (double)nframes; |
| 733 | PaJackStreamcxx . . $ PaJackStream# *stream = jackApi->processQueuecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#processQueue.; |
| 734 | |
| 735 | /* Update all streams in process queue */ |
| 736 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Acting on change in JACK samplerate: %f\n", __FUNCTION__, sampleRate )); |
| 737 | for( ; stream; stream = stream->nextcxx . . $ PaJackStream#next. ) |
| 738 | { |
| 739 | if( stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..sampleRatecxx . . $ PaStreamInfo#sampleRate. != sampleRate ) |
| 740 | { |
| 741 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Updating samplerate\n", __FUNCTION__ )); |
| 742 | UpdateSampleRatecxx . . $ UpdateSampleRate(a14b1df557c35d95).( stream, sampleRate ); |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | return 0; |
| 747 | } |
| 748 | |
| 749 | static int JackXRunCbcxx . . $ JackXRunCb(dedf1e9b1c614a07).(void *arg) { |
| 750 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *hostApi = (PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *)arg; |
| 751 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( hostApi ); |
| 752 | hostApi->xruncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#xrun. = TRUEcxx . . $ `external/portaudio/pa_jack.c:243:9`!; |
| 753 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: JACK signalled xrun\n", __FUNCTION__ )); |
| 754 | return 0; |
| 755 | } |
| 756 | |
| 757 | PaErrorcxx . . $ PaError# PaJack_Initializecxx . . $ PaJack_Initialize(73d6fc5159ec0bfd).( PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# **hostApi, |
| 758 | PaHostApiIndexcxx . . $ PaHostApiIndex# hostApiIndex ) |
| 759 | { |
| 760 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 761 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *jackHostApi; |
| 762 | int activated = 0; |
| 763 | jack_status_tcxx . . $ jack_status_t# jackStatus = 0; |
| 764 | *hostApi = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; /* Initialize to NULL */ |
| 765 | |
| 766 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( jackHostApi = (PaJackHostApiRepresentation*) |
| 767 | PaUtil_AllocateMemory( sizeof(PaJackHostApiRepresentation) ), paInsufficientMemory ); |
| 768 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( jackHostApi->deviceInfoMemory = PaUtil_CreateAllocationGroup(), paInsufficientMemory ); |
| 769 | |
| 770 | mainThread_cxx . . $ mainThread_. = pthread_selfcxx . . $ pthread_self(f708dce9a8856c70).(); |
| 771 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_init( &jackHostApi->mtx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ), 0 ); |
| 772 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_cond_init( &jackHostApi->cond, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ), 0 ); |
| 773 | |
| 774 | /* Try to become a client of the JACK server. If we cannot do |
| 775 | * this, then this API cannot be used. |
| 776 | * |
| 777 | * Without the JackNoStartServer option, the jackd server is started |
| 778 | * automatically which we do not want. |
| 779 | */ |
| 780 | |
| 781 | jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. = jack_client_opencxx . . $ jack_client_open(cab5dea5fa449abf).( clientName_cxx . . $ clientName_., JackNoStartServercxx . . $ JackNoStartServer., &jackStatus ); |
| 782 | if( !jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. ) |
| 783 | { |
| 784 | /* the V19 development docs say that if an implementation |
| 785 | * detects that it cannot be used, it should return a NULL |
| 786 | * interface and paNoError */ |
| 787 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Couldn't connect to JACK, status: %d\n", __FUNCTION__, jackStatus )); |
| 788 | result = paNoErrorcxx . . $ paNoError.; |
| 789 | goto error; |
| 790 | } |
| 791 | |
| 792 | jackHostApi->hostApiIndexcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#hostApiIndex. = hostApiIndex; |
| 793 | |
| 794 | *hostApi = &jackHostApi->commonHostApiRepcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#commonHostApiRep.; |
| 795 | (*hostApi)->infocxx . . $ PaUtilHostApiRepresentation#info..structVersioncxx . . $ PaHostApiInfo#structVersion. = 1; |
| 796 | (*hostApi)->infocxx . . $ PaUtilHostApiRepresentation#info..typecxx . . $ PaHostApiInfo#type. = paJACKcxx . . $ paJACK.; |
| 797 | (*hostApi)->infocxx . . $ PaUtilHostApiRepresentation#info..namecxx . . $ PaHostApiInfo#name. = "JACK Audio Connection Kit"; |
| 798 | |
| 799 | /* Build a device list by querying the JACK server */ |
| 800 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( BuildDeviceList( jackHostApi ) ); |
| 801 | |
| 802 | /* Register functions */ |
| 803 | |
| 804 | (*hostApi)->Terminatecxx . . $ PaUtilHostApiRepresentation#Terminate. = Terminatecxx . . $ Terminate(79277cf7c6a25a16).; |
| 805 | (*hostApi)->OpenStreamcxx . . $ PaUtilHostApiRepresentation#OpenStream. = OpenStreamcxx . . $ OpenStream(dd932161c061c960).; |
| 806 | (*hostApi)->IsFormatSupportedcxx . . $ PaUtilHostApiRepresentation#IsFormatSupported. = IsFormatSupportedcxx . . $ IsFormatSupported(dbae6b543f13ee5).; |
| 807 | |
| 808 | PaUtil_InitializeStreamInterfacecxx . . $ PaUtil_InitializeStreamInterface(4b35ac35495e68b2).( &jackHostApi->callbackStreamInterfacecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#callbackStreamInterface., |
| 809 | CloseStreamcxx . . $ CloseStream(dedf1e9b1c614a07)., StartStreamcxx . . $ StartStream(dedf1e9b1c614a07)., |
| 810 | StopStreamcxx . . $ StopStream(dedf1e9b1c614a07)., AbortStreamcxx . . $ AbortStream(dedf1e9b1c614a07)., |
| 811 | IsStreamStoppedcxx . . $ IsStreamStopped(dedf1e9b1c614a07)., IsStreamActivecxx . . $ IsStreamActive(dedf1e9b1c614a07)., |
| 812 | GetStreamTimecxx . . $ GetStreamTime(a405b17f82753acc)., GetStreamCpuLoadcxx . . $ GetStreamCpuLoad(a405b17f82753acc)., |
| 813 | PaUtil_DummyReadcxx . . $ PaUtil_DummyRead(c5040b39c98d43dd)., PaUtil_DummyWritecxx . . $ PaUtil_DummyWrite(72e086fd9bc8337a)., |
| 814 | PaUtil_DummyGetReadAvailablecxx . . $ PaUtil_DummyGetReadAvailable(72c1818a5177f981)., |
| 815 | PaUtil_DummyGetWriteAvailablecxx . . $ PaUtil_DummyGetWriteAvailable(72c1818a5177f981). ); |
| 816 | |
| 817 | PaUtil_InitializeStreamInterfacecxx . . $ PaUtil_InitializeStreamInterface(4b35ac35495e68b2).( &jackHostApi->blockingStreamInterfacecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#blockingStreamInterface., CloseStreamcxx . . $ CloseStream(dedf1e9b1c614a07)., StartStreamcxx . . $ StartStream(dedf1e9b1c614a07)., |
| 818 | StopStreamcxx . . $ StopStream(dedf1e9b1c614a07)., AbortStreamcxx . . $ AbortStream(dedf1e9b1c614a07)., IsStreamStoppedcxx . . $ IsStreamStopped(dedf1e9b1c614a07)., IsStreamActivecxx . . $ IsStreamActive(dedf1e9b1c614a07)., |
| 819 | GetStreamTimecxx . . $ GetStreamTime(a405b17f82753acc)., PaUtil_DummyGetCpuLoadcxx . . $ PaUtil_DummyGetCpuLoad(a405b17f82753acc)., |
| 820 | BlockingReadStreamcxx . . $ BlockingReadStream(c5040b39c98d43dd)., BlockingWriteStreamcxx . . $ BlockingWriteStream(72e086fd9bc8337a)., |
| 821 | BlockingGetStreamReadAvailablecxx . . $ BlockingGetStreamReadAvailable(72c1818a5177f981)., BlockingGetStreamWriteAvailablecxx . . $ BlockingGetStreamWriteAvailable(72c1818a5177f981). ); |
| 822 | |
| 823 | jackHostApi->inputBasecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#inputBase. = jackHostApi->outputBasecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#outputBase. = 0; |
| 824 | jackHostApi->xruncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#xrun. = 0; |
| 825 | jackHostApi->toAddcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toAdd. = jackHostApi->toRemovecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toRemove. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 826 | jackHostApi->processQueuecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#processQueue. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 827 | jackHostApi->jackIsDowncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jackIsDown. = 0; |
| 828 | |
| 829 | jack_on_shutdowncxx . . $ jack_on_shutdown(6492f1605712de1e).( jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client., JackOnShutdowncxx . . $ JackOnShutdown(5d22bdacc48458e8)., jackHostApi ); |
| 830 | jack_set_error_functioncxx . . $ jack_set_error_function(2b5110216a8f8410).( JackErrorCallbackcxx . . $ JackErrorCallback(85c52e162fed56f9). ); |
| 831 | jackHostApi->jack_buffer_sizecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_buffer_size. = jack_get_buffer_sizecxx . . $ jack_get_buffer_size(c09b6173c6c1729d). ( jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. ); |
| 832 | /* Don't check for error, may not be supported (deprecated in at least jackdmp) */ |
| 833 | jack_set_sample_rate_callbackcxx . . $ jack_set_sample_rate_callback(9b34cebc75da25bd).( jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client., JackSrCbcxx . . $ JackSrCb(3a1320329ebf51c9)., jackHostApi ); |
| 834 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !jack_set_xrun_callback( jackHostApi->jack_client, JackXRunCb, jackHostApi ), paUnanticipatedHostError ); |
| 835 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !jack_set_process_callback( jackHostApi->jack_client, JackCallback, jackHostApi ), paUnanticipatedHostError ); |
| 836 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !jack_activate( jackHostApi->jack_client ), paUnanticipatedHostError ); |
| 837 | activated = 1; |
| 838 | |
| 839 | return result; |
| 840 | |
| 841 | error: |
| 842 | if( activated ) |
| 843 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( jack_deactivate( jackHostApi->jack_client ), 0 ); |
| 844 | |
| 845 | if( jackHostApi ) |
| 846 | { |
| 847 | if( jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. ) |
| 848 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( jack_client_close( jackHostApi->jack_client ), 0 ); |
| 849 | |
| 850 | if( jackHostApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory. ) |
| 851 | { |
| 852 | PaUtil_FreeAllAllocationscxx . . $ PaUtil_FreeAllAllocations(312b3fcc9bc2c5fe).( jackHostApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory. ); |
| 853 | PaUtil_DestroyAllocationGroupcxx . . $ PaUtil_DestroyAllocationGroup(312b3fcc9bc2c5fe).( jackHostApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory. ); |
| 854 | } |
| 855 | |
| 856 | PaUtil_FreeMemorycxx . . $ PaUtil_FreeMemory(5d22bdacc48458e8).( jackHostApi ); |
| 857 | } |
| 858 | return result; |
| 859 | } |
| 860 | |
| 861 | |
| 862 | static void Terminatecxx . . $ Terminate(79277cf7c6a25a16).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi ) |
| 863 | { |
| 864 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *jackHostApi = (PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation#*)hostApi; |
| 865 | |
| 866 | /* note: this automatically disconnects all ports, since a deactivated |
| 867 | * client is not allowed to have any ports connected */ |
| 868 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( jack_deactivate( jackHostApi->jack_client ), 0 ); |
| 869 | |
| 870 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_destroy( &jackHostApi->mtx ), 0 ); |
| 871 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_cond_destroy( &jackHostApi->cond ), 0 ); |
| 872 | |
| 873 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( jack_client_close( jackHostApi->jack_client ), 0 ); |
| 874 | |
| 875 | if( jackHostApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory. ) |
| 876 | { |
| 877 | PaUtil_FreeAllAllocationscxx . . $ PaUtil_FreeAllAllocations(312b3fcc9bc2c5fe).( jackHostApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory. ); |
| 878 | PaUtil_DestroyAllocationGroupcxx . . $ PaUtil_DestroyAllocationGroup(312b3fcc9bc2c5fe).( jackHostApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory. ); |
| 879 | } |
| 880 | |
| 881 | PaUtil_FreeMemorycxx . . $ PaUtil_FreeMemory(5d22bdacc48458e8).( jackHostApi ); |
| 882 | |
| 883 | freecxx . . $ free(5d22bdacc48458e8).( jackErr_cxx . . $ jackErr_. ); |
| 884 | jackErr_cxx . . $ jackErr_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 885 | } |
| 886 | |
| 887 | static PaErrorcxx . . $ PaError# IsFormatSupportedcxx . . $ IsFormatSupported(dbae6b543f13ee5).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, |
| 888 | const PaStreamParameterscxx . . $ PaStreamParameters# *inputParameters, |
| 889 | const PaStreamParameterscxx . . $ PaStreamParameters# *outputParameters, |
| 890 | double sampleRate ) |
| 891 | { |
| 892 | int inputChannelCount = 0, outputChannelCount = 0; |
| 893 | PaSampleFormatcxx . . $ PaSampleFormat# inputSampleFormat, outputSampleFormat; |
| 894 | |
| 895 | if( inputParameters ) |
| 896 | { |
| 897 | inputChannelCount = inputParameters->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 898 | inputSampleFormat = inputParameters->sampleFormatcxx . . $ PaStreamParameters#sampleFormat.; |
| 899 | |
| 900 | /* unless alternate device specification is supported, reject the use of |
| 901 | paUseHostApiSpecificDeviceSpecification */ |
| 902 | |
| 903 | if( inputParameters->devicecxx . . $ PaStreamParameters#device. == paUseHostApiSpecificDeviceSpecificationcxx . . $ `external/portaudio/portaudio.h:228:9`! ) |
| 904 | return paInvalidDevicecxx . . $ paInvalidDevice.; |
| 905 | |
| 906 | /* check that input device can support inputChannelCount */ |
| 907 | if( inputChannelCount > hostApi->deviceInfoscxx . . $ PaUtilHostApiRepresentation#deviceInfos.[ inputParameters->devicecxx . . $ PaStreamParameters#device. ]->maxInputChannelscxx . . $ PaDeviceInfo#maxInputChannels. ) |
| 908 | return paInvalidChannelCountcxx . . $ paInvalidChannelCount.; |
| 909 | |
| 910 | /* validate inputStreamInfo */ |
| 911 | if( inputParameters->hostApiSpecificStreamInfocxx . . $ PaStreamParameters#hostApiSpecificStreamInfo. ) |
| 912 | return paIncompatibleHostApiSpecificStreamInfocxx . . $ paIncompatibleHostApiSpecificStreamInfo.; /* this implementation doesn't use custom stream info */ |
| 913 | } |
| 914 | else |
| 915 | { |
| 916 | inputChannelCount = 0; |
| 917 | } |
| 918 | |
| 919 | if( outputParameters ) |
| 920 | { |
| 921 | outputChannelCount = outputParameters->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 922 | outputSampleFormat = outputParameters->sampleFormatcxx . . $ PaStreamParameters#sampleFormat.; |
| 923 | |
| 924 | /* unless alternate device specification is supported, reject the use of |
| 925 | paUseHostApiSpecificDeviceSpecification */ |
| 926 | |
| 927 | if( outputParameters->devicecxx . . $ PaStreamParameters#device. == paUseHostApiSpecificDeviceSpecificationcxx . . $ `external/portaudio/portaudio.h:228:9`! ) |
| 928 | return paInvalidDevicecxx . . $ paInvalidDevice.; |
| 929 | |
| 930 | /* check that output device can support inputChannelCount */ |
| 931 | if( outputChannelCount > hostApi->deviceInfoscxx . . $ PaUtilHostApiRepresentation#deviceInfos.[ outputParameters->devicecxx . . $ PaStreamParameters#device. ]->maxOutputChannelscxx . . $ PaDeviceInfo#maxOutputChannels. ) |
| 932 | return paInvalidChannelCountcxx . . $ paInvalidChannelCount.; |
| 933 | |
| 934 | /* validate outputStreamInfo */ |
| 935 | if( outputParameters->hostApiSpecificStreamInfocxx . . $ PaStreamParameters#hostApiSpecificStreamInfo. ) |
| 936 | return paIncompatibleHostApiSpecificStreamInfocxx . . $ paIncompatibleHostApiSpecificStreamInfo.; /* this implementation doesn't use custom stream info */ |
| 937 | } |
| 938 | else |
| 939 | { |
| 940 | outputChannelCount = 0; |
| 941 | } |
| 942 | |
| 943 | /* |
| 944 | The following check is not necessary for JACK. |
| 945 | |
| 946 | - if a full duplex stream is requested, check that the combination |
| 947 | of input and output parameters is supported |
| 948 | |
| 949 | |
| 950 | Because the buffer adapter handles conversion between all standard |
| 951 | sample formats, the following checks are only required if paCustomFormat |
| 952 | is implemented, or under some other unusual conditions. |
| 953 | |
| 954 | - check that input device can support inputSampleFormat, or that |
| 955 | we have the capability to convert from outputSampleFormat to |
| 956 | a native format |
| 957 | |
| 958 | - check that output device can support outputSampleFormat, or that |
| 959 | we have the capability to convert from outputSampleFormat to |
| 960 | a native format |
| 961 | */ |
| 962 | |
| 963 | /* check that the device supports sampleRate */ |
| 964 | |
| 965 | #define ABScxx . . $ `external/portaudio/pa_jack.c:965:9`!(x) ( (x) > 0 ? (x) : -(x) ) |
| 966 | if( ABScxx . . $ `external/portaudio/pa_jack.c:965:9`!(sampleRate - jack_get_sample_rate(((PaJackHostApiRepresentation *) hostApi)->jack_client )) > 1 ) |
| 967 | return paInvalidSampleRatecxx . . $ paInvalidSampleRate.; |
| 968 | #undef ABScxx . . $ `external/portaudio/pa_jack.c:965:9`! |
| 969 | |
| 970 | return paFormatIsSupportedcxx . . $ `external/portaudio/portaudio.h:585:9`!; |
| 971 | } |
| 972 | |
| 973 | /* Basic stream initialization */ |
| 974 | static PaErrorcxx . . $ PaError# InitializeStreamcxx . . $ InitializeStream(e46c0c0530cc1a5e).( PaJackStreamcxx . . $ PaJackStream# *stream, PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *hostApi, int numInputChannels, |
| 975 | int numOutputChannels ) |
| 976 | { |
| 977 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 978 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( stream ); |
| 979 | |
| 980 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( stream, 0, sizeof (PaJackStreamcxx . . $ PaJackStream#) ); |
| 981 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( stream->stream_memory = PaUtil_CreateAllocationGroup(), paInsufficientMemory ); |
| 982 | stream->jack_clientcxx . . $ PaJackStream#jack_client. = hostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client.; |
| 983 | stream->hostApicxx . . $ PaJackStream#hostApi. = hostApi; |
| 984 | |
| 985 | if( numInputChannels > 0 ) |
| 986 | { |
| 987 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( stream->local_input_ports = |
| 988 | (jack_port_t**) PaUtil_GroupAllocateMemory( stream->stream_memory, sizeof(jack_port_t*) * numInputChannels ), |
| 989 | paInsufficientMemory ); |
| 990 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( stream->local_input_portscxx . . $ PaJackStream#local_input_ports., 0, sizeof(jack_port_tcxx . . $ jack_port_t#*) * numInputChannels ); |
| 991 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( stream->remote_output_ports = |
| 992 | (jack_port_t**) PaUtil_GroupAllocateMemory( stream->stream_memory, sizeof(jack_port_t*) * numInputChannels ), |
| 993 | paInsufficientMemory ); |
| 994 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( stream->remote_output_portscxx . . $ PaJackStream#remote_output_ports., 0, sizeof(jack_port_tcxx . . $ jack_port_t#*) * numInputChannels ); |
| 995 | } |
| 996 | if( numOutputChannels > 0 ) |
| 997 | { |
| 998 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( stream->local_output_ports = |
| 999 | (jack_port_t**) PaUtil_GroupAllocateMemory( stream->stream_memory, sizeof(jack_port_t*) * numOutputChannels ), |
| 1000 | paInsufficientMemory ); |
| 1001 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( stream->local_output_portscxx . . $ PaJackStream#local_output_ports., 0, sizeof(jack_port_tcxx . . $ jack_port_t#*) * numOutputChannels ); |
| 1002 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( stream->remote_input_ports = |
| 1003 | (jack_port_t**) PaUtil_GroupAllocateMemory( stream->stream_memory, sizeof(jack_port_t*) * numOutputChannels ), |
| 1004 | paInsufficientMemory ); |
| 1005 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( stream->remote_input_portscxx . . $ PaJackStream#remote_input_ports., 0, sizeof(jack_port_tcxx . . $ jack_port_t#*) * numOutputChannels ); |
| 1006 | } |
| 1007 | |
| 1008 | stream->num_incoming_connectionscxx . . $ PaJackStream#num_incoming_connections. = numInputChannels; |
| 1009 | stream->num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections. = numOutputChannels; |
| 1010 | |
| 1011 | error: |
| 1012 | return result; |
| 1013 | } |
| 1014 | |
| 1015 | /*! |
| 1016 | * Free resources associated with stream, and eventually stream itself. |
| 1017 | * |
| 1018 | * Frees allocated memory, and closes opened pcms. |
| 1019 | */ |
| 1020 | static void CleanUpStreamcxx . . $ CleanUpStream(ed87b707dc22180d).( PaJackStreamcxx . . $ PaJackStream# *stream, int terminateStreamRepresentation, int terminateBufferProcessor ) |
| 1021 | { |
| 1022 | int i; |
| 1023 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( stream ); |
| 1024 | |
| 1025 | if( stream->isBlockingStreamcxx . . $ PaJackStream#isBlockingStream. ) |
| 1026 | BlockingEndcxx . . $ BlockingEnd(ece44e1ba60f6043).( stream ); |
| 1027 | |
| 1028 | for( i = 0; i < stream->num_incoming_connectionscxx . . $ PaJackStream#num_incoming_connections.; ++i ) |
| 1029 | { |
| 1030 | if( stream->local_input_portscxx . . $ PaJackStream#local_input_ports.[i] ) |
| 1031 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( jack_port_unregister( stream->jack_client, stream->local_input_ports[i] ), 0 ); |
| 1032 | } |
| 1033 | for( i = 0; i < stream->num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections.; ++i ) |
| 1034 | { |
| 1035 | if( stream->local_output_portscxx . . $ PaJackStream#local_output_ports.[i] ) |
| 1036 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( jack_port_unregister( stream->jack_client, stream->local_output_ports[i] ), 0 ); |
| 1037 | } |
| 1038 | |
| 1039 | if( terminateStreamRepresentation ) |
| 1040 | PaUtil_TerminateStreamRepresentationcxx . . $ PaUtil_TerminateStreamRepresentation(d99c7cce07513a60).( &stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation. ); |
| 1041 | if( terminateBufferProcessor ) |
| 1042 | PaUtil_TerminateBufferProcessorcxx . . $ PaUtil_TerminateBufferProcessor(ad694745b6b5e2b0).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor. ); |
| 1043 | |
| 1044 | if( stream->stream_memorycxx . . $ PaJackStream#stream_memory. ) |
| 1045 | { |
| 1046 | PaUtil_FreeAllAllocationscxx . . $ PaUtil_FreeAllAllocations(312b3fcc9bc2c5fe).( stream->stream_memorycxx . . $ PaJackStream#stream_memory. ); |
| 1047 | PaUtil_DestroyAllocationGroupcxx . . $ PaUtil_DestroyAllocationGroup(312b3fcc9bc2c5fe).( stream->stream_memorycxx . . $ PaJackStream#stream_memory. ); |
| 1048 | } |
| 1049 | PaUtil_FreeMemorycxx . . $ PaUtil_FreeMemory(5d22bdacc48458e8).( stream ); |
| 1050 | } |
| 1051 | |
| 1052 | static PaErrorcxx . . $ PaError# WaitConditioncxx . . $ WaitCondition(f6fafa200cd34369).( PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *hostApi ) |
| 1053 | { |
| 1054 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1055 | int err = 0; |
| 1056 | PaTimecxx . . $ PaTime# pt = PaUtil_GetTimecxx . . $ PaUtil_GetTime(31fa7155c10fdd13).(); |
| 1057 | struct timespeccxx . . $ timespec# ts; |
| 1058 | |
| 1059 | ts.tv_seccxx . . $ timespec#tv_sec. = (time_tcxx . . $ time_t#) floor( pt + 10 * 60 /* 10 minutes */ ); |
| 1060 | ts.tv_nseccxx . . $ timespec#tv_nsec. = (long) ((pt - floor( pt )) * 1000000000); |
| 1061 | /* XXX: Best enclose in loop, in case of spurious wakeups? */ |
| 1062 | err = pthread_cond_timedwaitcxx . . $ pthread_cond_timedwait(d8fcb9edac03ad51).( &hostApi->condcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#cond., &hostApi->mtxcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#mtx., &ts ); |
| 1063 | |
| 1064 | /* Make sure we didn't time out */ |
| 1065 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( err != ETIMEDOUTcxx . . $ `<external>/17922322188510340118/errno.h:94:9`!, paTimedOut ); |
| 1066 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !err, paInternalError ); |
| 1067 | |
| 1068 | error: |
| 1069 | return result; |
| 1070 | } |
| 1071 | |
| 1072 | static PaErrorcxx . . $ PaError# AddStreamcxx . . $ AddStream(9573670de253170f).( PaJackStreamcxx . . $ PaJackStream# *stream ) |
| 1073 | { |
| 1074 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1075 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *hostApi = stream->hostApicxx . . $ PaJackStream#hostApi.; |
| 1076 | /* Add to queue of streams that should be processed */ |
| 1077 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_lock( &hostApi->mtx ), 0 ); |
| 1078 | if( !hostApi->jackIsDowncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jackIsDown. ) |
| 1079 | { |
| 1080 | hostApi->toAddcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toAdd. = stream; |
| 1081 | /* Unlock mutex and await signal from processing thread */ |
| 1082 | result = WaitConditioncxx . . $ WaitCondition(f6fafa200cd34369).( stream->hostApicxx . . $ PaJackStream#hostApi. ); |
| 1083 | } |
| 1084 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_unlock( &hostApi->mtx ), 0 ); |
| 1085 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( result ); |
| 1086 | |
| 1087 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !hostApi->jackIsDown, paDeviceUnavailable ); |
| 1088 | |
| 1089 | error: |
| 1090 | return result; |
| 1091 | } |
| 1092 | |
| 1093 | /* Remove stream from processing queue */ |
| 1094 | static PaErrorcxx . . $ PaError# RemoveStreamcxx . . $ RemoveStream(9573670de253170f).( PaJackStreamcxx . . $ PaJackStream# *stream ) |
| 1095 | { |
| 1096 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1097 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *hostApi = stream->hostApicxx . . $ PaJackStream#hostApi.; |
| 1098 | |
| 1099 | /* Add to queue over streams that should be processed */ |
| 1100 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_lock( &hostApi->mtx ), 0 ); |
| 1101 | if( !hostApi->jackIsDowncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jackIsDown. ) |
| 1102 | { |
| 1103 | hostApi->toRemovecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toRemove. = stream; |
| 1104 | /* Unlock mutex and await signal from processing thread */ |
| 1105 | result = WaitConditioncxx . . $ WaitCondition(f6fafa200cd34369).( stream->hostApicxx . . $ PaJackStream#hostApi. ); |
| 1106 | } |
| 1107 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_unlock( &hostApi->mtx ), 0 ); |
| 1108 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( result ); |
| 1109 | |
| 1110 | error: |
| 1111 | return result; |
| 1112 | } |
| 1113 | |
| 1114 | /* Add stream to JACK callback processing queue */ |
| 1115 | static PaErrorcxx . . $ PaError# OpenStreamcxx . . $ OpenStream(dd932161c061c960).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, |
| 1116 | PaStreamcxx . . $ PaStream#** s, |
| 1117 | const PaStreamParameterscxx . . $ PaStreamParameters# *inputParameters, |
| 1118 | const PaStreamParameterscxx . . $ PaStreamParameters# *outputParameters, |
| 1119 | double sampleRate, |
| 1120 | unsigned long framesPerBuffer, |
| 1121 | PaStreamFlagscxx . . $ PaStreamFlags# streamFlags, |
| 1122 | PaStreamCallbackcxx . . $ PaStreamCallback# *streamCallback, |
| 1123 | void *userData ) |
| 1124 | { |
| 1125 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1126 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *jackHostApi = (PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation#*)hostApi; |
| 1127 | PaJackStreamcxx . . $ PaJackStream# *stream = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1128 | char *port_string = PaUtil_GroupAllocateMemorycxx . . $ PaUtil_GroupAllocateMemory(1657cd93bd8e98c5).( jackHostApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory., jack_port_name_sizecxx . . $ jack_port_name_size(b126dc7c1de90089).() ); |
| 1129 | // In the worst case every character would be escaped which would double the string length. |
| 1130 | // Add 1 for null terminator |
| 1131 | size_t regex_escaped_client_name_size = jack_client_name_sizecxx . . $ jack_client_name_size(b126dc7c1de90089).() * 2 + 1; |
| 1132 | unsigned long regex_size = regex_escaped_client_name_size + strlencxx . . $ strlen(751346f8406fd082).(port_regex_suffixcxx . . $ port_regex_suffix.); |
| 1133 | char *regex_pattern = PaUtil_GroupAllocateMemorycxx . . $ PaUtil_GroupAllocateMemory(1657cd93bd8e98c5).( jackHostApi->deviceInfoMemorycxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#deviceInfoMemory., regex_size ); |
| 1134 | const char **jack_ports = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1135 | /* int jack_max_buffer_size = jack_get_buffer_size( jackHostApi->jack_client ); */ |
| 1136 | int i; |
| 1137 | int inputChannelCount, outputChannelCount; |
| 1138 | const double jackSr = jack_get_sample_ratecxx . . $ jack_get_sample_rate(c09b6173c6c1729d).( jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. ); |
| 1139 | PaSampleFormatcxx . . $ PaSampleFormat# inputSampleFormat = 0, outputSampleFormat = 0; |
| 1140 | int bpInitialized = 0, srInitialized = 0; /* Initialized buffer processor and stream representation? */ |
| 1141 | unsigned long ofs; |
| 1142 | |
| 1143 | /* validate platform specific flags */ |
| 1144 | if( (streamFlags & paPlatformSpecificFlagscxx . . $ `external/portaudio/portaudio.h:690:11`!) != 0 ) |
| 1145 | return paInvalidFlagcxx . . $ paInvalidFlag.; /* unexpected platform specific flag */ |
| 1146 | if( (streamFlags & paPrimeOutputBuffersUsingStreamCallbackcxx . . $ `external/portaudio/portaudio.h:685:11`!) != 0 ) |
| 1147 | { |
| 1148 | streamFlags &= ~paPrimeOutputBuffersUsingStreamCallbackcxx . . $ `external/portaudio/portaudio.h:685:11`!; |
| 1149 | /*return paInvalidFlag;*/ /* This implementation does not support buffer priming */ |
| 1150 | } |
| 1151 | |
| 1152 | if( framesPerBuffer != paFramesPerBufferUnspecifiedcxx . . $ `external/portaudio/portaudio.h:642:9`! ) |
| 1153 | { |
| 1154 | /* Jack operates with power of two buffers, and we don't support non-integer buffer adaption (yet) */ |
| 1155 | /*UNLESS( !(framesPerBuffer & (framesPerBuffer - 1)), paBufferTooBig );*/ /* TODO: Add descriptive error code? */ |
| 1156 | } |
| 1157 | |
| 1158 | /* Preliminary checks */ |
| 1159 | |
| 1160 | if( inputParameters ) |
| 1161 | { |
| 1162 | inputChannelCount = inputParameters->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 1163 | inputSampleFormat = inputParameters->sampleFormatcxx . . $ PaStreamParameters#sampleFormat.; |
| 1164 | |
| 1165 | /* unless alternate device specification is supported, reject the use of |
| 1166 | paUseHostApiSpecificDeviceSpecification */ |
| 1167 | |
| 1168 | if( inputParameters->devicecxx . . $ PaStreamParameters#device. == paUseHostApiSpecificDeviceSpecificationcxx . . $ `external/portaudio/portaudio.h:228:9`! ) |
| 1169 | return paInvalidDevicecxx . . $ paInvalidDevice.; |
| 1170 | |
| 1171 | /* check that input device can support inputChannelCount */ |
| 1172 | if( inputChannelCount > hostApi->deviceInfoscxx . . $ PaUtilHostApiRepresentation#deviceInfos.[ inputParameters->devicecxx . . $ PaStreamParameters#device. ]->maxInputChannelscxx . . $ PaDeviceInfo#maxInputChannels. ) |
| 1173 | return paInvalidChannelCountcxx . . $ paInvalidChannelCount.; |
| 1174 | |
| 1175 | /* validate inputStreamInfo */ |
| 1176 | if( inputParameters->hostApiSpecificStreamInfocxx . . $ PaStreamParameters#hostApiSpecificStreamInfo. ) |
| 1177 | return paIncompatibleHostApiSpecificStreamInfocxx . . $ paIncompatibleHostApiSpecificStreamInfo.; /* this implementation doesn't use custom stream info */ |
| 1178 | } |
| 1179 | else |
| 1180 | { |
| 1181 | inputChannelCount = 0; |
| 1182 | } |
| 1183 | |
| 1184 | if( outputParameters ) |
| 1185 | { |
| 1186 | outputChannelCount = outputParameters->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 1187 | outputSampleFormat = outputParameters->sampleFormatcxx . . $ PaStreamParameters#sampleFormat.; |
| 1188 | |
| 1189 | /* unless alternate device specification is supported, reject the use of |
| 1190 | paUseHostApiSpecificDeviceSpecification */ |
| 1191 | |
| 1192 | if( outputParameters->devicecxx . . $ PaStreamParameters#device. == paUseHostApiSpecificDeviceSpecificationcxx . . $ `external/portaudio/portaudio.h:228:9`! ) |
| 1193 | return paInvalidDevicecxx . . $ paInvalidDevice.; |
| 1194 | |
| 1195 | /* check that output device can support inputChannelCount */ |
| 1196 | if( outputChannelCount > hostApi->deviceInfoscxx . . $ PaUtilHostApiRepresentation#deviceInfos.[ outputParameters->devicecxx . . $ PaStreamParameters#device. ]->maxOutputChannelscxx . . $ PaDeviceInfo#maxOutputChannels. ) |
| 1197 | return paInvalidChannelCountcxx . . $ paInvalidChannelCount.; |
| 1198 | |
| 1199 | /* validate outputStreamInfo */ |
| 1200 | if( outputParameters->hostApiSpecificStreamInfocxx . . $ PaStreamParameters#hostApiSpecificStreamInfo. ) |
| 1201 | return paIncompatibleHostApiSpecificStreamInfocxx . . $ paIncompatibleHostApiSpecificStreamInfo.; /* this implementation doesn't use custom stream info */ |
| 1202 | } |
| 1203 | else |
| 1204 | { |
| 1205 | outputChannelCount = 0; |
| 1206 | } |
| 1207 | |
| 1208 | /* ... check that the sample rate exactly matches the ONE acceptable rate |
| 1209 | * A: This rate isn't necessarily constant though? */ |
| 1210 | |
| 1211 | #define ABScxx . . $ `external/portaudio/pa_jack.c:1211:9`!(x) ( (x) > 0 ? (x) : -(x) ) |
| 1212 | if( ABScxx . . $ `external/portaudio/pa_jack.c:1211:9`!(sampleRate - jackSr) > 1 ) |
| 1213 | return paInvalidSampleRatecxx . . $ paInvalidSampleRate.; |
| 1214 | #undef ABScxx . . $ `external/portaudio/pa_jack.c:1211:9`! |
| 1215 | |
| 1216 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( stream = (PaJackStream*)PaUtil_AllocateMemory( sizeof(PaJackStream) ), paInsufficientMemory ); |
| 1217 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( InitializeStream( stream, jackHostApi, inputChannelCount, outputChannelCount ) ); |
| 1218 | |
| 1219 | /* the blocking emulation, if necessary */ |
| 1220 | stream->isBlockingStreamcxx . . $ PaJackStream#isBlockingStream. = !streamCallback; |
| 1221 | if( stream->isBlockingStreamcxx . . $ PaJackStream#isBlockingStream. ) |
| 1222 | { |
| 1223 | float latency = 0.001; /* 1ms is the absolute minimum we support */ |
| 1224 | int minimum_buffer_frames = 0; |
| 1225 | |
| 1226 | if( inputParameters && inputParameters->suggestedLatencycxx . . $ PaStreamParameters#suggestedLatency. > latency ) |
| 1227 | latency = inputParameters->suggestedLatencycxx . . $ PaStreamParameters#suggestedLatency.; |
| 1228 | else if( outputParameters && outputParameters->suggestedLatencycxx . . $ PaStreamParameters#suggestedLatency. > latency ) |
| 1229 | latency = outputParameters->suggestedLatencycxx . . $ PaStreamParameters#suggestedLatency.; |
| 1230 | |
| 1231 | /* the latency the user asked for indicates the minimum buffer size in frames */ |
| 1232 | minimum_buffer_frames = (int) (latency * jack_get_sample_ratecxx . . $ jack_get_sample_rate(c09b6173c6c1729d).( jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. )); |
| 1233 | |
| 1234 | /* we also need to be able to store at least three full jack buffers to avoid dropouts */ |
| 1235 | if( jackHostApi->jack_buffer_sizecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_buffer_size. * 3 > minimum_buffer_frames ) |
| 1236 | minimum_buffer_frames = jackHostApi->jack_buffer_sizecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_buffer_size. * 3; |
| 1237 | |
| 1238 | /* setup blocking API data structures (FIXME: can fail) */ |
| 1239 | BlockingBegincxx . . $ BlockingBegin(6179de1e636293a).( stream, minimum_buffer_frames ); |
| 1240 | |
| 1241 | /* install our own callback for the blocking API */ |
| 1242 | streamCallback = BlockingCallbackcxx . . $ BlockingCallback(fb4a53f6a51faeed).; |
| 1243 | userData = stream; |
| 1244 | |
| 1245 | PaUtil_InitializeStreamRepresentationcxx . . $ PaUtil_InitializeStreamRepresentation(7f7193855de7d48b).( &stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation., |
| 1246 | &jackHostApi->blockingStreamInterfacecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#blockingStreamInterface., streamCallback, userData ); |
| 1247 | } |
| 1248 | else |
| 1249 | { |
| 1250 | PaUtil_InitializeStreamRepresentationcxx . . $ PaUtil_InitializeStreamRepresentation(7f7193855de7d48b).( &stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation., |
| 1251 | &jackHostApi->callbackStreamInterfacecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#callbackStreamInterface., streamCallback, userData ); |
| 1252 | } |
| 1253 | srInitialized = 1; |
| 1254 | PaUtil_InitializeCpuLoadMeasurercxx . . $ PaUtil_InitializeCpuLoadMeasurer(dc72d8645bcc5215).( &stream->cpuLoadMeasurercxx . . $ PaJackStream#cpuLoadMeasurer., jackSr ); |
| 1255 | |
| 1256 | /* create the JACK ports. We cannot connect them until audio |
| 1257 | * processing begins */ |
| 1258 | |
| 1259 | /* Register a unique set of ports for this stream |
| 1260 | * TODO: Robust allocation of new port names */ |
| 1261 | |
| 1262 | ofs = jackHostApi->inputBasecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#inputBase.; |
| 1263 | for( i = 0; i < inputChannelCount; i++ ) |
| 1264 | { |
| 1265 | snprintfcxx . . $ snprintf(ea502d73e74c754c).( port_string, jack_port_name_sizecxx . . $ jack_port_name_size(b126dc7c1de90089).(), "in_%lu", ofs + i ); |
| 1266 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( stream->local_input_ports[i] = jack_port_register( |
| 1267 | jackHostApi->jack_client, port_string, |
| 1268 | JACK_DEFAULT_AUDIO_TYPEcxx . . $ `<external>/2838810560580927090/types.h:451:9`!, JackPortIsInput, 0 ), paInsufficientMemory ); |
| 1269 | } |
| 1270 | jackHostApi->inputBasecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#inputBase. += inputChannelCount; |
| 1271 | |
| 1272 | ofs = jackHostApi->outputBasecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#outputBase.; |
| 1273 | for( i = 0; i < outputChannelCount; i++ ) |
| 1274 | { |
| 1275 | snprintfcxx . . $ snprintf(ea502d73e74c754c).( port_string, jack_port_name_sizecxx . . $ jack_port_name_size(b126dc7c1de90089).(), "out_%lu", ofs + i ); |
| 1276 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( stream->local_output_ports[i] = jack_port_register( |
| 1277 | jackHostApi->jack_client, port_string, |
| 1278 | JACK_DEFAULT_AUDIO_TYPEcxx . . $ `<external>/2838810560580927090/types.h:451:9`!, JackPortIsOutput, 0 ), paInsufficientMemory ); |
| 1279 | } |
| 1280 | jackHostApi->outputBasecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#outputBase. += outputChannelCount; |
| 1281 | |
| 1282 | /* look up the jack_port_t's for the remote ports. We could do |
| 1283 | * this at stream start time, but doing it here ensures the |
| 1284 | * name lookup only happens once. */ |
| 1285 | |
| 1286 | if( inputChannelCount > 0 ) |
| 1287 | { |
| 1288 | int err = 0; |
| 1289 | |
| 1290 | /* Get output ports of our capture device */ |
| 1291 | copy_string_and_escape_regex_charscxx . . $ copy_string_and_escape_regex_chars(584917e90c1c156b).( regex_pattern, |
| 1292 | hostApi->deviceInfoscxx . . $ PaUtilHostApiRepresentation#deviceInfos.[ inputParameters->devicecxx . . $ PaStreamParameters#device. ]->namecxx . . $ PaDeviceInfo#name., |
| 1293 | regex_escaped_client_name_size ); |
| 1294 | strncatcxx . . $ strncat(255158a415b673b0).( regex_pattern, port_regex_suffixcxx . . $ port_regex_suffix., regex_size ); |
| 1295 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( jack_ports = jack_get_ports( jackHostApi->jack_client, regex_pattern, |
| 1296 | JACK_PORT_TYPE_FILTERcxx . . $ `external/portaudio/pa_jack.c:241:9`!, JackPortIsOutput ), paUnanticipatedHostError ); |
| 1297 | for( i = 0; i < inputChannelCount && jack_ports[i]; i++ ) |
| 1298 | { |
| 1299 | if( (stream->remote_output_portscxx . . $ PaJackStream#remote_output_ports.[i] = jack_port_by_namecxx . . $ jack_port_by_name(4f48ea04666fdaa3).( |
| 1300 | jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client., jack_ports[i] )) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 1301 | { |
| 1302 | err = 1; |
| 1303 | break; |
| 1304 | } |
| 1305 | } |
| 1306 | freecxx . . $ free(5d22bdacc48458e8).( jack_ports ); |
| 1307 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !err, paInsufficientMemory ); |
| 1308 | |
| 1309 | /* Fewer ports than expected? */ |
| 1310 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( i == inputChannelCount, paInternalError ); |
| 1311 | } |
| 1312 | |
| 1313 | if( outputChannelCount > 0 ) |
| 1314 | { |
| 1315 | int err = 0; |
| 1316 | |
| 1317 | /* Get input ports of our playback device */ |
| 1318 | copy_string_and_escape_regex_charscxx . . $ copy_string_and_escape_regex_chars(584917e90c1c156b).( regex_pattern, |
| 1319 | hostApi->deviceInfoscxx . . $ PaUtilHostApiRepresentation#deviceInfos.[ outputParameters->devicecxx . . $ PaStreamParameters#device. ]->namecxx . . $ PaDeviceInfo#name., |
| 1320 | regex_escaped_client_name_size ); |
| 1321 | strncatcxx . . $ strncat(255158a415b673b0).( regex_pattern, port_regex_suffixcxx . . $ port_regex_suffix., regex_size ); |
| 1322 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( jack_ports = jack_get_ports( jackHostApi->jack_client, regex_pattern, |
| 1323 | JACK_PORT_TYPE_FILTERcxx . . $ `external/portaudio/pa_jack.c:241:9`!, JackPortIsInput ), paUnanticipatedHostError ); |
| 1324 | for( i = 0; i < outputChannelCount && jack_ports[i]; i++ ) |
| 1325 | { |
| 1326 | if( (stream->remote_input_portscxx . . $ PaJackStream#remote_input_ports.[i] = jack_port_by_namecxx . . $ jack_port_by_name(4f48ea04666fdaa3).( |
| 1327 | jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client., jack_ports[i] )) == 0 ) |
| 1328 | { |
| 1329 | err = 1; |
| 1330 | break; |
| 1331 | } |
| 1332 | } |
| 1333 | freecxx . . $ free(5d22bdacc48458e8).( jack_ports ); |
| 1334 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !err , paInsufficientMemory ); |
| 1335 | |
| 1336 | /* Fewer ports than expected? */ |
| 1337 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( i == outputChannelCount, paInternalError ); |
| 1338 | } |
| 1339 | |
| 1340 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( PaUtil_InitializeBufferProcessor( |
| 1341 | &stream->bufferProcessor, |
| 1342 | inputChannelCount, |
| 1343 | inputSampleFormat, |
| 1344 | paFloat32cxx . . $ `external/portaudio/portaudio.h:487:9`! | paNonInterleavedcxx . . $ `external/portaudio/portaudio.h:495:9`!, /* hostInputSampleFormat */ |
| 1345 | outputChannelCount, |
| 1346 | outputSampleFormat, |
| 1347 | paFloat32cxx . . $ `external/portaudio/portaudio.h:487:9`! | paNonInterleavedcxx . . $ `external/portaudio/portaudio.h:495:9`!, /* hostOutputSampleFormat */ |
| 1348 | jackSr, |
| 1349 | streamFlags, |
| 1350 | framesPerBuffer, |
| 1351 | 0, /* Ignored */ |
| 1352 | paUtilUnknownHostBufferSize, /* Buffer size may vary on JACK's discretion */ |
| 1353 | streamCallback, |
| 1354 | userData ) ); |
| 1355 | bpInitialized = 1; |
| 1356 | |
| 1357 | if( stream->num_incoming_connectionscxx . . $ PaJackStream#num_incoming_connections. > 0 ) |
| 1358 | stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..inputLatencycxx . . $ PaStreamInfo#inputLatency. = (jack_port_get_latencycxx . . $ jack_port_get_latency(d53b401d5aad02b0).( stream->remote_output_portscxx . . $ PaJackStream#remote_output_ports.[0] ) |
| 1359 | - jack_get_buffer_sizecxx . . $ jack_get_buffer_size(c09b6173c6c1729d).( jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. ) /* One buffer is not counted as latency */ |
| 1360 | + PaUtil_GetBufferProcessorInputLatencyFramescxx . . $ PaUtil_GetBufferProcessorInputLatencyFrames(a5da02a3b0f2cced).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor. )) / sampleRate; |
| 1361 | if( stream->num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections. > 0 ) |
| 1362 | stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..outputLatencycxx . . $ PaStreamInfo#outputLatency. = (jack_port_get_latencycxx . . $ jack_port_get_latency(d53b401d5aad02b0).( stream->remote_input_portscxx . . $ PaJackStream#remote_input_ports.[0] ) |
| 1363 | - jack_get_buffer_sizecxx . . $ jack_get_buffer_size(c09b6173c6c1729d).( jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. ) /* One buffer is not counted as latency */ |
| 1364 | + PaUtil_GetBufferProcessorOutputLatencyFramescxx . . $ PaUtil_GetBufferProcessorOutputLatencyFrames(a5da02a3b0f2cced).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor. )) / sampleRate; |
| 1365 | |
| 1366 | stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..sampleRatecxx . . $ PaStreamInfo#sampleRate. = jackSr; |
| 1367 | stream->t0cxx . . $ PaJackStream#t0. = jack_frame_timecxx . . $ jack_frame_time(2de41c207249b5fd).( jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. ); /* A: Time should run from Pa_OpenStream */ |
| 1368 | |
| 1369 | /* Add to queue of opened streams */ |
| 1370 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( AddStream( stream ) ); |
| 1371 | |
| 1372 | *s = (PaStreamcxx . . $ PaStream#*)stream; |
| 1373 | |
| 1374 | return result; |
| 1375 | |
| 1376 | error: |
| 1377 | if( stream ) |
| 1378 | CleanUpStreamcxx . . $ CleanUpStream(ed87b707dc22180d).( stream, srInitialized, bpInitialized ); |
| 1379 | |
| 1380 | return result; |
| 1381 | } |
| 1382 | |
| 1383 | /* |
| 1384 | When CloseStream() is called, the multi-api layer ensures that |
| 1385 | the stream has already been stopped or aborted. |
| 1386 | */ |
| 1387 | static PaErrorcxx . . $ PaError# CloseStreamcxx . . $ CloseStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream#* s ) |
| 1388 | { |
| 1389 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1390 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream#*)s; |
| 1391 | |
| 1392 | /* Remove this stream from the processing queue */ |
| 1393 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( RemoveStream( stream ) ); |
| 1394 | |
| 1395 | error: |
| 1396 | CleanUpStreamcxx . . $ CleanUpStream(ed87b707dc22180d).( stream, 1, 1 ); |
| 1397 | return result; |
| 1398 | } |
| 1399 | |
| 1400 | static PaErrorcxx . . $ PaError# RealProcesscxx . . $ RealProcess(9bdc92ff4bb8c8f3).( PaJackStreamcxx . . $ PaJackStream# *stream, jack_nframes_tcxx . . $ jack_nframes_t# frames ) |
| 1401 | { |
| 1402 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1403 | PaStreamCallbackTimeInfocxx . . $ PaStreamCallbackTimeInfo# timeInfo = {0,0,0}; |
| 1404 | int chn; |
| 1405 | int framesProcessed; |
| 1406 | const double sr = jack_get_sample_ratecxx . . $ jack_get_sample_rate(c09b6173c6c1729d).( stream->jack_clientcxx . . $ PaJackStream#jack_client. ); /* Shouldn't change during the process callback */ |
| 1407 | PaStreamCallbackFlagscxx . . $ PaStreamCallbackFlags# cbFlags = 0; |
| 1408 | |
| 1409 | /* If the user has returned !paContinue from the callback we'll want to flush the internal buffers, |
| 1410 | * when these are empty we can finally mark the stream as inactive */ |
| 1411 | if( stream->callbackResultcxx . . $ PaJackStream#callbackResult. != paContinuecxx . . $ paContinue. && |
| 1412 | PaUtil_IsBufferProcessorOutputEmptycxx . . $ PaUtil_IsBufferProcessorOutputEmpty(46b4b6bccb6a2631).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor. ) ) |
| 1413 | { |
| 1414 | stream->is_activecxx . . $ PaJackStream#is_active. = 0; |
| 1415 | if( stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation..streamFinishedCallbackcxx . . $ PaUtilStreamRepresentation#streamFinishedCallback. ) |
| 1416 | stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation..streamFinishedCallbackcxx . . $ PaUtilStreamRepresentation#streamFinishedCallback.( stream->streamRepresentationcxx . . $ PaJackStream#streamRepresentation..userDatacxx . . $ PaUtilStreamRepresentation#userData. ); |
| 1417 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Callback finished\n", __FUNCTION__ )); |
| 1418 | |
| 1419 | goto end; |
| 1420 | } |
| 1421 | |
| 1422 | timeInfo.currentTimecxx . . $ PaStreamCallbackTimeInfo#currentTime. = (jack_frame_timecxx . . $ jack_frame_time(2de41c207249b5fd).( stream->jack_clientcxx . . $ PaJackStream#jack_client. ) - stream->t0cxx . . $ PaJackStream#t0.) / sr; |
| 1423 | if( stream->num_incoming_connectionscxx . . $ PaJackStream#num_incoming_connections. > 0 ) |
| 1424 | timeInfo.inputBufferAdcTimecxx . . $ PaStreamCallbackTimeInfo#inputBufferAdcTime. = timeInfo.currentTimecxx . . $ PaStreamCallbackTimeInfo#currentTime. - jack_port_get_latencycxx . . $ jack_port_get_latency(d53b401d5aad02b0).( stream->remote_output_portscxx . . $ PaJackStream#remote_output_ports.[0] ) |
| 1425 | / sr; |
| 1426 | if( stream->num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections. > 0 ) |
| 1427 | timeInfo.outputBufferDacTimecxx . . $ PaStreamCallbackTimeInfo#outputBufferDacTime. = timeInfo.currentTimecxx . . $ PaStreamCallbackTimeInfo#currentTime. + jack_port_get_latencycxx . . $ jack_port_get_latency(d53b401d5aad02b0).( stream->remote_input_portscxx . . $ PaJackStream#remote_input_ports.[0] ) |
| 1428 | / sr; |
| 1429 | |
| 1430 | PaUtil_BeginCpuLoadMeasurementcxx . . $ PaUtil_BeginCpuLoadMeasurement(798ecf6f58992a18).( &stream->cpuLoadMeasurercxx . . $ PaJackStream#cpuLoadMeasurer. ); |
| 1431 | |
| 1432 | if( stream->xruncxx . . $ PaJackStream#xrun. ) |
| 1433 | { |
| 1434 | /* XXX: Any way to tell which of these occurred? */ |
| 1435 | cbFlags = paOutputUnderflowcxx . . $ `external/portaudio/portaudio.h:736:9`! | paInputOverflowcxx . . $ `external/portaudio/portaudio.h:730:9`!; |
| 1436 | stream->xruncxx . . $ PaJackStream#xrun. = FALSEcxx . . $ `external/portaudio/pa_jack.c:244:9`!; |
| 1437 | } |
| 1438 | PaUtil_BeginBufferProcessingcxx . . $ PaUtil_BeginBufferProcessing(df016153b88db4c).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor., &timeInfo, |
| 1439 | cbFlags ); |
| 1440 | |
| 1441 | if( stream->num_incoming_connectionscxx . . $ PaJackStream#num_incoming_connections. > 0 ) |
| 1442 | PaUtil_SetInputFrameCountcxx . . $ PaUtil_SetInputFrameCount(e404da6267a95ab).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor., frames ); |
| 1443 | if( stream->num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections. > 0 ) |
| 1444 | PaUtil_SetOutputFrameCountcxx . . $ PaUtil_SetOutputFrameCount(e404da6267a95ab).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor., frames ); |
| 1445 | |
| 1446 | for( chn = 0; chn < stream->num_incoming_connectionscxx . . $ PaJackStream#num_incoming_connections.; chn++ ) |
| 1447 | { |
| 1448 | jack_default_audio_sample_tcxx . . $ jack_default_audio_sample_t# *channel_buf = (jack_default_audio_sample_tcxx . . $ jack_default_audio_sample_t#*) |
| 1449 | jack_port_get_buffercxx . . $ jack_port_get_buffer(6fb2e47f084ecda1).( stream->local_input_portscxx . . $ PaJackStream#local_input_ports.[chn], |
| 1450 | frames ); |
| 1451 | |
| 1452 | PaUtil_SetNonInterleavedInputChannelcxx . . $ PaUtil_SetNonInterleavedInputChannel(ee6c92664ebd5de5).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor., |
| 1453 | chn, |
| 1454 | channel_buf ); |
| 1455 | } |
| 1456 | |
| 1457 | for( chn = 0; chn < stream->num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections.; chn++ ) |
| 1458 | { |
| 1459 | jack_default_audio_sample_tcxx . . $ jack_default_audio_sample_t# *channel_buf = (jack_default_audio_sample_tcxx . . $ jack_default_audio_sample_t#*) |
| 1460 | jack_port_get_buffercxx . . $ jack_port_get_buffer(6fb2e47f084ecda1).( stream->local_output_portscxx . . $ PaJackStream#local_output_ports.[chn], |
| 1461 | frames ); |
| 1462 | |
| 1463 | PaUtil_SetNonInterleavedOutputChannelcxx . . $ PaUtil_SetNonInterleavedOutputChannel(ee6c92664ebd5de5).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor., |
| 1464 | chn, |
| 1465 | channel_buf ); |
| 1466 | } |
| 1467 | |
| 1468 | framesProcessed = PaUtil_EndBufferProcessingcxx . . $ PaUtil_EndBufferProcessing(fd3913764679277b).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor., |
| 1469 | &stream->callbackResultcxx . . $ PaJackStream#callbackResult. ); |
| 1470 | /* We've specified a host buffer size mode where every frame should be consumed by the buffer processor */ |
| 1471 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( framesProcessed == frames ); |
| 1472 | |
| 1473 | PaUtil_EndCpuLoadMeasurementcxx . . $ PaUtil_EndCpuLoadMeasurement(394649c2147554a2).( &stream->cpuLoadMeasurercxx . . $ PaJackStream#cpuLoadMeasurer., framesProcessed ); |
| 1474 | |
| 1475 | end: |
| 1476 | return result; |
| 1477 | } |
| 1478 | |
| 1479 | /* Update the JACK callback's stream processing queue. */ |
| 1480 | static PaErrorcxx . . $ PaError# UpdateQueuecxx . . $ UpdateQueue(f6fafa200cd34369).( PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *hostApi ) |
| 1481 | { |
| 1482 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1483 | int queueModified = 0; |
| 1484 | const double jackSr = jack_get_sample_ratecxx . . $ jack_get_sample_rate(c09b6173c6c1729d).( hostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. ); |
| 1485 | int err; |
| 1486 | |
| 1487 | if( (err = pthread_mutex_trylockcxx . . $ pthread_mutex_trylock(d89ae235521888f9).( &hostApi->mtxcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#mtx. )) != 0 ) |
| 1488 | { |
| 1489 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( err == EBUSYcxx . . $ `<external>/8987895939074593727/errno-base.h:20:9`! ); |
| 1490 | return paNoErrorcxx . . $ paNoError.; |
| 1491 | } |
| 1492 | |
| 1493 | if( hostApi->toAddcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toAdd. ) |
| 1494 | { |
| 1495 | if( hostApi->processQueuecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#processQueue. ) |
| 1496 | { |
| 1497 | PaJackStreamcxx . . $ PaJackStream# *node = hostApi->processQueuecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#processQueue.; |
| 1498 | /* Advance to end of queue */ |
| 1499 | while( node->nextcxx . . $ PaJackStream#next. ) |
| 1500 | node = node->nextcxx . . $ PaJackStream#next.; |
| 1501 | |
| 1502 | node->nextcxx . . $ PaJackStream#next. = hostApi->toAddcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toAdd.; |
| 1503 | } |
| 1504 | else |
| 1505 | { |
| 1506 | /* The only queue entry. */ |
| 1507 | hostApi->processQueuecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#processQueue. = (PaJackStreamcxx . . $ PaJackStream# *)hostApi->toAddcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toAdd.; |
| 1508 | } |
| 1509 | |
| 1510 | /* If necessary, update stream state */ |
| 1511 | if( hostApi->toAddcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toAdd.->streamRepresentationcxx . . $ PaJackStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..sampleRatecxx . . $ PaStreamInfo#sampleRate. != jackSr ) |
| 1512 | UpdateSampleRatecxx . . $ UpdateSampleRate(a14b1df557c35d95).( hostApi->toAddcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toAdd., jackSr ); |
| 1513 | |
| 1514 | hostApi->toAddcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toAdd. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1515 | queueModified = 1; |
| 1516 | } |
| 1517 | if( hostApi->toRemovecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toRemove. ) |
| 1518 | { |
| 1519 | int removed = 0; |
| 1520 | PaJackStreamcxx . . $ PaJackStream# *node = hostApi->processQueuecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#processQueue., *prev = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1521 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( hostApi->processQueue ); |
| 1522 | |
| 1523 | while( node ) |
| 1524 | { |
| 1525 | if( node == hostApi->toRemovecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toRemove. ) |
| 1526 | { |
| 1527 | if( prev ) |
| 1528 | prev->nextcxx . . $ PaJackStream#next. = node->nextcxx . . $ PaJackStream#next.; |
| 1529 | else |
| 1530 | hostApi->processQueuecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#processQueue. = (PaJackStreamcxx . . $ PaJackStream# *)node->nextcxx . . $ PaJackStream#next.; |
| 1531 | |
| 1532 | removed = 1; |
| 1533 | break; |
| 1534 | } |
| 1535 | |
| 1536 | prev = node; |
| 1537 | node = node->nextcxx . . $ PaJackStream#next.; |
| 1538 | } |
| 1539 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( removed, paInternalError ); |
| 1540 | hostApi->toRemovecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#toRemove. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1541 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Removed stream from processing queue\n", __FUNCTION__ )); |
| 1542 | queueModified = 1; |
| 1543 | } |
| 1544 | |
| 1545 | if( queueModified ) |
| 1546 | { |
| 1547 | /* Signal that we've done what was asked of us */ |
| 1548 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_cond_signal( &hostApi->cond ), 0 ); |
| 1549 | } |
| 1550 | |
| 1551 | error: |
| 1552 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_unlock( &hostApi->mtx ), 0 ); |
| 1553 | |
| 1554 | return result; |
| 1555 | } |
| 1556 | |
| 1557 | /* Audio processing callback invoked periodically from JACK. */ |
| 1558 | static int JackCallbackcxx . . $ JackCallback(3a1320329ebf51c9).( jack_nframes_tcxx . . $ jack_nframes_t# frames, void *userData ) |
| 1559 | { |
| 1560 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1561 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *hostApi = (PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation# *)userData; |
| 1562 | PaJackStreamcxx . . $ PaJackStream# *stream = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1563 | int xrun = hostApi->xruncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#xrun.; |
| 1564 | hostApi->xruncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#xrun. = 0; |
| 1565 | |
| 1566 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( hostApi ); |
| 1567 | |
| 1568 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( UpdateQueue( hostApi ) ); |
| 1569 | |
| 1570 | /* Process each stream */ |
| 1571 | stream = hostApi->processQueuecxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#processQueue.; |
| 1572 | for( ; stream; stream = stream->nextcxx . . $ PaJackStream#next. ) |
| 1573 | { |
| 1574 | if( xrun ) /* Don't override if already set */ |
| 1575 | stream->xruncxx . . $ PaJackStream#xrun. = 1; |
| 1576 | |
| 1577 | /* See if this stream is to be started */ |
| 1578 | if( stream->doStartcxx . . $ PaJackStream#doStart. ) |
| 1579 | { |
| 1580 | /* If we can't obtain a lock, we'll try next time */ |
| 1581 | int err = pthread_mutex_trylockcxx . . $ pthread_mutex_trylock(d89ae235521888f9).( &stream->hostApicxx . . $ PaJackStream#hostApi.->mtxcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#mtx. ); |
| 1582 | if( !err ) |
| 1583 | { |
| 1584 | if( stream->doStartcxx . . $ PaJackStream#doStart. ) /* Could potentially change before obtaining the lock */ |
| 1585 | { |
| 1586 | stream->is_activecxx . . $ PaJackStream#is_active. = 1; |
| 1587 | stream->doStartcxx . . $ PaJackStream#doStart. = 0; |
| 1588 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Starting stream\n", __FUNCTION__ )); |
| 1589 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_cond_signal( &stream->hostApi->cond ), 0 ); |
| 1590 | stream->callbackResultcxx . . $ PaJackStream#callbackResult. = paContinuecxx . . $ paContinue.; |
| 1591 | stream->isSilencedcxx . . $ PaJackStream#isSilenced. = 0; |
| 1592 | } |
| 1593 | |
| 1594 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_unlock( &stream->hostApi->mtx ), 0 ); |
| 1595 | } |
| 1596 | else |
| 1597 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( err == EBUSYcxx . . $ `<external>/8987895939074593727/errno-base.h:20:9`! ); |
| 1598 | } |
| 1599 | else if( stream->doStopcxx . . $ PaJackStream#doStop. || stream->doAbortcxx . . $ PaJackStream#doAbort. ) /* Should we stop/abort stream? */ |
| 1600 | { |
| 1601 | if( stream->callbackResultcxx . . $ PaJackStream#callbackResult. == paContinuecxx . . $ paContinue. ) /* Ok, make it stop */ |
| 1602 | { |
| 1603 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Stopping stream\n", __FUNCTION__ )); |
| 1604 | stream->callbackResultcxx . . $ PaJackStream#callbackResult. = stream->doStopcxx . . $ PaJackStream#doStop. ? paCompletecxx . . $ paComplete. : paAbortcxx . . $ paAbort.; |
| 1605 | } |
| 1606 | } |
| 1607 | |
| 1608 | if( stream->is_activecxx . . $ PaJackStream#is_active. ) |
| 1609 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( RealProcess( stream, frames ) ); |
| 1610 | /* If we have just entered inactive state, silence output */ |
| 1611 | if( !stream->is_activecxx . . $ PaJackStream#is_active. && !stream->isSilencedcxx . . $ PaJackStream#isSilenced. ) |
| 1612 | { |
| 1613 | int i; |
| 1614 | |
| 1615 | /* Silence buffer after entering inactive state */ |
| 1616 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "Silencing the output\n" )); |
| 1617 | for( i = 0; i < stream->num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections.; ++i ) |
| 1618 | { |
| 1619 | jack_default_audio_sample_tcxx . . $ jack_default_audio_sample_t# *buffer = jack_port_get_buffercxx . . $ jack_port_get_buffer(6fb2e47f084ecda1).( stream->local_output_portscxx . . $ PaJackStream#local_output_ports.[i], frames ); |
| 1620 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( buffer, 0, sizeof (jack_default_audio_sample_tcxx . . $ jack_default_audio_sample_t#) * frames ); |
| 1621 | } |
| 1622 | |
| 1623 | stream->isSilencedcxx . . $ PaJackStream#isSilenced. = 1; |
| 1624 | } |
| 1625 | |
| 1626 | if( stream->doStopcxx . . $ PaJackStream#doStop. || stream->doAbortcxx . . $ PaJackStream#doAbort. ) |
| 1627 | { |
| 1628 | /* See if RealProcess has acted on the request */ |
| 1629 | if( !stream->is_activecxx . . $ PaJackStream#is_active. ) /* Ok, signal to the main thread that we've carried out the operation */ |
| 1630 | { |
| 1631 | /* If we can't obtain a lock, we'll try next time */ |
| 1632 | int err = pthread_mutex_trylockcxx . . $ pthread_mutex_trylock(d89ae235521888f9).( &stream->hostApicxx . . $ PaJackStream#hostApi.->mtxcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#mtx. ); |
| 1633 | if( !err ) |
| 1634 | { |
| 1635 | stream->doStopcxx . . $ PaJackStream#doStop. = stream->doAbortcxx . . $ PaJackStream#doAbort. = 0; |
| 1636 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_cond_signal( &stream->hostApi->cond ), 0 ); |
| 1637 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_unlock( &stream->hostApi->mtx ), 0 ); |
| 1638 | } |
| 1639 | else |
| 1640 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( err == EBUSYcxx . . $ `<external>/8987895939074593727/errno-base.h:20:9`! ); |
| 1641 | } |
| 1642 | } |
| 1643 | } |
| 1644 | |
| 1645 | return 0; |
| 1646 | error: |
| 1647 | return -1; |
| 1648 | } |
| 1649 | |
| 1650 | static PaErrorcxx . . $ PaError# StartStreamcxx . . $ StartStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 1651 | { |
| 1652 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1653 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream#*)s; |
| 1654 | int i; |
| 1655 | |
| 1656 | /* Ready the processor */ |
| 1657 | PaUtil_ResetBufferProcessorcxx . . $ PaUtil_ResetBufferProcessor(ad694745b6b5e2b0).( &stream->bufferProcessorcxx . . $ PaJackStream#bufferProcessor. ); |
| 1658 | |
| 1659 | /* Connect the ports. Note that the ports may already have been connected by someone else in |
| 1660 | * the meantime, in which case JACK returns EEXIST. */ |
| 1661 | |
| 1662 | if( stream->num_incoming_connectionscxx . . $ PaJackStream#num_incoming_connections. > 0 ) |
| 1663 | { |
| 1664 | for( i = 0; i < stream->num_incoming_connectionscxx . . $ PaJackStream#num_incoming_connections.; i++ ) |
| 1665 | { |
| 1666 | int r = jack_connectcxx . . $ jack_connect(ee4d906ff0109cc5).( stream->jack_clientcxx . . $ PaJackStream#jack_client., jack_port_namecxx . . $ jack_port_name(112a8335a6f5b10a).( stream->remote_output_portscxx . . $ PaJackStream#remote_output_ports.[i] ), |
| 1667 | jack_port_namecxx . . $ jack_port_name(112a8335a6f5b10a).( stream->local_input_portscxx . . $ PaJackStream#local_input_ports.[i] ) ); |
| 1668 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( 0 == r || EEXISTcxx . . $ `<external>/8987895939074593727/errno-base.h:21:9`! == r, paUnanticipatedHostError ); |
| 1669 | } |
| 1670 | } |
| 1671 | |
| 1672 | if( stream->num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections. > 0 ) |
| 1673 | { |
| 1674 | for( i = 0; i < stream->num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections.; i++ ) |
| 1675 | { |
| 1676 | int r = jack_connectcxx . . $ jack_connect(ee4d906ff0109cc5).( stream->jack_clientcxx . . $ PaJackStream#jack_client., jack_port_namecxx . . $ jack_port_name(112a8335a6f5b10a).( stream->local_output_portscxx . . $ PaJackStream#local_output_ports.[i] ), |
| 1677 | jack_port_namecxx . . $ jack_port_name(112a8335a6f5b10a).( stream->remote_input_portscxx . . $ PaJackStream#remote_input_ports.[i] ) ); |
| 1678 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( 0 == r || EEXISTcxx . . $ `<external>/8987895939074593727/errno-base.h:21:9`! == r, paUnanticipatedHostError ); |
| 1679 | } |
| 1680 | } |
| 1681 | |
| 1682 | stream->xruncxx . . $ PaJackStream#xrun. = FALSEcxx . . $ `external/portaudio/pa_jack.c:244:9`!; |
| 1683 | |
| 1684 | /* Enable processing */ |
| 1685 | |
| 1686 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_lock( &stream->hostApi->mtx ), 0 ); |
| 1687 | stream->doStartcxx . . $ PaJackStream#doStart. = 1; |
| 1688 | |
| 1689 | /* Wait for stream to be started */ |
| 1690 | result = WaitConditioncxx . . $ WaitCondition(f6fafa200cd34369).( stream->hostApicxx . . $ PaJackStream#hostApi. ); |
| 1691 | /* |
| 1692 | do |
| 1693 | { |
| 1694 | err = pthread_cond_timedwait( &stream->hostApi->cond, &stream->hostApi->mtx, &ts ); |
| 1695 | } while( !stream->is_active && !err ); |
| 1696 | */ |
| 1697 | if( result != paNoErrorcxx . . $ paNoError. ) /* Something went wrong, call off the stream start */ |
| 1698 | { |
| 1699 | stream->doStartcxx . . $ PaJackStream#doStart. = 0; |
| 1700 | stream->is_activecxx . . $ PaJackStream#is_active. = 0; /* Cancel any processing */ |
| 1701 | } |
| 1702 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_unlock( &stream->hostApi->mtx ), 0 ); |
| 1703 | |
| 1704 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( result ); |
| 1705 | |
| 1706 | stream->is_runningcxx . . $ PaJackStream#is_running. = TRUEcxx . . $ `external/portaudio/pa_jack.c:243:9`!; |
| 1707 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Stream started\n", __FUNCTION__ )); |
| 1708 | |
| 1709 | error: |
| 1710 | return result; |
| 1711 | } |
| 1712 | |
| 1713 | static PaErrorcxx . . $ PaError# RealStopcxx . . $ RealStop(6179de1e636293a).( PaJackStreamcxx . . $ PaJackStream# *stream, int abort ) |
| 1714 | { |
| 1715 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1716 | int i; |
| 1717 | |
| 1718 | if( stream->isBlockingStreamcxx . . $ PaJackStream#isBlockingStream. ) |
| 1719 | BlockingWaitEmptycxx . . $ BlockingWaitEmpty(dedf1e9b1c614a07). ( stream ); |
| 1720 | |
| 1721 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_lock( &stream->hostApi->mtx ), 0 ); |
| 1722 | if( abort ) |
| 1723 | stream->doAbortcxx . . $ PaJackStream#doAbort. = 1; |
| 1724 | else |
| 1725 | stream->doStopcxx . . $ PaJackStream#doStop. = 1; |
| 1726 | |
| 1727 | /* Wait for stream to be stopped */ |
| 1728 | result = WaitConditioncxx . . $ WaitCondition(f6fafa200cd34369).( stream->hostApicxx . . $ PaJackStream#hostApi. ); |
| 1729 | ASSERT_CALLcxx . . $ `external/portaudio/pa_jack.c:119:9`!( pthread_mutex_unlock( &stream->hostApi->mtx ), 0 ); |
| 1730 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( result ); |
| 1731 | |
| 1732 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !stream->is_active, paInternalError ); |
| 1733 | |
| 1734 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Stream stopped\n", __FUNCTION__ )); |
| 1735 | |
| 1736 | error: |
| 1737 | stream->is_runningcxx . . $ PaJackStream#is_running. = FALSEcxx . . $ `external/portaudio/pa_jack.c:244:9`!; |
| 1738 | |
| 1739 | /* Disconnect ports belonging to this stream */ |
| 1740 | |
| 1741 | if( !stream->hostApicxx . . $ PaJackStream#hostApi.->jackIsDowncxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jackIsDown. ) /* XXX: Well? */ |
| 1742 | { |
| 1743 | for( i = 0; i < stream->num_incoming_connectionscxx . . $ PaJackStream#num_incoming_connections.; i++ ) |
| 1744 | { |
| 1745 | if( jack_port_connectedcxx . . $ jack_port_connected(47a2b6fb9281608e).( stream->local_input_portscxx . . $ PaJackStream#local_input_ports.[i] ) ) |
| 1746 | { |
| 1747 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !jack_port_disconnect( stream->jack_client, stream->local_input_ports[i] ), |
| 1748 | paUnanticipatedHostError ); |
| 1749 | } |
| 1750 | } |
| 1751 | for( i = 0; i < stream->num_outgoing_connectionscxx . . $ PaJackStream#num_outgoing_connections.; i++ ) |
| 1752 | { |
| 1753 | if( jack_port_connectedcxx . . $ jack_port_connected(47a2b6fb9281608e).( stream->local_output_portscxx . . $ PaJackStream#local_output_ports.[i] ) ) |
| 1754 | { |
| 1755 | UNLESScxx . . $ `external/portaudio/pa_jack.c:103:9`!( !jack_port_disconnect( stream->jack_client, stream->local_output_ports[i] ), |
| 1756 | paUnanticipatedHostError ); |
| 1757 | } |
| 1758 | } |
| 1759 | } |
| 1760 | |
| 1761 | return result; |
| 1762 | } |
| 1763 | |
| 1764 | static PaErrorcxx . . $ PaError# StopStreamcxx . . $ StopStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 1765 | { |
| 1766 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(s); |
| 1767 | return RealStopcxx . . $ RealStop(6179de1e636293a).( (PaJackStreamcxx . . $ PaJackStream# *)s, 0 ); |
| 1768 | } |
| 1769 | |
| 1770 | static PaErrorcxx . . $ PaError# AbortStreamcxx . . $ AbortStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 1771 | { |
| 1772 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(s); |
| 1773 | return RealStopcxx . . $ RealStop(6179de1e636293a).( (PaJackStreamcxx . . $ PaJackStream# *)s, 1 ); |
| 1774 | } |
| 1775 | |
| 1776 | static PaErrorcxx . . $ PaError# IsStreamStoppedcxx . . $ IsStreamStopped(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 1777 | { |
| 1778 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream#*)s; |
| 1779 | return !stream->is_runningcxx . . $ PaJackStream#is_running.; |
| 1780 | } |
| 1781 | |
| 1782 | |
| 1783 | static PaErrorcxx . . $ PaError# IsStreamActivecxx . . $ IsStreamActive(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 1784 | { |
| 1785 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream#*)s; |
| 1786 | return stream->is_activecxx . . $ PaJackStream#is_active.; |
| 1787 | } |
| 1788 | |
| 1789 | |
| 1790 | static PaTimecxx . . $ PaTime# GetStreamTimecxx . . $ GetStreamTime(a405b17f82753acc).( PaStreamcxx . . $ PaStream# *s ) |
| 1791 | { |
| 1792 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream#*)s; |
| 1793 | |
| 1794 | /* A: Is this relevant?? --> TODO: what if we're recording-only? */ |
| 1795 | return (jack_frame_timecxx . . $ jack_frame_time(2de41c207249b5fd).( stream->jack_clientcxx . . $ PaJackStream#jack_client. ) - stream->t0cxx . . $ PaJackStream#t0.) / (PaTimecxx . . $ PaTime#)jack_get_sample_ratecxx . . $ jack_get_sample_rate(c09b6173c6c1729d).( stream->jack_clientcxx . . $ PaJackStream#jack_client. ); |
| 1796 | } |
| 1797 | |
| 1798 | |
| 1799 | static double GetStreamCpuLoadcxx . . $ GetStreamCpuLoad(a405b17f82753acc).( PaStreamcxx . . $ PaStream#* s ) |
| 1800 | { |
| 1801 | PaJackStreamcxx . . $ PaJackStream# *stream = (PaJackStreamcxx . . $ PaJackStream#*)s; |
| 1802 | return PaUtil_GetCpuLoadcxx . . $ PaUtil_GetCpuLoad(6d83850f5e898215).( &stream->cpuLoadMeasurercxx . . $ PaJackStream#cpuLoadMeasurer. ); |
| 1803 | } |
| 1804 | |
| 1805 | PaErrorcxx . . $ PaError# PaJack_SetClientNamecxx . . $ PaJack_SetClientName(5c4306d8553b3696).( const char* name ) |
| 1806 | { |
| 1807 | if( strlencxx . . $ strlen(751346f8406fd082).( name ) > jack_client_name_sizecxx . . $ jack_client_name_size(b126dc7c1de90089).() ) |
| 1808 | { |
| 1809 | /* OK, I don't know any better error code */ |
| 1810 | return paInvalidFlagcxx . . $ paInvalidFlag.; |
| 1811 | } |
| 1812 | clientName_cxx . . $ clientName_. = name; |
| 1813 | return paNoErrorcxx . . $ paNoError.; |
| 1814 | } |
| 1815 | |
| 1816 | PaErrorcxx . . $ PaError# PaJack_GetClientNamecxx . . $ PaJack_GetClientName(15355eb6db2855df).(const char** clientName) |
| 1817 | { |
| 1818 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1819 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation#* jackHostApi = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1820 | PaJackHostApiRepresentationcxx . . $ PaJackHostApiRepresentation#** ref = &jackHostApi; |
| 1821 | ENSURE_PAcxx . . $ `external/portaudio/pa_jack.c:86:9`!( PaUtil_GetHostApiRepresentation( (PaUtilHostApiRepresentation**)ref, paJACK ) ); |
| 1822 | *clientName = jack_get_client_namecxx . . $ jack_get_client_name(45ae01ec3d5b56b7).( jackHostApi->jack_clientcxx . . $ $anonymous_type_52a5d6dd71d7d1a9_0#jack_client. ); |
| 1823 | |
| 1824 | error: |
| 1825 | return result; |
| 1826 | } |
| 1827 | #endif |
| 1828 |