Commit bde8a20f authored by Jan Willhaus's avatar Jan Willhaus

Fixed error on OSX where non-pow2 channels can not be opened

Fix is borrowed from @bwhitman: https://gist.github.com/bwhitman/59d3761cfa7a8ab63e28
parent 902f8bf7
......@@ -186,7 +186,7 @@ PaError initializeBlioRingBuffers(
err = PaUtil_InitializeRingBuffer(
&blio->outputRingBuffer,
1, ringBufferSize*blio->outputSampleSizePow2*outChan,
outChan*blio->outputSampleSizePow2, ringBufferSize,
data );
assert( !err );
}
......@@ -268,9 +268,9 @@ PaError resetBlioRingBuffers( PaMacBlio *blio )
if( blio->outputRingBuffer.buffer ) {
PaUtil_FlushRingBuffer( &blio->outputRingBuffer );
bzero( blio->outputRingBuffer.buffer,
blio->outputRingBuffer.bufferSize );
blio->ringBufferFrames * blio->outputRingBuffer.elementSizeBytes );
/* Advance buffer */
PaUtil_AdvanceRingBufferWriteIndex( &blio->outputRingBuffer, blio->ringBufferFrames*blio->outputSampleSizeActual*blio->outChan );
PaUtil_AdvanceRingBufferWriteIndex( &blio->outputRingBuffer, blio->ringBufferFrames);
//PaUtil_AdvanceRingBufferWriteIndex( &blio->outputRingBuffer, blio->outputRingBuffer.bufferSize );
/* Update isOutputFull. */
......@@ -380,14 +380,14 @@ int BlioCallback( const void *input, void *output, unsigned long frameCount,
avail = PaUtil_GetRingBufferReadAvailable( &blio->outputRingBuffer );
/* check for underflow */
if( avail < frameCount * blio->outputSampleSizeActual * blio->outChan )
if( avail < frameCount)
OSAtomicOr32( paOutputUnderflow, &blio->statusFlags );
toWrite = MIN( avail, frameCount * blio->outputSampleSizeActual * blio->outChan );
toWrite = MIN( avail, frameCount);
if( toWrite != frameCount * blio->outputSampleSizeActual * blio->outChan )
if( toWrite != frameCount)
bzero( ((char *)output)+toWrite,
frameCount * blio->outputSampleSizeActual * blio->outChan - toWrite );
frameCount * 1 - toWrite );
/* copy the data */
/*printf( "writing %d\n", toWrite );*/
written = PaUtil_ReadRingBuffer( &blio->outputRingBuffer, output, toWrite );
......@@ -520,11 +520,10 @@ PaError WriteStream( PaStream* stream,
}
} while( avail == 0 );
toWrite = MIN( avail, frames * blio->outputSampleSizeActual * blio->outChan );
toWrite -= toWrite % blio->outputSampleSizeActual * blio->outChan ;
toWrite = MIN( avail, frames );
PaUtil_WriteRingBuffer( &blio->outputRingBuffer, (void *)cbuf, toWrite );
cbuf += toWrite;
frames -= toWrite / ( blio->outputSampleSizeActual * blio->outChan );
frames -= toWrite / 1;
#ifdef PA_MAC_BLIO_MUTEX
if( toWrite == avail ) {
......@@ -587,7 +586,6 @@ signed long GetStreamWriteAvailable( PaStream* stream )
PaMacBlio *blio = & ((PaMacCoreStream*)stream) -> blio;
VVDBUG(("GetStreamWriteAvailable()\n"));
return PaUtil_GetRingBufferWriteAvailable( &blio->outputRingBuffer )
/ ( blio->outputSampleSizeActual * blio->outChan );
return PaUtil_GetRingBufferWriteAvailable( &blio->outputRingBuffer );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment