mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Reverting r12591 as it was not complete and we're too close to
freeze to risk fixing it now. Will readdress after 2.0.5 is released. Basically, RingBuffer is ill equiped to handle an input stride other than 1. Thanks to Peter for testing this for me.
This commit is contained in:
parent
8cb1681e47
commit
e5a4eecb25
@ -3613,10 +3613,44 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
|
||||
|
||||
if (len > 0) {
|
||||
for( t = 0; t < numCaptureChannels; t++) {
|
||||
gAudioIO->mCaptureBuffers[t]->Put(((samplePtr)inputBuffer) + (t * SAMPLE_SIZE(gAudioIO->mCaptureFormat)),
|
||||
|
||||
// dmazzoni:
|
||||
// Un-interleave. Ugly special-case code required because the
|
||||
// capture channels could be in three different sample formats;
|
||||
// it'd be nice to be able to call CopySamples, but it can't
|
||||
// handle multiplying by the gain and then clipping. Bummer.
|
||||
|
||||
switch(gAudioIO->mCaptureFormat) {
|
||||
case floatSample: {
|
||||
float *inputFloats = (float *)inputBuffer;
|
||||
for( i = 0; i < len; i++)
|
||||
tempFloats[i] =
|
||||
inputFloats[numCaptureChannels*i+t];
|
||||
} break;
|
||||
case int24Sample:
|
||||
// We should never get here. Audacity's int24Sample format
|
||||
// is different from PortAudio's sample format and so we
|
||||
// make PortAudio return float samples when recording in
|
||||
// 24-bit samples.
|
||||
wxASSERT(false);
|
||||
break;
|
||||
case int16Sample: {
|
||||
short *inputShorts = (short *)inputBuffer;
|
||||
short *tempShorts = (short *)tempBuffer;
|
||||
for( i = 0; i < len; i++) {
|
||||
float tmp = inputShorts[numCaptureChannels*i+t];
|
||||
if (tmp > 32767)
|
||||
tmp = 32767;
|
||||
if (tmp < -32768)
|
||||
tmp = -32768;
|
||||
tempShorts[i] = (short)(tmp);
|
||||
}
|
||||
} break;
|
||||
} // switch
|
||||
|
||||
gAudioIO->mCaptureBuffers[t]->Put((samplePtr)tempBuffer,
|
||||
gAudioIO->mCaptureFormat,
|
||||
len,
|
||||
numCaptureChannels);
|
||||
len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ int RingBuffer::AvailForPut()
|
||||
}
|
||||
|
||||
int RingBuffer::Put(samplePtr buffer, sampleFormat format,
|
||||
int samplesToCopy, int stride /* = 1 */)
|
||||
int samplesToCopy)
|
||||
{
|
||||
samplePtr src;
|
||||
int block;
|
||||
@ -75,7 +75,7 @@ int RingBuffer::Put(samplePtr buffer, sampleFormat format,
|
||||
|
||||
CopySamples(src, format,
|
||||
mBuffer + pos * SAMPLE_SIZE(mFormat), mFormat,
|
||||
block, true, stride);
|
||||
block);
|
||||
|
||||
src += block * SAMPLE_SIZE(format);
|
||||
pos = (pos + block) % mBufferSize;
|
||||
|
@ -23,7 +23,7 @@ class RingBuffer {
|
||||
//
|
||||
|
||||
int AvailForPut();
|
||||
int Put(samplePtr buffer, sampleFormat format, int samples, int stride = 1);
|
||||
int Put(samplePtr buffer, sampleFormat format, int samples);
|
||||
|
||||
//
|
||||
// For the reader only:
|
||||
|
Loading…
x
Reference in New Issue
Block a user