From d0a02c0982359dc9d9d141d5db945c559a2bb927 Mon Sep 17 00:00:00 2001 From: stenkinevgeniy Date: Tue, 8 May 2018 07:17:53 +0000 Subject: [PATCH] Audio: remove out stream resampler. This never use - because - out->sample_rate and out->config configured in adev_open_output_stream out->config = can have deep or no pcm config with only 48000 sample rate. Change-Id: Ie1c4025585ab6e1b7a900486181c1bceeff88139 --- audio/audio_hw.c | 54 ++---------------------------------------------- audio/audio_hw.h | 4 ---- 2 files changed, 2 insertions(+), 56 deletions(-) diff --git a/audio/audio_hw.c b/audio/audio_hw.c index f97758cf..4d0b6709 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -2247,14 +2247,6 @@ static int out_close_pcm_devices(struct stream_out *out) pcm_close(pcm_device->pcm); pcm_device->pcm = NULL; } - if (pcm_device->resampler) { - release_resampler(pcm_device->resampler); - pcm_device->resampler = NULL; - } - if (pcm_device->res_buffer) { - free(pcm_device->res_buffer); - pcm_device->res_buffer = NULL; - } } return 0; @@ -2293,24 +2285,6 @@ static int out_open_pcm_devices(struct stream_out *out) ret = -EIO; goto error_open; } - /* - * If the stream rate differs from the PCM rate, we need to - * create a resampler. - */ - if (out->sample_rate != pcm_device->pcm_profile->config.rate) { - ALOGV("%s: create_resampler(), pcm_device_card(%d), pcm_device_id(%d), \ - out_rate(%d), device_rate(%d)",__func__, - pcm_device_card, pcm_device_id, - out->sample_rate, pcm_device->pcm_profile->config.rate); - ret = create_resampler(out->sample_rate, - pcm_device->pcm_profile->config.rate, - audio_channel_count_from_out_mask(out->channel_mask), - RESAMPLER_QUALITY_DEFAULT, - NULL, - &pcm_device->resampler); - pcm_device->res_byte_count = 0; - pcm_device->res_buffer = NULL; - } } return ret; @@ -2889,9 +2863,8 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, ssize_t ret = 0; struct pcm_device *pcm_device; struct listnode *node; - size_t frame_size = audio_stream_out_frame_size(stream); - size_t frames_wr = 0, frames_rq = 0; #ifdef PREPROCESSING_ENABLED + size_t frame_size = audio_stream_out_frame_size(stream); size_t in_frames = bytes / frame_size; size_t out_frames = in_frames; struct stream_in *in = NULL; @@ -2987,24 +2960,6 @@ false_alarm: memset((void *)buffer, 0, bytes); list_for_each(node, &out->pcm_dev_list) { pcm_device = node_to_item(node, struct pcm_device, stream_list_node); - if (pcm_device->resampler) { - if (bytes * pcm_device->pcm_profile->config.rate / out->sample_rate + frame_size - > pcm_device->res_byte_count) { - pcm_device->res_byte_count = - bytes * pcm_device->pcm_profile->config.rate / out->sample_rate + frame_size; - pcm_device->res_buffer = - realloc(pcm_device->res_buffer, pcm_device->res_byte_count); - ALOGV("%s: resampler res_byte_count = %zu", __func__, - pcm_device->res_byte_count); - } - frames_rq = bytes / frame_size; - frames_wr = pcm_device->res_byte_count / frame_size; - ALOGVV("%s: resampler request frames = %d frame_size = %d", - __func__, frames_rq, frame_size); - pcm_device->resampler->resample_from_input(pcm_device->resampler, - (int16_t *)buffer, &frames_rq, (int16_t *)pcm_device->res_buffer, &frames_wr); - ALOGVV("%s: resampler output frames_= %d", __func__, frames_wr); - } if (pcm_device->pcm) { #ifdef PREPROCESSING_ENABLED if (out->echo_reference != NULL && pcm_device->pcm_profile->devices != SND_DEVICE_OUT_SPEAKER) { @@ -3017,12 +2972,7 @@ false_alarm: } #endif ALOGVV("%s: writing buffer (%d bytes) to pcm device", __func__, bytes); - if (pcm_device->resampler && pcm_device->res_buffer) - pcm_device->status = - pcm_write(pcm_device->pcm, (void *)pcm_device->res_buffer, - frames_wr * frame_size); - else - pcm_device->status = pcm_write(pcm_device->pcm, (void *)buffer, bytes); + pcm_device->status = pcm_write(pcm_device->pcm, (void *)buffer, bytes); if (pcm_device->status != 0) ret = pcm_device->status; } diff --git a/audio/audio_hw.h b/audio/audio_hw.h index 820d3550..871c04fb 100644 --- a/audio/audio_hw.h +++ b/audio/audio_hw.h @@ -240,10 +240,6 @@ struct pcm_device { struct pcm_device_profile* pcm_profile; struct pcm* pcm; int status; - /* TODO: remove resampler if possible when AudioFlinger supports downsampling from 48 to 8 */ - struct resampler_itfe* resampler; - int16_t* res_buffer; - size_t res_byte_count; }; struct stream_out {