Audio: remove out stream resampler.
authorstenkinevgeniy <stenkinevgeniy@gmail.com>
Tue, 8 May 2018 07:17:53 +0000 (07:17 +0000)
committerBasil Gello <vasek.gello@gmail.com>
Thu, 24 May 2018 11:56:42 +0000 (14:56 +0300)
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
audio/audio_hw.h

index 20664573dc02f25db5d9b07ec81656dd0682bfee..c526e722fbed913727d1269b1b4a4d9f3955e714 100644 (file)
@@ -2378,14 +2378,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;
@@ -2424,24 +2416,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;
 
@@ -3020,9 +2994,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;
@@ -3118,24 +3091,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) {
@@ -3148,12 +3103,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;
             }
index 1c74d65133e19d2d3c9603b568149b60962810f9..69fef51e8700f74cc269caccce4363b9f3cf2f92 100644 (file)
@@ -241,10 +241,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 {