Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1376ca60 authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Gerrit - the friendly Code Review server
Browse files

audio: Remove unused var and unnecessary code

Remove update_mixer (as its unused) and change function signatures
wherever used.
Remove code chunk to set BT sample rate before enabling device as
thats part of the mixer path file now.

Change-Id: I5eb3bce5183acf505596be2b0ec93cdbd728bdaa
CRs-Fixed: 581453
parent ef1e3d33
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013 - 2014, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2013 The Android Open Source Project
+3 −3
Original line number Diff line number Diff line
@@ -122,11 +122,11 @@ static int32_t fm_stop(struct audio_device *adev)
    }

    /* 2. Get and set stream specific mixer controls */
    disable_audio_route(adev, uc_info, true);
    disable_audio_route(adev, uc_info);

    /* 3. Disable the rx and tx devices */
    disable_snd_device(adev, uc_info->out_snd_device, false);
    disable_snd_device(adev, uc_info->in_snd_device, true);
    disable_snd_device(adev, uc_info->out_snd_device);
    disable_snd_device(adev, uc_info->in_snd_device);

    list_remove(&uc_info->list);
    free(uc_info);
+4 −4
Original line number Diff line number Diff line
/* hfp.c
Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -245,11 +245,11 @@ static int32_t stop_hfp(struct audio_device *adev)
    }

    /* 2. Get and set stream specific mixer controls */
    disable_audio_route(adev, uc_info, true);
    disable_audio_route(adev, uc_info);

    /* 3. Disable the rx and tx devices */
    disable_snd_device(adev, uc_info->out_snd_device, false);
    disable_snd_device(adev, uc_info->in_snd_device, true);
    disable_snd_device(adev, uc_info->out_snd_device);
    disable_snd_device(adev, uc_info->in_snd_device);

    list_remove(&uc_info->list);
    free(uc_info);
+17 −17
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013 - 2014, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -227,8 +227,8 @@ static int spkr_calibrate(int t0)
    uc_info_rx->out_snd_device = SND_DEVICE_OUT_SPEAKER_PROTECTED;
    pthread_mutex_lock(&adev->lock);
    disable_rx = true;
    enable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED, true);
    enable_audio_route(adev, uc_info_rx, true);
    enable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED);
    enable_audio_route(adev, uc_info_rx);
    pthread_mutex_unlock(&adev->lock);

    pcm_dev_rx_id = platform_get_pcm_device_id(uc_info_rx->id, PCM_PLAYBACK);
@@ -257,8 +257,8 @@ static int spkr_calibrate(int t0)

    pthread_mutex_lock(&adev->lock);
    disable_tx = true;
    enable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK, true);
    enable_audio_route(adev, uc_info_tx, true);
    enable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
    enable_audio_route(adev, uc_info_tx);
    pthread_mutex_unlock(&adev->lock);

    pcm_dev_tx_id = platform_get_pcm_device_id(uc_info_tx->id, PCM_CAPTURE);
@@ -336,12 +336,12 @@ exit:
        handle.pcm_tx = NULL;
        pthread_mutex_lock(&adev->lock);
        if (disable_rx) {
            disable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED, true);
            disable_audio_route(adev, uc_info_rx, true);
            disable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED);
            disable_audio_route(adev, uc_info_rx);
        }
        if (disable_tx) {
            disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK, true);
            disable_audio_route(adev, uc_info_tx, true);
            disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
            disable_audio_route(adev, uc_info_tx);
        }
        pthread_mutex_unlock(&adev->lock);

@@ -598,7 +598,7 @@ int audio_extn_spkr_prot_start_processing(snd_device_t snd_device)
    }
    ALOGV("%s: snd_device(%d: %s)", __func__, snd_device,
         platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER_PROTECTED));
    audio_route_apply_path(adev->audio_route,
    audio_route_apply_and_update_path(adev->audio_route,
        platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER_PROTECTED));

    pthread_mutex_lock(&handle.mutex_spkr_prot);
@@ -610,8 +610,8 @@ int audio_extn_spkr_prot_start_processing(snd_device_t snd_device)
        uc_info_tx.out_snd_device = SND_DEVICE_NONE;
        handle.pcm_tx = NULL;

        enable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK, true);
        enable_audio_route(adev, &uc_info_tx, true);
        enable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
        enable_audio_route(adev, &uc_info_tx);

        pcm_dev_tx_id = platform_get_pcm_device_id(uc_info_tx.id, PCM_CAPTURE);
        if (pcm_dev_tx_id < 0) {
@@ -642,8 +642,8 @@ exit:
        if (handle.pcm_tx)
            pcm_close(handle.pcm_tx);
        handle.pcm_tx = NULL;
        disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK, true);
        disable_audio_route(adev, &uc_info_tx, true);
        disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
        disable_audio_route(adev, &uc_info_tx);
    } else
        handle.spkr_processing_state = SPKR_PROCESSING_IN_PROGRESS;
    pthread_mutex_unlock(&handle.mutex_spkr_prot);
