Commit 0e5127f7 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

pulse: if we can't peek in audio input, we can't drop samples

parent 786cd2d1
......@@ -496,24 +496,21 @@ void PulseLayer::readFromMic (void)
if (!record_ or !record_->isReady())
return;
const char *data = NULL;
const char *data = NULL;
size_t bytes;
size_t samples;
unsigned int mainBufferSampleRate = getMainBuffer()->getInternalSamplingRate();
bool resample = audioSampleRate_ != mainBufferSampleRate;
if (pa_stream_peek (record_->pulseStream() , (const void**) &data , &bytes) < 0 or !data) {
_error("Audio: Error capture stream peek failed: %s" , pa_strerror (pa_context_errno (context_)));
goto end;
return;
}
unsigned int mainBufferSampleRate = getMainBuffer()->getInternalSamplingRate();
bool resample = audioSampleRate_ != mainBufferSampleRate;
if (resample) {
double resampleFactor = (double) audioSampleRate_ / mainBufferSampleRate;
bytes = (double) bytes * resampleFactor;
}
samples = bytes / sizeof(SFLDataFormat);
size_t samples = bytes / sizeof(SFLDataFormat);
if (bytes > mic_buf_size_) {
mic_buf_size_ = bytes;
delete[] mic_buffer_;
......@@ -526,7 +523,6 @@ void PulseLayer::readFromMic (void)
dcblocker_.process(mic_buffer_, resample ? mic_buffer_ : (SFLDataFormat*)data, samples);
getMainBuffer()->putData(mic_buffer_, bytes);
end:
if (pa_stream_drop (record_->pulseStream()) < 0)
_error ("Audio: Error: capture stream drop failed: %s" , pa_strerror (pa_context_errno (context_)));
}
......
Supports Markdown
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