dep/cubeb: Update to 1d66483
This commit is contained in:
@ -61,8 +61,7 @@ long passthrough_resampler<T>::fill(void * input_buffer, long * input_frames_cou
|
||||
if (input_buffer) {
|
||||
assert(input_frames_count);
|
||||
}
|
||||
assert((input_buffer && output_buffer &&
|
||||
*input_frames_count + static_cast<int>(samples_to_frames(internal_input_buffer.length())) >= output_frames) ||
|
||||
assert((input_buffer && output_buffer) ||
|
||||
(output_buffer && !input_buffer && (!input_frames_count || *input_frames_count == 0)) ||
|
||||
(input_buffer && !output_buffer && output_frames == 0));
|
||||
|
||||
@ -74,14 +73,26 @@ long passthrough_resampler<T>::fill(void * input_buffer, long * input_frames_cou
|
||||
if (input_buffer && !output_buffer) {
|
||||
output_frames = *input_frames_count;
|
||||
} else if(input_buffer) {
|
||||
if (internal_input_buffer.length() != 0) {
|
||||
// In this case we have pending input data left and have
|
||||
// to first append the input so we can pass it as one pointer
|
||||
// to the callback
|
||||
if (internal_input_buffer.length() != 0 ||
|
||||
*input_frames_count < output_frames) {
|
||||
// If we have pending input data left and have to first append the input
|
||||
// so we can pass it as one pointer to the callback. Or this is a glitch.
|
||||
// It can happen when system's performance is poor. Audible silence is
|
||||
// being pushed at the end of the short input buffer. An improvement for
|
||||
// the future is to resample to the output number of frames, when that happens.
|
||||
internal_input_buffer.push(static_cast<T*>(input_buffer),
|
||||
frames_to_samples(*input_frames_count));
|
||||
if (internal_input_buffer.length() < frames_to_samples(output_frames)) {
|
||||
// This is unxpected but it can happen when a glitch occurs. Fill the
|
||||
// buffer with silence. First keep the actual number of input samples
|
||||
// used without the silence.
|
||||
pop_input_count = internal_input_buffer.length();
|
||||
internal_input_buffer.push_silence(
|
||||
frames_to_samples(output_frames) - internal_input_buffer.length());
|
||||
} else {
|
||||
pop_input_count = frames_to_samples(output_frames);
|
||||
}
|
||||
in_buf = internal_input_buffer.data();
|
||||
pop_input_count = frames_to_samples(output_frames);
|
||||
} else if(*input_frames_count > output_frames) {
|
||||
// In this case we have more input that we need output and
|
||||
// fill the overflowing input into internal_input_buffer
|
||||
@ -99,15 +110,20 @@ long passthrough_resampler<T>::fill(void * input_buffer, long * input_frames_cou
|
||||
if (input_buffer) {
|
||||
if (pop_input_count) {
|
||||
internal_input_buffer.pop(nullptr, pop_input_count);
|
||||
*input_frames_count = samples_to_frames(pop_input_count);
|
||||
} else {
|
||||
*input_frames_count = output_frames;
|
||||
}
|
||||
|
||||
*input_frames_count = output_frames;
|
||||
drop_audio_if_needed();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Explicit instantiation of template class.
|
||||
template class passthrough_resampler<float>;
|
||||
template class passthrough_resampler<short>;
|
||||
|
||||
template<typename T, typename InputProcessor, typename OutputProcessor>
|
||||
cubeb_resampler_speex<T, InputProcessor, OutputProcessor>
|
||||
::cubeb_resampler_speex(InputProcessor * input_processor,
|
||||
@ -122,17 +138,6 @@ cubeb_resampler_speex<T, InputProcessor, OutputProcessor>
|
||||
, user_ptr(ptr)
|
||||
{
|
||||
if (input_processor && output_processor) {
|
||||
// Add some delay on the processor that has the lowest delay so that the
|
||||
// streams are synchronized.
|
||||
uint32_t in_latency = input_processor->latency();
|
||||
uint32_t out_latency = output_processor->latency();
|
||||
if (in_latency > out_latency) {
|
||||
uint32_t latency_diff = in_latency - out_latency;
|
||||
output_processor->add_latency(latency_diff);
|
||||
} else if (in_latency < out_latency) {
|
||||
uint32_t latency_diff = out_latency - in_latency;
|
||||
input_processor->add_latency(latency_diff);
|
||||
}
|
||||
fill_internal = &cubeb_resampler_speex::fill_internal_duplex;
|
||||
} else if (input_processor) {
|
||||
fill_internal = &cubeb_resampler_speex::fill_internal_input;
|
||||
|
||||
Reference in New Issue
Block a user