@@ -667,12 +667,12 @@ void audio_extn_spkr_prot_stop_processing()
        if (handle.pcm_tx)
            pcm_close(handle.pcm_tx);
        handle.pcm_tx = NULL;
        disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK, true);
        disable_audio_route(adev, &uc_info_tx, true);
        disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
        disable_audio_route(adev, &uc_info_tx);
    }
    handle.spkr_processing_state = SPKR_PROCESSING_IN_IDLE;
    pthread_mutex_unlock(&handle.mutex_spkr_prot);
    audio_route_reset_path(adev->audio_route,
    audio_route_reset_and_update_path(adev->audio_route,
      platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER_PROTECTED));
    ALOGV("%s: Exit", __func__);
}
+25 −41
Original line number Diff line number Diff line
@@ -238,8 +238,7 @@ static int get_snd_codec_id(audio_format_t format)
}

int enable_audio_route(struct audio_device *adev,
                              struct audio_usecase *usecase,
                              bool __unused update_mixer)
                       struct audio_usecase *usecase)
{
    snd_device_t snd_device;
    char mixer_path[MIXER_PATH_MAX_LENGTH];
@@ -267,8 +266,7 @@ int enable_audio_route(struct audio_device *adev,
}

int disable_audio_route(struct audio_device *adev,
                        struct audio_usecase *usecase,
                        bool __unused update_mixer)
                        struct audio_usecase *usecase)
{
    snd_device_t snd_device;
    char mixer_path[MIXER_PATH_MAX_LENGTH];
@@ -290,8 +288,7 @@ int disable_audio_route(struct audio_device *adev,
}

int enable_snd_device(struct audio_device *adev,
                             snd_device_t snd_device,
                             bool __unused update_mixer)
                      snd_device_t snd_device)
{
    char device_name[DEVICE_NAME_MAX_SIZE] = {0};

@@ -313,18 +310,6 @@ int enable_snd_device(struct audio_device *adev,
        return 0;
    }

    /* Set BT sample rate before enabling the devices. Adding sample rate mixer
     * control in use-case does not work because rate update takes place after
     * AFE port open due to the limitation of mixer control order execution.
     */
    if ((snd_device == SND_DEVICE_OUT_BT_SCO) ||
        (snd_device == SND_DEVICE_IN_BT_SCO_MIC)) {
        audio_route_apply_and_update_path(adev->audio_route, BT_SCO_SAMPLE_RATE);
    } else if ((snd_device == SND_DEVICE_OUT_BT_SCO_WB) ||
               (snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB)) {
        audio_route_apply_and_update_path(adev->audio_route, BT_SCO_WB_SAMPLE_RATE);
    }

    /* start usb playback thread */
    if(SND_DEVICE_OUT_USB_HEADSET == snd_device ||
       SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET == snd_device)
@@ -360,8 +345,7 @@ int enable_snd_device(struct audio_device *adev,
}

int disable_snd_device(struct audio_device *adev,
                       snd_device_t snd_device,
                       bool __unused update_mixer)
                       snd_device_t snd_device)
{
    char device_name[DEVICE_NAME_MAX_SIZE] = {0};

@@ -441,7 +425,7 @@ static void check_usecases_codec_backend(struct audio_device *adev,
            ALOGV("%s: Usecase (%s) is active on (%s) - disabling ..",
                  __func__, use_case_table[usecase->id],
                  platform_get_snd_device_name(usecase->out_snd_device));
            disable_audio_route(adev, usecase, false);
            disable_audio_route(adev, usecase);
            switch_device[usecase->id] = true;
            num_uc_to_switch++;
        }
@@ -455,14 +439,14 @@ static void check_usecases_codec_backend(struct audio_device *adev,
        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);
            if (switch_device[usecase->id]) {
                disable_snd_device(adev, usecase->out_snd_device, true);
                disable_snd_device(adev, usecase->out_snd_device);
            }
        }

        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);
            if (switch_device[usecase->id]) {
                enable_snd_device(adev, snd_device, true);
                enable_snd_device(adev, snd_device);
            }
        }

@@ -473,7 +457,7 @@ static void check_usecases_codec_backend(struct audio_device *adev,
            /* Update the out_snd_device only before enabling the audio route */
            if (switch_device[usecase->id] ) {
                usecase->out_snd_device = snd_device;
                enable_audio_route(adev, usecase, false);
                enable_audio_route(adev, usecase);
            }
        }
    }
