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

Commit f9306750 authored by Haynes Mathew George's avatar Haynes Mathew George
Browse files

audio: use of audio_route_{apply/reset}_and_update_path APIs

1) Update enable/disable device and route to use the new APIs.
   With this change, mixer controls will be updated in the order
   listed in mixer paths XML file.
2) update_mixer is now an unused var.

Change-Id: Ic0a8874e4a2080347cfa0c2e66af606a08a207a7
CRs-Fixed: 581453
parent 6ee9e97c
Loading
Loading
Loading
Loading
+12 −28
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ static int get_snd_codec_id(audio_format_t format)

int enable_audio_route(struct audio_device *adev,
                              struct audio_usecase *usecase,
                              bool update_mixer)
                              bool __unused update_mixer)
{
    snd_device_t snd_device;
    char mixer_path[MIXER_PATH_MAX_LENGTH];
@@ -237,18 +237,15 @@ int enable_audio_route(struct audio_device *adev,
#endif
    strcpy(mixer_path, use_case_table[usecase->id]);
    platform_add_backend_name(mixer_path, snd_device);
    ALOGV("%s: apply mixer path: %s", __func__, mixer_path);
    audio_route_apply_path(adev->audio_route, mixer_path);
    if (update_mixer)
        audio_route_update_mixer(adev->audio_route);

    ALOGV("%s: apply mixer and update path: %s", __func__, mixer_path);
    audio_route_apply_and_update_path(adev->audio_route, mixer_path);
    ALOGV("%s: exit", __func__);
    return 0;
}

int disable_audio_route(struct audio_device *adev,
                        struct audio_usecase *usecase,
                        bool update_mixer)
                        bool __unused update_mixer)
{
    snd_device_t snd_device;
    char mixer_path[MIXER_PATH_MAX_LENGTH];
@@ -263,18 +260,15 @@ int disable_audio_route(struct audio_device *adev,
        snd_device = usecase->out_snd_device;
    strcpy(mixer_path, use_case_table[usecase->id]);
    platform_add_backend_name(mixer_path, snd_device);
    ALOGV("%s: reset mixer path: %s", __func__, mixer_path);
    audio_route_reset_path(adev->audio_route, mixer_path);
    if (update_mixer)
        audio_route_update_mixer(adev->audio_route);

    ALOGV("%s: reset and update mixer path: %s", __func__, mixer_path);
    audio_route_reset_and_update_path(adev->audio_route, mixer_path);
    ALOGV("%s: exit", __func__);
    return 0;
}

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

@@ -321,17 +315,14 @@ int enable_snd_device(struct audio_device *adev,
        audio_extn_listen_update_status(snd_device,
                LISTEN_EVENT_SND_DEVICE_BUSY);

        audio_route_apply_path(adev->audio_route, device_name);
        audio_route_apply_and_update_path(adev->audio_route, device_name);
    }
    if (update_mixer)
        audio_route_update_mixer(adev->audio_route);

    return 0;
}

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

@@ -368,10 +359,7 @@ int disable_snd_device(struct audio_device *adev,
            audio_extn_spkr_prot_is_enabled()) {
            audio_extn_spkr_prot_stop_processing();
        } else
            audio_route_reset_path(adev->audio_route, device_name);

        if (update_mixer)
            audio_route_update_mixer(adev->audio_route);
            audio_route_reset_and_update_path(adev->audio_route, device_name);

        audio_extn_listen_update_status(snd_device,
                                        LISTEN_EVENT_SND_DEVICE_FREE);
@@ -420,8 +408,7 @@ static void check_usecases_codec_backend(struct audio_device *adev,
    }

    if (num_uc_to_switch) {
        /* Make sure all the streams are de-routed before disabling the device */
        audio_route_update_mixer(adev->audio_route);
        /* All streams have been de-routed. Disable the device */

        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);
@@ -490,8 +477,7 @@ static void check_and_route_capture_usecases(struct audio_device *adev,
    }

    if (num_uc_to_switch) {
        /* Make sure all the streams are de-routed before disabling the device */
        audio_route_update_mixer(adev->audio_route);
        /* All streams have been de-routed. Disable the device */

        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);
@@ -716,8 +702,6 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
                                                        out_snd_device,
                                                        in_snd_device);

    audio_route_update_mixer(adev->audio_route);

    usecase->in_snd_device = in_snd_device;
    usecase->out_snd_device = out_snd_device;