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

Commit 957b4382 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "add offloaded audio visualizer" into klp-dev

parents b891db54 c4aef75c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ include $(MY_LOCAL_PATH)/legacy/Android.mk
else
include $(MY_LOCAL_PATH)/hal/Android.mk
include $(MY_LOCAL_PATH)/voice_processing/Android.mk
include $(MY_LOCAL_PATH)/visualizer/Android.mk
endif

endif
+25 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <sys/time.h>
#include <stdlib.h>
#include <math.h>
#include <dlfcn.h>
#include <sys/resource.h>
#include <sys/prctl.h>

@@ -797,6 +798,10 @@ static int stop_output_stream(struct stream_out *out)
        return -EINVAL;
    }

    if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD &&
            adev->visualizer_stop_output != NULL)
        adev->visualizer_stop_output(out->handle);

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

@@ -863,6 +868,9 @@ int start_output_stream(struct stream_out *out)
        }
        if (out->offload_callback)
            compress_nonblock(out->compr, out->non_blocking);

        if (adev->visualizer_start_output != NULL)
            adev->visualizer_start_output(out->handle);
    }
    ALOGV("%s: exit", __func__);
    return 0;
@@ -1742,6 +1750,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
    out->sample_rate = config->sample_rate;
    out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
    out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_STEREO;
    out->handle = handle;

    /* Init use case and pcm_config */
    if (out->flags & AUDIO_OUTPUT_FLAG_DIRECT &&
@@ -2263,6 +2272,22 @@ static int adev_open(const hw_module_t *module, const char *name,
        *device = NULL;
        return -EINVAL;
    }

    if (access(VISUALIZER_LIBRARY_PATH, R_OK) == 0) {
        adev->visualizer_lib = dlopen(VISUALIZER_LIBRARY_PATH, RTLD_NOW);
        if (adev->visualizer_lib == NULL) {
            ALOGE("%s: DLOPEN failed for %s", __func__, VISUALIZER_LIBRARY_PATH);
        } else {
            ALOGV("%s: DLOPEN successful for %s", __func__, VISUALIZER_LIBRARY_PATH);
            adev->visualizer_start_output =
                        (int (*)(audio_io_handle_t))dlsym(adev->visualizer_lib,
                                                        "visualizer_hal_start_output");
            adev->visualizer_stop_output =
                        (int (*)(audio_io_handle_t))dlsym(adev->visualizer_lib,
                                                        "visualizer_hal_stop_output");
        }
    }

    *device = &adev->device.common;

    ALOGV("%s: exit", __func__);
+7 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@

#include <audio_route/audio_route.h>

#define VISUALIZER_LIBRARY_PATH "/system/lib/soundfx/libqcomvisualizer.so"

/* Flags used to initialize acdb_settings variable that goes to ACDB library */
#define DMIC_FLAG       0x00000002
#define TTY_MODE_OFF    0x00000010
@@ -110,6 +112,7 @@ struct stream_out {
    audio_channel_mask_t supported_channel_masks[MAX_SUPPORTED_CHANNEL_MASKS + 1];
    bool muted;
    uint64_t written; /* total frames written, not cleared when entering standby */
    audio_io_handle_t handle;

    int non_blocking;
    int playback_started;
@@ -187,6 +190,10 @@ struct audio_device {
    bool speaker_lr_swap;

    void *platform;

    void *visualizer_lib;
    int (*visualizer_start_output)(audio_io_handle_t);
    int (*visualizer_stop_output)(audio_io_handle_t);
};

/*

visualizer/Android.mk

0 → 100644
+36 −0
Original line number Diff line number Diff line
# Copyright 2013 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
	offload_visualizer.c

LOCAL_CFLAGS+= -O2 -fvisibility=hidden

LOCAL_SHARED_LIBRARIES := \
	libcutils \
	liblog \
	libtinyalsa

LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
LOCAL_MODULE:= libqcomvisualizer

LOCAL_C_INCLUDES := \
	external/tinyalsa/include \
	$(call include-path-for, audio-effects)

include $(BUILD_SHARED_LIBRARY)
+0 −0

Empty file added.

Loading