@@ -509,7 +493,7 @@ static void check_and_route_capture_usecases(struct audio_device *adev,
            ALOGV("%s: Usecase (%s) is active on (%s) - disabling ..",
                  __func__, use_case_table[usecase->id],
                  platform_get_snd_device_name(usecase->in_snd_device));
            disable_audio_route(adev, usecase, false);
            disable_audio_route(adev, usecase);
            switch_device[usecase->id] = true;
            num_uc_to_switch++;
        }
@@ -523,14 +507,14 @@ static void check_and_route_capture_usecases(struct audio_device *adev,
        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);
            if (switch_device[usecase->id]) {
                disable_snd_device(adev, usecase->in_snd_device, true);
                disable_snd_device(adev, usecase->in_snd_device);
            }
        }

        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);
            if (switch_device[usecase->id]) {
                enable_snd_device(adev, snd_device, true);
                enable_snd_device(adev, snd_device);
            }
        }

@@ -541,7 +525,7 @@ static void check_and_route_capture_usecases(struct audio_device *adev,
            /* Update the in_snd_device only before enabling the audio route */
            if (switch_device[usecase->id] ) {
                usecase->in_snd_device = snd_device;
                enable_audio_route(adev, usecase, false);
                enable_audio_route(adev, usecase);
            }
        }
    }
@@ -708,13 +692,13 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)

    /* Disable current sound devices */
    if (usecase->out_snd_device != SND_DEVICE_NONE) {
        disable_audio_route(adev, usecase, true);
        disable_snd_device(adev, usecase->out_snd_device, true);
        disable_audio_route(adev, usecase);
        disable_snd_device(adev, usecase->out_snd_device);
    }

    if (usecase->in_snd_device != SND_DEVICE_NONE) {
        disable_audio_route(adev, usecase, true);
        disable_snd_device(adev, usecase->in_snd_device, true);
        disable_audio_route(adev, usecase);
        disable_snd_device(adev, usecase->in_snd_device);
    }

    /* Applicable only on the targets that has external modem.
@@ -730,12 +714,12 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
    if (out_snd_device != SND_DEVICE_NONE) {
        if (usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND)
            check_usecases_codec_backend(adev, usecase, out_snd_device);
        enable_snd_device(adev, out_snd_device, false);
        enable_snd_device(adev, out_snd_device);
    }

    if (in_snd_device != SND_DEVICE_NONE) {
        check_and_route_capture_usecases(adev, usecase, in_snd_device);
        enable_snd_device(adev, in_snd_device, false);
        enable_snd_device(adev, in_snd_device);
    }

    if (usecase->type == VOICE_CALL || usecase->type == VOIP_CALL)
@@ -746,7 +730,7 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
    usecase->in_snd_device = in_snd_device;
    usecase->out_snd_device = out_snd_device;

    enable_audio_route(adev, usecase, true);
    enable_audio_route(adev, usecase);

    /* Applicable only on the targets that has external modem.
     * Enable device command should be sent to modem only after
@@ -781,10 +765,10 @@ static int stop_input_stream(struct stream_in *in)
    voice_check_and_stop_incall_rec_usecase(adev, in);

    /* 1. Disable stream specific mixer controls */
    disable_audio_route(adev, uc_info, true);
    disable_audio_route(adev, uc_info);

    /* 2. Disable the tx device */
    disable_snd_device(adev, uc_info->in_snd_device, true);
    disable_snd_device(adev, uc_info->in_snd_device);

    list_remove(&uc_info->list);
    free(uc_info);
@@ -1113,7 +1097,7 @@ static int check_and_set_hdmi_channels(struct audio_device *adev,
        usecase = node_to_item(node, struct audio_usecase, list);
        if (usecase->type == PCM_PLAYBACK &&
                usecase->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
            disable_audio_route(adev, usecase, true);
            disable_audio_route(adev, usecase);
        }
    }

@@ -1125,7 +1109,7 @@ static int check_and_set_hdmi_channels(struct audio_device *adev,
        usecase = node_to_item(node, struct audio_usecase, list);
        if (usecase->type == PCM_PLAYBACK &&
                usecase->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
            enable_audio_route(adev, usecase, true);
            enable_audio_route(adev, usecase);
        }
    }

@@ -1155,10 +1139,10 @@ static int stop_output_stream(struct stream_out *out)
    }

    /* 1. Get and set stream specific mixer controls */
    disable_audio_route(adev, uc_info, true);
    disable_audio_route(adev, uc_info);

    /* 2. Disable the rx device */
    disable_snd_device(adev, uc_info->out_snd_device, true);
    disable_snd_device(adev, uc_info->out_snd_device);

    list_remove(&uc_info->list);
    free(uc_info);
Loading