| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
#include <string.h> |
| 55 |
|
| 56 |
#include "pa_util.h" |
| 57 |
#include "pa_allocation.h" |
| 58 |
#include "pa_hostapi.h" |
| 59 |
#include "pa_stream.h" |
| 60 |
#include "pa_cpuload.h" |
| 61 |
#include "pa_process.h" |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
#ifdef __cplusplus |
| 67 |
extern "C" |
| 68 |
{ |
| 69 |
#endif |
| 70 |
|
| 71 |
PaError PaSkeleton_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index ); |
| 72 |
|
| 73 |
#ifdef __cplusplus |
| 74 |
} |
| 75 |
#endif |
| 76 |
|
| 77 |
|
| 78 |
static void Terminate( struct PaUtilHostApiRepresentation *hostApi ); |
| 79 |
static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi, |
| 80 |
const PaStreamParameters *inputParameters, |
| 81 |
const PaStreamParameters *outputParameters, |
| 82 |
double sampleRate ); |
| 83 |
static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi, |
| 84 |
PaStream** s, |
| 85 |
const PaStreamParameters *inputParameters, |
| 86 |
const PaStreamParameters *outputParameters, |
| 87 |
double sampleRate, |
| 88 |
unsigned long framesPerBuffer, |
| 89 |
PaStreamFlags streamFlags, |
| 90 |
PaStreamCallback *streamCallback, |
| 91 |
void *userData ); |
| 92 |
static PaError CloseStream( PaStream* stream ); |
| 93 |
static PaError StartStream( PaStream *stream ); |
| 94 |
static PaError StopStream( PaStream *stream ); |
| 95 |
static PaError AbortStream( PaStream *stream ); |
| 96 |
static PaError IsStreamStopped( PaStream *s ); |
| 97 |
static PaError IsStreamActive( PaStream *stream ); |
| 98 |
static PaTime GetStreamTime( PaStream *stream ); |
| 99 |
static double GetStreamCpuLoad( PaStream* stream ); |
| 100 |
static PaError ReadStream( PaStream* stream, void *buffer, unsigned long frames ); |
| 101 |
static PaError WriteStream( PaStream* stream, const void *buffer, unsigned long frames ); |
| 102 |
static signed long GetStreamReadAvailable( PaStream* stream ); |
| 103 |
static signed long GetStreamWriteAvailable( PaStream* stream ); |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
#define PA_SKELETON_SET_LAST_HOST_ERROR( errorCode, errorText ) \ |
| 109 |
PaUtil_SetLastHostErrorInfo( paInDevelopment, errorCode, errorText ) |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
typedef struct |
| 114 |
{ |
| 115 |
PaUtilHostApiRepresentation inheritedHostApiRep; |
| 116 |
PaUtilStreamInterface callbackStreamInterface; |
| 117 |
PaUtilStreamInterface blockingStreamInterface; |
| 118 |
|
| 119 |
PaUtilAllocationGroup *allocations; |
| 120 |
|
| 121 |
|
| 122 |
} |
| 123 |
PaSkeletonHostApiRepresentation; |
| 124 |
|
| 125 |
|
| 126 |
PaError PaSkeleton_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex hostApiIndex ) |
| 127 |
{ |
| 128 |
PaError result = paNoError; |
| 129 |
int i, deviceCount; |
| 130 |
PaSkeletonHostApiRepresentation *skeletonHostApi; |
| 131 |
PaDeviceInfo *deviceInfoArray; |
| 132 |
|
| 133 |
skeletonHostApi = (PaSkeletonHostApiRepresentation*)PaUtil_AllocateMemory( sizeof(PaSkeletonHostApiRepresentation) ); |
| 134 |
if( !skeletonHostApi ) |
| 135 |
{ |
| 136 |
result = paInsufficientMemory; |
| 137 |
goto error; |
| 138 |
} |
| 139 |
|
| 140 |
skeletonHostApi->allocations = PaUtil_CreateAllocationGroup(); |
| 141 |
if( !skeletonHostApi->allocations ) |
| 142 |
{ |
| 143 |
result = paInsufficientMemory; |
| 144 |
goto error; |
| 145 |
} |
| 146 |
|
| 147 |
*hostApi = &skeletonHostApi->inheritedHostApiRep; |
| 148 |
(*hostApi)->info.structVersion = 1; |
| 149 |
(*hostApi)->info.type = paInDevelopment; |
| 150 |
(*hostApi)->info.name = "skeleton implementation"; |
| 151 |
|
| 152 |
(*hostApi)->info.defaultInputDevice = paNoDevice; |
| 153 |
(*hostApi)->info.defaultOutputDevice = paNoDevice; |
| 154 |
|
| 155 |
(*hostApi)->info.deviceCount = 0; |
| 156 |
|
| 157 |
deviceCount = 0; |
| 158 |
|
| 159 |
if( deviceCount > 0 ) |
| 160 |
{ |
| 161 |
(*hostApi)->deviceInfos = (PaDeviceInfo**)PaUtil_GroupAllocateMemory( |
| 162 |
skeletonHostApi->allocations, sizeof(PaDeviceInfo*) * deviceCount ); |
| 163 |
if( !(*hostApi)->deviceInfos ) |
| 164 |
{ |
| 165 |
result = paInsufficientMemory; |
| 166 |
goto error; |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
deviceInfoArray = (PaDeviceInfo*)PaUtil_GroupAllocateMemory( |
| 171 |
skeletonHostApi->allocations, sizeof(PaDeviceInfo) * deviceCount ); |
| 172 |
if( !deviceInfoArray ) |
| 173 |
{ |
| 174 |
result = paInsufficientMemory; |
| 175 |
goto error; |
| 176 |
} |
| 177 |
|
| 178 |
for( i=0; i < deviceCount; ++i ) |
| 179 |
{ |
| 180 |
PaDeviceInfo *deviceInfo = &deviceInfoArray[i]; |
| 181 |
deviceInfo->structVersion = 2; |
| 182 |
deviceInfo->hostApi = hostApiIndex; |
| 183 |
deviceInfo->name = 0; |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
deviceInfo->maxInputChannels = 0; |
| 195 |
deviceInfo->maxOutputChannels = 0; |
| 196 |
|
| 197 |
deviceInfo->defaultLowInputLatency = 0.; |
| 198 |
deviceInfo->defaultLowOutputLatency = 0.; |
| 199 |
deviceInfo->defaultHighInputLatency = 0.; |
| 200 |
deviceInfo->defaultHighOutputLatency = 0.; |
| 201 |
|
| 202 |
deviceInfo->defaultSampleRate = 0.; |
| 203 |
|
| 204 |
(*hostApi)->deviceInfos[i] = deviceInfo; |
| 205 |
++(*hostApi)->info.deviceCount; |
| 206 |
} |
| 207 |
} |
| 208 |
|
| 209 |
(*hostApi)->Terminate = Terminate; |
| 210 |
(*hostApi)->OpenStream = OpenStream; |
| 211 |
(*hostApi)->IsFormatSupported = IsFormatSupported; |
| 212 |
|
| 213 |
PaUtil_InitializeStreamInterface( &skeletonHostApi->callbackStreamInterface, CloseStream, StartStream, |
| 214 |
StopStream, AbortStream, IsStreamStopped, IsStreamActive, |
| 215 |
GetStreamTime, GetStreamCpuLoad, |
| 216 |
PaUtil_DummyRead, PaUtil_DummyWrite, |
| 217 |
PaUtil_DummyGetReadAvailable, PaUtil_DummyGetWriteAvailable ); |
| 218 |
|
| 219 |
PaUtil_InitializeStreamInterface( &skeletonHostApi->blockingStreamInterface, CloseStream, StartStream, |
| 220 |
StopStream, AbortStream, IsStreamStopped, IsStreamActive, |
| 221 |
GetStreamTime, PaUtil_DummyGetCpuLoad, |
| 222 |
ReadStream, WriteStream, GetStreamReadAvailable, GetStreamWriteAvailable ); |
| 223 |
|
| 224 |
return result; |
| 225 |
|
| 226 |
error: |
| 227 |
if( skeletonHostApi ) |
| 228 |
{ |
| 229 |
if( skeletonHostApi->allocations ) |
| 230 |
{ |
| 231 |
PaUtil_FreeAllAllocations( skeletonHostApi->allocations ); |
| 232 |
PaUtil_DestroyAllocationGroup( skeletonHostApi->allocations ); |
| 233 |
} |
| 234 |
|
| 235 |
PaUtil_FreeMemory( skeletonHostApi ); |
| 236 |
} |
| 237 |
return result; |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
static void Terminate( struct PaUtilHostApiRepresentation *hostApi ) |
| 242 |
{ |
| 243 |
PaSkeletonHostApiRepresentation *skeletonHostApi = (PaSkeletonHostApiRepresentation*)hostApi; |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
if( skeletonHostApi->allocations ) |
| 251 |
{ |
| 252 |
PaUtil_FreeAllAllocations( skeletonHostApi->allocations ); |
| 253 |
PaUtil_DestroyAllocationGroup( skeletonHostApi->allocations ); |
| 254 |
} |
| 255 |
|
| 256 |
PaUtil_FreeMemory( skeletonHostApi ); |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi, |
| 261 |
const PaStreamParameters *inputParameters, |
| 262 |
const PaStreamParameters *outputParameters, |
| 263 |
double sampleRate ) |
| 264 |
{ |
| 265 |
int inputChannelCount, outputChannelCount; |
| 266 |
PaSampleFormat inputSampleFormat, outputSampleFormat; |
| 267 |
|
| 268 |
if( inputParameters ) |
| 269 |
{ |
| 270 |
inputChannelCount = inputParameters->channelCount; |
| 271 |
inputSampleFormat = inputParameters->sampleFormat; |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
if( inputSampleFormat & paCustomFormat ) |
| 276 |
return paSampleFormatNotSupported; |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
if( inputParameters->device == paUseHostApiSpecificDeviceSpecification ) |
| 282 |
return paInvalidDevice; |
| 283 |
|
| 284 |
|
| 285 |
if( inputChannelCount > hostApi->deviceInfos[ inputParameters->device ]->maxInputChannels ) |
| 286 |
return paInvalidChannelCount; |
| 287 |
|
| 288 |
|
| 289 |
if( inputParameters->hostApiSpecificStreamInfo ) |
| 290 |
return paIncompatibleHostApiSpecificStreamInfo; |
| 291 |
} |
| 292 |
else |
| 293 |
{ |
| 294 |
inputChannelCount = 0; |
| 295 |
} |
| 296 |
|
| 297 |
if( outputParameters ) |
| 298 |
{ |
| 299 |
outputChannelCount = outputParameters->channelCount; |
| 300 |
outputSampleFormat = outputParameters->sampleFormat; |
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
if( outputSampleFormat & paCustomFormat ) |
| 305 |
return paSampleFormatNotSupported; |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
if( outputParameters->device == paUseHostApiSpecificDeviceSpecification ) |
| 311 |
return paInvalidDevice; |
| 312 |
|
| 313 |
|
| 314 |
if( outputChannelCount > hostApi->deviceInfos[ outputParameters->device ]->maxOutputChannels ) |
| 315 |
return paInvalidChannelCount; |
| 316 |
|
| 317 |
|
| 318 |
if( outputParameters->hostApiSpecificStreamInfo ) |
| 319 |
return paIncompatibleHostApiSpecificStreamInfo; |
| 320 |
} |
| 321 |
else |
| 322 |
{ |
| 323 |
outputChannelCount = 0; |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
(void) sampleRate; |
| 350 |
|
| 351 |
return paFormatIsSupported; |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
typedef struct PaSkeletonStream |
| 357 |
{ |
| 358 |
PaUtilStreamRepresentation streamRepresentation; |
| 359 |
PaUtilCpuLoadMeasurer cpuLoadMeasurer; |
| 360 |
PaUtilBufferProcessor bufferProcessor; |
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
unsigned long framesPerHostCallback; |
| 366 |
} |
| 367 |
PaSkeletonStream; |
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi, |
| 372 |
PaStream** s, |
| 373 |
const PaStreamParameters *inputParameters, |
| 374 |
const PaStreamParameters *outputParameters, |
| 375 |
double sampleRate, |
| 376 |
unsigned long framesPerBuffer, |
| 377 |
PaStreamFlags streamFlags, |
| 378 |
PaStreamCallback *streamCallback, |
| 379 |
void *userData ) |
| 380 |
{ |
| 381 |
PaError result = paNoError; |
| 382 |
PaSkeletonHostApiRepresentation *skeletonHostApi = (PaSkeletonHostApiRepresentation*)hostApi; |
| 383 |
PaSkeletonStream *stream = 0; |
| 384 |
unsigned long framesPerHostBuffer = framesPerBuffer; |
| 385 |
int inputChannelCount, outputChannelCount; |
| 386 |
PaSampleFormat inputSampleFormat, outputSampleFormat; |
| 387 |
PaSampleFormat hostInputSampleFormat, hostOutputSampleFormat; |
| 388 |
|
| 389 |
|
| 390 |
if( inputParameters ) |
| 391 |
{ |
| 392 |
inputChannelCount = inputParameters->channelCount; |
| 393 |
inputSampleFormat = inputParameters->sampleFormat; |
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
if( inputParameters->device == paUseHostApiSpecificDeviceSpecification ) |
| 399 |
return paInvalidDevice; |
| 400 |
|
| 401 |
|
| 402 |
if( inputChannelCount > hostApi->deviceInfos[ inputParameters->device ]->maxInputChannels ) |
| 403 |
return paInvalidChannelCount; |
| 404 |
|
| 405 |
|
| 406 |
if( inputParameters->hostApiSpecificStreamInfo ) |
| 407 |
return paIncompatibleHostApiSpecificStreamInfo; |
| 408 |
|
| 409 |
|
| 410 |
hostInputSampleFormat = |
| 411 |
PaUtil_SelectClosestAvailableFormat( paInt16 , inputSampleFormat ); |
| 412 |
} |
| 413 |
else |
| 414 |
{ |
| 415 |
inputChannelCount = 0; |
| 416 |
inputSampleFormat = hostInputSampleFormat = paInt16; |
| 417 |
} |
| 418 |
|
| 419 |
if( outputParameters ) |
| 420 |
{ |
| 421 |
outputChannelCount = outputParameters->channelCount; |
| 422 |
outputSampleFormat = outputParameters->sampleFormat; |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
if( outputParameters->device == paUseHostApiSpecificDeviceSpecification ) |
| 428 |
return paInvalidDevice; |
| 429 |
|
| 430 |
|
| 431 |
if( outputChannelCount > hostApi->deviceInfos[ outputParameters->device ]->maxOutputChannels ) |
| 432 |
return paInvalidChannelCount; |
| 433 |
|
| 434 |
|
| 435 |
if( outputParameters->hostApiSpecificStreamInfo ) |
| 436 |
return paIncompatibleHostApiSpecificStreamInfo; |
| 437 |
|
| 438 |
|
| 439 |
hostOutputSampleFormat = |
| 440 |
PaUtil_SelectClosestAvailableFormat( paInt16 , outputSampleFormat ); |
| 441 |
} |
| 442 |
else |
| 443 |
{ |
| 444 |
outputChannelCount = 0; |
| 445 |
outputSampleFormat = hostOutputSampleFormat = paInt16; |
| 446 |
} |
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
if( (streamFlags & paPlatformSpecificFlags) != 0 ) |
| 477 |
return paInvalidFlag; |
| 478 |
|
| 479 |
|
| 480 |
stream = (PaSkeletonStream*)PaUtil_AllocateMemory( sizeof(PaSkeletonStream) ); |
| 481 |
if( !stream ) |
| 482 |
{ |
| 483 |
result = paInsufficientMemory; |
| 484 |
goto error; |
| 485 |
} |
| 486 |
|
| 487 |
if( streamCallback ) |
| 488 |
{ |
| 489 |
PaUtil_InitializeStreamRepresentation( &stream->streamRepresentation, |
| 490 |
&skeletonHostApi->callbackStreamInterface, streamCallback, userData ); |
| 491 |
} |
| 492 |
else |
| 493 |
{ |
| 494 |
PaUtil_InitializeStreamRepresentation( &stream->streamRepresentation, |
| 495 |
&skeletonHostApi->blockingStreamInterface, streamCallback, userData ); |
| 496 |
} |
| 497 |
|
| 498 |
PaUtil_InitializeCpuLoadMeasurer( &stream->cpuLoadMeasurer, sampleRate ); |
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
result = PaUtil_InitializeBufferProcessor( &stream->bufferProcessor, |
| 507 |
inputChannelCount, inputSampleFormat, hostInputSampleFormat, |
| 508 |
outputChannelCount, outputSampleFormat, hostOutputSampleFormat, |
| 509 |
sampleRate, streamFlags, framesPerBuffer, |
| 510 |
framesPerHostBuffer, paUtilFixedHostBufferSize, |
| 511 |
streamCallback, userData ); |
| 512 |
if( result != paNoError ) |
| 513 |
goto error; |
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
stream->streamRepresentation.streamInfo.inputLatency = |
| 521 |
(PaTime)PaUtil_GetBufferProcessorInputLatencyFrames(&stream->bufferProcessor) / sampleRate; |
| 522 |
stream->streamRepresentation.streamInfo.outputLatency = |
| 523 |
(PaTime)PaUtil_GetBufferProcessorOutputLatencyFrames(&stream->bufferProcessor) / sampleRate; |
| 524 |
stream->streamRepresentation.streamInfo.sampleRate = sampleRate; |
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
stream->framesPerHostCallback = framesPerHostBuffer; |
| 533 |
|
| 534 |
*s = (PaStream*)stream; |
| 535 |
|
| 536 |
return result; |
| 537 |
|
| 538 |
error: |
| 539 |
if( stream ) |
| 540 |
PaUtil_FreeMemory( stream ); |
| 541 |
|
| 542 |
return result; |
| 543 |
} |
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
static void ExampleHostProcessingLoop( void *inputBuffer, void *outputBuffer, void *userData ) |
| 551 |
{ |
| 552 |
PaSkeletonStream *stream = (PaSkeletonStream*)userData; |
| 553 |
PaStreamCallbackTimeInfo timeInfo = {0,0,0}; |
| 554 |
int callbackResult; |
| 555 |
unsigned long framesProcessed; |
| 556 |
|
| 557 |
PaUtil_BeginCpuLoadMeasurement( &stream->cpuLoadMeasurer ); |
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
PaUtil_BeginBufferProcessing( &stream->bufferProcessor, &timeInfo, 0 ); |
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
PaUtil_SetInputFrameCount( &stream->bufferProcessor, 0 ); |
| 581 |
PaUtil_SetInterleavedInputChannels( &stream->bufferProcessor, |
| 582 |
0, |
| 583 |
inputBuffer, |
| 584 |
0 ); |
| 585 |
|
| 586 |
PaUtil_SetOutputFrameCount( &stream->bufferProcessor, 0 ); |
| 587 |
PaUtil_SetInterleavedOutputChannels( &stream->bufferProcessor, |
| 588 |
0, |
| 589 |
outputBuffer, |
| 590 |
0 ); |
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
callbackResult = paContinue; |
| 599 |
framesProcessed = PaUtil_EndBufferProcessing( &stream->bufferProcessor, &callbackResult ); |
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
PaUtil_EndCpuLoadMeasurement( &stream->cpuLoadMeasurer, framesProcessed ); |
| 608 |
|
| 609 |
|
| 610 |
if( callbackResult == paContinue ) |
| 611 |
{ |
| 612 |
|
| 613 |
} |
| 614 |
else if( callbackResult == paAbort ) |
| 615 |
{ |
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
if( stream->streamRepresentation.streamFinishedCallback != 0 ) |
| 620 |
stream->streamRepresentation.streamFinishedCallback( stream->streamRepresentation.userData ); |
| 621 |
} |
| 622 |
else |
| 623 |
{ |
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
if( stream->streamRepresentation.streamFinishedCallback != 0 ) |
| 630 |
stream->streamRepresentation.streamFinishedCallback( stream->streamRepresentation.userData ); |
| 631 |
} |
| 632 |
} |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
static PaError CloseStream( PaStream* s ) |
| 640 |
{ |
| 641 |
PaError result = paNoError; |
| 642 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
PaUtil_TerminateBufferProcessor( &stream->bufferProcessor ); |
| 650 |
PaUtil_TerminateStreamRepresentation( &stream->streamRepresentation ); |
| 651 |
PaUtil_FreeMemory( stream ); |
| 652 |
|
| 653 |
return result; |
| 654 |
} |
| 655 |
|
| 656 |
|
| 657 |
static PaError StartStream( PaStream *s ) |
| 658 |
{ |
| 659 |
PaError result = paNoError; |
| 660 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 661 |
|
| 662 |
PaUtil_ResetBufferProcessor( &stream->bufferProcessor ); |
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
(void) ExampleHostProcessingLoop; |
| 671 |
|
| 672 |
return result; |
| 673 |
} |
| 674 |
|
| 675 |
|
| 676 |
static PaError StopStream( PaStream *s ) |
| 677 |
{ |
| 678 |
PaError result = paNoError; |
| 679 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 680 |
|
| 681 |
|
| 682 |
(void) stream; |
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
return result; |
| 687 |
} |
| 688 |
|
| 689 |
|
| 690 |
static PaError AbortStream( PaStream *s ) |
| 691 |
{ |
| 692 |
PaError result = paNoError; |
| 693 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 694 |
|
| 695 |
|
| 696 |
(void) stream; |
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
return result; |
| 701 |
} |
| 702 |
|
| 703 |
|
| 704 |
static PaError IsStreamStopped( PaStream *s ) |
| 705 |
{ |
| 706 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 707 |
|
| 708 |
|
| 709 |
(void) stream; |
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
return 0; |
| 714 |
} |
| 715 |
|
| 716 |
|
| 717 |
static PaError IsStreamActive( PaStream *s ) |
| 718 |
{ |
| 719 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 720 |
|
| 721 |
|
| 722 |
(void) stream; |
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
return 0; |
| 727 |
} |
| 728 |
|
| 729 |
|
| 730 |
static PaTime GetStreamTime( PaStream *s ) |
| 731 |
{ |
| 732 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 733 |
|
| 734 |
|
| 735 |
(void) stream; |
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
return 0; |
| 740 |
} |
| 741 |
|
| 742 |
|
| 743 |
static double GetStreamCpuLoad( PaStream* s ) |
| 744 |
{ |
| 745 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 746 |
|
| 747 |
return PaUtil_GetCpuLoad( &stream->cpuLoadMeasurer ); |
| 748 |
} |
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
static PaError ReadStream( PaStream* s, |
| 758 |
void *buffer, |
| 759 |
unsigned long frames ) |
| 760 |
{ |
| 761 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 762 |
|
| 763 |
|
| 764 |
(void) buffer; |
| 765 |
(void) frames; |
| 766 |
(void) stream; |
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
return paNoError; |
| 771 |
} |
| 772 |
|
| 773 |
|
| 774 |
static PaError WriteStream( PaStream* s, |
| 775 |
const void *buffer, |
| 776 |
unsigned long frames ) |
| 777 |
{ |
| 778 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 779 |
|
| 780 |
|
| 781 |
(void) buffer; |
| 782 |
(void) frames; |
| 783 |
(void) stream; |
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
return paNoError; |
| 788 |
} |
| 789 |
|
| 790 |
|
| 791 |
static signed long GetStreamReadAvailable( PaStream* s ) |
| 792 |
{ |
| 793 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 794 |
|
| 795 |
|
| 796 |
(void) stream; |
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
return 0; |
| 801 |
} |
| 802 |
|
| 803 |
|
| 804 |
static signed long GetStreamWriteAvailable( PaStream* s ) |
| 805 |
{ |
| 806 |
PaSkeletonStream *stream = (PaSkeletonStream*)s; |
| 807 |
|
| 808 |
|
| 809 |
(void) stream; |
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
return 0; |
| 814 |
} |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|