├── Android.mk ├── audiod ├── Android.mk ├── AudioDaemon.cpp ├── AudioDaemon.h └── audiod_main.cpp ├── hal ├── Android.mk ├── audio_extn │ ├── audio_defs.h │ ├── audio_extn.c │ ├── audio_extn.h │ ├── compress_capture.c │ ├── dev_arbi.c │ ├── dolby.c │ ├── dts_eagle.c │ ├── fm.c │ ├── hfp.c │ ├── listen.c │ ├── pm.c │ ├── pm.h │ ├── soundtrigger.c │ ├── source_track.c │ ├── spkr_protection.c │ ├── ssr.c │ ├── usb.c │ └── utils.c ├── audio_hw.c ├── audio_hw.h ├── edid.c ├── edid.h ├── msm8916 │ ├── hw_info.c │ ├── platform.c │ └── platform.h ├── msm8960 │ ├── platform.c │ └── platform.h ├── msm8974 │ ├── hw_info.c │ ├── platform.c │ └── platform.h ├── platform_api.h ├── platform_info.c ├── voice.c ├── voice.h └── voice_extn │ ├── compress_voip.c │ ├── voice_extn.c │ └── voice_extn.h ├── mm-audio ├── Android.mk ├── Makefile ├── Makefile.am ├── aenc-aac │ ├── Android.mk │ ├── Makefile │ ├── Makefile.am │ └── qdsp6 │ │ ├── Android.mk │ │ ├── Makefile │ │ ├── Makefile.am │ │ ├── inc │ │ ├── Map.h │ │ ├── aenc_svr.h │ │ └── omx_aac_aenc.h │ │ ├── src │ │ ├── aenc_svr.c │ │ └── omx_aac_aenc.cpp │ │ └── test │ │ └── omx_aac_enc_test.c ├── aenc-amrnb │ ├── Android.mk │ ├── Makefile │ └── qdsp6 │ │ ├── Android.mk │ │ ├── Makefile │ │ ├── inc │ │ ├── Map.h │ │ ├── aenc_svr.h │ │ └── omx_amr_aenc.h │ │ ├── src │ │ ├── aenc_svr.c │ │ └── omx_amr_aenc.cpp │ │ └── test │ │ └── omx_amr_enc_test.c ├── aenc-evrc │ ├── Android.mk │ ├── Makefile │ └── qdsp6 │ │ ├── Android.mk │ │ ├── Makefile │ │ ├── inc │ │ ├── Map.h │ │ ├── aenc_svr.h │ │ └── omx_evrc_aenc.h │ │ ├── src │ │ ├── aenc_svr.c │ │ └── omx_evrc_aenc.cpp │ │ └── test │ │ └── omx_evrc_enc_test.c ├── aenc-qcelp13 │ ├── Android.mk │ ├── Makefile │ └── qdsp6 │ │ ├── Android.mk │ │ ├── Makefile │ │ ├── inc │ │ ├── Map.h │ │ ├── aenc_svr.h │ │ └── omx_qcelp13_aenc.h │ │ ├── src │ │ ├── aenc_svr.c │ │ └── omx_qcelp13_aenc.cpp │ │ └── test │ │ └── omx_qcelp13_enc_test.c ├── autogen.sh └── configure.ac ├── policy_hal ├── Android.mk ├── AudioPolicyManager.cpp └── AudioPolicyManager.h ├── post_proc ├── Android.mk ├── EffectsHwAcc.cpp ├── EffectsHwAcc.h ├── asphere.c ├── asphere.h ├── bass_boost.c ├── bass_boost.h ├── bundle.c ├── bundle.h ├── effect_api.c ├── effect_api.h ├── effect_util.c ├── effect_util.h ├── equalizer.c ├── equalizer.h ├── hw_accelerator.c ├── hw_accelerator.h ├── reverb.c ├── reverb.h ├── virtualizer.c ├── virtualizer.h └── volume_listener.c ├── visualizer ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── offload_visualizer.c └── voice_processing ├── Android.mk └── voice_processing.c /Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(filter mpq8092 msm8960 msm8226 msm8x26 msm8610 msm8974 msm8x74 apq8084 msm8916 msm8994 msm8992 msm8909 msm8996 msm8952 msm8937 thorium,$(TARGET_BOARD_PLATFORM)),) 2 | 3 | MY_LOCAL_PATH := $(call my-dir) 4 | 5 | ifeq ($(BOARD_USES_LEGACY_ALSA_AUDIO),true) 6 | include $(MY_LOCAL_PATH)/legacy/Android.mk 7 | else 8 | ifneq ($(filter mpq8092,$(TARGET_BOARD_PLATFORM)),) 9 | include $(MY_LOCAL_PATH)/hal_mpq/Android.mk 10 | else 11 | include $(MY_LOCAL_PATH)/hal/Android.mk 12 | endif 13 | include $(MY_LOCAL_PATH)/voice_processing/Android.mk 14 | include $(MY_LOCAL_PATH)/mm-audio/Android.mk 15 | include $(MY_LOCAL_PATH)/policy_hal/Android.mk 16 | include $(MY_LOCAL_PATH)/visualizer/Android.mk 17 | include $(MY_LOCAL_PATH)/audiod/Android.mk 18 | include $(MY_LOCAL_PATH)/post_proc/Android.mk 19 | endif 20 | 21 | endif 22 | -------------------------------------------------------------------------------- /audiod/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | ifneq (,$(findstring $(PLATFORM_VERSION), 5.0 5.1 5.1.1)) 6 | include external/stlport/libstlport.mk 7 | endif 8 | 9 | LOCAL_SRC_FILES:= \ 10 | audiod_main.cpp \ 11 | AudioDaemon.cpp \ 12 | 13 | LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES 14 | 15 | LOCAL_SHARED_LIBRARIES := \ 16 | libcutils \ 17 | libutils \ 18 | libbinder \ 19 | libmedia 20 | 21 | ifneq (,$(findstring $(PLATFORM_VERSION), 5.0 5.1 5.1.1)) 22 | LOCAL_SHARED_LIBRARIES += libstlport 23 | endif 24 | 25 | LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 26 | 27 | LOCAL_MODULE:= audiod 28 | 29 | include $(BUILD_EXECUTABLE) 30 | -------------------------------------------------------------------------------- /audiod/AudioDaemon.h: -------------------------------------------------------------------------------- 1 | /* AudioDaemon.h 2 | 3 | Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following 12 | disclaimer in the documentation and/or other materials provided 13 | with the distribution. 14 | * Neither the name of The Linux Foundation nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 28 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | 41 | namespace android { 42 | 43 | enum notify_status { 44 | snd_card_online, 45 | snd_card_offline, 46 | cpe_online, 47 | cpe_offline 48 | }; 49 | 50 | enum notify_status_type { 51 | SND_CARD_STATE, 52 | CPE_STATE 53 | }; 54 | 55 | enum audio_event_status {audio_event_on, audio_event_off}; 56 | 57 | #define AUDIO_PARAMETER_KEY_EXT_AUDIO_DEVICE "ext_audio_device" 58 | 59 | class AudioDaemon:public Thread, public IBinder :: DeathRecipient 60 | { 61 | /*Overrides*/ 62 | virtual bool threadLoop(); 63 | virtual status_t readyToRun(); 64 | virtual void onFirstRef(); 65 | virtual void binderDied(const wp < IBinder > &who); 66 | 67 | bool processUeventMessage(); 68 | void notifyAudioSystem(int snd_card, 69 | notify_status status, 70 | notify_status_type type); 71 | void notifyAudioSystemEventStatus(const char* event, audio_event_status status); 72 | int mUeventSock; 73 | bool getStateFDs(std::vector > &sndcardFdPair); 74 | void putStateFDs(std::vector > &sndcardFdPair); 75 | bool getDeviceEventFDs(); 76 | void putDeviceEventFDs(); 77 | void checkEventState(int fd, int index); 78 | 79 | public: 80 | AudioDaemon(); 81 | virtual ~AudioDaemon(); 82 | 83 | private: 84 | std::vector > mSndCardFd; 85 | 86 | //file descriptors for audio device events and their statuses 87 | std::vector > mAudioEvents; 88 | std::vector > mAudioEventsStatus; 89 | 90 | }; 91 | 92 | } 93 | -------------------------------------------------------------------------------- /audiod/audiod_main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 The Android Open Source Project 2 | 3 | Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. 4 | 5 | Not a Contribution, Apache license notifications and license are retained 6 | for attribution purposes only. 7 | 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #define LOG_TAG "AudioDaemonMain" 22 | #define LOG_NDEBUG 0 23 | #define LOG_NDDEBUG 0 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | #if defined(HAVE_PTHREADS) 35 | # include 36 | # include 37 | #endif 38 | 39 | #include "AudioDaemon.h" 40 | 41 | using namespace android; 42 | 43 | // --------------------------------------------------------------------------- 44 | 45 | int main(int argc, char** argv) 46 | { 47 | #if defined(HAVE_PTHREADS) 48 | setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_AUDIO); 49 | #endif 50 | 51 | 52 | ALOGV("Audio daemon starting sequence.."); 53 | sp proc(ProcessState::self()); 54 | ProcessState::self()->startThreadPool(); 55 | 56 | sp audioService = new AudioDaemon(); 57 | IPCThreadState::self()->joinThreadPool(); 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /hal/Android.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(strip $(BOARD_USES_ALSA_AUDIO)),true) 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | 7 | LOCAL_ARM_MODE := arm 8 | 9 | AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM) 10 | 11 | ifneq ($(filter msm8974 msm8226 msm8610 apq8084 msm8994 msm8992 msm8996,$(TARGET_BOARD_PLATFORM)),) 12 | # B-family platform uses msm8974 code base 13 | AUDIO_PLATFORM = msm8974 14 | MULTIPLE_HW_VARIANTS_ENABLED := true 15 | ifneq ($(filter msm8610,$(TARGET_BOARD_PLATFORM)),) 16 | LOCAL_CFLAGS := -DPLATFORM_MSM8610 17 | endif 18 | ifneq ($(filter msm8226,$(TARGET_BOARD_PLATFORM)),) 19 | LOCAL_CFLAGS := -DPLATFORM_MSM8x26 20 | endif 21 | ifneq ($(filter apq8084,$(TARGET_BOARD_PLATFORM)),) 22 | LOCAL_CFLAGS := -DPLATFORM_APQ8084 23 | endif 24 | ifneq ($(filter msm8994,$(TARGET_BOARD_PLATFORM)),) 25 | LOCAL_CFLAGS := -DPLATFORM_MSM8994 26 | endif 27 | ifneq ($(filter msm8992,$(TARGET_BOARD_PLATFORM)),) 28 | LOCAL_CFLAGS := -DPLATFORM_MSM8994 29 | endif 30 | ifneq ($(filter msm8996,$(TARGET_BOARD_PLATFORM)),) 31 | LOCAL_CFLAGS := -DPLATFORM_MSM8996 32 | endif 33 | endif 34 | 35 | ifneq ($(filter msm8916 msm8909 msm8952 msm8937 thorium,$(TARGET_BOARD_PLATFORM)),) 36 | AUDIO_PLATFORM = msm8916 37 | MULTIPLE_HW_VARIANTS_ENABLED := true 38 | LOCAL_CFLAGS := -DPLATFORM_MSM8916 39 | ifneq ($(filter msm8909,$(TARGET_BOARD_PLATFORM)),) 40 | LOCAL_CFLAGS := -DPLATFORM_MSM8909 41 | endif 42 | endif 43 | 44 | LOCAL_SRC_FILES := \ 45 | audio_hw.c \ 46 | voice.c \ 47 | platform_info.c \ 48 | $(AUDIO_PLATFORM)/platform.c 49 | 50 | LOCAL_SRC_FILES += audio_extn/audio_extn.c \ 51 | audio_extn/utils.c 52 | LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 53 | LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 54 | 55 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_EDID)),true) 56 | LOCAL_CFLAGS += -DHDMI_EDID 57 | LOCAL_SRC_FILES += edid.c 58 | endif 59 | 60 | ifeq ($(strip $(AUDIO_USE_LL_AS_PRIMARY_OUTPUT)),true) 61 | LOCAL_CFLAGS += -DUSE_LL_AS_PRIMARY_OUTPUT 62 | endif 63 | 64 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD)),true) 65 | LOCAL_CFLAGS += -DPCM_OFFLOAD_ENABLED 66 | endif 67 | 68 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ANC_HEADSET)),true) 69 | LOCAL_CFLAGS += -DANC_HEADSET_ENABLED 70 | endif 71 | 72 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_VBAT_MONITOR)),true) 73 | LOCAL_CFLAGS += -DVBAT_MONITOR_ENABLED 74 | endif 75 | 76 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FLUENCE)),true) 77 | LOCAL_CFLAGS += -DFLUENCE_ENABLED 78 | endif 79 | 80 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PROXY_DEVICE)),true) 81 | LOCAL_CFLAGS += -DAFE_PROXY_ENABLED 82 | endif 83 | 84 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_KPI_OPTIMIZE)),true) 85 | LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED 86 | endif 87 | 88 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FM_POWER_OPT)),true) 89 | LOCAL_CFLAGS += -DFM_POWER_OPT 90 | LOCAL_SRC_FILES += audio_extn/fm.c 91 | endif 92 | 93 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USBAUDIO)),true) 94 | LOCAL_CFLAGS += -DUSB_HEADSET_ENABLED 95 | LOCAL_SRC_FILES += audio_extn/usb.c 96 | endif 97 | 98 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HFP)),true) 99 | LOCAL_CFLAGS += -DHFP_ENABLED 100 | LOCAL_SRC_FILES += audio_extn/hfp.c 101 | endif 102 | 103 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_CUSTOMSTEREO)),true) 104 | LOCAL_CFLAGS += -DCUSTOM_STEREO_ENABLED 105 | endif 106 | 107 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SSR)),true) 108 | LOCAL_CFLAGS += -DSSR_ENABLED 109 | LOCAL_SRC_FILES += audio_extn/ssr.c 110 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/surround_sound_3mic/ 111 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc/ 112 | endif 113 | 114 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_MULTI_VOICE_SESSIONS)),true) 115 | LOCAL_CFLAGS += -DMULTI_VOICE_SESSION_ENABLED 116 | LOCAL_SRC_FILES += voice_extn/voice_extn.c 117 | 118 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_INCALL_MUSIC)),true) 119 | LOCAL_CFLAGS += -DINCALL_MUSIC_ENABLED 120 | endif 121 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_COMPRESS_VOIP)),true) 122 | LOCAL_CFLAGS += -DCOMPRESS_VOIP_ENABLED 123 | LOCAL_SRC_FILES += voice_extn/compress_voip.c 124 | endif 125 | 126 | endif 127 | 128 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FORMATS)),true) 129 | LOCAL_CFLAGS += -DAUDIO_EXTN_FORMATS_ENABLED 130 | endif 131 | 132 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SPKR_PROTECTION)),true) 133 | LOCAL_CFLAGS += -DSPKR_PROT_ENABLED 134 | LOCAL_SRC_FILES += audio_extn/spkr_protection.c 135 | endif 136 | 137 | ifdef MULTIPLE_HW_VARIANTS_ENABLED 138 | LOCAL_CFLAGS += -DHW_VARIANTS_ENABLED 139 | LOCAL_SRC_FILES += $(AUDIO_PLATFORM)/hw_info.c 140 | endif 141 | 142 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_COMPRESS_CAPTURE)),true) 143 | LOCAL_CFLAGS += -DCOMPRESS_CAPTURE_ENABLED 144 | LOCAL_SRC_FILES += audio_extn/compress_capture.c 145 | endif 146 | 147 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DTS_EAGLE)),true) 148 | LOCAL_CFLAGS += -DDTS_EAGLE 149 | LOCAL_SRC_FILES += audio_extn/dts_eagle.c 150 | endif 151 | 152 | ifeq ($(strip $(DOLBY_DDP)),true) 153 | LOCAL_CFLAGS += -DDS1_DOLBY_DDP_ENABLED 154 | LOCAL_SRC_FILES += audio_extn/dolby.c 155 | endif 156 | 157 | ifeq ($(strip $(DS1_DOLBY_DAP)),true) 158 | LOCAL_CFLAGS += -DDS1_DOLBY_DAP_ENABLED 159 | ifneq ($(strip $(DOLBY_DDP)),true) 160 | LOCAL_SRC_FILES += audio_extn/dolby.c 161 | endif 162 | endif 163 | 164 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FLAC_DECODER)),true) 165 | LOCAL_CFLAGS += -DFLAC_OFFLOAD_ENABLED 166 | LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED 167 | endif 168 | 169 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_VORBIS_OFFLOAD)),true) 170 | LOCAL_CFLAGS += -DVORBIS_OFFLOAD_ENABLED 171 | LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED 172 | 173 | endif 174 | 175 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_WMA_OFFLOAD)),true) 176 | LOCAL_CFLAGS += -DWMA_OFFLOAD_ENABLED 177 | LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED 178 | endif 179 | 180 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ALAC_OFFLOAD)),true) 181 | LOCAL_CFLAGS += -DALAC_OFFLOAD_ENABLED 182 | LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED 183 | endif 184 | 185 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_APE_OFFLOAD)),true) 186 | LOCAL_CFLAGS += -DAPE_OFFLOAD_ENABLED 187 | LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED 188 | endif 189 | 190 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD_24)),true) 191 | LOCAL_CFLAGS += -DPCM_OFFLOAD_ENABLED_24 192 | endif 193 | 194 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AAC_ADTS_OFFLOAD)),true) 195 | LOCAL_CFLAGS += -DAAC_ADTS_OFFLOAD_ENABLED 196 | endif 197 | 198 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DEV_ARBI)),true) 199 | LOCAL_CFLAGS += -DDEV_ARBI_ENABLED 200 | LOCAL_SRC_FILES += audio_extn/dev_arbi.c 201 | endif 202 | 203 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_RECORD_PLAY_CONCURRENCY)),true) 204 | LOCAL_CFLAGS += -DRECORD_PLAY_CONCURRENCY 205 | endif 206 | 207 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ACDB_LICENSE)), true) 208 | LOCAL_CFLAGS += -DDOLBY_ACDB_LICENSE 209 | endif 210 | 211 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DS2_DOLBY_DAP)),true) 212 | LOCAL_CFLAGS += -DDS2_DOLBY_DAP_ENABLED 213 | LOCAL_CFLAGS += -DDS1_DOLBY_DDP_ENABLED 214 | ifneq ($(strip $(DOLBY_DDP)),true) 215 | ifneq ($(strip $(DS1_DOLBY_DAP)),true) 216 | LOCAL_SRC_FILES += audio_extn/dolby.c 217 | endif 218 | endif 219 | endif 220 | 221 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_PASSTHROUGH)),true) 222 | LOCAL_CFLAGS += -DHDMI_PASSTHROUGH_ENABLED 223 | endif 224 | 225 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SOURCE_TRACKING)),true) 226 | LOCAL_CFLAGS += -DSOURCE_TRACKING_ENABLED 227 | LOCAL_SRC_FILES += audio_extn/source_track.c 228 | endif 229 | 230 | LOCAL_SHARED_LIBRARIES := \ 231 | liblog \ 232 | libcutils \ 233 | libtinyalsa \ 234 | libtinycompress \ 235 | libaudioroute \ 236 | libdl \ 237 | libexpat 238 | 239 | LOCAL_C_INCLUDES += \ 240 | external/tinyalsa/include \ 241 | external/tinycompress/include \ 242 | external/expat/lib \ 243 | $(call include-path-for, audio-route) \ 244 | $(call include-path-for, audio-effects) \ 245 | $(LOCAL_PATH)/$(AUDIO_PLATFORM) \ 246 | $(LOCAL_PATH)/audio_extn \ 247 | $(LOCAL_PATH)/voice_extn 248 | 249 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_LISTEN)),true) 250 | LOCAL_CFLAGS += -DAUDIO_LISTEN_ENABLED 251 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-listen 252 | LOCAL_SRC_FILES += audio_extn/listen.c 253 | endif 254 | 255 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXT_HDMI)),true) 256 | LOCAL_CFLAGS += -DAUDIO_EXTERNAL_HDMI_ENABLED 257 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_PASSTHROUGH)),true) 258 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-parsers 259 | LOCAL_SHARED_LIBRARIES += libaudioparsers 260 | endif 261 | endif 262 | 263 | ifeq ($(strip $(BOARD_SUPPORTS_SOUND_TRIGGER)),true) 264 | LOCAL_CFLAGS += -DSOUND_TRIGGER_ENABLED 265 | LOCAL_CFLAGS += -DSOUND_TRIGGER_PLATFORM_NAME=$(TARGET_BOARD_PLATFORM) 266 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/sound_trigger 267 | LOCAL_SRC_FILES += audio_extn/soundtrigger.c 268 | endif 269 | 270 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUXPCM_BT)),true) 271 | LOCAL_CFLAGS += -DAUXPCM_BT_ENABLED 272 | endif 273 | 274 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PM_SUPPORT)),true) 275 | LOCAL_CFLAGS += -DPM_SUPPORT_ENABLED 276 | LOCAL_SRC_FILES += audio_extn/pm.c 277 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/libperipheralclient/inc 278 | LOCAL_SHARED_LIBRARIES += libperipheral_client 279 | endif 280 | 281 | LOCAL_CFLAGS += -Wall -Werror 282 | 283 | LOCAL_COPY_HEADERS_TO := mm-audio 284 | LOCAL_COPY_HEADERS := audio_extn/audio_defs.h 285 | 286 | LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM) 287 | 288 | LOCAL_MODULE_RELATIVE_PATH := hw 289 | 290 | LOCAL_MODULE_TAGS := optional 291 | 292 | include $(BUILD_SHARED_LIBRARY) 293 | 294 | endif 295 | -------------------------------------------------------------------------------- /hal/audio_extn/audio_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above 10 | * copyright notice, this list of conditions and the following 11 | * disclaimer in the documentation and/or other materials provided 12 | * with the distribution. 13 | * * Neither the name of The Linux Foundation nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef AUDIO_DEFS_H 31 | #define AUDIO_DEFS_H 32 | 33 | 34 | /** 35 | * extended audio codec parameters 36 | */ 37 | 38 | #define AUDIO_OFFLOAD_CODEC_WMA_FORMAT_TAG "music_offload_wma_format_tag" 39 | #define AUDIO_OFFLOAD_CODEC_WMA_BLOCK_ALIGN "music_offload_wma_block_align" 40 | #define AUDIO_OFFLOAD_CODEC_WMA_BIT_PER_SAMPLE "music_offload_wma_bit_per_sample" 41 | #define AUDIO_OFFLOAD_CODEC_WMA_CHANNEL_MASK "music_offload_wma_channel_mask" 42 | #define AUDIO_OFFLOAD_CODEC_WMA_ENCODE_OPTION "music_offload_wma_encode_option" 43 | #define AUDIO_OFFLOAD_CODEC_WMA_ENCODE_OPTION1 "music_offload_wma_encode_option1" 44 | #define AUDIO_OFFLOAD_CODEC_WMA_ENCODE_OPTION2 "music_offload_wma_encode_option2" 45 | #define AUDIO_OFFLOAD_CODEC_FORMAT "music_offload_codec_format" 46 | #define AUDIO_OFFLOAD_CODEC_FLAC_MIN_BLK_SIZE "music_offload_flac_min_blk_size" 47 | #define AUDIO_OFFLOAD_CODEC_FLAC_MAX_BLK_SIZE "music_offload_flac_max_blk_size" 48 | #define AUDIO_OFFLOAD_CODEC_FLAC_MIN_FRAME_SIZE "music_offload_flac_min_frame_size" 49 | #define AUDIO_OFFLOAD_CODEC_FLAC_MAX_FRAME_SIZE "music_offload_flac_max_frame_size" 50 | 51 | #define AUDIO_OFFLOAD_CODEC_ALAC_FRAME_LENGTH "music_offload_alac_frame_length" 52 | #define AUDIO_OFFLOAD_CODEC_ALAC_COMPATIBLE_VERSION "music_offload_alac_compatible_version" 53 | #define AUDIO_OFFLOAD_CODEC_ALAC_BIT_DEPTH "music_offload_alac_bit_depth" 54 | #define AUDIO_OFFLOAD_CODEC_ALAC_PB "music_offload_alac_pb" 55 | #define AUDIO_OFFLOAD_CODEC_ALAC_MB "music_offload_alac_mb" 56 | #define AUDIO_OFFLOAD_CODEC_ALAC_KB "music_offload_alac_kb" 57 | #define AUDIO_OFFLOAD_CODEC_ALAC_NUM_CHANNELS "music_offload_alac_num_channels" 58 | #define AUDIO_OFFLOAD_CODEC_ALAC_MAX_RUN "music_offload_alac_max_run" 59 | #define AUDIO_OFFLOAD_CODEC_ALAC_MAX_FRAME_BYTES "music_offload_alac_max_frame_bytes" 60 | #define AUDIO_OFFLOAD_CODEC_ALAC_AVG_BIT_RATE "music_offload_alac_avg_bit_rate" 61 | #define AUDIO_OFFLOAD_CODEC_ALAC_SAMPLING_RATE "music_offload_alac_sampling_rate" 62 | #define AUDIO_OFFLOAD_CODEC_ALAC_CHANNEL_LAYOUT_TAG "music_offload_alac_channel_layout_tag" 63 | 64 | #define AUDIO_OFFLOAD_CODEC_APE_COMPATIBLE_VERSION "music_offload_ape_compatible_version" 65 | #define AUDIO_OFFLOAD_CODEC_APE_COMPRESSION_LEVEL "music_offload_ape_compression_level" 66 | #define AUDIO_OFFLOAD_CODEC_APE_FORMAT_FLAGS "music_offload_ape_format_flags" 67 | #define AUDIO_OFFLOAD_CODEC_APE_BLOCKS_PER_FRAME "music_offload_ape_blocks_per_frame" 68 | #define AUDIO_OFFLOAD_CODEC_APE_FINAL_FRAME_BLOCKS "music_offload_ape_final_frame_blocks" 69 | #define AUDIO_OFFLOAD_CODEC_APE_TOTAL_FRAMES "music_offload_ape_total_frames" 70 | #define AUDIO_OFFLOAD_CODEC_APE_BITS_PER_SAMPLE "music_offload_ape_bits_per_sample" 71 | #define AUDIO_OFFLOAD_CODEC_APE_NUM_CHANNELS "music_offload_ape_num_channels" 72 | #define AUDIO_OFFLOAD_CODEC_APE_SAMPLE_RATE "music_offload_ape_sample_rate" 73 | #define AUDIO_OFFLOAD_CODEC_APE_SEEK_TABLE_PRESENT "music_offload_seek_table_present" 74 | 75 | #define AUDIO_OFFLOAD_CODEC_VORBIS_BITSTREAM_FMT "music_offload_vorbis_bitstream_fmt" 76 | 77 | /* Query handle fm parameter*/ 78 | #define AUDIO_PARAMETER_KEY_HANDLE_FM "handle_fm" 79 | 80 | /* Query fm volume */ 81 | #define AUDIO_PARAMETER_KEY_FM_VOLUME "fm_volume" 82 | 83 | /* Query Fluence type */ 84 | #define AUDIO_PARAMETER_KEY_FLUENCE "fluence" 85 | #define AUDIO_PARAMETER_VALUE_QUADMIC "quadmic" 86 | #define AUDIO_PARAMETER_VALUE_DUALMIC "dualmic" 87 | #define AUDIO_PARAMETER_KEY_NO_FLUENCE "none" 88 | 89 | /* Query if surround sound recording is supported */ 90 | #define AUDIO_PARAMETER_KEY_SSR "ssr" 91 | 92 | /* Query if a2dp is supported */ 93 | #define AUDIO_PARAMETER_KEY_HANDLE_A2DP_DEVICE "isA2dpDeviceSupported" 94 | 95 | /* Query ADSP Status */ 96 | #define AUDIO_PARAMETER_KEY_ADSP_STATUS "ADSP_STATUS" 97 | 98 | /* Query Sound Card Status */ 99 | #define AUDIO_PARAMETER_KEY_SND_CARD_STATUS "SND_CARD_STATUS" 100 | 101 | /* Query if Proxy can be Opend */ 102 | #define AUDIO_PARAMETER_KEY_CAN_OPEN_PROXY "can_open_proxy" 103 | 104 | #define AUDIO_PARAMETER_IS_HW_DECODER_SESSION_ALLOWED "is_hw_dec_session_allowed" 105 | 106 | #endif /* AUDIO_DEFS_H */ 107 | -------------------------------------------------------------------------------- /hal/audio_extn/compress_capture.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 - 2014, The Linux Foundation. All rights reserved. 3 | * Not a Contribution. 4 | * 5 | * Copyright (C) 2013 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #define LOG_TAG "audio_hw_compress" 21 | /*#define LOG_NDEBUG 0*/ 22 | #define LOG_NDDEBUG 0 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "audio_hw.h" 32 | #include "platform.h" 33 | #include "platform_api.h" 34 | 35 | #include "sound/compress_params.h" 36 | #include "sound/compress_offload.h" 37 | 38 | #ifdef COMPRESS_CAPTURE_ENABLED 39 | 40 | #define COMPRESS_IN_CONFIG_CHANNELS 1 41 | #define COMPRESS_IN_CONFIG_PERIOD_SIZE 2048 42 | #define COMPRESS_IN_CONFIG_PERIOD_COUNT 16 43 | 44 | 45 | struct compress_in_module { 46 | uint8_t *in_buf; 47 | }; 48 | 49 | static struct compress_in_module c_in_mod = { 50 | .in_buf = NULL, 51 | }; 52 | 53 | 54 | void audio_extn_compr_cap_init(struct stream_in *in) 55 | { 56 | in->usecase = USECASE_AUDIO_RECORD_COMPRESS; 57 | in->config.channels = COMPRESS_IN_CONFIG_CHANNELS; 58 | in->config.period_size = COMPRESS_IN_CONFIG_PERIOD_SIZE; 59 | in->config.period_count= COMPRESS_IN_CONFIG_PERIOD_COUNT; 60 | in->config.format = AUDIO_FORMAT_AMR_WB; 61 | c_in_mod.in_buf = (uint8_t*)calloc(1, in->config.period_size*2); 62 | } 63 | 64 | void audio_extn_compr_cap_deinit() 65 | { 66 | if (c_in_mod.in_buf) { 67 | free(c_in_mod.in_buf); 68 | c_in_mod.in_buf = NULL; 69 | } 70 | } 71 | 72 | bool audio_extn_compr_cap_enabled() 73 | { 74 | char prop_value[PROPERTY_VALUE_MAX] = {0}; 75 | bool tunnel_encode = false; 76 | 77 | property_get("tunnel.audio.encode",prop_value,"0"); 78 | if (!strncmp("true", prop_value, sizeof("true"))) 79 | return true; 80 | else 81 | return false; 82 | } 83 | 84 | bool audio_extn_compr_cap_format_supported(audio_format_t format) 85 | { 86 | if (format == AUDIO_FORMAT_AMR_WB) 87 | return true; 88 | else 89 | return false; 90 | } 91 | 92 | 93 | bool audio_extn_compr_cap_usecase_supported(audio_usecase_t usecase) 94 | { 95 | if ((usecase == USECASE_AUDIO_RECORD_COMPRESS) || 96 | (usecase == USECASE_INCALL_REC_UPLINK_COMPRESS) || 97 | (usecase == USECASE_INCALL_REC_DOWNLINK_COMPRESS) || 98 | (usecase == USECASE_INCALL_REC_UPLINK_AND_DOWNLINK_COMPRESS)) 99 | return true; 100 | else 101 | return false; 102 | } 103 | 104 | 105 | size_t audio_extn_compr_cap_get_buffer_size(audio_format_t format) 106 | { 107 | if (format == AUDIO_FORMAT_AMR_WB) 108 | /*One AMR WB frame is 61 bytes. Return that to the caller. 109 | The buffer size is not altered, that is still period size.*/ 110 | return AMR_WB_FRAMESIZE; 111 | else 112 | return 0; 113 | } 114 | 115 | size_t audio_extn_compr_cap_read(struct stream_in * in, 116 | void *buffer, size_t bytes) 117 | { 118 | int ret; 119 | struct snd_compr_audio_info *header; 120 | uint32_t c_in_header; 121 | uint32_t c_in_buf_size; 122 | 123 | c_in_buf_size = in->config.period_size*2; 124 | 125 | if (in->pcm) { 126 | ret = pcm_read(in->pcm, c_in_mod.in_buf, c_in_buf_size); 127 | if (ret < 0) { 128 | ALOGE("pcm_read() returned failure: %d", ret); 129 | return ret; 130 | } else { 131 | header = (struct snd_compr_audio_info *) c_in_mod.in_buf; 132 | c_in_header = sizeof(*header) + header->reserved[0]; 133 | if (header->frame_size > 0) { 134 | if (c_in_header + header->frame_size > c_in_buf_size) { 135 | ALOGW("AMR WB read buffer overflow."); 136 | header->frame_size = 137 | bytes - sizeof(*header) - header->reserved[0]; 138 | } 139 | ALOGV("c_in_buf: %p, data offset: %p, header size: %zu," 140 | "reserved[0]: %u frame_size: %d", c_in_mod.in_buf, 141 | c_in_mod.in_buf + c_in_header, 142 | sizeof(*header), header->reserved[0], 143 | header->frame_size); 144 | memcpy(buffer, c_in_mod.in_buf + c_in_header, header->frame_size); 145 | } else { 146 | ALOGE("pcm_read() with zero frame size"); 147 | ret = -EINVAL; 148 | } 149 | } 150 | } 151 | 152 | return 0; 153 | } 154 | 155 | #endif /* COMPRESS_CAPTURE_ENABLED end */ 156 | -------------------------------------------------------------------------------- /hal/audio_extn/dev_arbi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, The Linux Foundation. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above 10 | * copyright notice, this list of conditions and the following 11 | * disclaimer in the documentation and/or other materials provided 12 | * with the distribution. 13 | * * Neither the name of The Linux Foundation nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #define LOG_TAG "audio_hw_dev_arbi" 31 | /*#define LOG_NDEBUG 0*/ 32 | #define LOG_NDDEBUG 0 33 | 34 | #include 35 | #include 36 | #include 37 | #include "audio_hw.h" 38 | #include "platform.h" 39 | #include "platform_api.h" 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include "audio_extn.h" 45 | 46 | #ifdef DEV_ARBI_ENABLED 47 | 48 | typedef int (init_fn_t)(); 49 | typedef int (deinit_fn_t)(); 50 | typedef int (acquire_fn_t)(audio_devices_t aud_dev); 51 | typedef int (release_fn_t)(audio_devices_t aud_dev); 52 | 53 | typedef struct { 54 | snd_device_t snd_device; 55 | audio_devices_t aud_device; 56 | } snd_aud_dev_mapping_t; 57 | 58 | static void* lib_handle = NULL; 59 | 60 | static init_fn_t *init_fp = NULL; 61 | static deinit_fn_t *deinit_fp = NULL; 62 | static acquire_fn_t *acquire_fp = NULL; 63 | static release_fn_t *release_fp = NULL; 64 | 65 | static int load_dev_arbi_lib() 66 | { 67 | int rc = -EINVAL; 68 | 69 | if (lib_handle != NULL) { 70 | ALOGE("%s: library already loaded", __func__); 71 | return rc; 72 | } 73 | 74 | lib_handle = dlopen("libaudiodevarb.so", RTLD_NOW); 75 | if (lib_handle != NULL) { 76 | init_fp = (init_fn_t*)dlsym(lib_handle, "aud_dev_arbi_server_init"); 77 | deinit_fp = (deinit_fn_t*)dlsym(lib_handle, "aud_dev_arbi_server_deinit"); 78 | acquire_fp = (acquire_fn_t*)dlsym(lib_handle, "aud_dev_arbi_server_acquire"); 79 | release_fp = (release_fn_t*)dlsym(lib_handle, "aud_dev_arbi_server_release"); 80 | 81 | if ((init_fp == NULL) || 82 | (deinit_fp == NULL) || 83 | (acquire_fp == NULL) || 84 | (release_fp == NULL)) { 85 | 86 | ALOGE("%s: error loading symbols from library", __func__); 87 | 88 | init_fp = NULL; 89 | deinit_fp = NULL; 90 | acquire_fp = NULL; 91 | release_fp = NULL; 92 | } else 93 | return 0; 94 | } 95 | 96 | return rc; 97 | } 98 | 99 | int audio_extn_dev_arbi_init() 100 | { 101 | int rc = load_dev_arbi_lib(); 102 | if (!rc) 103 | rc = init_fp(); 104 | 105 | return rc; 106 | } 107 | 108 | int audio_extn_dev_arbi_deinit() 109 | { 110 | int rc = -EINVAL; 111 | 112 | if(deinit_fp != NULL) { 113 | rc = deinit_fp(); 114 | 115 | init_fp = NULL; 116 | deinit_fp = NULL; 117 | acquire_fp = NULL; 118 | release_fp = NULL; 119 | 120 | dlclose(lib_handle); 121 | lib_handle = NULL; 122 | } 123 | 124 | return rc; 125 | } 126 | 127 | static audio_devices_t get_audio_device(snd_device_t snd_device) 128 | { 129 | static snd_aud_dev_mapping_t snd_aud_dev_map[] = { 130 | {SND_DEVICE_OUT_HANDSET, AUDIO_DEVICE_OUT_EARPIECE}, 131 | {SND_DEVICE_OUT_VOICE_HANDSET, AUDIO_DEVICE_OUT_EARPIECE}, 132 | {SND_DEVICE_OUT_SPEAKER, AUDIO_DEVICE_OUT_SPEAKER}, 133 | {SND_DEVICE_OUT_VOICE_SPEAKER, AUDIO_DEVICE_OUT_SPEAKER}, 134 | {SND_DEVICE_OUT_HEADPHONES, AUDIO_DEVICE_OUT_WIRED_HEADPHONE}, 135 | {SND_DEVICE_OUT_VOICE_HEADPHONES, AUDIO_DEVICE_OUT_WIRED_HEADPHONE}, 136 | {SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, 137 | AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_WIRED_HEADPHONE} 138 | }; 139 | 140 | audio_devices_t aud_device = AUDIO_DEVICE_NONE; 141 | uint32_t ind = 0; 142 | 143 | for (ind = 0; ind < ARRAY_SIZE(snd_aud_dev_map); ++ind) { 144 | if (snd_device == snd_aud_dev_map[ind].snd_device) { 145 | aud_device = snd_aud_dev_map[ind].aud_device; 146 | break; 147 | } 148 | } 149 | 150 | return aud_device; 151 | } 152 | 153 | int audio_extn_dev_arbi_acquire(snd_device_t snd_device) 154 | { 155 | int rc = -EINVAL; 156 | audio_devices_t audio_device = get_audio_device(snd_device); 157 | 158 | if ((acquire_fp != NULL) && (audio_device != AUDIO_DEVICE_NONE)) 159 | rc = acquire_fp(audio_device); 160 | 161 | return rc; 162 | } 163 | 164 | int audio_extn_dev_arbi_release(snd_device_t snd_device) 165 | { 166 | int rc = -EINVAL; 167 | audio_devices_t audio_device = get_audio_device(snd_device); 168 | 169 | if ((release_fp != NULL) && (audio_device != AUDIO_DEVICE_NONE)) 170 | rc = release_fp(audio_device); 171 | 172 | return rc; 173 | } 174 | 175 | #endif /*DEV_ARBI_ENABLED*/ 176 | -------------------------------------------------------------------------------- /hal/audio_extn/listen.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #define LOG_TAG "listen_hal_loader" 30 | /* #define LOG_NDEBUG 0 */ 31 | /* #define LOG_NDDEBUG 0 */ 32 | #include 33 | #include 34 | #include 35 | #include 36 | #ifdef AUDIO_LISTEN_ENABLED 37 | #include 38 | #endif 39 | #include "audio_hw.h" 40 | #include "audio_extn.h" 41 | #include "platform.h" 42 | #include "platform_api.h" 43 | 44 | 45 | #ifdef AUDIO_LISTEN_ENABLED 46 | 47 | #define LIB_LISTEN_LOADER "/vendor/lib/liblistenhardware.so" 48 | 49 | #define LISTEN_LOAD_SYMBOLS(dev, func_p, func_type, symbol) \ 50 | {\ 51 | dev->func_p = (func_type)dlsym(dev->lib_handle,#symbol);\ 52 | if (dev->func_p == NULL) {\ 53 | ALOGE("%s: dlsym error %s for %s",\ 54 | __func__, dlerror(), #symbol);\ 55 | free(dev);\ 56 | dev = NULL;\ 57 | return -EINVAL;\ 58 | }\ 59 | } 60 | 61 | 62 | typedef int (*create_listen_hw_t)(unsigned int snd_card, 63 | struct audio_route *audio_route); 64 | typedef void (*destroy_listen_hw_t)(); 65 | 66 | typedef int (*open_listen_session_t)(struct audio_hw_device *, 67 | struct listen_open_params*, 68 | struct listen_session**); 69 | 70 | typedef int (*close_listen_session_t)(struct audio_hw_device *dev, 71 | struct listen_session* handle); 72 | 73 | typedef int (*set_mad_observer_t)(struct audio_hw_device *dev, 74 | listen_callback_t cb_func); 75 | 76 | typedef int (*listen_set_parameters_t)(struct audio_hw_device *dev, 77 | const char *kv_pairs); 78 | typedef char* (*get_parameters_t)(const struct audio_hw_device *dev, 79 | const char *keys); 80 | typedef void (*listen_notify_event_t)(event_type_t event_type); 81 | 82 | struct listen_audio_device { 83 | void *lib_handle; 84 | struct audio_device *adev; 85 | 86 | create_listen_hw_t create_listen_hw; 87 | destroy_listen_hw_t destroy_listen_hw; 88 | open_listen_session_t open_listen_session; 89 | close_listen_session_t close_listen_session; 90 | set_mad_observer_t set_mad_observer; 91 | listen_set_parameters_t listen_set_parameters; 92 | get_parameters_t get_parameters; 93 | listen_notify_event_t notify_event; 94 | }; 95 | 96 | static struct listen_audio_device *listen_dev; 97 | 98 | void audio_extn_listen_update_device_status(snd_device_t snd_device, 99 | listen_event_type_t event) 100 | { 101 | bool raise_event = false; 102 | int device_type = -1; 103 | 104 | if (snd_device >= SND_DEVICE_OUT_BEGIN && 105 | snd_device < SND_DEVICE_OUT_END) 106 | device_type = PCM_PLAYBACK; 107 | else if (snd_device >= SND_DEVICE_IN_BEGIN && 108 | snd_device < SND_DEVICE_IN_END) 109 | device_type = PCM_CAPTURE; 110 | else { 111 | ALOGE("%s: invalid device 0x%x, for event %d", 112 | __func__, snd_device, event); 113 | return; 114 | } 115 | 116 | if (listen_dev) { 117 | raise_event = platform_listen_device_needs_event(snd_device); 118 | ALOGI("%s(): device 0x%x of type %d for Event %d, with Raise=%d", 119 | __func__, snd_device, device_type, event, raise_event); 120 | if (raise_event && (device_type == PCM_CAPTURE)) { 121 | switch(event) { 122 | case LISTEN_EVENT_SND_DEVICE_FREE: 123 | listen_dev->notify_event(AUDIO_DEVICE_IN_INACTIVE); 124 | break; 125 | case LISTEN_EVENT_SND_DEVICE_BUSY: 126 | listen_dev->notify_event(AUDIO_DEVICE_IN_ACTIVE); 127 | break; 128 | default: 129 | ALOGW("%s:invalid event %d for device 0x%x", 130 | __func__, event, snd_device); 131 | } 132 | }/*Events for output device, if required can be placed here in else*/ 133 | } 134 | } 135 | 136 | void audio_extn_listen_update_stream_status(struct audio_usecase *uc_info, 137 | listen_event_type_t event) 138 | { 139 | bool raise_event = false; 140 | audio_usecase_t uc_id; 141 | int usecase_type = -1; 142 | 143 | if (uc_info == NULL) { 144 | ALOGE("%s: usecase is NULL!!!", __func__); 145 | return; 146 | } 147 | uc_id = uc_info->id; 148 | usecase_type = uc_info->type; 149 | 150 | if (listen_dev) { 151 | raise_event = platform_listen_usecase_needs_event(uc_id); 152 | ALOGI("%s(): uc_id %d of type %d for Event %d, with Raise=%d", 153 | __func__, uc_id, usecase_type, event, raise_event); 154 | if (raise_event && (usecase_type == PCM_PLAYBACK)) { 155 | switch(event) { 156 | case LISTEN_EVENT_STREAM_FREE: 157 | listen_dev->notify_event(AUDIO_STREAM_OUT_INACTIVE); 158 | break; 159 | case LISTEN_EVENT_STREAM_BUSY: 160 | listen_dev->notify_event(AUDIO_STREAM_OUT_ACTIVE); 161 | break; 162 | default: 163 | ALOGW("%s:invalid event %d, for usecase %d", 164 | __func__, event, uc_id); 165 | } 166 | }/*Events for capture usecase, if required can be placed here in else*/ 167 | } 168 | } 169 | 170 | void audio_extn_listen_set_parameters(struct audio_device *adev, 171 | struct str_parms *parms) 172 | { 173 | ALOGV("%s: enter", __func__); 174 | if (listen_dev) { 175 | char *kv_pairs = str_parms_to_str(parms); 176 | ALOGV_IF(kv_pairs != NULL, "%s: %s", __func__, kv_pairs); 177 | listen_dev->listen_set_parameters(&adev->device, kv_pairs); 178 | free(kv_pairs); 179 | } 180 | 181 | return; 182 | } 183 | 184 | int audio_extn_listen_init(struct audio_device *adev, unsigned int snd_card) 185 | { 186 | int ret; 187 | void *lib_handle; 188 | 189 | ALOGI("%s: Enter", __func__); 190 | 191 | lib_handle = dlopen(LIB_LISTEN_LOADER, RTLD_NOW); 192 | 193 | if (lib_handle == NULL) { 194 | ALOGE("%s: DLOPEN failed for %s. error = %s", __func__, LIB_LISTEN_LOADER, 195 | dlerror()); 196 | return -EINVAL; 197 | } else { 198 | ALOGI("%s: DLOPEN successful for %s", __func__, LIB_LISTEN_LOADER); 199 | 200 | listen_dev = (struct listen_audio_device*) 201 | calloc(1, sizeof(struct listen_audio_device)); 202 | 203 | if (!listen_dev) { 204 | ALOGE("failed to allocate listen_dev mem"); 205 | return -ENOMEM; 206 | } 207 | 208 | listen_dev->lib_handle = lib_handle; 209 | listen_dev->adev = adev; 210 | 211 | LISTEN_LOAD_SYMBOLS(listen_dev, create_listen_hw, 212 | create_listen_hw_t, create_listen_hw); 213 | 214 | LISTEN_LOAD_SYMBOLS(listen_dev, destroy_listen_hw, 215 | destroy_listen_hw_t, destroy_listen_hw); 216 | 217 | LISTEN_LOAD_SYMBOLS(listen_dev, open_listen_session, 218 | open_listen_session_t, open_listen_session); 219 | 220 | adev->device.open_listen_session = listen_dev->open_listen_session; 221 | 222 | LISTEN_LOAD_SYMBOLS(listen_dev, close_listen_session, 223 | close_listen_session_t, close_listen_session); 224 | 225 | adev->device.close_listen_session = listen_dev->close_listen_session; 226 | 227 | LISTEN_LOAD_SYMBOLS(listen_dev, set_mad_observer, 228 | set_mad_observer_t, set_mad_observer); 229 | 230 | adev->device.set_mad_observer = listen_dev->set_mad_observer; 231 | 232 | LISTEN_LOAD_SYMBOLS(listen_dev, listen_set_parameters, 233 | listen_set_parameters_t, listen_hw_set_parameters); 234 | 235 | adev->device.listen_set_parameters = listen_dev->listen_set_parameters; 236 | 237 | LISTEN_LOAD_SYMBOLS(listen_dev, get_parameters, 238 | get_parameters_t, listen_hw_get_parameters); 239 | 240 | LISTEN_LOAD_SYMBOLS(listen_dev, notify_event, 241 | listen_notify_event_t, listen_hw_notify_event); 242 | 243 | listen_dev->create_listen_hw(snd_card, adev->audio_route); 244 | } 245 | return 0; 246 | } 247 | 248 | void audio_extn_listen_deinit(struct audio_device *adev) 249 | { 250 | ALOGI("%s: Enter", __func__); 251 | 252 | if (listen_dev && (listen_dev->adev == adev) && listen_dev->lib_handle) { 253 | listen_dev->destroy_listen_hw(); 254 | dlclose(listen_dev->lib_handle); 255 | free(listen_dev); 256 | listen_dev = NULL; 257 | } 258 | } 259 | 260 | #endif /* AUDIO_LISTEN_ENABLED */ 261 | -------------------------------------------------------------------------------- /hal/audio_extn/pm.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #define LOG_TAG "audio_hw_pm" 31 | /*#define LOG_NDEBUG 0*/ 32 | 33 | #include "pm.h" 34 | #include 35 | 36 | static s_audio_subsys audio_ss; 37 | 38 | int audio_extn_pm_vote(void) 39 | { 40 | int err, intfd, ret; 41 | FILE *fd; 42 | enum pm_event subsys_state; 43 | char halPropVal[PROPERTY_VALUE_MAX]; 44 | bool prop_unload_image = false; 45 | bool pm_reg = false; 46 | bool pm_supp = false; 47 | 48 | platform_get_subsys_image_name((char *)&audio_ss.img_name); 49 | ALOGD("%s: register with peripheral manager for %s",__func__, audio_ss.img_name); 50 | ret = pm_client_register(audio_extn_pm_event_notifier, 51 | &audio_ss, 52 | audio_ss.img_name, 53 | PM_CLIENT_NAME, 54 | &subsys_state, 55 | &audio_ss.pm_handle); 56 | if (ret == PM_RET_SUCCESS) { 57 | pm_reg = true; 58 | pm_supp = true; 59 | ALOGV("%s: registered with peripheral manager for %s", 60 | __func__, audio_ss.img_name); 61 | } else if (ret == PM_RET_UNSUPPORTED) { 62 | pm_reg = true; 63 | pm_supp = false; 64 | ALOGV("%s: peripheral mgr unsupported for %s", 65 | __func__, audio_ss.img_name); 66 | return ret; 67 | } else { 68 | return ret; 69 | } 70 | if (pm_supp == true && 71 | pm_reg == true) { 72 | ALOGD("%s: Voting for subsystem power up", __func__); 73 | pm_client_connect(audio_ss.pm_handle); 74 | 75 | if (property_get("sys.audio.init", halPropVal, NULL)) { 76 | prop_unload_image = !(strncmp("false", halPropVal, sizeof("false"))); 77 | } 78 | /* 79 | * adsp-loader loads modem/adsp image at boot up to play boot tone, 80 | * before peripheral manager service is up. Once PM is up, vote to PM 81 | * and unload the image to give control to PM to load/unload image 82 | */ 83 | if (prop_unload_image) { 84 | intfd = open(BOOT_IMG_SYSFS_PATH, O_WRONLY); 85 | if (intfd == -1) { 86 | ALOGE("failed to open fd in write mode, %d", errno); 87 | } else { 88 | ALOGD("%s: write to sysfs to unload image", __func__); 89 | err = write(intfd, UNLOAD_IMAGE, 1); 90 | close(intfd); 91 | property_set("sys.audio.init", "true"); 92 | } 93 | } 94 | } 95 | return 0; 96 | } 97 | 98 | void audio_extn_pm_unvote(void) 99 | { 100 | ALOGD("%s", __func__); 101 | if (audio_ss.pm_handle) { 102 | pm_client_disconnect(audio_ss.pm_handle); 103 | pm_client_unregister(audio_ss.pm_handle); 104 | } 105 | } 106 | 107 | void audio_extn_pm_set_parameters(struct str_parms *parms) 108 | { 109 | int ret; 110 | char value[32]; 111 | 112 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_DEV_SHUTDOWN, value, sizeof(value)); 113 | if (ret >= 0) { 114 | if (strstr(value, "true")) { 115 | ALOGD("Device shutdown notification received, unregister with PM"); 116 | audio_extn_pm_unvote(); 117 | } 118 | } 119 | } 120 | 121 | void audio_extn_pm_event_notifier(void *client_data, enum pm_event event) 122 | { 123 | pm_client_event_acknowledge(audio_ss.pm_handle, event); 124 | 125 | /* Closing and re-opening of session is done based on snd card status given 126 | * by AudioDaemon during SS offline/online (legacy code). Just return for now. 127 | */ 128 | switch (event) { 129 | case EVENT_PERIPH_GOING_OFFLINE: 130 | ALOGV("%s: %s is going offline", __func__, audio_ss.img_name); 131 | break; 132 | 133 | case EVENT_PERIPH_IS_OFFLINE: 134 | ALOGV("%s: %s is offline", __func__, audio_ss.img_name); 135 | break; 136 | 137 | case EVENT_PERIPH_GOING_ONLINE: 138 | ALOGV("%s: %s is going online", __func__, audio_ss.img_name); 139 | break; 140 | 141 | case EVENT_PERIPH_IS_ONLINE: 142 | ALOGV("%s: %s is online", __func__, audio_ss.img_name); 143 | break; 144 | 145 | default: 146 | ALOGV("%s: invalid event received from PM", __func__); 147 | break; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /hal/audio_extn/pm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef AUDIO_EXTN_PM_H 31 | #define AUDIO_EXTN_PM_H 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include "audio_hw.h" 40 | #include 41 | #include 42 | #include 43 | 44 | 45 | /* Client name to be registered with PM */ 46 | #define PM_CLIENT_NAME "audio" 47 | /* Command to sysfs to unload image */ 48 | #define UNLOAD_IMAGE "0" 49 | #define MAX_NAME_LEN 32 50 | #define BOOT_IMG_SYSFS_PATH "/sys/kernel/boot_adsp/boot" 51 | 52 | typedef struct { 53 | //MAX_NAME_LEN defined in mdm_detect.h 54 | char img_name[MAX_NAME_LEN]; 55 | //this handle is used by peripheral mgr 56 | void *pm_handle; 57 | }s_audio_subsys; 58 | 59 | /* Vote to peripheral manager for required subsystem */ 60 | int audio_extn_pm_vote (void); 61 | 62 | /* Unvote to peripheral manager */ 63 | void audio_extn_pm_unvote (void); 64 | 65 | /* Get subsytem status notification from PM */ 66 | void audio_extn_pm_event_notifier (void *client_data, enum pm_event event); 67 | 68 | #endif // AUDIO_EXTN_PM_H 69 | -------------------------------------------------------------------------------- /hal/edid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above 10 | * copyright notice, this list of conditions and the following 11 | * disclaimer in the documentation and/or other materials provided 12 | * with the distribution. 13 | * * Neither the name of The Linux Foundation nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef EDID_H 31 | #define EDID_H 32 | 33 | /* HDMI EDID Information */ 34 | #define BIT(nr) (1UL << (nr)) 35 | #define MAX_EDID_BLOCKS 10 36 | #define MAX_SHORT_AUDIO_DESC_CNT 30 37 | #define MIN_AUDIO_DESC_LENGTH 3 38 | #define MIN_SPKR_ALLOCATION_DATA_LENGTH 3 39 | #define MAX_CHANNELS_SUPPORTED 8 40 | #define MAX_DISPLAY_DEVICES 3 41 | #define MAX_FRAME_BUFFER_NAME_SIZE 80 42 | #define MAX_CHAR_PER_INT 13 43 | 44 | #define PCM_CHANNEL_FL 1 /* Front left channel. */ 45 | #define PCM_CHANNEL_FR 2 /* Front right channel. */ 46 | #define PCM_CHANNEL_FC 3 /* Front center channel. */ 47 | #define PCM_CHANNEL_LS 4 /* Left surround channel. */ 48 | #define PCM_CHANNEL_RS 5 /* Right surround channel. */ 49 | #define PCM_CHANNEL_LFE 6 /* Low frequency effect channel. */ 50 | #define PCM_CHANNEL_CS 7 /* Center surround channel; Rear center channel. */ 51 | #define PCM_CHANNEL_LB 8 /* Left back channel; Rear left channel. */ 52 | #define PCM_CHANNEL_RB 9 /* Right back channel; Rear right channel. */ 53 | #define PCM_CHANNEL_TS 10 /* Top surround channel. */ 54 | #define PCM_CHANNEL_CVH 11 /* Center vertical height channel. */ 55 | #define PCM_CHANNEL_MS 12 /* Mono surround channel. */ 56 | #define PCM_CHANNEL_FLC 13 /* Front left of center. */ 57 | #define PCM_CHANNEL_FRC 14 /* Front right of center. */ 58 | #define PCM_CHANNEL_RLC 15 /* Rear left of center. */ 59 | #define PCM_CHANNEL_RRC 16 /* Rear right of center. */ 60 | 61 | #define MAX_HDMI_CHANNEL_CNT 8 62 | 63 | typedef enum edid_audio_format_id { 64 | LPCM = 1, 65 | AC3, 66 | MPEG1, 67 | MP3, 68 | MPEG2_MULTI_CHANNEL, 69 | AAC, 70 | DTS, 71 | ATRAC, 72 | SACD, 73 | DOLBY_DIGITAL_PLUS, 74 | DTS_HD, 75 | MAT, 76 | DST, 77 | WMA_PRO 78 | } edid_audio_format_id; 79 | 80 | typedef struct edid_audio_block_info { 81 | edid_audio_format_id format_id; 82 | int sampling_freq; 83 | int bits_per_sample; 84 | int channels; 85 | } edid_audio_block_info; 86 | 87 | typedef struct edid_audio_info { 88 | int audio_blocks; 89 | unsigned char speaker_allocation[MIN_SPKR_ALLOCATION_DATA_LENGTH]; 90 | edid_audio_block_info audio_blocks_array[MAX_EDID_BLOCKS]; 91 | char channel_map[MAX_CHANNELS_SUPPORTED]; 92 | int channel_allocation; 93 | } edid_audio_info; 94 | 95 | #ifndef HDMI_EDID 96 | #define edid_get_sink_caps(info, edid_data) (0) 97 | #else 98 | bool edid_get_sink_caps(edid_audio_info* info, char *edid_data); 99 | #endif 100 | 101 | bool edid_is_supported_sr(edid_audio_info* info, int sr); 102 | bool edid_is_supported_bps(edid_audio_info* info, int bps); 103 | 104 | #endif /* EDID_H */ 105 | -------------------------------------------------------------------------------- /hal/msm8960/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, 2015 The Linux Foundation. All rights reserved. 3 | * Not a contribution. 4 | * 5 | * Copyright (C) 2013 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef QCOM_AUDIO_PLATFORM_H 21 | #define QCOM_AUDIO_PLATFORM_H 22 | 23 | enum { 24 | FLUENCE_NONE, 25 | FLUENCE_DUAL_MIC, 26 | FLUENCE_QUAD_MIC 27 | }; 28 | 29 | /* 30 | * Below are the devices for which is back end is same, SLIMBUS_0_RX. 31 | * All these devices are handled by the internal HW codec. We can 32 | * enable any one of these devices at any time 33 | */ 34 | #define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \ 35 | (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \ 36 | AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE) 37 | 38 | /* 39 | * Below are the input devices for which back end is same, SLIMBUS_0_TX. 40 | * All these devices are handled by the internal HW codec. We can 41 | * enable any one of these devices at any time 42 | */ 43 | #define AUDIO_DEVICE_IN_ALL_CODEC_BACKEND \ 44 | (AUDIO_DEVICE_IN_BUILTIN_MIC | AUDIO_DEVICE_IN_BACK_MIC | \ 45 | AUDIO_DEVICE_IN_WIRED_HEADSET | AUDIO_DEVICE_IN_VOICE_CALL) & ~AUDIO_DEVICE_BIT_IN 46 | 47 | /* Sound devices specific to the platform 48 | * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound 49 | * devices to enable corresponding mixer paths 50 | */ 51 | enum { 52 | SND_DEVICE_NONE = 0, 53 | 54 | /* Playback devices */ 55 | SND_DEVICE_MIN, 56 | SND_DEVICE_OUT_BEGIN = SND_DEVICE_MIN, 57 | SND_DEVICE_OUT_HANDSET = SND_DEVICE_OUT_BEGIN, 58 | SND_DEVICE_OUT_SPEAKER, 59 | SND_DEVICE_OUT_SPEAKER_REVERSE, 60 | SND_DEVICE_OUT_HEADPHONES, 61 | SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, 62 | SND_DEVICE_OUT_VOICE_SPEAKER, 63 | SND_DEVICE_OUT_VOICE_HEADPHONES, 64 | SND_DEVICE_OUT_HDMI, 65 | SND_DEVICE_OUT_SPEAKER_AND_HDMI, 66 | SND_DEVICE_OUT_BT_SCO, 67 | SND_DEVICE_OUT_BT_SCO_WB, 68 | SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES, 69 | SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES, 70 | SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET, 71 | SND_DEVICE_OUT_USB_HEADSET, 72 | SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET, 73 | SND_DEVICE_OUT_END, 74 | 75 | /* 76 | * Note: IN_BEGIN should be same as OUT_END because total number of devices 77 | * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices. 78 | */ 79 | /* Capture devices */ 80 | SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END, 81 | SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN, 82 | SND_DEVICE_IN_SPEAKER_MIC, 83 | SND_DEVICE_IN_HEADSET_MIC, 84 | SND_DEVICE_IN_HANDSET_MIC_AEC, 85 | SND_DEVICE_IN_SPEAKER_MIC_AEC, 86 | SND_DEVICE_IN_HEADSET_MIC_AEC, 87 | SND_DEVICE_IN_VOICE_SPEAKER_MIC, 88 | SND_DEVICE_IN_VOICE_HEADSET_MIC, 89 | SND_DEVICE_IN_HDMI_MIC, 90 | SND_DEVICE_IN_BT_SCO_MIC, 91 | SND_DEVICE_IN_BT_SCO_MIC_WB, 92 | SND_DEVICE_IN_CAMCORDER_MIC, 93 | SND_DEVICE_IN_VOICE_DMIC, 94 | SND_DEVICE_IN_VOICE_SPEAKER_DMIC, 95 | SND_DEVICE_IN_VOICE_SPEAKER_QMIC, 96 | SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC, 97 | SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC, 98 | SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC, 99 | SND_DEVICE_IN_VOICE_REC_MIC, 100 | SND_DEVICE_IN_VOICE_REC_DMIC, 101 | SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE, 102 | SND_DEVICE_IN_USB_HEADSET_MIC, 103 | SND_DEVICE_IN_END, 104 | 105 | SND_DEVICE_MAX = SND_DEVICE_IN_END, 106 | 107 | }; 108 | 109 | #define MIXER_CARD 0 110 | #define SOUND_CARD 0 111 | 112 | #define DEFAULT_OUTPUT_SAMPLING_RATE 48000 113 | 114 | #define ALL_SESSION_VSID 0xFFFFFFFF 115 | #define DEFAULT_MUTE_RAMP_DURATION_MS 20 116 | #define DEFAULT_VOLUME_RAMP_DURATION_MS 20 117 | #define MIXER_PATH_MAX_LENGTH 100 118 | 119 | #define MAX_VOL_INDEX 5 120 | #define MIN_VOL_INDEX 0 121 | #define percent_to_index(val, min, max) \ 122 | ((val) * ((max) - (min)) * 0.01 + (min) + .5) 123 | 124 | /* 125 | * tinyAlsa library interprets period size as number of frames 126 | * one frame = channel_count * sizeof (pcm sample) 127 | * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes 128 | * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes 129 | * We should take care of returning proper size when AudioFlinger queries for 130 | * the buffer size of an input/output stream 131 | */ 132 | #define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960 133 | #define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 4 134 | #define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240 135 | #define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2 136 | 137 | #define HDMI_MULTI_PERIOD_SIZE 336 138 | #define HDMI_MULTI_PERIOD_COUNT 8 139 | #define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6 140 | #define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2) 141 | 142 | #define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20 143 | #define AUDIO_CAPTURE_PERIOD_COUNT 2 144 | 145 | #define DEVICE_NAME_MAX_SIZE 128 146 | 147 | /* Define macro for Internal FM volume mixer */ 148 | #define FM_RX_VOLUME "Internal FM RX Volume" 149 | 150 | #define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000 151 | #define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240 152 | #define LOW_LATENCY_CAPTURE_USE_CASE 0 153 | 154 | #define AFE_PROXY_PLAYBACK_PCM_DEVICE 7 155 | #define AFE_PROXY_RECORD_PCM_DEVICE 8 156 | 157 | #define DEVICE_NAME_MAX_SIZE 128 158 | 159 | #endif // QCOM_AUDIO_PLATFORM_H 160 | -------------------------------------------------------------------------------- /hal/platform_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. 3 | * Not a contribution. 4 | * 5 | * Copyright (C) 2013 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef AUDIO_PLATFORM_API_H 21 | #define AUDIO_PLATFORM_API_H 22 | #include 23 | 24 | #define CODEC_BACKEND_DEFAULT_BIT_WIDTH 16 25 | #define CODEC_BACKEND_DEFAULT_SAMPLE_RATE 48000 26 | 27 | void *platform_init(struct audio_device *adev); 28 | void platform_deinit(void *platform); 29 | const char *platform_get_snd_device_name(snd_device_t snd_device); 30 | int platform_get_snd_device_name_extn(void *platform, snd_device_t snd_device, 31 | char *device_name); 32 | void platform_add_backend_name(char *mixer_path, snd_device_t snd_device, 33 | struct audio_usecase *usecase); 34 | bool platform_send_gain_dep_cal(void *platform, int level); 35 | int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type); 36 | int platform_get_snd_device_index(char *snd_device_index_name); 37 | int platform_set_fluence_type(void *platform, char *value); 38 | int platform_get_fluence_type(void *platform, char *value, uint32_t len); 39 | int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id); 40 | int platform_get_snd_device_acdb_id(snd_device_t snd_device); 41 | int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width); 42 | int platform_get_snd_device_bit_width(snd_device_t snd_device); 43 | int platform_set_native_support(bool codec_support); 44 | int platform_get_native_support(); 45 | int platform_send_audio_calibration(void *platform, struct audio_usecase *usecase, 46 | int app_type, int sample_rate); 47 | int platform_get_default_app_type(void *platform); 48 | int platform_get_default_app_type_v2(void *platform, usecase_type_t type); 49 | int platform_switch_voice_call_device_pre(void *platform); 50 | int platform_switch_voice_call_enable_device_config(void *platform, 51 | snd_device_t out_snd_device, 52 | snd_device_t in_snd_device); 53 | int platform_switch_voice_call_device_post(void *platform, 54 | snd_device_t out_snd_device, 55 | snd_device_t in_snd_device); 56 | int platform_switch_voice_call_usecase_route_post(void *platform, 57 | snd_device_t out_snd_device, 58 | snd_device_t in_snd_device); 59 | int platform_start_voice_call(void *platform, uint32_t vsid); 60 | int platform_stop_voice_call(void *platform, uint32_t vsid); 61 | int platform_set_voice_volume(void *platform, int volume); 62 | int platform_set_mic_mute(void *platform, bool state); 63 | int platform_get_sample_rate(void *platform, uint32_t *rate); 64 | int platform_set_device_mute(void *platform, bool state, char *dir); 65 | snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *out); 66 | snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device); 67 | int platform_set_hdmi_channels(void *platform, int channel_count); 68 | int platform_edid_get_max_channels(void *platform); 69 | void platform_get_parameters(void *platform, struct str_parms *query, 70 | struct str_parms *reply); 71 | int platform_set_parameters(void *platform, struct str_parms *parms); 72 | int platform_set_incall_recording_session_id(void *platform, uint32_t session_id, 73 | int rec_mode); 74 | int platform_stop_incall_recording_usecase(void *platform); 75 | int platform_start_incall_music_usecase(void *platform); 76 | int platform_stop_incall_music_usecase(void *platform); 77 | int platform_update_lch(void *platform, struct voice_session *session, 78 | enum voice_lch_mode lch_mode); 79 | /* returns the latency for a usecase in Us */ 80 | int64_t platform_render_latency(audio_usecase_t usecase); 81 | int platform_update_usecase_from_source(int source, audio_usecase_t usecase); 82 | 83 | bool platform_listen_device_needs_event(snd_device_t snd_device); 84 | bool platform_listen_usecase_needs_event(audio_usecase_t uc_id); 85 | 86 | bool platform_sound_trigger_device_needs_event(snd_device_t snd_device); 87 | bool platform_sound_trigger_usecase_needs_event(audio_usecase_t uc_id); 88 | 89 | int platform_set_snd_device_backend(snd_device_t snd_device, const char * backend, 90 | const char * hw_interface); 91 | 92 | /* From platform_info.c */ 93 | int platform_info_init(const char *filename, void *); 94 | 95 | void platform_snd_card_update(void *platform, int snd_scard_state); 96 | 97 | struct audio_offload_info_t; 98 | uint32_t platform_get_compress_offload_buffer_size(audio_offload_info_t* info); 99 | uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info); 100 | bool platform_use_small_buffer(audio_offload_info_t* info); 101 | uint32_t platform_get_compress_passthrough_buffer_size(audio_offload_info_t* info); 102 | 103 | bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, 104 | struct audio_usecase *usecase, snd_device_t snd_device); 105 | int platform_get_usecase_index(const char * usecase); 106 | int platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id); 107 | void platform_set_echo_reference(struct audio_device *adev, bool enable, audio_devices_t out_device); 108 | void platform_get_device_to_be_id_map(int **be_id_map, int *length); 109 | 110 | int platform_set_channel_allocation(void *platform, int channel_alloc); 111 | int platform_get_edid_info(void *platform); 112 | int platform_set_channel_map(void *platform, int ch_count, char *ch_map, 113 | int snd_id); 114 | int platform_set_stream_channel_map(void *platform, audio_channel_mask_t channel_mask, int snd_id); 115 | int platform_set_edid_channels_configuration(void *platform, int channels); 116 | unsigned char platform_map_to_edid_format(int format); 117 | bool platform_is_edid_supported_format(void *platform, int format); 118 | void platform_cache_edid(void * platform); 119 | void platform_invalidate_hdmi_config(void * platform); 120 | int platform_set_hdmi_config(struct stream_out *out); 121 | int platform_set_device_params(struct stream_out *out, int param, int value); 122 | int platform_set_audio_device_interface(const char * device_name, const char *intf_name, 123 | const char * codec_type); 124 | void platform_set_gsm_mode(void *platform, bool enable); 125 | bool platform_can_split_snd_device(snd_device_t in_snd_device, 126 | int *num_devices, 127 | snd_device_t *out_snd_devices); 128 | 129 | bool platform_check_backends_match(snd_device_t snd_device1, snd_device_t snd_device2); 130 | #endif // AUDIO_PLATFORM_API_H 131 | -------------------------------------------------------------------------------- /hal/voice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. 3 | * Not a contribution. 4 | * 5 | * Copyright (C) 2013 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef VOICE_H 21 | #define VOICE_H 22 | 23 | #define BASE_SESS_IDX 0 24 | #define VOICE_SESS_IDX (BASE_SESS_IDX) 25 | 26 | #ifdef MULTI_VOICE_SESSION_ENABLED 27 | #define MAX_VOICE_SESSIONS 7 28 | #else 29 | #define MAX_VOICE_SESSIONS 1 30 | #endif 31 | 32 | #define BASE_CALL_STATE 1 33 | #define CALL_INACTIVE (BASE_CALL_STATE) 34 | #define CALL_ACTIVE (BASE_CALL_STATE + 1) 35 | 36 | #define VOICE_VSID 0x10C01000 37 | 38 | #define AUDIO_PARAMETER_KEY_INCALLMUSIC "incall_music_enabled" 39 | #define AUDIO_PARAMETER_VALUE_TRUE "true" 40 | 41 | struct audio_device; 42 | struct str_parms; 43 | struct stream_in; 44 | struct stream_out; 45 | typedef int audio_usecase_t; 46 | typedef int snd_device_t; 47 | 48 | struct call_state { 49 | int current; 50 | int new; 51 | }; 52 | 53 | struct voice_session { 54 | struct pcm *pcm_rx; 55 | struct pcm *pcm_tx; 56 | struct call_state state; 57 | uint32_t vsid; 58 | }; 59 | 60 | struct voice { 61 | struct voice_session session[MAX_VOICE_SESSIONS]; 62 | int tty_mode; 63 | bool mic_mute; 64 | float volume; 65 | bool in_call; 66 | }; 67 | 68 | enum { 69 | INCALL_REC_NONE = -1, 70 | INCALL_REC_UPLINK, 71 | INCALL_REC_DOWNLINK, 72 | INCALL_REC_UPLINK_AND_DOWNLINK, 73 | }; 74 | 75 | int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id); 76 | int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id); 77 | 78 | int voice_start_call(struct audio_device *adev); 79 | int voice_stop_call(struct audio_device *adev); 80 | int voice_set_parameters(struct audio_device *adev, struct str_parms *parms); 81 | void voice_get_parameters(struct audio_device *adev, struct str_parms *query, 82 | struct str_parms *reply); 83 | void voice_init(struct audio_device *adev); 84 | bool voice_is_in_call(const struct audio_device *adev); 85 | bool voice_is_in_call_rec_stream(const struct stream_in *in); 86 | int voice_set_mic_mute(struct audio_device *dev, bool state); 87 | bool voice_get_mic_mute(struct audio_device *dev); 88 | int voice_set_volume(struct audio_device *adev, float volume); 89 | int voice_check_and_set_incall_rec_usecase(struct audio_device *adev, 90 | struct stream_in *in); 91 | int voice_check_and_set_incall_music_usecase(struct audio_device *adev, 92 | struct stream_out *out); 93 | int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev, 94 | struct stream_in *in); 95 | void voice_update_devices_for_all_voice_usecases(struct audio_device *adev); 96 | snd_device_t voice_get_incall_rec_snd_device(snd_device_t in_snd_device); 97 | void voice_set_sidetone(struct audio_device *adev, 98 | snd_device_t out_snd_device, 99 | bool enable); 100 | bool voice_is_call_state_active(struct audio_device *adev); 101 | #endif //VOICE_H 102 | -------------------------------------------------------------------------------- /mm-audio/Android.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(strip $(TARGET_USES_QCOM_MM_AUDIO)),true) 2 | include $(call all-subdir-makefiles) 3 | endif 4 | -------------------------------------------------------------------------------- /mm-audio/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo "invoking omxaudio make" 3 | $(MAKE) -C adec-mp3 4 | $(MAKE) -C adec-aac 5 | $(MAKE) -C aenc-aac 6 | 7 | install: 8 | $(MAKE) -C adec-mp3 install 9 | $(MAKE) -C adec-aac install 10 | $(MAKE) -C aenc-aac install 11 | -------------------------------------------------------------------------------- /mm-audio/Makefile.am: -------------------------------------------------------------------------------- 1 | # Makefile.am - Automake script for mm-omxaudio 2 | # 3 | ACLOCAL_AMFLAGS = -I m4 4 | 5 | SUBDIRS = adec-aac adec-mp3 aenc-aac 6 | -------------------------------------------------------------------------------- /mm-audio/aenc-aac/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(filter arm aarch64 arm64, $(TARGET_ARCH)),) 2 | 3 | 4 | AENC_AAC_PATH:= $(call my-dir) 5 | 6 | include $(AENC_AAC_PATH)/qdsp6/Android.mk 7 | 8 | endif 9 | -------------------------------------------------------------------------------- /mm-audio/aenc-aac/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo "invoking omxaudio make" 3 | $(MAKE) -C qdsp6 4 | 5 | install: 6 | $(MAKE) -C qdsp6 install 7 | -------------------------------------------------------------------------------- /mm-audio/aenc-aac/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = qdsp6 2 | -------------------------------------------------------------------------------- /mm-audio/aenc-aac/qdsp6/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(BUILD_TINY_ANDROID),true) 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | # --------------------------------------------------------------------------------- 7 | # Common definitons 8 | # --------------------------------------------------------------------------------- 9 | 10 | libOmxAacEnc-def := -g -O3 11 | libOmxAacEnc-def += -DQC_MODIFIED 12 | libOmxAacEnc-def += -D_ANDROID_ 13 | libOmxAacEnc-def += -D_ENABLE_QC_MSG_LOG_ 14 | libOmxAacEnc-def += -DVERBOSE 15 | libOmxAacEnc-def += -D_DEBUG 16 | libOmxAacEnc-def += -Wconversion 17 | libOmxAacEnc-def += -DAUDIOV2 18 | 19 | # --------------------------------------------------------------------------------- 20 | # Make the Shared library (libOmxAacEnc) 21 | # --------------------------------------------------------------------------------- 22 | 23 | include $(CLEAR_VARS) 24 | 25 | libOmxAacEnc-inc := $(LOCAL_PATH)/inc 26 | libOmxAacEnc-inc += $(TARGET_OUT_HEADERS)/mm-core/omxcore 27 | 28 | LOCAL_MODULE := libOmxAacEnc 29 | LOCAL_MODULE_TAGS := optional 30 | LOCAL_CFLAGS := $(libOmxAacEnc-def) 31 | LOCAL_C_INCLUDES := $(libOmxAacEnc-inc) 32 | LOCAL_PRELINK_MODULE := false 33 | LOCAL_SHARED_LIBRARIES := libutils liblog 34 | 35 | LOCAL_SRC_FILES := src/aenc_svr.c 36 | LOCAL_SRC_FILES += src/omx_aac_aenc.cpp 37 | 38 | LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 39 | LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 40 | 41 | include $(BUILD_SHARED_LIBRARY) 42 | 43 | endif 44 | 45 | # --------------------------------------------------------------------------------- 46 | # END 47 | # --------------------------------------------------------------------------------- 48 | 49 | -------------------------------------------------------------------------------- /mm-audio/aenc-aac/qdsp6/Makefile: -------------------------------------------------------------------------------- 1 | # --------------------------------------------------------------------------------- 2 | # MM-AUDIO-OSS-8K-AENC-AAC 3 | # --------------------------------------------------------------------------------- 4 | 5 | # cross-compiler flags 6 | CFLAGS += -Wall 7 | CFLAGS += -Wundef 8 | CFLAGS += -Wstrict-prototypes 9 | CFLAGS += -Wno-trigraphs 10 | 11 | # cross-compile flags specific to shared objects 12 | CFLAGS_SO += -fpic 13 | 14 | # required pre-processor flags 15 | CPPFLAGS := -D__packed__= 16 | CPPFLAGS += -DIMAGE_APPS_PROC 17 | CPPFLAGS += -DFEATURE_Q_SINGLE_LINK 18 | CPPFLAGS += -DFEATURE_Q_NO_SELF_QPTR 19 | CPPFLAGS += -DFEATURE_LINUX 20 | CPPFLAGS += -DFEATURE_NATIVELINUX 21 | CPPFLAGS += -DFEATURE_DSM_DUP_ITEMS 22 | 23 | CPPFLAGS += -g 24 | CPPFALGS += -D_DEBUG 25 | CPPFLAGS += -Iinc 26 | 27 | # linker flags 28 | LDFLAGS += -L$(SYSROOT)/usr/lib 29 | 30 | # linker flags for shared objects 31 | LDFLAGS_SO := -shared 32 | 33 | # defintions 34 | LIBMAJOR := $(basename $(basename $(LIBVER))) 35 | LIBINSTALLDIR := $(DESTDIR)usr/lib 36 | INCINSTALLDIR := $(DESTDIR)usr/include 37 | BININSTALLDIR := $(DESTDIR)usr/bin 38 | 39 | # --------------------------------------------------------------------------------- 40 | # BUILD 41 | # --------------------------------------------------------------------------------- 42 | all: libOmxAacEnc.so.$(LIBVER) mm-aenc-omxaac-test 43 | 44 | install: 45 | echo "intalling aenc-aac in $(DESTDIR)" 46 | if [ ! -d $(LIBINSTALLDIR) ]; then mkdir -p $(LIBINSTALLDIR); fi 47 | if [ ! -d $(INCINSTALLDIR) ]; then mkdir -p $(INCINSTALLDIR); fi 48 | if [ ! -d $(BININSTALLDIR) ]; then mkdir -p $(BININSTALLDIR); fi 49 | install -m 555 libOmxAacEnc.so.$(LIBVER) $(LIBINSTALLDIR) 50 | cd $(LIBINSTALLDIR) && ln -s libOmxAacEnc.so.$(LIBVER) libOmxAacEnc.so.$(LIBMAJOR) 51 | cd $(LIBINSTALLDIR) && ln -s libOmxAacEnc.so.$(LIBMAJOR) libOmxAacEnc.so 52 | install -m 555 mm-aenc-omxaac-test $(BININSTALLDIR) 53 | 54 | # --------------------------------------------------------------------------------- 55 | # COMPILE LIBRARY 56 | # --------------------------------------------------------------------------------- 57 | LDLIBS := -lpthread 58 | LDLIBS += -lstdc++ 59 | LDLIBS += -lOmxCore 60 | 61 | SRCS := src/omx_aac_aenc.cpp 62 | SRCS += src/aenc_svr.c 63 | 64 | libOmxAacEnc.so.$(LIBVER): $(SRCS) 65 | $(CC) $(CPPFLAGS) $(CFLAGS_SO) $(LDFLAGS_SO) -Wl,-soname,libOmxAacEnc.so.$(LIBMAJOR) -o $@ $^ $(LDFLAGS) $(LDLIBS) 66 | 67 | # --------------------------------------------------------------------------------- 68 | # COMPILE TEST APP 69 | # --------------------------------------------------------------------------------- 70 | TEST_LDLIBS := -lpthread 71 | TEST_LDLIBS += -ldl 72 | TEST_LDLIBS += -lOmxCore 73 | 74 | TEST_SRCS := test/omx_aac_enc_test.c 75 | 76 | mm-aenc-omxaac-test: libOmxAacEnc.so.$(LIBVER) $(TEST_SRCS) 77 | $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^ $(TEST_LDLIBS) 78 | 79 | # --------------------------------------------------------------------------------- 80 | # END 81 | # --------------------------------------------------------------------------------- 82 | -------------------------------------------------------------------------------- /mm-audio/aenc-aac/qdsp6/Makefile.am: -------------------------------------------------------------------------------- 1 | # sources and intermediate files are separated 2 | 3 | AM_CFLAGS = -Wall 4 | AM_CFLAGS += -Wundef 5 | AM_CFLAGS += -Wstrict-prototypes 6 | AM_CFLAGS += -Wno-trigraphs 7 | AM_CFLAGS += -g -O3 8 | 9 | AM_CPPFLAGS = -D__packed__= 10 | AM_CPPFLAGS += -DIMAGE_APPS_PROC 11 | AM_CPPFLAGS += -DFEATURE_Q_SINGLE_LINK 12 | AM_CPPFLAGS += -DFEATURE_Q_NO_SELF_QPTR 13 | AM_CPPFLAGS += -DFEATURE_LINUX 14 | AM_CPPFLAGS += -DFEATURE_NATIVELINUX 15 | AM_CPPFLAGS += -DFEATURE_DSM_DUP_ITEMS 16 | AM_CPPFLAGS += -D_DEBUG 17 | AM_CPPFLAGS += -Iinc 18 | 19 | c_sources =src/omx_aac_aenc.cpp 20 | c_sources +=src/aenc_svr.c 21 | 22 | lib_LTLIBRARIES = libOmxAacEnc.la 23 | libOmxAacEnc_la_SOURCES = $(c_sources) 24 | libOmxAacEnc_la_CFLAGS = $(AM_CFLAGS) -fPIC 25 | libOmxAacEnc_la_LDLIBS = -lOmxCore -lstdc++ -lpthread 26 | libOmxAacEnc_la_LDFLAGS = -shared -version-info $(OMXAUDIO_LIBRARY_VERSION) 27 | 28 | bin_PROGRAMS = mm-aenc-omxaac-test 29 | mm_aenc_omxaac_test_SOURCES = test/omx_aac_enc_test.c 30 | mm_aenc_omxaac_test_LDADD = -lOmxCore -ldl -lpthread libOmxAacEnc.la 31 | -------------------------------------------------------------------------------- /mm-audio/aenc-aac/qdsp6/inc/Map.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #ifndef _MAP_H_ 29 | #define _MAP_H_ 30 | 31 | #include 32 | using namespace std; 33 | 34 | template 35 | class Map 36 | { 37 | struct node 38 | { 39 | T data; 40 | T2 data2; 41 | node* prev; 42 | node* next; 43 | node(T t, T2 t2,node* p, node* n) : 44 | data(t), data2(t2), prev(p), next(n) {} 45 | }; 46 | node* head; 47 | node* tail; 48 | node* tmp; 49 | unsigned size_of_list; 50 | static Map *m_self; 51 | public: 52 | Map() : head( NULL ), tail ( NULL ),tmp(head),size_of_list(0) {} 53 | bool empty() const { return ( !head || !tail ); } 54 | operator bool() const { return !empty(); } 55 | void insert(T,T2); 56 | void show(); 57 | int size(); 58 | T2 find(T); // Return VALUE 59 | T find_ele(T);// Check if the KEY is present or not 60 | T2 begin(); //give the first ele 61 | bool erase(T); 62 | bool eraseall(); 63 | bool isempty(); 64 | ~Map() 65 | { 66 | while(head) 67 | { 68 | node* temp(head); 69 | head=head->next; 70 | size_of_list--; 71 | delete temp; 72 | } 73 | } 74 | }; 75 | 76 | template 77 | T2 Map::find(T d1) 78 | { 79 | tmp = head; 80 | while(tmp) 81 | { 82 | if(tmp->data == d1) 83 | { 84 | return tmp->data2; 85 | } 86 | tmp = tmp->next; 87 | } 88 | return 0; 89 | } 90 | 91 | template 92 | T Map::find_ele(T d1) 93 | { 94 | tmp = head; 95 | while(tmp) 96 | { 97 | if(tmp->data == d1) 98 | { 99 | return tmp->data; 100 | } 101 | tmp = tmp->next; 102 | } 103 | return 0; 104 | } 105 | 106 | template 107 | T2 Map::begin() 108 | { 109 | tmp = head; 110 | if(tmp) 111 | { 112 | return (tmp->data2); 113 | } 114 | return 0; 115 | } 116 | 117 | template 118 | void Map::show() 119 | { 120 | tmp = head; 121 | while(tmp) 122 | { 123 | printf("%d-->%d\n",tmp->data,tmp->data2); 124 | tmp = tmp->next; 125 | } 126 | } 127 | 128 | template 129 | int Map::size() 130 | { 131 | int count =0; 132 | tmp = head; 133 | while(tmp) 134 | { 135 | tmp = tmp->next; 136 | count++; 137 | } 138 | return count; 139 | } 140 | 141 | template 142 | void Map::insert(T data, T2 data2) 143 | { 144 | tail = new node(data, data2,tail, NULL); 145 | if( tail->prev ) 146 | tail->prev->next = tail; 147 | 148 | if( empty() ) 149 | { 150 | head = tail; 151 | tmp=head; 152 | } 153 | tmp = head; 154 | size_of_list++; 155 | } 156 | 157 | template 158 | bool Map::erase(T d) 159 | { 160 | bool found = false; 161 | tmp = head; 162 | node* prevnode = tmp; 163 | node *tempnode; 164 | 165 | while(tmp) 166 | { 167 | if((head == tail) && (head->data == d)) 168 | { 169 | found = true; 170 | tempnode = head; 171 | head = tail = NULL; 172 | delete tempnode; 173 | break; 174 | } 175 | if((tmp ==head) && (tmp->data ==d)) 176 | { 177 | found = true; 178 | tempnode = tmp; 179 | tmp = tmp->next; 180 | tmp->prev = NULL; 181 | head = tmp; 182 | tempnode->next = NULL; 183 | delete tempnode; 184 | break; 185 | } 186 | if((tmp == tail) && (tmp->data ==d)) 187 | { 188 | found = true; 189 | tempnode = tmp; 190 | prevnode->next = NULL; 191 | tmp->prev = NULL; 192 | tail = prevnode; 193 | delete tempnode; 194 | break; 195 | } 196 | if(tmp->data == d) 197 | { 198 | found = true; 199 | prevnode->next = tmp->next; 200 | tmp->next->prev = prevnode->next; 201 | tempnode = tmp; 202 | //tmp = tmp->next; 203 | delete tempnode; 204 | break; 205 | } 206 | prevnode = tmp; 207 | tmp = tmp->next; 208 | } 209 | if(found)size_of_list--; 210 | return found; 211 | } 212 | 213 | template 214 | bool Map::eraseall() 215 | { 216 | // Be careful while using this method 217 | // it not only removes the node but FREES(not delete) the allocated 218 | // memory. 219 | node *tempnode; 220 | tmp = head; 221 | while(head) 222 | { 223 | tempnode = head; 224 | head = head->next; 225 | tempnode->next = NULL; 226 | if(tempnode->data) 227 | free(tempnode->data); 228 | if(tempnode->data2) 229 | free(tempnode->data2); 230 | delete tempnode; 231 | } 232 | tail = head = NULL; 233 | return true; 234 | } 235 | 236 | 237 | template 238 | bool Map::isempty() 239 | { 240 | if(!size_of_list) return true; 241 | else return false; 242 | } 243 | 244 | #endif // _MAP_H_ 245 | -------------------------------------------------------------------------------- /mm-audio/aenc-aac/qdsp6/inc/aenc_svr.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #ifndef AENC_SVR_H 29 | #define AENC_SVR_H 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | #include 35 | #include 36 | #include 37 | 38 | #ifdef _ANDROID_ 39 | #define LOG_TAG "QC_AACENC" 40 | #endif 41 | 42 | #ifndef LOGE 43 | #define LOGE ALOGE 44 | #endif 45 | 46 | #ifndef LOGW 47 | #define LOGW ALOGW 48 | #endif 49 | 50 | #ifndef LOGD 51 | #define LOGD ALOGD 52 | #endif 53 | 54 | #ifndef LOGV 55 | #define LOGV ALOGV 56 | #endif 57 | 58 | #ifndef LOGI 59 | #define LOGI ALOGI 60 | #endif 61 | 62 | #define DEBUG_PRINT_ERROR LOGE 63 | #define DEBUG_PRINT LOGV 64 | #define DEBUG_DETAIL LOGV 65 | 66 | typedef void (*message_func)(void* client_data, unsigned char id); 67 | 68 | /** 69 | @brief audio encoder ipc info structure 70 | 71 | */ 72 | struct aac_ipc_info 73 | { 74 | pthread_t thr; 75 | int pipe_in; 76 | int pipe_out; 77 | int dead; 78 | message_func process_msg_cb; 79 | void *client_data; 80 | char thread_name[128]; 81 | }; 82 | 83 | /** 84 | @brief This function starts command server 85 | 86 | @param cb pointer to callback function from the client 87 | @param client_data reference client wants to get back 88 | through callback 89 | @return handle to command server 90 | */ 91 | struct aac_ipc_info *omx_aac_thread_create(message_func cb, 92 | void* client_data, 93 | char *th_name); 94 | 95 | struct aac_ipc_info *omx_aac_event_thread_create(message_func cb, 96 | void* client_data, 97 | char *th_name); 98 | /** 99 | @brief This function stop command server 100 | 101 | @param svr handle to command server 102 | @return none 103 | */ 104 | void omx_aac_thread_stop(struct aac_ipc_info *aac_ipc); 105 | 106 | 107 | /** 108 | @brief This function post message in the command server 109 | 110 | @param svr handle to command server 111 | @return none 112 | */ 113 | void omx_aac_post_msg(struct aac_ipc_info *aac_ipc, 114 | unsigned char id); 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif /* AENC_SVR */ 121 | -------------------------------------------------------------------------------- /mm-audio/aenc-aac/qdsp6/src/aenc_svr.c: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | /** 38 | @brief This function processes posted messages 39 | 40 | Once thread is being spawned, this function is run to 41 | start processing commands posted by client 42 | 43 | @param info pointer to context 44 | 45 | */ 46 | void *omx_aac_msg(void *info) 47 | { 48 | struct aac_ipc_info *aac_info = (struct aac_ipc_info*)info; 49 | unsigned char id; 50 | ssize_t n; 51 | 52 | DEBUG_DETAIL("\n%s: message thread start\n", __FUNCTION__); 53 | while (!aac_info->dead) 54 | { 55 | n = read(aac_info->pipe_in, &id, 1); 56 | if (0 == n) break; 57 | if (1 == n) 58 | { 59 | DEBUG_DETAIL("\n%s-->pipe_in=%d pipe_out=%d\n", 60 | aac_info->thread_name, 61 | aac_info->pipe_in, 62 | aac_info->pipe_out); 63 | 64 | aac_info->process_msg_cb(aac_info->client_data, id); 65 | } 66 | if ((n < 0) && (errno != EINTR)) break; 67 | } 68 | DEBUG_DETAIL("%s: message thread stop\n", __FUNCTION__); 69 | 70 | return 0; 71 | } 72 | 73 | void *omx_aac_events(void *info) 74 | { 75 | struct aac_ipc_info *aac_info = (struct aac_ipc_info*)info; 76 | unsigned char id = 0; 77 | 78 | DEBUG_DETAIL("%s: message thread start\n", aac_info->thread_name); 79 | aac_info->process_msg_cb(aac_info->client_data, id); 80 | DEBUG_DETAIL("%s: message thread stop\n", aac_info->thread_name); 81 | return 0; 82 | } 83 | 84 | /** 85 | @brief This function starts command server 86 | 87 | @param cb pointer to callback function from the client 88 | @param client_data reference client wants to get back 89 | through callback 90 | @return handle to msging thread 91 | */ 92 | struct aac_ipc_info *omx_aac_thread_create( 93 | message_func cb, 94 | void* client_data, 95 | char* th_name) 96 | { 97 | int r; 98 | int fds[2]; 99 | struct aac_ipc_info *aac_info; 100 | 101 | aac_info = calloc(1, sizeof(struct aac_ipc_info)); 102 | if (!aac_info) 103 | { 104 | return 0; 105 | } 106 | 107 | aac_info->client_data = client_data; 108 | aac_info->process_msg_cb = cb; 109 | strlcpy(aac_info->thread_name, th_name, sizeof(aac_info->thread_name)); 110 | 111 | if (pipe(fds)) 112 | { 113 | DEBUG_PRINT_ERROR("\n%s: pipe creation failed\n", __FUNCTION__); 114 | goto fail_pipe; 115 | } 116 | 117 | aac_info->pipe_in = fds[0]; 118 | aac_info->pipe_out = fds[1]; 119 | 120 | r = pthread_create(&aac_info->thr, 0, omx_aac_msg, aac_info); 121 | if (r < 0) goto fail_thread; 122 | 123 | DEBUG_DETAIL("Created thread for %s \n", aac_info->thread_name); 124 | return aac_info; 125 | 126 | 127 | fail_thread: 128 | close(aac_info->pipe_in); 129 | close(aac_info->pipe_out); 130 | 131 | fail_pipe: 132 | free(aac_info); 133 | 134 | return 0; 135 | } 136 | 137 | /** 138 | * @brief This function starts command server 139 | * 140 | * @param cb pointer to callback function from the client 141 | * @param client_data reference client wants to get back 142 | * through callback 143 | * @return handle to msging thread 144 | * */ 145 | struct aac_ipc_info *omx_aac_event_thread_create( 146 | message_func cb, 147 | void* client_data, 148 | char* th_name) 149 | { 150 | int r; 151 | int fds[2]; 152 | struct aac_ipc_info *aac_info; 153 | 154 | aac_info = calloc(1, sizeof(struct aac_ipc_info)); 155 | if (!aac_info) 156 | { 157 | return 0; 158 | } 159 | 160 | aac_info->client_data = client_data; 161 | aac_info->process_msg_cb = cb; 162 | strlcpy(aac_info->thread_name, th_name, sizeof(aac_info->thread_name)); 163 | 164 | if (pipe(fds)) 165 | { 166 | DEBUG_PRINT("\n%s: pipe creation failed\n", __FUNCTION__); 167 | goto fail_pipe; 168 | } 169 | 170 | aac_info->pipe_in = fds[0]; 171 | aac_info->pipe_out = fds[1]; 172 | 173 | r = pthread_create(&aac_info->thr, 0, omx_aac_events, aac_info); 174 | if (r < 0) goto fail_thread; 175 | 176 | DEBUG_DETAIL("Created thread for %s \n", aac_info->thread_name); 177 | return aac_info; 178 | 179 | 180 | fail_thread: 181 | close(aac_info->pipe_in); 182 | close(aac_info->pipe_out); 183 | 184 | fail_pipe: 185 | free(aac_info); 186 | 187 | return 0; 188 | } 189 | 190 | void omx_aac_thread_stop(struct aac_ipc_info *aac_info) { 191 | DEBUG_DETAIL("%s stop server\n", __FUNCTION__); 192 | close(aac_info->pipe_in); 193 | close(aac_info->pipe_out); 194 | pthread_join(aac_info->thr,NULL); 195 | aac_info->pipe_out = -1; 196 | aac_info->pipe_in = -1; 197 | DEBUG_DETAIL("%s: message thread close fds%d %d\n", aac_info->thread_name, 198 | aac_info->pipe_in,aac_info->pipe_out); 199 | free(aac_info); 200 | } 201 | 202 | void omx_aac_post_msg(struct aac_ipc_info *aac_info, unsigned char id) { 203 | DEBUG_DETAIL("\n%s id=%d\n", __FUNCTION__,id); 204 | 205 | write(aac_info->pipe_out, &id, 1); 206 | } 207 | -------------------------------------------------------------------------------- /mm-audio/aenc-amrnb/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(filter arm aarch64 arm64, $(TARGET_ARCH)),) 2 | 3 | 4 | AENC_AMR_PATH:= $(call my-dir) 5 | 6 | include $(AENC_AMR_PATH)/qdsp6/Android.mk 7 | 8 | endif 9 | -------------------------------------------------------------------------------- /mm-audio/aenc-amrnb/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo "invoking omxaudio make" 3 | $(MAKE) -C qdsp6 4 | 5 | install: 6 | $(MAKE) -C qdsp6 install 7 | -------------------------------------------------------------------------------- /mm-audio/aenc-amrnb/qdsp6/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(BUILD_TINY_ANDROID),true) 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | # --------------------------------------------------------------------------------- 7 | # Common definitons 8 | # --------------------------------------------------------------------------------- 9 | 10 | libOmxAmrEnc-def := -g -O3 11 | libOmxAmrEnc-def += -DQC_MODIFIED 12 | libOmxAmrEnc-def += -D_ANDROID_ 13 | libOmxAmrEnc-def += -D_ENABLE_QC_MSG_LOG_ 14 | libOmxAmrEnc-def += -DVERBOSE 15 | libOmxAmrEnc-def += -D_DEBUG 16 | libOmxAmrEnc-def += -Wconversion 17 | libOmxAmrEnc-def += -DAUDIOV2 18 | 19 | # --------------------------------------------------------------------------------- 20 | # Make the Shared library (libOmxAmrEnc) 21 | # --------------------------------------------------------------------------------- 22 | 23 | include $(CLEAR_VARS) 24 | 25 | libOmxAmrEnc-inc := $(LOCAL_PATH)/inc 26 | libOmxAmrEnc-inc += $(TARGET_OUT_HEADERS)/mm-core/omxcore 27 | 28 | LOCAL_MODULE := libOmxAmrEnc 29 | LOCAL_MODULE_TAGS := optional 30 | LOCAL_CFLAGS := $(libOmxAmrEnc-def) 31 | LOCAL_C_INCLUDES := $(libOmxAmrEnc-inc) 32 | LOCAL_PRELINK_MODULE := false 33 | LOCAL_SHARED_LIBRARIES := libutils liblog 34 | 35 | LOCAL_SRC_FILES := src/aenc_svr.c 36 | LOCAL_SRC_FILES += src/omx_amr_aenc.cpp 37 | 38 | LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 39 | LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 40 | 41 | include $(BUILD_SHARED_LIBRARY) 42 | 43 | endif 44 | 45 | # --------------------------------------------------------------------------------- 46 | # END 47 | # --------------------------------------------------------------------------------- 48 | 49 | -------------------------------------------------------------------------------- /mm-audio/aenc-amrnb/qdsp6/Makefile: -------------------------------------------------------------------------------- 1 | # --------------------------------------------------------------------------------- 2 | # MM-AUDIO-OSS-8K-AENC-AMR 3 | # --------------------------------------------------------------------------------- 4 | 5 | # cross-compiler flags 6 | CFLAGS += -Wall 7 | CFLAGS += -Wundef 8 | CFLAGS += -Wstrict-prototypes 9 | CFLAGS += -Wno-trigraphs 10 | 11 | # cross-compile flags specific to shared objects 12 | CFLAGS_SO += -fpic 13 | 14 | # required pre-processor flags 15 | CPPFLAGS := -D__packed__= 16 | CPPFLAGS += -DIMAGE_APPS_PROC 17 | CPPFLAGS += -DFEATURE_Q_SINGLE_LINK 18 | CPPFLAGS += -DFEATURE_Q_NO_SELF_QPTR 19 | CPPFLAGS += -DFEATURE_LINUX 20 | CPPFLAGS += -DFEATURE_NATIVELINUX 21 | CPPFLAGS += -DFEATURE_DSM_DUP_ITEMS 22 | 23 | CPPFLAGS += -g 24 | CPPFALGS += -D_DEBUG 25 | CPPFLAGS += -Iinc 26 | 27 | # linker flags 28 | LDFLAGS += -L$(SYSROOT)/usr/lib 29 | 30 | # linker flags for shared objects 31 | LDFLAGS_SO := -shared 32 | 33 | # defintions 34 | LIBMAJOR := $(basename $(basename $(LIBVER))) 35 | LIBINSTALLDIR := $(DESTDIR)usr/lib 36 | INCINSTALLDIR := $(DESTDIR)usr/include 37 | BININSTALLDIR := $(DESTDIR)usr/bin 38 | 39 | # --------------------------------------------------------------------------------- 40 | # BUILD 41 | # --------------------------------------------------------------------------------- 42 | all: libOmxAmrEnc.so.$(LIBVER) mm-aenc-omxamr-test 43 | 44 | install: 45 | echo "intalling aenc-amr in $(DESTDIR)" 46 | if [ ! -d $(LIBINSTALLDIR) ]; then mkdir -p $(LIBINSTALLDIR); fi 47 | if [ ! -d $(INCINSTALLDIR) ]; then mkdir -p $(INCINSTALLDIR); fi 48 | if [ ! -d $(BININSTALLDIR) ]; then mkdir -p $(BININSTALLDIR); fi 49 | install -m 555 libOmxAmrEnc.so.$(LIBVER) $(LIBINSTALLDIR) 50 | cd $(LIBINSTALLDIR) && ln -s libOmxAmrEnc.so.$(LIBVER) libOmxAmrEnc.so.$(LIBMAJOR) 51 | cd $(LIBINSTALLDIR) && ln -s libOmxAmrEnc.so.$(LIBMAJOR) libOmxAmrEnc.so 52 | install -m 555 mm-aenc-omxamr-test $(BININSTALLDIR) 53 | 54 | # --------------------------------------------------------------------------------- 55 | # COMPILE LIBRARY 56 | # --------------------------------------------------------------------------------- 57 | LDLIBS := -lpthread 58 | LDLIBS += -lstdc++ 59 | LDLIBS += -lOmxCore 60 | 61 | SRCS := src/omx_amr_aenc.cpp 62 | SRCS += src/aenc_svr.c 63 | 64 | libOmxAmrEnc.so.$(LIBVER): $(SRCS) 65 | $(CC) $(CPPFLAGS) $(CFLAGS_SO) $(LDFLAGS_SO) -Wl,-soname,libOmxAmrEnc.so.$(LIBMAJOR) -o $@ $^ $(LDFLAGS) $(LDLIBS) 66 | 67 | # --------------------------------------------------------------------------------- 68 | # COMPILE TEST APP 69 | # --------------------------------------------------------------------------------- 70 | TEST_LDLIBS := -lpthread 71 | TEST_LDLIBS += -ldl 72 | TEST_LDLIBS += -lOmxCore 73 | 74 | TEST_SRCS := test/omx_amr_enc_test.c 75 | 76 | mm-aenc-omxamr-test: libOmxAmrEnc.so.$(LIBVER) $(TEST_SRCS) 77 | $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^ $(TEST_LDLIBS) 78 | 79 | # --------------------------------------------------------------------------------- 80 | # END 81 | # --------------------------------------------------------------------------------- 82 | -------------------------------------------------------------------------------- /mm-audio/aenc-amrnb/qdsp6/inc/Map.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #ifndef _MAP_H_ 29 | #define _MAP_H_ 30 | 31 | #include 32 | using namespace std; 33 | 34 | template 35 | class Map 36 | { 37 | struct node 38 | { 39 | T data; 40 | T2 data2; 41 | node* prev; 42 | node* next; 43 | node(T t, T2 t2,node* p, node* n) : 44 | data(t), data2(t2), prev(p), next(n) {} 45 | }; 46 | node* head; 47 | node* tail; 48 | node* tmp; 49 | unsigned size_of_list; 50 | static Map *m_self; 51 | public: 52 | Map() : head( NULL ), tail ( NULL ),tmp(head),size_of_list(0) {} 53 | bool empty() const { return ( !head || !tail ); } 54 | operator bool() const { return !empty(); } 55 | void insert(T,T2); 56 | void show(); 57 | int size(); 58 | T2 find(T); // Return VALUE 59 | T find_ele(T);// Check if the KEY is present or not 60 | T2 begin(); //give the first ele 61 | bool erase(T); 62 | bool eraseall(); 63 | bool isempty(); 64 | ~Map() 65 | { 66 | while(head) 67 | { 68 | node* temp(head); 69 | head=head->next; 70 | size_of_list--; 71 | delete temp; 72 | } 73 | } 74 | }; 75 | 76 | template 77 | T2 Map::find(T d1) 78 | { 79 | tmp = head; 80 | while(tmp) 81 | { 82 | if(tmp->data == d1) 83 | { 84 | return tmp->data2; 85 | } 86 | tmp = tmp->next; 87 | } 88 | return 0; 89 | } 90 | 91 | template 92 | T Map::find_ele(T d1) 93 | { 94 | tmp = head; 95 | while(tmp) 96 | { 97 | if(tmp->data == d1) 98 | { 99 | return tmp->data; 100 | } 101 | tmp = tmp->next; 102 | } 103 | return 0; 104 | } 105 | 106 | template 107 | T2 Map::begin() 108 | { 109 | tmp = head; 110 | if(tmp) 111 | { 112 | return (tmp->data2); 113 | } 114 | return 0; 115 | } 116 | 117 | template 118 | void Map::show() 119 | { 120 | tmp = head; 121 | while(tmp) 122 | { 123 | printf("%d-->%d\n",tmp->data,tmp->data2); 124 | tmp = tmp->next; 125 | } 126 | } 127 | 128 | template 129 | int Map::size() 130 | { 131 | int count =0; 132 | tmp = head; 133 | while(tmp) 134 | { 135 | tmp = tmp->next; 136 | count++; 137 | } 138 | return count; 139 | } 140 | 141 | template 142 | void Map::insert(T data, T2 data2) 143 | { 144 | tail = new node(data, data2,tail, NULL); 145 | if( tail->prev ) 146 | tail->prev->next = tail; 147 | 148 | if( empty() ) 149 | { 150 | head = tail; 151 | tmp=head; 152 | } 153 | tmp = head; 154 | size_of_list++; 155 | } 156 | 157 | template 158 | bool Map::erase(T d) 159 | { 160 | bool found = false; 161 | tmp = head; 162 | node* prevnode = tmp; 163 | node *tempnode; 164 | 165 | while(tmp) 166 | { 167 | if((head == tail) && (head->data == d)) 168 | { 169 | found = true; 170 | tempnode = head; 171 | head = tail = NULL; 172 | delete tempnode; 173 | break; 174 | } 175 | if((tmp ==head) && (tmp->data ==d)) 176 | { 177 | found = true; 178 | tempnode = tmp; 179 | tmp = tmp->next; 180 | tmp->prev = NULL; 181 | head = tmp; 182 | tempnode->next = NULL; 183 | delete tempnode; 184 | break; 185 | } 186 | if((tmp == tail) && (tmp->data ==d)) 187 | { 188 | found = true; 189 | tempnode = tmp; 190 | prevnode->next = NULL; 191 | tmp->prev = NULL; 192 | tail = prevnode; 193 | delete tempnode; 194 | break; 195 | } 196 | if(tmp->data == d) 197 | { 198 | found = true; 199 | prevnode->next = tmp->next; 200 | tmp->next->prev = prevnode->next; 201 | tempnode = tmp; 202 | //tmp = tmp->next; 203 | delete tempnode; 204 | break; 205 | } 206 | prevnode = tmp; 207 | tmp = tmp->next; 208 | } 209 | if(found)size_of_list--; 210 | return found; 211 | } 212 | 213 | template 214 | bool Map::eraseall() 215 | { 216 | // Be careful while using this method 217 | // it not only removes the node but FREES(not delete) the allocated 218 | // memory. 219 | node *tempnode; 220 | tmp = head; 221 | while(head) 222 | { 223 | tempnode = head; 224 | head = head->next; 225 | tempnode->next = NULL; 226 | if(tempnode->data) 227 | free(tempnode->data); 228 | if(tempnode->data2) 229 | free(tempnode->data2); 230 | delete tempnode; 231 | } 232 | tail = head = NULL; 233 | return true; 234 | } 235 | 236 | 237 | template 238 | bool Map::isempty() 239 | { 240 | if(!size_of_list) return true; 241 | else return false; 242 | } 243 | 244 | #endif // _MAP_H_ 245 | -------------------------------------------------------------------------------- /mm-audio/aenc-amrnb/qdsp6/inc/aenc_svr.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #ifndef AENC_SVR_H 29 | #define AENC_SVR_H 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | #include 35 | #include 36 | #include 37 | 38 | #ifdef _ANDROID_ 39 | #define LOG_TAG "QC_AMRENC" 40 | #endif 41 | 42 | #ifndef LOGE 43 | #define LOGE ALOGE 44 | #endif 45 | 46 | #ifndef LOGW 47 | #define LOGW ALOGW 48 | #endif 49 | 50 | #ifndef LOGD 51 | #define LOGD ALOGD 52 | #endif 53 | 54 | #ifndef LOGV 55 | #define LOGV ALOGV 56 | #endif 57 | 58 | #ifndef LOGI 59 | #define LOGI ALOGI 60 | #endif 61 | 62 | #define DEBUG_PRINT_ERROR LOGE 63 | #define DEBUG_PRINT LOGI 64 | #define DEBUG_DETAIL LOGV 65 | 66 | typedef void (*message_func)(void* client_data, unsigned char id); 67 | 68 | /** 69 | @brief audio encoder ipc info structure 70 | 71 | */ 72 | struct amr_ipc_info 73 | { 74 | pthread_t thr; 75 | int pipe_in; 76 | int pipe_out; 77 | int dead; 78 | message_func process_msg_cb; 79 | void *client_data; 80 | char thread_name[128]; 81 | }; 82 | 83 | /** 84 | @brief This function starts command server 85 | 86 | @param cb pointer to callback function from the client 87 | @param client_data reference client wants to get back 88 | through callback 89 | @return handle to command server 90 | */ 91 | struct amr_ipc_info *omx_amr_thread_create(message_func cb, 92 | void* client_data, 93 | char *th_name); 94 | 95 | struct amr_ipc_info *omx_amr_event_thread_create(message_func cb, 96 | void* client_data, 97 | char *th_name); 98 | /** 99 | @brief This function stop command server 100 | 101 | @param svr handle to command server 102 | @return none 103 | */ 104 | void omx_amr_thread_stop(struct amr_ipc_info *amr_ipc); 105 | 106 | 107 | /** 108 | @brief This function post message in the command server 109 | 110 | @param svr handle to command server 111 | @return none 112 | */ 113 | void omx_amr_post_msg(struct amr_ipc_info *amr_ipc, 114 | unsigned char id); 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif /* AENC_SVR */ 121 | -------------------------------------------------------------------------------- /mm-audio/aenc-amrnb/qdsp6/src/aenc_svr.c: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | /** 38 | @brief This function processes posted messages 39 | 40 | Once thread is being spawned, this function is run to 41 | start processing commands posted by client 42 | 43 | @param info pointer to context 44 | 45 | */ 46 | void *omx_amr_msg(void *info) 47 | { 48 | struct amr_ipc_info *amr_info = (struct amr_ipc_info*)info; 49 | unsigned char id; 50 | ssize_t n; 51 | 52 | DEBUG_DETAIL("\n%s: message thread start\n", __FUNCTION__); 53 | while (!amr_info->dead) 54 | { 55 | n = read(amr_info->pipe_in, &id, 1); 56 | if (0 == n) break; 57 | if (1 == n) 58 | { 59 | DEBUG_DETAIL("\n%s-->pipe_in=%d pipe_out=%d\n", 60 | amr_info->thread_name, 61 | amr_info->pipe_in, 62 | amr_info->pipe_out); 63 | 64 | amr_info->process_msg_cb(amr_info->client_data, id); 65 | } 66 | if ((n < 0) && (errno != EINTR)) break; 67 | } 68 | DEBUG_DETAIL("%s: message thread stop\n", __FUNCTION__); 69 | 70 | return 0; 71 | } 72 | 73 | void *omx_amr_events(void *info) 74 | { 75 | struct amr_ipc_info *amr_info = (struct amr_ipc_info*)info; 76 | unsigned char id = 0; 77 | 78 | DEBUG_DETAIL("%s: message thread start\n", amr_info->thread_name); 79 | amr_info->process_msg_cb(amr_info->client_data, id); 80 | DEBUG_DETAIL("%s: message thread stop\n", amr_info->thread_name); 81 | return 0; 82 | } 83 | 84 | /** 85 | @brief This function starts command server 86 | 87 | @param cb pointer to callback function from the client 88 | @param client_data reference client wants to get back 89 | through callback 90 | @return handle to msging thread 91 | */ 92 | struct amr_ipc_info *omx_amr_thread_create( 93 | message_func cb, 94 | void* client_data, 95 | char* th_name) 96 | { 97 | int r; 98 | int fds[2]; 99 | struct amr_ipc_info *amr_info; 100 | 101 | amr_info = calloc(1, sizeof(struct amr_ipc_info)); 102 | if (!amr_info) 103 | { 104 | return 0; 105 | } 106 | 107 | amr_info->client_data = client_data; 108 | amr_info->process_msg_cb = cb; 109 | strlcpy(amr_info->thread_name, th_name, sizeof(amr_info->thread_name)); 110 | 111 | if (pipe(fds)) 112 | { 113 | DEBUG_PRINT_ERROR("\n%s: pipe creation failed\n", __FUNCTION__); 114 | goto fail_pipe; 115 | } 116 | 117 | amr_info->pipe_in = fds[0]; 118 | amr_info->pipe_out = fds[1]; 119 | 120 | r = pthread_create(&amr_info->thr, 0, omx_amr_msg, amr_info); 121 | if (r < 0) goto fail_thread; 122 | 123 | DEBUG_DETAIL("Created thread for %s \n", amr_info->thread_name); 124 | return amr_info; 125 | 126 | 127 | fail_thread: 128 | close(amr_info->pipe_in); 129 | close(amr_info->pipe_out); 130 | 131 | fail_pipe: 132 | free(amr_info); 133 | 134 | return 0; 135 | } 136 | 137 | /** 138 | * @brief This function starts command server 139 | * 140 | * @param cb pointer to callback function from the client 141 | * @param client_data reference client wants to get back 142 | * through callback 143 | * @return handle to msging thread 144 | * */ 145 | struct amr_ipc_info *omx_amr_event_thread_create( 146 | message_func cb, 147 | void* client_data, 148 | char* th_name) 149 | { 150 | int r; 151 | int fds[2]; 152 | struct amr_ipc_info *amr_info; 153 | 154 | amr_info = calloc(1, sizeof(struct amr_ipc_info)); 155 | if (!amr_info) 156 | { 157 | return 0; 158 | } 159 | 160 | amr_info->client_data = client_data; 161 | amr_info->process_msg_cb = cb; 162 | strlcpy(amr_info->thread_name, th_name, sizeof(amr_info->thread_name)); 163 | 164 | if (pipe(fds)) 165 | { 166 | DEBUG_PRINT("\n%s: pipe creation failed\n", __FUNCTION__); 167 | goto fail_pipe; 168 | } 169 | 170 | amr_info->pipe_in = fds[0]; 171 | amr_info->pipe_out = fds[1]; 172 | 173 | r = pthread_create(&amr_info->thr, 0, omx_amr_events, amr_info); 174 | if (r < 0) goto fail_thread; 175 | 176 | DEBUG_DETAIL("Created thread for %s \n", amr_info->thread_name); 177 | return amr_info; 178 | 179 | 180 | fail_thread: 181 | close(amr_info->pipe_in); 182 | close(amr_info->pipe_out); 183 | 184 | fail_pipe: 185 | free(amr_info); 186 | 187 | return 0; 188 | } 189 | 190 | void omx_amr_thread_stop(struct amr_ipc_info *amr_info) { 191 | DEBUG_DETAIL("%s stop server\n", __FUNCTION__); 192 | close(amr_info->pipe_in); 193 | close(amr_info->pipe_out); 194 | pthread_join(amr_info->thr,NULL); 195 | amr_info->pipe_out = -1; 196 | amr_info->pipe_in = -1; 197 | DEBUG_DETAIL("%s: message thread close fds%d %d\n", amr_info->thread_name, 198 | amr_info->pipe_in,amr_info->pipe_out); 199 | free(amr_info); 200 | } 201 | 202 | void omx_amr_post_msg(struct amr_ipc_info *amr_info, unsigned char id) { 203 | DEBUG_DETAIL("\n%s id=%d\n", __FUNCTION__,id); 204 | write(amr_info->pipe_out, &id, 1); 205 | } 206 | -------------------------------------------------------------------------------- /mm-audio/aenc-evrc/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(filter arm aarch64 arm64, $(TARGET_ARCH)),) 2 | 3 | AENC_EVRC_PATH:= $(call my-dir) 4 | 5 | include $(AENC_EVRC_PATH)/qdsp6/Android.mk 6 | 7 | endif 8 | -------------------------------------------------------------------------------- /mm-audio/aenc-evrc/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo "invoking omxaudio make" 3 | $(MAKE) -C qdsp6 4 | 5 | install: 6 | $(MAKE) -C qdsp6 install 7 | -------------------------------------------------------------------------------- /mm-audio/aenc-evrc/qdsp6/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(BUILD_TINY_ANDROID),true) 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | # --------------------------------------------------------------------------------- 7 | # Common definitons 8 | # --------------------------------------------------------------------------------- 9 | 10 | libOmxEvrcEnc-def := -g -O3 11 | libOmxEvrcEnc-def += -DQC_MODIFIED 12 | libOmxEvrcEnc-def += -D_ANDROID_ 13 | libOmxEvrcEnc-def += -D_ENABLE_QC_MSG_LOG_ 14 | libOmxEvrcEnc-def += -DVERBOSE 15 | libOmxEvrcEnc-def += -D_DEBUG 16 | libOmxEvrcEnc-def += -Wconversion 17 | libOmxEvrcEnc-def += -DAUDIOV2 18 | 19 | # --------------------------------------------------------------------------------- 20 | # Make the Shared library (libOmxEvrcEnc) 21 | # --------------------------------------------------------------------------------- 22 | 23 | include $(CLEAR_VARS) 24 | 25 | libOmxEvrcEnc-inc := $(LOCAL_PATH)/inc 26 | libOmxEvrcEnc-inc += $(TARGET_OUT_HEADERS)/mm-core/omxcore 27 | 28 | LOCAL_MODULE := libOmxEvrcEnc 29 | LOCAL_MODULE_TAGS := optional 30 | LOCAL_CFLAGS := $(libOmxEvrcEnc-def) 31 | LOCAL_C_INCLUDES := $(libOmxEvrcEnc-inc) 32 | LOCAL_PRELINK_MODULE := false 33 | LOCAL_SHARED_LIBRARIES := libutils liblog 34 | 35 | LOCAL_SRC_FILES := src/aenc_svr.c 36 | LOCAL_SRC_FILES += src/omx_evrc_aenc.cpp 37 | 38 | LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 39 | LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 40 | 41 | include $(BUILD_SHARED_LIBRARY) 42 | 43 | endif 44 | 45 | # --------------------------------------------------------------------------------- 46 | # END 47 | # --------------------------------------------------------------------------------- 48 | 49 | -------------------------------------------------------------------------------- /mm-audio/aenc-evrc/qdsp6/Makefile: -------------------------------------------------------------------------------- 1 | # --------------------------------------------------------------------------------- 2 | # MM-AUDIO-OSS-8K-AENC-EVRC 3 | # --------------------------------------------------------------------------------- 4 | 5 | # cross-compiler flags 6 | CFLAGS += -Wall 7 | CFLAGS += -Wundef 8 | CFLAGS += -Wstrict-prototypes 9 | CFLAGS += -Wno-trigraphs 10 | 11 | # cross-compile flags specific to shared objects 12 | CFLAGS_SO += -fpic 13 | 14 | # required pre-processor flags 15 | CPPFLAGS := -D__packed__= 16 | CPPFLAGS += -DIMAGE_APPS_PROC 17 | CPPFLAGS += -DFEATURE_Q_SINGLE_LINK 18 | CPPFLAGS += -DFEATURE_Q_NO_SELF_QPTR 19 | CPPFLAGS += -DFEATURE_LINUX 20 | CPPFLAGS += -DFEATURE_NATIVELINUX 21 | CPPFLAGS += -DFEATURE_DSM_DUP_ITEMS 22 | 23 | CPPFLAGS += -g 24 | CPPFALGS += -D_DEBUG 25 | CPPFLAGS += -Iinc 26 | 27 | # linker flags 28 | LDFLAGS += -L$(SYSROOT)/usr/lib 29 | 30 | # linker flags for shared objects 31 | LDFLAGS_SO := -shared 32 | 33 | # defintions 34 | LIBMAJOR := $(basename $(basename $(LIBVER))) 35 | LIBINSTALLDIR := $(DESTDIR)usr/lib 36 | INCINSTALLDIR := $(DESTDIR)usr/include 37 | BININSTALLDIR := $(DESTDIR)usr/bin 38 | 39 | # --------------------------------------------------------------------------------- 40 | # BUILD 41 | # --------------------------------------------------------------------------------- 42 | all: libOmxEvrcEnc.so.$(LIBVER) mm-aenc-omxevrc-test 43 | 44 | install: 45 | echo "intalling aenc-evrc in $(DESTDIR)" 46 | if [ ! -d $(LIBINSTALLDIR) ]; then mkdir -p $(LIBINSTALLDIR); fi 47 | if [ ! -d $(INCINSTALLDIR) ]; then mkdir -p $(INCINSTALLDIR); fi 48 | if [ ! -d $(BININSTALLDIR) ]; then mkdir -p $(BININSTALLDIR); fi 49 | install -m 555 libOmxEvrcEnc.so.$(LIBVER) $(LIBINSTALLDIR) 50 | cd $(LIBINSTALLDIR) && ln -s libOmxEvrcEnc.so.$(LIBVER) libOmxEvrcEnc.so.$(LIBMAJOR) 51 | cd $(LIBINSTALLDIR) && ln -s libOmxEvrcEnc.so.$(LIBMAJOR) libOmxEvrcEnc.so 52 | install -m 555 mm-aenc-omxevrc-test $(BININSTALLDIR) 53 | 54 | # --------------------------------------------------------------------------------- 55 | # COMPILE LIBRARY 56 | # --------------------------------------------------------------------------------- 57 | LDLIBS := -lpthread 58 | LDLIBS += -lstdc++ 59 | LDLIBS += -lOmxCore 60 | 61 | SRCS := src/omx_evrc_aenc.cpp 62 | SRCS += src/aenc_svr.c 63 | 64 | libOmxEvrcEnc.so.$(LIBVER): $(SRCS) 65 | $(CC) $(CPPFLAGS) $(CFLAGS_SO) $(LDFLAGS_SO) -Wl,-soname,libOmxEvrcEnc.so.$(LIBMAJOR) -o $@ $^ $(LDFLAGS) $(LDLIBS) 66 | 67 | # --------------------------------------------------------------------------------- 68 | # COMPILE TEST APP 69 | # --------------------------------------------------------------------------------- 70 | TEST_LDLIBS := -lpthread 71 | TEST_LDLIBS += -ldl 72 | TEST_LDLIBS += -lOmxCore 73 | 74 | TEST_SRCS := test/omx_evrc_enc_test.c 75 | 76 | mm-aenc-omxevrc-test: libOmxEvrcEnc.so.$(LIBVER) $(TEST_SRCS) 77 | $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^ $(TEST_LDLIBS) 78 | 79 | # --------------------------------------------------------------------------------- 80 | # END 81 | # --------------------------------------------------------------------------------- 82 | -------------------------------------------------------------------------------- /mm-audio/aenc-evrc/qdsp6/inc/Map.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #ifndef _MAP_H_ 29 | #define _MAP_H_ 30 | 31 | #include 32 | using namespace std; 33 | 34 | template 35 | class Map 36 | { 37 | struct node 38 | { 39 | T data; 40 | T2 data2; 41 | node* prev; 42 | node* next; 43 | node(T t, T2 t2,node* p, node* n) : 44 | data(t), data2(t2), prev(p), next(n) {} 45 | }; 46 | node* head; 47 | node* tail; 48 | node* tmp; 49 | unsigned size_of_list; 50 | static Map *m_self; 51 | public: 52 | Map() : head( NULL ), tail ( NULL ),tmp(head),size_of_list(0) {} 53 | bool empty() const { return ( !head || !tail ); } 54 | operator bool() const { return !empty(); } 55 | void insert(T,T2); 56 | void show(); 57 | int size(); 58 | T2 find(T); // Return VALUE 59 | T find_ele(T);// Check if the KEY is present or not 60 | T2 begin(); //give the first ele 61 | bool erase(T); 62 | bool eraseall(); 63 | bool isempty(); 64 | ~Map() 65 | { 66 | while(head) 67 | { 68 | node* temp(head); 69 | head=head->next; 70 | size_of_list--; 71 | delete temp; 72 | } 73 | } 74 | }; 75 | 76 | template 77 | T2 Map::find(T d1) 78 | { 79 | tmp = head; 80 | while(tmp) 81 | { 82 | if(tmp->data == d1) 83 | { 84 | return tmp->data2; 85 | } 86 | tmp = tmp->next; 87 | } 88 | return 0; 89 | } 90 | 91 | template 92 | T Map::find_ele(T d1) 93 | { 94 | tmp = head; 95 | while(tmp) 96 | { 97 | if(tmp->data == d1) 98 | { 99 | return tmp->data; 100 | } 101 | tmp = tmp->next; 102 | } 103 | return 0; 104 | } 105 | 106 | template 107 | T2 Map::begin() 108 | { 109 | tmp = head; 110 | if(tmp) 111 | { 112 | return (tmp->data2); 113 | } 114 | return 0; 115 | } 116 | 117 | template 118 | void Map::show() 119 | { 120 | tmp = head; 121 | while(tmp) 122 | { 123 | printf("%d-->%d\n",tmp->data,tmp->data2); 124 | tmp = tmp->next; 125 | } 126 | } 127 | 128 | template 129 | int Map::size() 130 | { 131 | int count =0; 132 | tmp = head; 133 | while(tmp) 134 | { 135 | tmp = tmp->next; 136 | count++; 137 | } 138 | return count; 139 | } 140 | 141 | template 142 | void Map::insert(T data, T2 data2) 143 | { 144 | tail = new node(data, data2,tail, NULL); 145 | if( tail->prev ) 146 | tail->prev->next = tail; 147 | 148 | if( empty() ) 149 | { 150 | head = tail; 151 | tmp=head; 152 | } 153 | tmp = head; 154 | size_of_list++; 155 | } 156 | 157 | template 158 | bool Map::erase(T d) 159 | { 160 | bool found = false; 161 | tmp = head; 162 | node* prevnode = tmp; 163 | node *tempnode; 164 | 165 | while(tmp) 166 | { 167 | if((head == tail) && (head->data == d)) 168 | { 169 | found = true; 170 | tempnode = head; 171 | head = tail = NULL; 172 | delete tempnode; 173 | break; 174 | } 175 | if((tmp ==head) && (tmp->data ==d)) 176 | { 177 | found = true; 178 | tempnode = tmp; 179 | tmp = tmp->next; 180 | tmp->prev = NULL; 181 | head = tmp; 182 | tempnode->next = NULL; 183 | delete tempnode; 184 | break; 185 | } 186 | if((tmp == tail) && (tmp->data ==d)) 187 | { 188 | found = true; 189 | tempnode = tmp; 190 | prevnode->next = NULL; 191 | tmp->prev = NULL; 192 | tail = prevnode; 193 | delete tempnode; 194 | break; 195 | } 196 | if(tmp->data == d) 197 | { 198 | found = true; 199 | prevnode->next = tmp->next; 200 | tmp->next->prev = prevnode->next; 201 | tempnode = tmp; 202 | //tmp = tmp->next; 203 | delete tempnode; 204 | break; 205 | } 206 | prevnode = tmp; 207 | tmp = tmp->next; 208 | } 209 | if(found)size_of_list--; 210 | return found; 211 | } 212 | 213 | template 214 | bool Map::eraseall() 215 | { 216 | // Be careful while using this method 217 | // it not only removes the node but FREES(not delete) the allocated 218 | // memory. 219 | node *tempnode; 220 | tmp = head; 221 | while(head) 222 | { 223 | tempnode = head; 224 | head = head->next; 225 | tempnode->next = NULL; 226 | if(tempnode->data) 227 | free(tempnode->data); 228 | if(tempnode->data2) 229 | free(tempnode->data2); 230 | delete tempnode; 231 | } 232 | tail = head = NULL; 233 | return true; 234 | } 235 | 236 | 237 | template 238 | bool Map::isempty() 239 | { 240 | if(!size_of_list) return true; 241 | else return false; 242 | } 243 | 244 | #endif // _MAP_H_ 245 | -------------------------------------------------------------------------------- /mm-audio/aenc-evrc/qdsp6/inc/aenc_svr.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #ifndef AENC_SVR_H 29 | #define AENC_SVR_H 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | #include 35 | #include 36 | #include 37 | 38 | #ifdef _ANDROID_ 39 | #define LOG_TAG "QC_EVRCENC" 40 | #endif 41 | 42 | #ifndef LOGE 43 | #define LOGE ALOGE 44 | #endif 45 | 46 | #ifndef LOGW 47 | #define LOGW ALOGW 48 | #endif 49 | 50 | #ifndef LOGD 51 | #define LOGD ALOGD 52 | #endif 53 | 54 | #ifndef LOGV 55 | #define LOGV ALOGV 56 | #endif 57 | 58 | #ifndef LOGI 59 | #define LOGI ALOGI 60 | #endif 61 | 62 | #define DEBUG_PRINT_ERROR LOGE 63 | #define DEBUG_PRINT LOGI 64 | #define DEBUG_DETAIL LOGV 65 | 66 | typedef void (*message_func)(void* client_data, unsigned char id); 67 | 68 | /** 69 | @brief audio encoder ipc info structure 70 | 71 | */ 72 | struct evrc_ipc_info 73 | { 74 | pthread_t thr; 75 | int pipe_in; 76 | int pipe_out; 77 | int dead; 78 | message_func process_msg_cb; 79 | void *client_data; 80 | char thread_name[128]; 81 | }; 82 | 83 | /** 84 | @brief This function starts command server 85 | 86 | @param cb pointer to callback function from the client 87 | @param client_data reference client wants to get back 88 | through callback 89 | @return handle to command server 90 | */ 91 | struct evrc_ipc_info *omx_evrc_thread_create(message_func cb, 92 | void* client_data, 93 | char *th_name); 94 | 95 | struct evrc_ipc_info *omx_evrc_event_thread_create(message_func cb, 96 | void* client_data, 97 | char *th_name); 98 | /** 99 | @brief This function stop command server 100 | 101 | @param svr handle to command server 102 | @return none 103 | */ 104 | void omx_evrc_thread_stop(struct evrc_ipc_info *evrc_ipc); 105 | 106 | 107 | /** 108 | @brief This function post message in the command server 109 | 110 | @param svr handle to command server 111 | @return none 112 | */ 113 | void omx_evrc_post_msg(struct evrc_ipc_info *evrc_ipc, 114 | unsigned char id); 115 | 116 | void* omx_evrc_comp_timer_handler(void *); 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* AENC_SVR */ 123 | -------------------------------------------------------------------------------- /mm-audio/aenc-evrc/qdsp6/src/aenc_svr.c: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | /** 38 | @brief This function processes posted messages 39 | 40 | Once thread is being spawned, this function is run to 41 | start processing commands posted by client 42 | 43 | @param info pointer to context 44 | 45 | */ 46 | void *omx_evrc_msg(void *info) 47 | { 48 | struct evrc_ipc_info *evrc_info = (struct evrc_ipc_info*)info; 49 | unsigned char id; 50 | ssize_t n; 51 | 52 | DEBUG_DETAIL("\n%s: message thread start\n", __FUNCTION__); 53 | while (!evrc_info->dead) 54 | { 55 | n = read(evrc_info->pipe_in, &id, 1); 56 | if (0 == n) break; 57 | if (1 == n) 58 | { 59 | DEBUG_DETAIL("\n%s-->pipe_in=%d pipe_out=%d\n", 60 | evrc_info->thread_name, 61 | evrc_info->pipe_in, 62 | evrc_info->pipe_out); 63 | 64 | evrc_info->process_msg_cb(evrc_info->client_data, id); 65 | } 66 | if ((n < 0) && (errno != EINTR)) break; 67 | } 68 | DEBUG_DETAIL("%s: message thread stop\n", __FUNCTION__); 69 | 70 | return 0; 71 | } 72 | 73 | void *omx_evrc_events(void *info) 74 | { 75 | struct evrc_ipc_info *evrc_info = (struct evrc_ipc_info*)info; 76 | unsigned char id = 0; 77 | 78 | DEBUG_DETAIL("%s: message thread start\n", evrc_info->thread_name); 79 | evrc_info->process_msg_cb(evrc_info->client_data, id); 80 | DEBUG_DETAIL("%s: message thread stop\n", evrc_info->thread_name); 81 | return 0; 82 | } 83 | 84 | /** 85 | @brief This function starts command server 86 | 87 | @param cb pointer to callback function from the client 88 | @param client_data reference client wants to get back 89 | through callback 90 | @return handle to msging thread 91 | */ 92 | struct evrc_ipc_info *omx_evrc_thread_create( 93 | message_func cb, 94 | void* client_data, 95 | char* th_name) 96 | { 97 | int r; 98 | int fds[2]; 99 | struct evrc_ipc_info *evrc_info; 100 | 101 | evrc_info = calloc(1, sizeof(struct evrc_ipc_info)); 102 | if (!evrc_info) 103 | { 104 | return 0; 105 | } 106 | 107 | evrc_info->client_data = client_data; 108 | evrc_info->process_msg_cb = cb; 109 | strlcpy(evrc_info->thread_name, th_name, sizeof(evrc_info->thread_name)); 110 | 111 | if (pipe(fds)) 112 | { 113 | DEBUG_PRINT_ERROR("\n%s: pipe creation failed\n", __FUNCTION__); 114 | goto fail_pipe; 115 | } 116 | 117 | evrc_info->pipe_in = fds[0]; 118 | evrc_info->pipe_out = fds[1]; 119 | 120 | r = pthread_create(&evrc_info->thr, 0, omx_evrc_msg, evrc_info); 121 | if (r < 0) goto fail_thread; 122 | 123 | DEBUG_DETAIL("Created thread for %s \n", evrc_info->thread_name); 124 | return evrc_info; 125 | 126 | 127 | fail_thread: 128 | close(evrc_info->pipe_in); 129 | close(evrc_info->pipe_out); 130 | 131 | fail_pipe: 132 | free(evrc_info); 133 | 134 | return 0; 135 | } 136 | 137 | /** 138 | * @brief This function starts command server 139 | * 140 | * @param cb pointer to callback function from the client 141 | * @param client_data reference client wants to get back 142 | * through callback 143 | * @return handle to msging thread 144 | * */ 145 | struct evrc_ipc_info *omx_evrc_event_thread_create( 146 | message_func cb, 147 | void* client_data, 148 | char* th_name) 149 | { 150 | int r; 151 | int fds[2]; 152 | struct evrc_ipc_info *evrc_info; 153 | 154 | evrc_info = calloc(1, sizeof(struct evrc_ipc_info)); 155 | if (!evrc_info) 156 | { 157 | return 0; 158 | } 159 | 160 | evrc_info->client_data = client_data; 161 | evrc_info->process_msg_cb = cb; 162 | strlcpy(evrc_info->thread_name, th_name, sizeof(evrc_info->thread_name)); 163 | 164 | if (pipe(fds)) 165 | { 166 | DEBUG_PRINT("\n%s: pipe creation failed\n", __FUNCTION__); 167 | goto fail_pipe; 168 | } 169 | 170 | evrc_info->pipe_in = fds[0]; 171 | evrc_info->pipe_out = fds[1]; 172 | 173 | r = pthread_create(&evrc_info->thr, 0, omx_evrc_events, evrc_info); 174 | if (r < 0) goto fail_thread; 175 | 176 | DEBUG_DETAIL("Created thread for %s \n", evrc_info->thread_name); 177 | return evrc_info; 178 | 179 | 180 | fail_thread: 181 | close(evrc_info->pipe_in); 182 | close(evrc_info->pipe_out); 183 | 184 | fail_pipe: 185 | free(evrc_info); 186 | 187 | return 0; 188 | } 189 | 190 | void omx_evrc_thread_stop(struct evrc_ipc_info *evrc_info) { 191 | DEBUG_DETAIL("%s stop server\n", __FUNCTION__); 192 | close(evrc_info->pipe_in); 193 | close(evrc_info->pipe_out); 194 | pthread_join(evrc_info->thr,NULL); 195 | evrc_info->pipe_out = -1; 196 | evrc_info->pipe_in = -1; 197 | DEBUG_DETAIL("%s: message thread close fds%d %d\n", evrc_info->thread_name, 198 | evrc_info->pipe_in,evrc_info->pipe_out); 199 | free(evrc_info); 200 | } 201 | 202 | void omx_evrc_post_msg(struct evrc_ipc_info *evrc_info, unsigned char id) { 203 | DEBUG_DETAIL("\n%s id=%d\n", __FUNCTION__,id); 204 | write(evrc_info->pipe_out, &id, 1); 205 | } 206 | -------------------------------------------------------------------------------- /mm-audio/aenc-qcelp13/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(filter arm aarch64 arm64, $(TARGET_ARCH)),) 2 | 3 | AENC_QCELP13_PATH:= $(call my-dir) 4 | 5 | include $(AENC_QCELP13_PATH)/qdsp6/Android.mk 6 | 7 | endif 8 | -------------------------------------------------------------------------------- /mm-audio/aenc-qcelp13/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo "invoking omxaudio make" 3 | $(MAKE) -C qdsp6 4 | 5 | install: 6 | $(MAKE) -C qdsp6 install 7 | -------------------------------------------------------------------------------- /mm-audio/aenc-qcelp13/qdsp6/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(BUILD_TINY_ANDROID),true) 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | # --------------------------------------------------------------------------------- 7 | # Common definitons 8 | # --------------------------------------------------------------------------------- 9 | 10 | libOmxQcelp13Enc-def := -g -O3 11 | libOmxQcelp13Enc-def += -DQC_MODIFIED 12 | libOmxQcelp13Enc-def += -D_ANDROID_ 13 | libOmxQcelp13Enc-def += -D_ENABLE_QC_MSG_LOG_ 14 | libOmxQcelp13Enc-def += -DVERBOSE 15 | libOmxQcelp13Enc-def += -D_DEBUG 16 | libOmxQcelp13Enc-def += -Wconversion 17 | libOmxQcelp13Enc-def += -DAUDIOV2 18 | 19 | # --------------------------------------------------------------------------------- 20 | # Make the Shared library (libOmxQcelp13Enc) 21 | # --------------------------------------------------------------------------------- 22 | 23 | include $(CLEAR_VARS) 24 | 25 | libOmxQcelp13Enc-inc := $(LOCAL_PATH)/inc 26 | libOmxQcelp13Enc-inc += $(TARGET_OUT_HEADERS)/mm-core/omxcore 27 | 28 | LOCAL_MODULE := libOmxQcelp13Enc 29 | LOCAL_MODULE_TAGS := optional 30 | LOCAL_CFLAGS := $(libOmxQcelp13Enc-def) 31 | LOCAL_C_INCLUDES := $(libOmxQcelp13Enc-inc) 32 | LOCAL_PRELINK_MODULE := false 33 | LOCAL_SHARED_LIBRARIES := libutils liblog 34 | 35 | LOCAL_SRC_FILES := src/aenc_svr.c 36 | LOCAL_SRC_FILES += src/omx_qcelp13_aenc.cpp 37 | 38 | LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 39 | LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 40 | 41 | 42 | include $(BUILD_SHARED_LIBRARY) 43 | 44 | endif 45 | 46 | # --------------------------------------------------------------------------------- 47 | # END 48 | # --------------------------------------------------------------------------------- 49 | 50 | -------------------------------------------------------------------------------- /mm-audio/aenc-qcelp13/qdsp6/Makefile: -------------------------------------------------------------------------------- 1 | # --------------------------------------------------------------------------------- 2 | # MM-AUDIO-OSS-8K-AENC-QCELP13 3 | # --------------------------------------------------------------------------------- 4 | 5 | # cross-compiler flags 6 | CFLAGS += -Wall 7 | CFLAGS += -Wundef 8 | CFLAGS += -Wstrict-prototypes 9 | CFLAGS += -Wno-trigraphs 10 | 11 | # cross-compile flags specific to shared objects 12 | CFLAGS_SO += -fpic 13 | 14 | # required pre-processor flags 15 | CPPFLAGS := -D__packed__= 16 | CPPFLAGS += -DIMAGE_APPS_PROC 17 | CPPFLAGS += -DFEATURE_Q_SINGLE_LINK 18 | CPPFLAGS += -DFEATURE_Q_NO_SELF_QPTR 19 | CPPFLAGS += -DFEATURE_LINUX 20 | CPPFLAGS += -DFEATURE_NATIVELINUX 21 | CPPFLAGS += -DFEATURE_DSM_DUP_ITEMS 22 | 23 | CPPFLAGS += -g 24 | CPPFALGS += -D_DEBUG 25 | CPPFLAGS += -Iinc 26 | 27 | # linker flags 28 | LDFLAGS += -L$(SYSROOT)/usr/lib 29 | 30 | # linker flags for shared objects 31 | LDFLAGS_SO := -shared 32 | 33 | # defintions 34 | LIBMAJOR := $(basename $(basename $(LIBVER))) 35 | LIBINSTALLDIR := $(DESTDIR)usr/lib 36 | INCINSTALLDIR := $(DESTDIR)usr/include 37 | BININSTALLDIR := $(DESTDIR)usr/bin 38 | 39 | # --------------------------------------------------------------------------------- 40 | # BUILD 41 | # --------------------------------------------------------------------------------- 42 | all: libOmxQcelp13Enc.so.$(LIBVER) mm-aenc-omxqcelp13-test 43 | 44 | install: 45 | echo "intalling aenc-qcelp13 in $(DESTDIR)" 46 | if [ ! -d $(LIBINSTALLDIR) ]; then mkdir -p $(LIBINSTALLDIR); fi 47 | if [ ! -d $(INCINSTALLDIR) ]; then mkdir -p $(INCINSTALLDIR); fi 48 | if [ ! -d $(BININSTALLDIR) ]; then mkdir -p $(BININSTALLDIR); fi 49 | install -m 555 libOmxQcelp13Enc.so.$(LIBVER) $(LIBINSTALLDIR) 50 | cd $(LIBINSTALLDIR) && ln -s libOmxQcelp13Enc.so.$(LIBVER) libOmxQcelp13Enc.so.$(LIBMAJOR) 51 | cd $(LIBINSTALLDIR) && ln -s libOmxQcelp13Enc.so.$(LIBMAJOR) libOmxQcelp13Enc.so 52 | install -m 555 mm-aenc-omxqcelp13-test $(BININSTALLDIR) 53 | 54 | # --------------------------------------------------------------------------------- 55 | # COMPILE LIBRARY 56 | # --------------------------------------------------------------------------------- 57 | LDLIBS := -lpthread 58 | LDLIBS += -lstdc++ 59 | LDLIBS += -lOmxCore 60 | 61 | SRCS := src/omx_qcelp13_aenc.cpp 62 | SRCS += src/aenc_svr.c 63 | 64 | libOmxQcelp13Enc.so.$(LIBVER): $(SRCS) 65 | $(CC) $(CPPFLAGS) $(CFLAGS_SO) $(LDFLAGS_SO) -Wl,-soname,libOmxQcelp13Enc.so.$(LIBMAJOR) -o $@ $^ $(LDFLAGS) $(LDLIBS) 66 | 67 | # --------------------------------------------------------------------------------- 68 | # COMPILE TEST APP 69 | # --------------------------------------------------------------------------------- 70 | TEST_LDLIBS := -lpthread 71 | TEST_LDLIBS += -ldl 72 | TEST_LDLIBS += -lOmxCore 73 | 74 | TEST_SRCS := test/omx_qcelp13_enc_test.c 75 | 76 | mm-aenc-omxqcelp13-test: libOmxQcelp13Enc.so.$(LIBVER) $(TEST_SRCS) 77 | $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^ $(TEST_LDLIBS) 78 | 79 | # --------------------------------------------------------------------------------- 80 | # END 81 | # --------------------------------------------------------------------------------- 82 | -------------------------------------------------------------------------------- /mm-audio/aenc-qcelp13/qdsp6/inc/Map.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #ifndef _MAP_H_ 29 | #define _MAP_H_ 30 | 31 | #include 32 | using namespace std; 33 | 34 | template 35 | class Map 36 | { 37 | struct node 38 | { 39 | T data; 40 | T2 data2; 41 | node* prev; 42 | node* next; 43 | node(T t, T2 t2,node* p, node* n) : 44 | data(t), data2(t2), prev(p), next(n) {} 45 | }; 46 | node* head; 47 | node* tail; 48 | node* tmp; 49 | unsigned size_of_list; 50 | static Map *m_self; 51 | public: 52 | Map() : head( NULL ), tail ( NULL ),tmp(head),size_of_list(0) {} 53 | bool empty() const { return ( !head || !tail ); } 54 | operator bool() const { return !empty(); } 55 | void insert(T,T2); 56 | void show(); 57 | int size(); 58 | T2 find(T); // Return VALUE 59 | T find_ele(T);// Check if the KEY is present or not 60 | T2 begin(); //give the first ele 61 | bool erase(T); 62 | bool eraseall(); 63 | bool isempty(); 64 | ~Map() 65 | { 66 | while(head) 67 | { 68 | node* temp(head); 69 | head=head->next; 70 | size_of_list--; 71 | delete temp; 72 | } 73 | } 74 | }; 75 | 76 | template 77 | T2 Map::find(T d1) 78 | { 79 | tmp = head; 80 | while(tmp) 81 | { 82 | if(tmp->data == d1) 83 | { 84 | return tmp->data2; 85 | } 86 | tmp = tmp->next; 87 | } 88 | return 0; 89 | } 90 | 91 | template 92 | T Map::find_ele(T d1) 93 | { 94 | tmp = head; 95 | while(tmp) 96 | { 97 | if(tmp->data == d1) 98 | { 99 | return tmp->data; 100 | } 101 | tmp = tmp->next; 102 | } 103 | return 0; 104 | } 105 | 106 | template 107 | T2 Map::begin() 108 | { 109 | tmp = head; 110 | if(tmp) 111 | { 112 | return (tmp->data2); 113 | } 114 | return 0; 115 | } 116 | 117 | template 118 | void Map::show() 119 | { 120 | tmp = head; 121 | while(tmp) 122 | { 123 | printf("%d-->%d\n",tmp->data,tmp->data2); 124 | tmp = tmp->next; 125 | } 126 | } 127 | 128 | template 129 | int Map::size() 130 | { 131 | int count =0; 132 | tmp = head; 133 | while(tmp) 134 | { 135 | tmp = tmp->next; 136 | count++; 137 | } 138 | return count; 139 | } 140 | 141 | template 142 | void Map::insert(T data, T2 data2) 143 | { 144 | tail = new node(data, data2,tail, NULL); 145 | if( tail->prev ) 146 | tail->prev->next = tail; 147 | 148 | if( empty() ) 149 | { 150 | head = tail; 151 | tmp=head; 152 | } 153 | tmp = head; 154 | size_of_list++; 155 | } 156 | 157 | template 158 | bool Map::erase(T d) 159 | { 160 | bool found = false; 161 | tmp = head; 162 | node* prevnode = tmp; 163 | node *tempnode; 164 | 165 | while(tmp) 166 | { 167 | if((head == tail) && (head->data == d)) 168 | { 169 | found = true; 170 | tempnode = head; 171 | head = tail = NULL; 172 | delete tempnode; 173 | break; 174 | } 175 | if((tmp ==head) && (tmp->data ==d)) 176 | { 177 | found = true; 178 | tempnode = tmp; 179 | tmp = tmp->next; 180 | tmp->prev = NULL; 181 | head = tmp; 182 | tempnode->next = NULL; 183 | delete tempnode; 184 | break; 185 | } 186 | if((tmp == tail) && (tmp->data ==d)) 187 | { 188 | found = true; 189 | tempnode = tmp; 190 | prevnode->next = NULL; 191 | tmp->prev = NULL; 192 | tail = prevnode; 193 | delete tempnode; 194 | break; 195 | } 196 | if(tmp->data == d) 197 | { 198 | found = true; 199 | prevnode->next = tmp->next; 200 | tmp->next->prev = prevnode->next; 201 | tempnode = tmp; 202 | //tmp = tmp->next; 203 | delete tempnode; 204 | break; 205 | } 206 | prevnode = tmp; 207 | tmp = tmp->next; 208 | } 209 | if(found)size_of_list--; 210 | return found; 211 | } 212 | 213 | template 214 | bool Map::eraseall() 215 | { 216 | // Be careful while using this method 217 | // it not only removes the node but FREES(not delete) the allocated 218 | // memory. 219 | node *tempnode; 220 | tmp = head; 221 | while(head) 222 | { 223 | tempnode = head; 224 | head = head->next; 225 | tempnode->next = NULL; 226 | if(tempnode->data) 227 | free(tempnode->data); 228 | if(tempnode->data2) 229 | free(tempnode->data2); 230 | delete tempnode; 231 | } 232 | tail = head = NULL; 233 | return true; 234 | } 235 | 236 | 237 | template 238 | bool Map::isempty() 239 | { 240 | if(!size_of_list) return true; 241 | else return false; 242 | } 243 | 244 | #endif // _MAP_H_ 245 | -------------------------------------------------------------------------------- /mm-audio/aenc-qcelp13/qdsp6/inc/aenc_svr.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #ifndef AENC_SVR_H 29 | #define AENC_SVR_H 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | #include 35 | #include 36 | #include 37 | 38 | #ifdef _ANDROID_ 39 | #define LOG_TAG "QC_QCELP13ENC" 40 | #endif 41 | 42 | #ifndef LOGE 43 | #define LOGE ALOGE 44 | #endif 45 | 46 | #ifndef LOGW 47 | #define LOGW ALOGW 48 | #endif 49 | 50 | #ifndef LOGD 51 | #define LOGD ALOGD 52 | #endif 53 | 54 | #ifndef LOGV 55 | #define LOGV ALOGV 56 | #endif 57 | 58 | #ifndef LOGI 59 | #define LOGI ALOGI 60 | #endif 61 | 62 | #define DEBUG_PRINT_ERROR LOGE 63 | #define DEBUG_PRINT LOGI 64 | #define DEBUG_DETAIL LOGV 65 | 66 | typedef void (*message_func)(void* client_data, unsigned char id); 67 | 68 | /** 69 | @brief audio encoder ipc info structure 70 | 71 | */ 72 | struct qcelp13_ipc_info 73 | { 74 | pthread_t thr; 75 | int pipe_in; 76 | int pipe_out; 77 | int dead; 78 | message_func process_msg_cb; 79 | void *client_data; 80 | char thread_name[128]; 81 | }; 82 | 83 | /** 84 | @brief This function starts command server 85 | 86 | @param cb pointer to callback function from the client 87 | @param client_data reference client wants to get back 88 | through callback 89 | @return handle to command server 90 | */ 91 | struct qcelp13_ipc_info *omx_qcelp13_thread_create(message_func cb, 92 | void* client_data, 93 | char *th_name); 94 | 95 | struct qcelp13_ipc_info *omx_qcelp13_event_thread_create(message_func cb, 96 | void* client_data, 97 | char *th_name); 98 | /** 99 | @brief This function stop command server 100 | 101 | @param svr handle to command server 102 | @return none 103 | */ 104 | void omx_qcelp13_thread_stop(struct qcelp13_ipc_info *qcelp13_ipc); 105 | 106 | 107 | /** 108 | @brief This function post message in the command server 109 | 110 | @param svr handle to command server 111 | @return none 112 | */ 113 | void omx_qcelp13_post_msg(struct qcelp13_ipc_info *qcelp13_ipc, 114 | unsigned char id); 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif /* AENC_SVR */ 121 | -------------------------------------------------------------------------------- /mm-audio/aenc-qcelp13/qdsp6/src/aenc_svr.c: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------- 2 | Copyright (c) 2010, The Linux Foundation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of The Linux Foundation nor 12 | the names of its contributors may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------*/ 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | /** 38 | @brief This function processes posted messages 39 | 40 | Once thread is being spawned, this function is run to 41 | start processing commands posted by client 42 | 43 | @param info pointer to context 44 | 45 | */ 46 | void *omx_qcelp13_msg(void *info) 47 | { 48 | struct qcelp13_ipc_info *qcelp13_info = (struct qcelp13_ipc_info*)info; 49 | unsigned char id; 50 | ssize_t n; 51 | 52 | DEBUG_DETAIL("\n%s: message thread start\n", __FUNCTION__); 53 | while (!qcelp13_info->dead) 54 | { 55 | n = read(qcelp13_info->pipe_in, &id, 1); 56 | if (0 == n) break; 57 | if (1 == n) 58 | { 59 | DEBUG_DETAIL("\n%s-->pipe_in=%d pipe_out=%d\n", 60 | qcelp13_info->thread_name, 61 | qcelp13_info->pipe_in, 62 | qcelp13_info->pipe_out); 63 | 64 | qcelp13_info->process_msg_cb(qcelp13_info->client_data, id); 65 | } 66 | if ((n < 0) && (errno != EINTR)) break; 67 | } 68 | DEBUG_DETAIL("%s: message thread stop\n", __FUNCTION__); 69 | 70 | return 0; 71 | } 72 | 73 | void *omx_qcelp13_events(void *info) 74 | { 75 | struct qcelp13_ipc_info *qcelp13_info = (struct qcelp13_ipc_info*)info; 76 | unsigned char id = 0; 77 | 78 | DEBUG_DETAIL("%s: message thread start\n", qcelp13_info->thread_name); 79 | qcelp13_info->process_msg_cb(qcelp13_info->client_data, id); 80 | DEBUG_DETAIL("%s: message thread stop\n", qcelp13_info->thread_name); 81 | return 0; 82 | } 83 | 84 | /** 85 | @brief This function starts command server 86 | 87 | @param cb pointer to callback function from the client 88 | @param client_data reference client wants to get back 89 | through callback 90 | @return handle to msging thread 91 | */ 92 | struct qcelp13_ipc_info *omx_qcelp13_thread_create( 93 | message_func cb, 94 | void* client_data, 95 | char* th_name) 96 | { 97 | int r; 98 | int fds[2]; 99 | struct qcelp13_ipc_info *qcelp13_info; 100 | 101 | qcelp13_info = calloc(1, sizeof(struct qcelp13_ipc_info)); 102 | if (!qcelp13_info) 103 | { 104 | return 0; 105 | } 106 | 107 | qcelp13_info->client_data = client_data; 108 | qcelp13_info->process_msg_cb = cb; 109 | strlcpy(qcelp13_info->thread_name, th_name, 110 | sizeof(qcelp13_info->thread_name)); 111 | 112 | if (pipe(fds)) 113 | { 114 | DEBUG_PRINT_ERROR("\n%s: pipe creation failed\n", __FUNCTION__); 115 | goto fail_pipe; 116 | } 117 | 118 | qcelp13_info->pipe_in = fds[0]; 119 | qcelp13_info->pipe_out = fds[1]; 120 | 121 | r = pthread_create(&qcelp13_info->thr, 0, omx_qcelp13_msg, qcelp13_info); 122 | if (r < 0) goto fail_thread; 123 | 124 | DEBUG_DETAIL("Created thread for %s \n", qcelp13_info->thread_name); 125 | return qcelp13_info; 126 | 127 | 128 | fail_thread: 129 | close(qcelp13_info->pipe_in); 130 | close(qcelp13_info->pipe_out); 131 | 132 | fail_pipe: 133 | free(qcelp13_info); 134 | 135 | return 0; 136 | } 137 | 138 | /** 139 | * @brief This function starts command server 140 | * 141 | * @param cb pointer to callback function from the client 142 | * @param client_data reference client wants to get back 143 | * through callback 144 | * @return handle to msging thread 145 | * */ 146 | struct qcelp13_ipc_info *omx_qcelp13_event_thread_create( 147 | message_func cb, 148 | void* client_data, 149 | char* th_name) 150 | { 151 | int r; 152 | int fds[2]; 153 | struct qcelp13_ipc_info *qcelp13_info; 154 | 155 | qcelp13_info = calloc(1, sizeof(struct qcelp13_ipc_info)); 156 | if (!qcelp13_info) 157 | { 158 | return 0; 159 | } 160 | 161 | qcelp13_info->client_data = client_data; 162 | qcelp13_info->process_msg_cb = cb; 163 | strlcpy(qcelp13_info->thread_name, th_name, 164 | sizeof(qcelp13_info->thread_name)); 165 | 166 | if (pipe(fds)) 167 | { 168 | DEBUG_PRINT("\n%s: pipe creation failed\n", __FUNCTION__); 169 | goto fail_pipe; 170 | } 171 | 172 | qcelp13_info->pipe_in = fds[0]; 173 | qcelp13_info->pipe_out = fds[1]; 174 | 175 | r = pthread_create(&qcelp13_info->thr, 0, omx_qcelp13_events, qcelp13_info); 176 | if (r < 0) goto fail_thread; 177 | 178 | DEBUG_DETAIL("Created thread for %s \n", qcelp13_info->thread_name); 179 | return qcelp13_info; 180 | 181 | 182 | fail_thread: 183 | close(qcelp13_info->pipe_in); 184 | close(qcelp13_info->pipe_out); 185 | 186 | fail_pipe: 187 | free(qcelp13_info); 188 | 189 | return 0; 190 | } 191 | 192 | void omx_qcelp13_thread_stop(struct qcelp13_ipc_info *qcelp13_info) { 193 | DEBUG_DETAIL("%s stop server\n", __FUNCTION__); 194 | close(qcelp13_info->pipe_in); 195 | close(qcelp13_info->pipe_out); 196 | pthread_join(qcelp13_info->thr,NULL); 197 | qcelp13_info->pipe_out = -1; 198 | qcelp13_info->pipe_in = -1; 199 | DEBUG_DETAIL("%s: message thread close fds%d %d\n", qcelp13_info->thread_name, 200 | qcelp13_info->pipe_in,qcelp13_info->pipe_out); 201 | free(qcelp13_info); 202 | } 203 | 204 | void omx_qcelp13_post_msg(struct qcelp13_ipc_info *qcelp13_info, unsigned char id) { 205 | DEBUG_DETAIL("\n%s id=%d\n", __FUNCTION__,id); 206 | 207 | write(qcelp13_info->pipe_out, &id, 1); 208 | } 209 | -------------------------------------------------------------------------------- /mm-audio/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # autogen.sh -- Autotools bootstrapping 4 | 5 | libtoolize --copy --force 6 | aclocal &&\ 7 | autoheader &&\ 8 | autoconf &&\ 9 | automake --add-missing --copy 10 | 11 | -------------------------------------------------------------------------------- /mm-audio/configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | 3 | # configure.ac -- Autoconf script for mm-omxaudio 4 | # 5 | 6 | # Process this file with autoconf to produce a configure script. 7 | 8 | AC_PREREQ(2.61) 9 | AC_INIT([omxaudio], 10 | 1.0.0) 11 | AM_INIT_AUTOMAKE([-Wall -Werror gnu foreign]) 12 | AM_MAINTAINER_MODE 13 | AC_CONFIG_HEADER([config.h]) 14 | AC_CONFIG_MACRO_DIR([m4]) 15 | 16 | #release versioning 17 | OMXAUDIO_MAJOR_VERSION=1 18 | OMXAUDIO_MINOR_VERSION=0 19 | OMXAUDIO_MICRO_VERSION=0 20 | 21 | OMXAUDIO_LIBRARY_VERSION=$OMXAUDIO_MAJOR_VERSION:$OMXAUDIO_MINOR_VERSION:$OMXAUDIO_MICRO_VERSION 22 | AC_SUBST(OMXAUDIO_LIBRARY_VERSION) 23 | 24 | # Checks for programs. 25 | AC_PROG_CC 26 | AC_PROG_CPP 27 | AC_PROG_CXX 28 | AM_PROG_CC_C_O 29 | AC_PROG_LIBTOOL 30 | AC_PROG_AWK 31 | AC_PROG_INSTALL 32 | AC_PROG_LN_S 33 | AC_PROG_MAKE_SET 34 | 35 | AC_CONFIG_FILES([ \ 36 | Makefile \ 37 | adec-aac/Makefile \ 38 | adec-mp3/Makefile \ 39 | aenc-aac/Makefile \ 40 | adec-aac/qdsp6/Makefile \ 41 | adec-mp3/qdsp6/Makefile \ 42 | aenc-aac/qdsp6/Makefile \ 43 | ]) 44 | AC_OUTPUT 45 | -------------------------------------------------------------------------------- /policy_hal/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(USE_LEGACY_AUDIO_POLICY), 1) 2 | ifeq ($(USE_CUSTOM_AUDIO_POLICY), 1) 3 | LOCAL_PATH := $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES := AudioPolicyManager.cpp 7 | 8 | LOCAL_C_INCLUDES := $(TOPDIR)frameworks/av/services \ 9 | $(TOPDIR)frameworks/av/services/audioflinger \ 10 | $(call include-path-for, audio-effects) \ 11 | $(call include-path-for, audio-utils) \ 12 | $(TOPDIR)frameworks/av/services/audiopolicy/common/include \ 13 | $(TOPDIR)frameworks/av/services/audiopolicy/engine/interface \ 14 | $(TOPDIR)frameworks/av/services/audiopolicy \ 15 | $(TOPDIR)frameworks/av/services/audiopolicy/common/managerdefinitions/include \ 16 | $(call include-path-for, avextension) 17 | 18 | 19 | LOCAL_SHARED_LIBRARIES := \ 20 | libcutils \ 21 | libutils \ 22 | liblog \ 23 | libsoundtrigger \ 24 | libaudiopolicymanagerdefault \ 25 | libserviceutility 26 | 27 | LOCAL_STATIC_LIBRARIES := \ 28 | libmedia_helper \ 29 | 30 | LOCAL_CFLAGS += -Wall -Werror 31 | 32 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_VOICE_CONCURRENCY)),true) 33 | LOCAL_CFLAGS += -DVOICE_CONCURRENCY 34 | endif 35 | 36 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_RECORD_PLAY_CONCURRENCY)),true) 37 | LOCAL_CFLAGS += -DRECORD_PLAY_CONCURRENCY 38 | endif 39 | 40 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD)),true) 41 | LOCAL_CFLAGS += -DPCM_OFFLOAD_ENABLED 42 | endif 43 | 44 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD_24)),true) 45 | LOCAL_CFLAGS += -DPCM_OFFLOAD_ENABLED_24 46 | endif 47 | 48 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FORMATS)),true) 49 | LOCAL_CFLAGS += -DAUDIO_EXTN_FORMATS_ENABLED 50 | endif 51 | 52 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AAC_ADTS_OFFLOAD)),true) 53 | LOCAL_CFLAGS += -DAAC_ADTS_OFFLOAD_ENABLED 54 | endif 55 | 56 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_SPK)),true) 57 | LOCAL_CFLAGS += -DAUDIO_EXTN_HDMI_SPK_ENABLED 58 | endif 59 | 60 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PROXY_DEVICE)),true) 61 | LOCAL_CFLAGS += -DAUDIO_EXTN_AFE_PROXY_ENABLED 62 | endif 63 | 64 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FM_POWER_OPT)),true) 65 | LOCAL_CFLAGS += -DFM_POWER_OPT 66 | endif 67 | 68 | LOCAL_MODULE := libaudiopolicymanager 69 | 70 | include $(BUILD_SHARED_LIBRARY) 71 | 72 | endif 73 | endif 74 | -------------------------------------------------------------------------------- /policy_hal/AudioPolicyManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. 3 | * Not a contribution. 4 | * 5 | * Copyright (C) 2009 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | namespace android { 27 | #ifndef AUDIO_EXTN_FORMATS_ENABLED 28 | #define AUDIO_FORMAT_WMA 0x12000000UL 29 | #define AUDIO_FORMAT_WMA_PRO 0x13000000UL 30 | #define AUDIO_FORMAT_FLAC 0x1B000000UL 31 | #define AUDIO_FORMAT_ALAC 0x1C000000UL 32 | #define AUDIO_FORMAT_APE 0x1D000000UL 33 | #endif 34 | 35 | #ifndef AAC_ADTS_OFFLOAD_ENABLED 36 | #define AUDIO_FORMAT_AAC_ADTS 0x1E000000UL 37 | #endif 38 | 39 | #ifndef AUDIO_EXTN_AFE_PROXY_ENABLED 40 | #define AUDIO_DEVICE_OUT_PROXY 0x1000000 41 | #endif 42 | // ---------------------------------------------------------------------------- 43 | 44 | class AudioPolicyManagerCustom: public AudioPolicyManager 45 | { 46 | 47 | public: 48 | AudioPolicyManagerCustom(AudioPolicyClientInterface *clientInterface); 49 | 50 | virtual ~AudioPolicyManagerCustom() {} 51 | 52 | status_t setDeviceConnectionStateInt(audio_devices_t device, 53 | audio_policy_dev_state_t state, 54 | const char *device_address, 55 | const char *device_name); 56 | virtual void setPhoneState(audio_mode_t state); 57 | virtual void setForceUse(audio_policy_force_use_t usage, 58 | audio_policy_forced_cfg_t config); 59 | 60 | virtual bool isOffloadSupported(const audio_offload_info_t& offloadInfo); 61 | 62 | virtual status_t getInputForAttr(const audio_attributes_t *attr, 63 | audio_io_handle_t *input, 64 | audio_session_t session, 65 | uid_t uid, 66 | uint32_t samplingRate, 67 | audio_format_t format, 68 | audio_channel_mask_t channelMask, 69 | audio_input_flags_t flags, 70 | audio_port_handle_t selectedDeviceId, 71 | input_type_t *inputType); 72 | // indicates to the audio policy manager that the input starts being used. 73 | virtual status_t startInput(audio_io_handle_t input, 74 | audio_session_t session); 75 | // indicates to the audio policy manager that the input stops being used. 76 | virtual status_t stopInput(audio_io_handle_t input, 77 | audio_session_t session); 78 | 79 | virtual void closeAllInputs(); 80 | 81 | protected: 82 | 83 | status_t checkAndSetVolume(audio_stream_type_t stream, 84 | int index, 85 | const sp& outputDesc, 86 | audio_devices_t device, 87 | int delayMs = 0, bool force = false); 88 | 89 | // selects the most appropriate device on output for current state 90 | // must be called every time a condition that affects the device choice for a given output is 91 | // changed: connected device, phone state, force use, output start, output stop.. 92 | // see getDeviceForStrategy() for the use of fromCache parameter 93 | audio_devices_t getNewOutputDevice(const sp& outputDesc, 94 | bool fromCache); 95 | // returns true if given output is direct output 96 | bool isDirectOutput(audio_io_handle_t output); 97 | 98 | // if argument "device" is different from AUDIO_DEVICE_NONE, startSource() will force 99 | // the re-evaluation of the output device. 100 | status_t startSource(sp outputDesc, 101 | audio_stream_type_t stream, 102 | audio_devices_t device, 103 | uint32_t *delayMs); 104 | status_t stopSource(sp outputDesc, 105 | audio_stream_type_t stream, 106 | bool forceDeviceUpdate); 107 | // event is one of STARTING_OUTPUT, STARTING_BEACON, STOPPING_OUTPUT, STOPPING_BEACON 108 | // returns 0 if no mute/unmute event happened, the largest latency of the device where 109 | // the mute/unmute happened 110 | uint32_t handleEventForBeacon(int){return 0;} 111 | uint32_t setBeaconMute(bool){return 0;} 112 | #ifdef VOICE_CONCURRENCY 113 | static audio_output_flags_t getFallBackPath(); 114 | int mFallBackflag; 115 | #endif /*VOICE_CONCURRENCY*/ 116 | 117 | // handle special cases for sonification strategy while in call: mute streams or replace by 118 | // a special tone in the device used for communication 119 | void handleIncallSonification(audio_stream_type_t stream, bool starting, bool stateChange, audio_io_handle_t output); 120 | //parameter indicates of HDMI speakers disabled 121 | bool mHdmiAudioDisabled; 122 | //parameter indicates if HDMI plug in/out detected 123 | bool mHdmiAudioEvent; 124 | private: 125 | // updates device caching and output for streams that can influence the 126 | // routing of notifications 127 | void handleNotificationRoutingForStream(audio_stream_type_t stream); 128 | // internal method to return the output handle for the given device and format 129 | audio_io_handle_t getOutputForDevice( 130 | audio_devices_t device, 131 | audio_session_t session, 132 | audio_stream_type_t stream, 133 | uint32_t samplingRate, 134 | audio_format_t format, 135 | audio_channel_mask_t channelMask, 136 | audio_output_flags_t flags, 137 | const audio_offload_info_t *offloadInfo); 138 | // internal method to fill offload info in case of Direct PCM 139 | status_t getOutputForAttr(const audio_attributes_t *attr, 140 | audio_io_handle_t *output, 141 | audio_session_t session, 142 | audio_stream_type_t *stream, 143 | uid_t uid, 144 | uint32_t samplingRate, 145 | audio_format_t format, 146 | audio_channel_mask_t channelMask, 147 | audio_output_flags_t flags, 148 | audio_port_handle_t selectedDeviceId, 149 | const audio_offload_info_t *offloadInfo); 150 | // Used for voip + voice concurrency usecase 151 | int mPrevPhoneState; 152 | int mvoice_call_state; 153 | #ifdef RECORD_PLAY_CONCURRENCY 154 | // Used for record + playback concurrency 155 | bool mIsInputRequestOnProgress; 156 | #endif 157 | float mPrevFMVolumeDb; 158 | bool mFMIsActive; 159 | }; 160 | 161 | }; 162 | -------------------------------------------------------------------------------- /post_proc/Android.mk: -------------------------------------------------------------------------------- 1 | 2 | LOCAL_PATH:= $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | 6 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PROXY_DEVICE)),true) 7 | LOCAL_CFLAGS += -DAFE_PROXY_ENABLED 8 | endif 9 | 10 | LOCAL_SRC_FILES:= \ 11 | bundle.c \ 12 | equalizer.c \ 13 | bass_boost.c \ 14 | virtualizer.c \ 15 | reverb.c \ 16 | effect_api.c \ 17 | effect_util.c 18 | 19 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HW_ACCELERATED_EFFECTS)),true) 20 | LOCAL_CFLAGS += -DHW_ACCELERATED_EFFECTS 21 | LOCAL_SRC_FILES += hw_accelerator.c 22 | endif 23 | 24 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUDIOSPHERE)),true) 25 | LOCAL_CFLAGS += -DAUDIOSPHERE_ENABLED 26 | LOCAL_SRC_FILES += asphere.c 27 | endif 28 | 29 | LOCAL_CFLAGS+= -O2 -fvisibility=hidden 30 | 31 | ifneq ($(strip $(AUDIO_FEATURE_DISABLED_DTS_EAGLE)),true) 32 | LOCAL_CFLAGS += -DDTS_EAGLE 33 | endif 34 | 35 | LOCAL_SHARED_LIBRARIES := \ 36 | libcutils \ 37 | liblog \ 38 | libtinyalsa \ 39 | libdl 40 | 41 | LOCAL_MODULE_TAGS := optional 42 | 43 | LOCAL_MODULE_RELATIVE_PATH := soundfx 44 | LOCAL_MODULE:= libqcompostprocbundle 45 | 46 | LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 47 | 48 | LOCAL_C_INCLUDES := \ 49 | external/tinyalsa/include \ 50 | $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include \ 51 | $(call include-path-for, audio-effects) 52 | 53 | include $(BUILD_SHARED_LIBRARY) 54 | 55 | 56 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HW_ACCELERATED_EFFECTS)),true) 57 | include $(CLEAR_VARS) 58 | 59 | LOCAL_SRC_FILES := EffectsHwAcc.cpp 60 | 61 | LOCAL_C_INCLUDES := \ 62 | $(call include-path-for, audio-effects) 63 | 64 | LOCAL_SHARED_LIBRARIES := \ 65 | liblog \ 66 | libeffects 67 | 68 | LOCAL_MODULE_TAGS := optional 69 | 70 | LOCAL_CFLAGS += -O2 -fvisibility=hidden 71 | 72 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DTS_EAGLE)), true) 73 | LOCAL_CFLAGS += -DHW_ACC_HPX 74 | endif 75 | 76 | LOCAL_MODULE:= libhwacceffectswrapper 77 | 78 | include $(BUILD_STATIC_LIBRARY) 79 | endif 80 | 81 | 82 | ################################################################################ 83 | 84 | ifneq ($(filter msm8992 msm8994 msm8996 msm8952 msm8937 thorium,$(TARGET_BOARD_PLATFORM)),) 85 | 86 | include $(CLEAR_VARS) 87 | 88 | LOCAL_CFLAGS := -DLIB_AUDIO_HAL="/system/lib/hw/audio.primary."$(TARGET_BOARD_PLATFORM)".so" 89 | 90 | LOCAL_SRC_FILES:= \ 91 | volume_listener.c 92 | 93 | LOCAL_CFLAGS+= -O2 -fvisibility=hidden 94 | 95 | LOCAL_SHARED_LIBRARIES := \ 96 | libcutils \ 97 | liblog \ 98 | libdl 99 | 100 | LOCAL_MODULE_RELATIVE_PATH := soundfx 101 | LOCAL_MODULE:= libvolumelistener 102 | 103 | LOCAL_C_INCLUDES := \ 104 | $(call include-path-for, audio-effects) 105 | 106 | include $(BUILD_SHARED_LIBRARY) 107 | 108 | endif 109 | -------------------------------------------------------------------------------- /post_proc/EffectsHwAcc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-15, The Linux Foundation. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above 10 | * copyright notice, this list of conditions and the following 11 | * disclaimer in the documentation and/or other materials provided 12 | * with the distribution. 13 | * * Neither the name of The Linux Foundation nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * 18 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 28 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef ANDROID_EFFECTS_HW_ACC_H 32 | #define ANDROID_EFFECTS_HW_ACC_H 33 | 34 | #include 35 | 36 | namespace android { 37 | 38 | // ---------------------------------------------------------------------------- 39 | class EffectsHwAcc { 40 | public: 41 | EffectsHwAcc(uint32_t sampleRate); 42 | virtual ~EffectsHwAcc(); 43 | 44 | virtual void setSampleRate(uint32_t inpSR, uint32_t outSR); 45 | virtual void unprepareEffects(AudioBufferProvider **trackBufferProvider); 46 | virtual status_t prepareEffects(AudioBufferProvider **trackInputBufferProvider, 47 | AudioBufferProvider **trackBufferProvider, 48 | int sessionId, audio_channel_mask_t channelMask, 49 | int frameCount); 50 | virtual void setBufferProvider(AudioBufferProvider **trackInputbufferProvider, 51 | AudioBufferProvider **trackBufferProvider); 52 | #ifdef HW_ACC_HPX 53 | virtual void updateHPXState(uint32_t state); 54 | #endif 55 | 56 | /* AudioBufferProvider that wraps a track AudioBufferProvider by a call to 57 | h/w accelerated effect */ 58 | class EffectsBufferProvider : public AudioBufferProvider { 59 | public: 60 | EffectsBufferProvider(); 61 | virtual ~EffectsBufferProvider(); 62 | 63 | virtual status_t getNextBuffer(Buffer* buffer, int64_t pts); 64 | virtual void releaseBuffer(Buffer* buffer); 65 | 66 | AudioBufferProvider* mTrackInputBufferProvider; 67 | AudioBufferProvider* mTrackBufferProvider; 68 | effect_handle_t mEffectsHandle; 69 | effect_config_t mEffectsConfig; 70 | 71 | void *mInputBuffer; 72 | void *mOutputBuffer; 73 | uint32_t mInputBufferFrameCountOffset; 74 | }; 75 | 76 | bool mEnabled; 77 | int32_t mFd; 78 | 79 | EffectsBufferProvider* mBufferProvider; 80 | 81 | private: 82 | uint32_t mInputSampleRate; 83 | uint32_t mOutputSampleRate; 84 | }; 85 | 86 | 87 | // ---------------------------------------------------------------------------- 88 | }; // namespace android 89 | 90 | #endif // ANDROID_EFFECTS_HW_ACC_H 91 | -------------------------------------------------------------------------------- /post_proc/asphere.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef OFFLOAD_ASPHERE_H_ 31 | #define OFFLOAD_ASPHERE_H_ 32 | 33 | #include 34 | #include 35 | #include "bundle.h" 36 | 37 | #ifdef AUDIOSPHERE_ENABLED 38 | void asphere_get_parameters(struct str_parms *query, 39 | struct str_parms *reply); 40 | void asphere_set_parameters(struct str_parms *reply); 41 | void handle_asphere_on_effect_enabled(bool enable, 42 | effect_context_t *context, 43 | struct listnode *created_effects); 44 | #else 45 | #define asphere_get_parameters(query, reply) (0) 46 | #define asphere_set_parameters(parms) (0) 47 | #define handle_asphere_on_effect_enabled(enable, context, created_effects) (0) 48 | #endif /* AUDIOSPHERE_ENABLED */ 49 | 50 | #endif /* OFFLOAD_ASPHERE_H_ */ 51 | -------------------------------------------------------------------------------- /post_proc/bass_boost.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. 3 | * Not a Contribution. 4 | * 5 | * Copyright (C) 2013 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef OFFLOAD_EFFECT_BASS_BOOST_H_ 21 | #define OFFLOAD_EFFECT_BASS_BOOST_H_ 22 | 23 | #include "bundle.h" 24 | 25 | enum { 26 | BASS_INVALID = -1, 27 | BASS_BOOST = 0, // index of bassboost 28 | BASS_PBE, // index of PBE 29 | BASS_COUNT // totol number of bass type 30 | }; 31 | 32 | extern const effect_descriptor_t bassboost_descriptor; 33 | 34 | typedef struct bassboost_context_s { 35 | effect_context_t common; 36 | 37 | int strength; 38 | 39 | // Offload vars 40 | struct mixer_ctl *ctl; 41 | int hw_acc_fd; 42 | bool temp_disabled; 43 | uint32_t device; 44 | struct bass_boost_params offload_bass; 45 | } bassboost_context_t; 46 | 47 | typedef struct pbe_context_s { 48 | effect_context_t common; 49 | 50 | // Offload vars 51 | struct mixer_ctl *ctl; 52 | int hw_acc_fd; 53 | bool temp_disabled; 54 | uint32_t device; 55 | struct pbe_params offload_pbe; 56 | } pbe_context_t; 57 | 58 | typedef struct bass_context_s { 59 | effect_context_t common; 60 | bassboost_context_t bassboost_ctxt; 61 | pbe_context_t pbe_ctxt; 62 | int active_index; 63 | } bass_context_t; 64 | 65 | int bass_get_parameter(effect_context_t *context, effect_param_t *p, 66 | uint32_t *size); 67 | 68 | int bass_set_parameter(effect_context_t *context, effect_param_t *p, 69 | uint32_t size); 70 | 71 | int bass_set_device(effect_context_t *context, uint32_t device); 72 | 73 | int bass_set_mode(effect_context_t *context, int32_t hw_acc_fd); 74 | 75 | int bass_reset(effect_context_t *context); 76 | 77 | int bass_init(effect_context_t *context); 78 | 79 | int bass_enable(effect_context_t *context); 80 | 81 | int bass_disable(effect_context_t *context); 82 | 83 | int bass_start(effect_context_t *context, output_context_t *output); 84 | 85 | int bass_stop(effect_context_t *context, output_context_t *output); 86 | 87 | 88 | int bassboost_get_strength(bassboost_context_t *context); 89 | 90 | int bassboost_set_strength(bassboost_context_t *context, uint32_t strength); 91 | 92 | int bassboost_set_device(effect_context_t *context, uint32_t device); 93 | 94 | int bassboost_set_mode(effect_context_t *context, int32_t hw_acc_fd); 95 | 96 | int bassboost_reset(effect_context_t *context); 97 | 98 | int bassboost_init(effect_context_t *context); 99 | 100 | int bassboost_enable(effect_context_t *context); 101 | 102 | int bassboost_disable(effect_context_t *context); 103 | 104 | int bassboost_start(effect_context_t *context, output_context_t *output); 105 | 106 | int bassboost_stop(effect_context_t *context, output_context_t *output); 107 | 108 | int pbe_set_device(effect_context_t *context, uint32_t device); 109 | 110 | int pbe_set_mode(effect_context_t *context, int32_t hw_acc_fd); 111 | 112 | int pbe_reset(effect_context_t *context); 113 | 114 | int pbe_init(effect_context_t *context); 115 | 116 | int pbe_enable(effect_context_t *context); 117 | 118 | int pbe_disable(effect_context_t *context); 119 | 120 | int pbe_start(effect_context_t *context, output_context_t *output); 121 | 122 | int pbe_stop(effect_context_t *context, output_context_t *output); 123 | 124 | #endif /* OFFLOAD_EFFECT_BASS_BOOST_H_ */ 125 | -------------------------------------------------------------------------------- /post_proc/bundle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. 3 | * Not a contribution. 4 | * 5 | * Copyright (C) 2013 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef OFFLOAD_EFFECT_BUNDLE_H 21 | #define OFFLOAD_EFFECT_BUNDLE_H 22 | 23 | #include 24 | #include 25 | #include "effect_api.h" 26 | 27 | /* Retry for delay for mixer open */ 28 | #define RETRY_NUMBER 10 29 | #define RETRY_US 500000 30 | #ifdef HW_ACCELERATED_EFFECTS 31 | #define EFFECT_CMD_HW_ACC 20 32 | #endif 33 | #define MIXER_CARD 0 34 | #define SOUND_CARD 0 35 | 36 | extern const struct effect_interface_s effect_interface; 37 | 38 | typedef struct output_context_s output_context_t; 39 | typedef struct effect_ops_s effect_ops_t; 40 | typedef struct effect_context_s effect_context_t; 41 | 42 | struct output_context_s { 43 | /* node in active_outputs_list */ 44 | struct listnode outputs_list_node; 45 | /* io handle */ 46 | audio_io_handle_t handle; 47 | /* list of effects attached to this output */ 48 | struct listnode effects_list; 49 | /* pcm device id */ 50 | int pcm_device_id; 51 | struct mixer *mixer; 52 | struct mixer_ctl *ctl; 53 | struct mixer_ctl *ref_ctl; 54 | }; 55 | 56 | /* effect specific operations. 57 | * Only the init() and process() operations must be defined. 58 | * Others are optional. 59 | */ 60 | struct effect_ops_s { 61 | int (*init)(effect_context_t *context); 62 | int (*release)(effect_context_t *context); 63 | int (*reset)(effect_context_t *context); 64 | int (*enable)(effect_context_t *context); 65 | int (*start)(effect_context_t *context, output_context_t *output); 66 | int (*stop)(effect_context_t *context, output_context_t *output); 67 | int (*disable)(effect_context_t *context); 68 | int (*process)(effect_context_t *context, audio_buffer_t *in, audio_buffer_t *out); 69 | int (*set_parameter)(effect_context_t *context, effect_param_t *param, uint32_t size); 70 | int (*get_parameter)(effect_context_t *context, effect_param_t *param, uint32_t *size); 71 | int (*set_device)(effect_context_t *context, uint32_t device); 72 | int (*set_hw_acc_mode)(effect_context_t *context, int32_t value); 73 | int (*command)(effect_context_t *context, uint32_t cmdCode, uint32_t cmdSize, 74 | void *pCmdData, uint32_t *replySize, void *pReplyData); 75 | }; 76 | 77 | struct effect_context_s { 78 | const struct effect_interface_s *itfe; 79 | /* node in created_effects_list */ 80 | struct listnode effects_list_node; 81 | /* node in output_context_t.effects_list */ 82 | struct listnode output_node; 83 | effect_config_t config; 84 | const effect_descriptor_t *desc; 85 | /* io handle of the output the effect is attached to */ 86 | audio_io_handle_t out_handle; 87 | uint32_t state; 88 | bool offload_enabled; 89 | bool hw_acc_enabled; 90 | effect_ops_t ops; 91 | }; 92 | 93 | int set_config(effect_context_t *context, effect_config_t *config); 94 | 95 | bool effect_is_active(effect_context_t *context); 96 | 97 | #endif /* OFFLOAD_EFFECT_BUNDLE_H */ 98 | -------------------------------------------------------------------------------- /post_proc/effect_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) 2014 DTS, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include "effect_util.h" 21 | #include 22 | 23 | #ifdef LOG_TAG 24 | #undef LOG_TAG 25 | #endif 26 | #define LOG_TAG "effect_util" 27 | 28 | /*#define LOG_NDEBUG 0*/ 29 | 30 | enum { 31 | EQUALIZER, 32 | VIRTUALIZER, 33 | BASSBOOST, 34 | }; 35 | 36 | static const char *paramList[10] = { 37 | "eq_enable", 38 | "virt_enable", 39 | "bb_enable", 40 | "eq_param_level0", 41 | "eq_param_level1", 42 | "eq_param_level2", 43 | "eq_param_level3", 44 | "eq_param_level4", 45 | "virt_param_strength", 46 | "bassboost_param_strength" 47 | }; 48 | 49 | #define EFFECT_FILE "/data/misc/dts/effect" 50 | #define MAX_LENGTH_OF_INTEGER_IN_STRING 13 51 | 52 | #ifdef DTS_EAGLE 53 | void create_effect_state_node(int device_id) 54 | { 55 | char prop[PROPERTY_VALUE_MAX]; 56 | int fd; 57 | char buf[1024]; 58 | char path[PATH_MAX]; 59 | char value[MAX_LENGTH_OF_INTEGER_IN_STRING]; 60 | 61 | property_get("use.dts_eagle", prop, "0"); 62 | if (!strncmp("true", prop, sizeof("true")) || atoi(prop)) { 63 | ALOGV("create_effect_node for - device_id: %d", device_id); 64 | strlcpy(path, EFFECT_FILE, sizeof(path)); 65 | snprintf(value, sizeof(value), "%d", device_id); 66 | strlcat(path, value, sizeof(path)); 67 | if ((fd=open(path, O_RDONLY)) < 0) { 68 | ALOGV("No File exist"); 69 | } else { 70 | ALOGV("A file with the same name exist. So, not creating again"); 71 | return; 72 | } 73 | if ((fd=creat(path, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) { 74 | ALOGE("opening effect state node failed returned"); 75 | return; 76 | } 77 | chmod(path, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH); 78 | snprintf(buf, sizeof(buf), "eq_enable=%d;virt_enable=%d;bb_enable=%d;eq_param_level0=%d;eq_param_level1=%d;eq_param_level2=%d;eq_param_level3=%d;eq_param_level4=%d;virt_param_strength=%d;bassboost_param_strength=%d", 0,0,0,0,0,0,0,0,0,0); 79 | int n = write(fd, buf, strlen(buf)); 80 | ALOGV("number of bytes written: %d", n); 81 | close(fd); 82 | } 83 | } 84 | 85 | void update_effects_node(int device_id, int effect_type, int enable_or_set, int enable_disable, int strength, int eq_band, int eq_level) 86 | { 87 | char prop[PROPERTY_VALUE_MAX]; 88 | char buf[1024]; 89 | int fd = 0; 90 | int paramValue = 0; 91 | char path[PATH_MAX]; 92 | char value[MAX_LENGTH_OF_INTEGER_IN_STRING]; 93 | char parameterValue[MAX_LENGTH_OF_INTEGER_IN_STRING]; 94 | int keyParamIndex = -1; //index in the paramlist array which has to be updated 95 | char *s1, *s2; 96 | char resultBuf[1024]; 97 | int index1 = -1; 98 | //ALOGV("value of device_id and effect_type is %d and %d", device_id, effect_type); 99 | property_get("use.dts_eagle", prop, "0"); 100 | if (!strncmp("true", prop, sizeof("true")) || atoi(prop)) { 101 | strlcpy(path, EFFECT_FILE, sizeof(path)); 102 | snprintf(value, sizeof(value), "%d", device_id); 103 | strlcat(path, value, sizeof(path)); 104 | switch (effect_type) 105 | { 106 | case EQUALIZER: 107 | if (enable_or_set) { 108 | keyParamIndex = 0; 109 | paramValue = enable_disable; 110 | } else { 111 | switch (eq_band) { 112 | case 0: 113 | keyParamIndex = 3; 114 | break; 115 | case 1: 116 | keyParamIndex = 4; 117 | break; 118 | case 2: 119 | keyParamIndex = 5; 120 | break; 121 | case 3: 122 | keyParamIndex = 6; 123 | break; 124 | case 4: 125 | keyParamIndex = 7; 126 | break; 127 | default: 128 | break; 129 | } 130 | paramValue = eq_level; 131 | } 132 | break; 133 | case VIRTUALIZER: 134 | if(enable_or_set) { 135 | keyParamIndex = 1; 136 | paramValue = enable_disable; 137 | } else { 138 | keyParamIndex = 8; 139 | paramValue = strength; 140 | } 141 | break; 142 | case BASSBOOST: 143 | if (enable_or_set) { 144 | keyParamIndex = 2; 145 | paramValue = enable_disable; 146 | } else { 147 | keyParamIndex = 9; 148 | paramValue = strength; 149 | } 150 | break; 151 | default: 152 | break; 153 | } 154 | if(keyParamIndex !=-1) { 155 | FILE *fp; 156 | fp = fopen(path,"r"); 157 | if (fp != NULL) { 158 | memset(buf, 0, 1024); 159 | memset(resultBuf, 0, 1024); 160 | if (fgets(buf, 1024, fp) != NULL) { 161 | s1 = strstr(buf, paramList[keyParamIndex]); 162 | s2 = strstr(s1,";"); 163 | index1 = s1 - buf; 164 | strncpy(resultBuf, buf, index1); 165 | strncat(resultBuf, paramList[keyParamIndex], sizeof(resultBuf)-strlen(resultBuf)-1); 166 | strncat(resultBuf, "=", sizeof(resultBuf)-strlen(resultBuf)-1); 167 | snprintf(parameterValue, sizeof(parameterValue), "%d", paramValue); 168 | strncat(resultBuf, parameterValue, sizeof(resultBuf)-strlen(resultBuf)-1); 169 | if (s2) 170 | strncat(resultBuf, s2, sizeof(resultBuf)-strlen(resultBuf)-1); 171 | fclose(fp); 172 | if ((fd=open(path, O_TRUNC|O_WRONLY)) < 0) { 173 | ALOGV("opening file for writing failed"); 174 | return; 175 | } 176 | int n = write(fd, resultBuf, strlen(resultBuf)); 177 | close(fd); 178 | ALOGV("number of bytes written: %d", n); 179 | } else { 180 | ALOGV("file could not be read"); 181 | fclose(fp); 182 | } 183 | } else 184 | ALOGV("file could not be opened"); 185 | } 186 | } 187 | } 188 | 189 | void remove_effect_state_node(int device_id) 190 | { 191 | char prop[PROPERTY_VALUE_MAX]; 192 | int fd; 193 | char path[PATH_MAX]; 194 | char value[MAX_LENGTH_OF_INTEGER_IN_STRING]; 195 | 196 | property_get("use.dts_eagle", prop, "0"); 197 | if (!strncmp("true", prop, sizeof("true")) || atoi(prop)) { 198 | ALOGV("remove_state_notifier_node: device_id - %d", device_id); 199 | strlcpy(path, EFFECT_FILE, sizeof(path)); 200 | snprintf(value, sizeof(value), "%d", device_id); 201 | strlcat(path, value, sizeof(path)); 202 | if ((fd=open(path, O_RDONLY)) < 0) { 203 | ALOGV("open effect state node failed"); 204 | } else { 205 | ALOGV("open effect state node successful"); 206 | ALOGV("Remove the file"); 207 | close(fd); 208 | remove(path); 209 | } 210 | } 211 | } 212 | #endif 213 | -------------------------------------------------------------------------------- /post_proc/effect_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) 2014 DTS, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef EFFECT_UTIL_H_ 18 | #define EFFECT_UTIL_H_ 19 | 20 | #ifdef DTS_EAGLE 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | enum { 27 | EFFECT_TYPE_EQ = 0, 28 | EFFECT_TYPE_VIRT, 29 | EFFECT_TYPE_BB, 30 | }; 31 | 32 | enum { 33 | EFFECT_SET_PARAM = 0, 34 | EFFECT_ENABLE_PARAM, 35 | }; 36 | 37 | 38 | #define EFFECT_NO_OP 0 39 | #define PCM_DEV_ID 9 40 | 41 | void create_effect_state_node(int device_id); 42 | void update_effects_node(int device_id, int effect_type, int enable_or_set, int enable_disable, int strength, int band, int level); 43 | void remove_effect_state_node(int device_id); 44 | 45 | #endif /*DTS_EAGLE*/ 46 | 47 | #endif /*EFFECT_UTIL_H_*/ 48 | -------------------------------------------------------------------------------- /post_proc/equalizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. 3 | * Not a Contribution. 4 | * 5 | * Copyright (C) 2013 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef OFFLOAD_EQUALIZER_H_ 21 | #define OFFLOAD_EQUALIZER_H_ 22 | 23 | #include "bundle.h" 24 | 25 | #define NUM_EQ_BANDS 5 26 | #define INVALID_PRESET -2 27 | #define PRESET_CUSTOM -1 28 | 29 | extern const effect_descriptor_t equalizer_descriptor; 30 | 31 | typedef struct equalizer_context_s { 32 | effect_context_t common; 33 | 34 | int preset; 35 | int band_levels[NUM_EQ_BANDS]; 36 | 37 | // Offload vars 38 | struct mixer_ctl *ctl; 39 | int hw_acc_fd; 40 | uint32_t device; 41 | struct eq_params offload_eq; 42 | } equalizer_context_t; 43 | 44 | int equalizer_get_parameter(effect_context_t *context, effect_param_t *p, 45 | uint32_t *size); 46 | 47 | int equalizer_set_parameter(effect_context_t *context, effect_param_t *p, 48 | uint32_t size); 49 | 50 | int equalizer_set_device(effect_context_t *context, uint32_t device); 51 | 52 | int equalizer_set_mode(effect_context_t *context, int32_t hw_acc_fd); 53 | 54 | int equalizer_reset(effect_context_t *context); 55 | 56 | int equalizer_init(effect_context_t *context); 57 | 58 | int equalizer_enable(effect_context_t *context); 59 | 60 | int equalizer_disable(effect_context_t *context); 61 | 62 | int equalizer_start(effect_context_t *context, output_context_t *output); 63 | 64 | int equalizer_stop(effect_context_t *context, output_context_t *output); 65 | 66 | #endif /*OFFLOAD_EQUALIZER_H_*/ 67 | -------------------------------------------------------------------------------- /post_proc/hw_accelerator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, The Linux Foundation. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above 10 | * copyright notice, this list of conditions and the following 11 | * disclaimer in the documentation and/or other materials provided 12 | * with the distribution. 13 | * * Neither the name of The Linux Foundation nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * 18 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 28 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef HW_ACCELERATOR_EFFECT_H_ 32 | #define HW_ACCELERATOR_EFFECT_H_ 33 | 34 | #include "bundle.h" 35 | 36 | #include 37 | 38 | #define HWACCELERATOR_OUTPUT_CHANNELS AUDIO_CHANNEL_OUT_STEREO 39 | 40 | extern const effect_descriptor_t hw_accelerator_descriptor; 41 | 42 | typedef struct hw_accelerator_context_s { 43 | effect_context_t common; 44 | 45 | int fd; 46 | uint32_t device; 47 | bool intial_buffer_done; 48 | struct msm_hwacc_effects_config cfg; 49 | } hw_accelerator_context_t; 50 | 51 | int hw_accelerator_get_parameter(effect_context_t *context, 52 | effect_param_t *p, uint32_t *size); 53 | 54 | int hw_accelerator_set_parameter(effect_context_t *context, 55 | effect_param_t *p, uint32_t size); 56 | 57 | int hw_accelerator_set_device(effect_context_t *context, uint32_t device); 58 | 59 | int hw_accelerator_reset(effect_context_t *context); 60 | 61 | int hw_accelerator_init(effect_context_t *context); 62 | 63 | int hw_accelerator_enable(effect_context_t *context); 64 | 65 | int hw_accelerator_disable(effect_context_t *context); 66 | 67 | int hw_accelerator_release(effect_context_t *context); 68 | 69 | int hw_accelerator_set_mode(effect_context_t *context, int32_t frame_count); 70 | 71 | int hw_accelerator_process(effect_context_t *context, audio_buffer_t *in, 72 | audio_buffer_t *out); 73 | 74 | #endif /* HW_ACCELERATOR_EFFECT_H_ */ 75 | -------------------------------------------------------------------------------- /post_proc/reverb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. 3 | * Not a Contribution. 4 | * 5 | * Copyright (C) 2013 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef OFFLOAD_REVERB_H_ 21 | #define OFFLOAD_REVERB_H_ 22 | 23 | #include "bundle.h" 24 | 25 | #define REVERB_DEFAULT_PRESET REVERB_PRESET_NONE 26 | 27 | extern const effect_descriptor_t aux_env_reverb_descriptor; 28 | extern const effect_descriptor_t ins_env_reverb_descriptor; 29 | extern const effect_descriptor_t aux_preset_reverb_descriptor; 30 | extern const effect_descriptor_t ins_preset_reverb_descriptor; 31 | 32 | typedef struct reverb_settings_s { 33 | int16_t roomLevel; 34 | int16_t roomHFLevel; 35 | uint32_t decayTime; 36 | int16_t decayHFRatio; 37 | int16_t reflectionsLevel; 38 | uint32_t reflectionsDelay; 39 | int16_t reverbLevel; 40 | uint32_t reverbDelay; 41 | int16_t diffusion; 42 | int16_t density; 43 | } __attribute__((packed)) reverb_settings_t; 44 | 45 | typedef struct reverb_context_s { 46 | effect_context_t common; 47 | 48 | // Offload vars 49 | struct mixer_ctl *ctl; 50 | int hw_acc_fd; 51 | bool enabled_by_client; 52 | bool auxiliary; 53 | bool preset; 54 | uint16_t cur_preset; 55 | uint16_t next_preset; 56 | reverb_settings_t reverb_settings; 57 | uint32_t device; 58 | struct reverb_params offload_reverb; 59 | } reverb_context_t; 60 | 61 | 62 | void reverb_auxiliary_init(reverb_context_t *context); 63 | 64 | void reverb_preset_init(reverb_context_t *context); 65 | 66 | void reverb_insert_init(reverb_context_t *context); 67 | 68 | int reverb_get_parameter(effect_context_t *context, effect_param_t *p, 69 | uint32_t *size); 70 | 71 | int reverb_set_parameter(effect_context_t *context, effect_param_t *p, 72 | uint32_t size); 73 | 74 | int reverb_set_device(effect_context_t *context, uint32_t device); 75 | 76 | int reverb_set_mode(effect_context_t *context, int32_t hw_acc_fd); 77 | 78 | int reverb_reset(effect_context_t *context); 79 | 80 | int reverb_init(effect_context_t *context); 81 | 82 | int reverb_enable(effect_context_t *context); 83 | 84 | int reverb_disable(effect_context_t *context); 85 | 86 | int reverb_start(effect_context_t *context, output_context_t *output); 87 | 88 | int reverb_stop(effect_context_t *context, output_context_t *output); 89 | 90 | #endif /* OFFLOAD_REVERB_H_ */ 91 | -------------------------------------------------------------------------------- /post_proc/virtualizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. 3 | * Not a Contribution. 4 | * 5 | * Copyright (C) 2013 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef OFFLOAD_VIRTUALIZER_H_ 21 | #define OFFLOAD_VIRTUALIZER_H_ 22 | 23 | #include "bundle.h" 24 | 25 | extern const effect_descriptor_t virtualizer_descriptor; 26 | 27 | typedef struct virtualizer_context_s { 28 | effect_context_t common; 29 | 30 | int strength; 31 | 32 | // Offload vars 33 | struct mixer_ctl *ctl; 34 | int hw_acc_fd; 35 | bool enabled_by_client; 36 | bool temp_disabled; 37 | audio_devices_t forced_device; 38 | audio_devices_t device; 39 | struct virtualizer_params offload_virt; 40 | } virtualizer_context_t; 41 | 42 | int virtualizer_get_parameter(effect_context_t *context, effect_param_t *p, 43 | uint32_t *size); 44 | 45 | int virtualizer_set_parameter(effect_context_t *context, effect_param_t *p, 46 | uint32_t size); 47 | 48 | int virtualizer_set_device(effect_context_t *context, uint32_t device); 49 | 50 | int virtualizer_set_mode(effect_context_t *context, int32_t hw_acc_fd); 51 | 52 | int virtualizer_reset(effect_context_t *context); 53 | 54 | int virtualizer_init(effect_context_t *context); 55 | 56 | int virtualizer_enable(effect_context_t *context); 57 | 58 | int virtualizer_disable(effect_context_t *context); 59 | 60 | int virtualizer_start(effect_context_t *context, output_context_t *output); 61 | 62 | int virtualizer_stop(effect_context_t *context, output_context_t *output); 63 | 64 | #endif /* OFFLOAD_VIRTUALIZER_H_ */ 65 | -------------------------------------------------------------------------------- /visualizer/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | 19 | LOCAL_SRC_FILES:= \ 20 | offload_visualizer.c 21 | 22 | LOCAL_CFLAGS+= -O2 -fvisibility=hidden 23 | 24 | LOCAL_SHARED_LIBRARIES := \ 25 | libcutils \ 26 | liblog \ 27 | libdl \ 28 | libtinyalsa 29 | 30 | LOCAL_MODULE_RELATIVE_PATH := soundfx 31 | LOCAL_MODULE:= libqcomvisualizer 32 | 33 | LOCAL_C_INCLUDES := \ 34 | external/tinyalsa/include \ 35 | $(call include-path-for, audio-effects) 36 | 37 | include $(BUILD_SHARED_LIBRARY) 38 | -------------------------------------------------------------------------------- /visualizer/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OnePlusOSS/android_hardware_qcom_audio/cf149a1062f791e12bd8432f528749f164db826b/visualizer/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /voice_processing/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | # audio preprocessing wrapper 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_MODULE:= libqcomvoiceprocessing 7 | LOCAL_MODULE_TAGS := optional 8 | LOCAL_MODULE_RELATIVE_PATH := soundfx 9 | 10 | LOCAL_SRC_FILES:= \ 11 | voice_processing.c 12 | 13 | LOCAL_C_INCLUDES += \ 14 | $(call include-path-for, audio-effects) 15 | 16 | LOCAL_SHARED_LIBRARIES := \ 17 | libcutils 18 | 19 | LOCAL_SHARED_LIBRARIES += libdl 20 | 21 | LOCAL_CFLAGS += -fvisibility=hidden 22 | 23 | include $(BUILD_SHARED_LIBRARY) 24 | --------------------------------------------------------------------------------