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

Unverified Commit 921d3e24 authored by Rashed Abdel-Tawab's avatar Rashed Abdel-Tawab
Browse files

audio: Guard power@1.2 hints

Not every device will implement these, so guard them behind
AUDIO_FEATURE_ENABLED_PERF_HINTS

Change-Id: If2f4e373f1ab2924d84b4a18ddce9f68e301e7c4
parent 041c2b53
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -437,8 +437,11 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SND_MONITOR)), true)
    LOCAL_SRC_FILES += audio_extn/sndmonitor.c
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PERF_HINTS)), true)
LOCAL_SHARED_LIBRARIES += libbase libhidlbase libhwbinder libutils android.hardware.power@1.2 liblog
LOCAL_SRC_FILES += audio_perf.cpp
LOCAL_CFLAGS += -DPERF_HINTS_ENABLED
endif

LOCAL_HEADER_LIBRARIES += libhardware_headers

+18 −0
Original line number Diff line number Diff line
@@ -73,7 +73,9 @@
#include "platform_api.h"
#include <platform.h>
#include "audio_extn.h"
#ifdef PERF_HINTS_ENABLED
#include "audio_perf.h"
#endif
#include "voice_extn.h"
#include "ip_hdlr_intf.h"
#include "audio_amplifier.h"
@@ -2475,7 +2477,9 @@ int start_input_stream(struct stream_in *in)
    uc_info->out_snd_device = SND_DEVICE_NONE;

    list_add_tail(&adev->usecase_list, &uc_info->list);
#ifdef PERF_HINTS_ENABLED
    audio_streaming_hint_start();
#endif
    audio_extn_perf_lock_acquire(&adev->perf_lock_handle, 0,
                                 adev->perf_lock_opts,
                                 adev->perf_lock_opts_size);
@@ -2565,14 +2569,18 @@ int start_input_stream(struct stream_in *in)
    check_and_enable_effect(adev);

done_open:
#ifdef PERF_HINTS_ENABLED
    audio_streaming_hint_end();
#endif
    audio_extn_perf_lock_release(&adev->perf_lock_handle);
    ALOGD("%s: exit", __func__);

    return ret;

error_open:
#ifdef PERF_HINTS_ENABLED
    audio_streaming_hint_end();
#endif
    audio_extn_perf_lock_release(&adev->perf_lock_handle);
    stop_input_stream(in);
error_config:
@@ -2912,9 +2920,11 @@ static int stop_output_stream(struct stream_out *out)

        if (adev->offload_effects_stop_output != NULL)
            adev->offload_effects_stop_output(out->handle, out->pcm_device_id);
#ifdef PERF_HINTS_ENABLED
    } else if (out->usecase == USECASE_AUDIO_PLAYBACK_ULL ||
               out->usecase == USECASE_AUDIO_PLAYBACK_MMAP) {
        audio_low_latency_hint_end();
#endif
    }

    /* 1. Get and set stream specific mixer controls */
@@ -3050,7 +3060,9 @@ int start_output_stream(struct stream_out *out)

    list_add_tail(&adev->usecase_list, &uc_info->list);

#ifdef PERF_HINTS_ENABLED
    audio_streaming_hint_start();
#endif
    audio_extn_perf_lock_acquire(&adev->perf_lock_handle, 0,
                                 adev->perf_lock_opts,
                                 adev->perf_lock_opts_size);
@@ -3231,13 +3243,17 @@ int start_output_stream(struct stream_out *out)
        }
    }

#ifdef PERF_HINTS_ENABLED
    audio_streaming_hint_end();
#endif
    audio_extn_perf_lock_release(&adev->perf_lock_handle);

#ifdef PERF_HINTS_ENABLED
    if (out->usecase == USECASE_AUDIO_PLAYBACK_ULL ||
        out->usecase == USECASE_AUDIO_PLAYBACK_MMAP) {
        audio_low_latency_hint_start();
    }
#endif

    ALOGD("%s: exit", __func__);

@@ -3257,7 +3273,9 @@ int start_output_stream(struct stream_out *out)
    ATRACE_END();
    return ret;
error_open:
#ifdef PERF_HINTS_ENABLED
    audio_streaming_hint_end();
#endif
    audio_extn_perf_lock_release(&adev->perf_lock_handle);
    stop_output_stream(out);
error_config: