git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2646 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.90
@@ -45,13 +45,13 @@ int JackCallbackNetIOAdapter::Process(jack_nframes_t frames, void* arg) | |||
// Push/pull from ringbuffer | |||
for (i = 0; i < adapter->fCaptureChannels; i++) { | |||
buffer = static_cast<float*>(jack_port_get_buffer(adapter->fCapturePortList[i], frames)); | |||
if (adapter->fCaptureRingBuffer[i]->Read(buffer, frames) == 0) | |||
if (adapter->fCaptureRingBuffer[i]->Read(buffer, frames) < frames) | |||
failure = true; | |||
} | |||
for (i = 0; i < adapter->fPlaybackChannels; i++) { | |||
buffer = static_cast<float*>(jack_port_get_buffer(adapter->fPlaybackPortList[i], frames)); | |||
if (adapter->fPlaybackRingBuffer[i]->Write(buffer, frames) == 0) | |||
if (adapter->fPlaybackRingBuffer[i]->Write(buffer, frames) < frames) | |||
failure = true; | |||
} | |||
@@ -42,7 +42,7 @@ void JackLibSampleRateResampler::Reset() | |||
src_reset(fResampler); | |||
} | |||
int JackLibSampleRateResampler::ReadResample(float* buffer, unsigned int frames) | |||
unsigned int JackLibSampleRateResampler::ReadResample(float* buffer, unsigned int frames) | |||
{ | |||
jack_ringbuffer_data_t ring_buffer_data[2]; | |||
SRC_DATA src_data; | |||
@@ -66,14 +66,17 @@ int JackLibSampleRateResampler::ReadResample(float* buffer, unsigned int frames) | |||
src_data.src_ratio = fRatio; | |||
res = src_process(fResampler, &src_data); | |||
if (res != 0) | |||
if (res != 0) { | |||
jack_error("JackLibSampleRateResampler::ReadResample err = %s", src_strerror(res)); | |||
return 0; | |||
} | |||
frames_to_write -= src_data.output_frames_gen; | |||
written_frames += src_data.output_frames_gen; | |||
if ((src_data.input_frames_used == 0 || src_data.output_frames_gen == 0) && j == 0) { | |||
jack_error("Output : j = %d input_frames_used = %ld output_frames_gen = %ld", j, src_data.input_frames_used, src_data.output_frames_gen); | |||
return 0; | |||
} | |||
jack_log("Output : j = %d input_frames_used = %ld output_frames_gen = %ld", j, src_data.input_frames_used, src_data.output_frames_gen); | |||
@@ -89,7 +92,7 @@ int JackLibSampleRateResampler::ReadResample(float* buffer, unsigned int frames) | |||
return written_frames; | |||
} | |||
int JackLibSampleRateResampler::WriteResample(float* buffer, unsigned int frames) | |||
unsigned int JackLibSampleRateResampler::WriteResample(float* buffer, unsigned int frames) | |||
{ | |||
jack_ringbuffer_data_t ring_buffer_data[2]; | |||
SRC_DATA src_data; | |||
@@ -113,14 +116,17 @@ int JackLibSampleRateResampler::WriteResample(float* buffer, unsigned int frames | |||
src_data.src_ratio = fRatio; | |||
res = src_process(fResampler, &src_data); | |||
if (res != 0) | |||
if (res != 0) { | |||
jack_error("JackLibSampleRateResampler::ReadResample err = %s", src_strerror(res)); | |||
return 0; | |||
} | |||
frames_to_read -= src_data.input_frames_used; | |||
read_frames += src_data.input_frames_used; | |||
if ((src_data.input_frames_used == 0 || src_data.output_frames_gen == 0) && j == 0) { | |||
jack_error("Input : j = %d input_frames_used = %ld output_frames_gen = %ld", j, src_data.input_frames_used, src_data.output_frames_gen); | |||
return 0; | |||
} | |||
jack_log("Input : j = %d input_frames_used = %ld output_frames_gen = %ld", j, src_data.input_frames_used, src_data.output_frames_gen); | |||
@@ -39,8 +39,8 @@ namespace Jack | |||
JackLibSampleRateResampler(); | |||
virtual ~JackLibSampleRateResampler(); | |||
int ReadResample(float* buffer, unsigned int frames); | |||
int WriteResample(float* buffer, unsigned int frames); | |||
unsigned int ReadResample(float* buffer, unsigned int frames); | |||
unsigned int WriteResample(float* buffer, unsigned int frames); | |||
void SetRatio(unsigned int num, unsigned int denom) | |||
{ | |||
@@ -49,7 +49,7 @@ unsigned int JackResampler::WriteSpace() | |||
return (jack_ringbuffer_write_space(fRingBuffer) / sizeof(float)); | |||
} | |||
int JackResampler::Read(float* buffer, unsigned int frames) | |||
unsigned int JackResampler::Read(float* buffer, unsigned int frames) | |||
{ | |||
size_t len = jack_ringbuffer_read_space(fRingBuffer); | |||
jack_log("JackResampler::Read input available = %ld", len / sizeof(float)); | |||
@@ -63,7 +63,7 @@ int JackResampler::Read(float* buffer, unsigned int frames) | |||
} | |||
} | |||
int JackResampler::Write(float* buffer, unsigned int frames) | |||
unsigned int JackResampler::Write(float* buffer, unsigned int frames) | |||
{ | |||
size_t len = jack_ringbuffer_write_space(fRingBuffer); | |||
jack_log("JackResampler::Write output available = %ld", len / sizeof(float)); | |||
@@ -77,12 +77,12 @@ int JackResampler::Write(float* buffer, unsigned int frames) | |||
} | |||
} | |||
int JackResampler::ReadResample(float* buffer, unsigned int frames) | |||
unsigned int JackResampler::ReadResample(float* buffer, unsigned int frames) | |||
{ | |||
return Read(buffer, frames); | |||
} | |||
int JackResampler::WriteResample(float* buffer, unsigned int frames) | |||
unsigned int JackResampler::WriteResample(float* buffer, unsigned int frames) | |||
{ | |||
return Write(buffer, frames); | |||
} | |||
@@ -45,11 +45,11 @@ namespace Jack | |||
virtual void Reset(); | |||
virtual int ReadResample(float* buffer, unsigned int frames); | |||
virtual int WriteResample(float* buffer, unsigned int frames); | |||
virtual unsigned int ReadResample(float* buffer, unsigned int frames); | |||
virtual unsigned int WriteResample(float* buffer, unsigned int frames); | |||
virtual int Read(float* buffer, unsigned int frames); | |||
virtual int Write(float* buffer, unsigned int frames); | |||
virtual unsigned int Read(float* buffer, unsigned int frames); | |||
virtual unsigned int Write(float* buffer, unsigned int frames); | |||
virtual unsigned int ReadSpace(); | |||
virtual unsigned int WriteSpace(); | |||
@@ -129,13 +129,13 @@ OSStatus JackCoreAudioIOAdapter::Render(void *inRefCon, | |||
for (int i = 0; i < adapter->fCaptureChannels; i++) { | |||
adapter->fCaptureRingBuffer[i]->SetRatio(time1, time2); | |||
if (adapter->fCaptureRingBuffer[i]->WriteResample((float*)adapter->fInputData->mBuffers[i].mData, inNumberFrames) == 0) | |||
if (adapter->fCaptureRingBuffer[i]->WriteResample((float*)adapter->fInputData->mBuffers[i].mData, inNumberFrames) < inNumberFrames) | |||
failure = true; | |||
} | |||
for (int i = 0; i < adapter->fPlaybackChannels; i++) { | |||
adapter->fPlaybackRingBuffer[i]->SetRatio(time2, time1); | |||
if (adapter->fPlaybackRingBuffer[i]->ReadResample((float*)ioData->mBuffers[i].mData, inNumberFrames) == 0) | |||
if (adapter->fPlaybackRingBuffer[i]->ReadResample((float*)ioData->mBuffers[i].mData, inNumberFrames) < inNumberFrames) | |||
failure = true; | |||
} | |||
@@ -42,7 +42,7 @@ int JackPortAudioIOAdapter::Render(const void* inputBuffer, void* outputBuffer, | |||
for (int i = 0; i < adapter->fCaptureChannels; i++) { | |||
buffer = (float*)paBuffer[i]; | |||
adapter->fCaptureRingBuffer[i]->SetRatio(time1, time2); | |||
if (adapter->fCaptureRingBuffer[i]->WriteResample(buffer, framesPerBuffer) == 0) | |||
if (adapter->fCaptureRingBuffer[i]->WriteResample(buffer, framesPerBuffer) < framesPerBuffer) | |||
failure = true; | |||
} | |||
@@ -50,7 +50,7 @@ int JackPortAudioIOAdapter::Render(const void* inputBuffer, void* outputBuffer, | |||
for (int i = 0; i < adapter->fPlaybackChannels; i++) { | |||
buffer = (float*)paBuffer[i]; | |||
adapter->fPlaybackRingBuffer[i]->SetRatio(time2, time1); | |||
if (adapter->fPlaybackRingBuffer[i]->ReadResample(buffer, framesPerBuffer) == 0) | |||
if (adapter->fPlaybackRingBuffer[i]->ReadResample(buffer, framesPerBuffer) < framesPerBuffer) | |||
failure = true; | |||
} | |||