Merge changes Ic355174a,I8b04ba9e,I3fefb13c am: dd67435bac
am: 29745f29b8
Change-Id: I31e6b092149c3fabe7715277a43e611f3f96648e
This commit is contained in:
commit
1e2b77935c
14 changed files with 67 additions and 5259 deletions
43
Android.bp
43
Android.bp
|
@ -1,10 +1,51 @@
|
|||
// Copyright 2006 The Android Open Source Project
|
||||
|
||||
subdirs = [
|
||||
"audio",
|
||||
]
|
||||
|
||||
cc_library_headers {
|
||||
name: "libhardware_legacy_headers",
|
||||
export_include_dirs: ["include"],
|
||||
|
||||
header_libs: ["libcutils_headers"],
|
||||
export_header_lib_headers: ["libcutils_headers"],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libpower",
|
||||
|
||||
srcs: ["power/power.c"],
|
||||
srcs: ["power.c"],
|
||||
export_include_dirs: ["include"],
|
||||
shared_libs: ["libcutils", "liblog"],
|
||||
vendor_available: true,
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
name: "libhardware_legacy",
|
||||
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libdl",
|
||||
"libcutils",
|
||||
"liblog",
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"libhardware_legacy_headers",
|
||||
],
|
||||
export_header_lib_headers: ["libhardware_legacy_headers"],
|
||||
|
||||
export_include_dirs: ["include"],
|
||||
|
||||
cflags: [
|
||||
"-DQEMU_HARDWARE",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-gnu-designator",
|
||||
],
|
||||
|
||||
srcs: [
|
||||
"power.c",
|
||||
"uevent.c",
|
||||
],
|
||||
}
|
||||
|
|
41
Android.mk
41
Android.mk
|
@ -1,41 +0,0 @@
|
|||
# Copyright 2006 The Android Open Source Project
|
||||
|
||||
# Setting LOCAL_PATH will mess up all-subdir-makefiles, so do it beforehand.
|
||||
legacy_modules := power uevent
|
||||
|
||||
SAVE_MAKEFILES := $(call all-named-subdir-makefiles,$(legacy_modules))
|
||||
LEGACY_AUDIO_MAKEFILES := $(call all-named-subdir-makefiles,audio)
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := libbase libcutils liblog libmedia
|
||||
LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libmedia
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
|
||||
|
||||
LOCAL_CFLAGS += -DQEMU_HARDWARE -Wno-unused-parameter -Wno-gnu-designator
|
||||
QEMU_HARDWARE := true
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += libdl
|
||||
|
||||
include $(SAVE_MAKEFILES)
|
||||
|
||||
# TODO: Remove this line b/29915755
|
||||
ifndef BRILLO
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := libwifi-hal-common
|
||||
endif
|
||||
|
||||
LOCAL_MODULE:= libhardware_legacy
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libhardware_legacy_headers
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
|
||||
include $(BUILD_HEADER_LIBRARY)
|
||||
|
||||
# legacy_audio builds it's own set of libraries that aren't linked into
|
||||
# hardware_legacy
|
||||
include $(LEGACY_AUDIO_MAKEFILES)
|
25
audio/Android.bp
Normal file
25
audio/Android.bp
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2011 The Android Open Source Project
|
||||
|
||||
//AUDIO_POLICY_TEST := true
|
||||
//ENABLE_AUDIO_DUMP := true
|
||||
|
||||
cc_library_static {
|
||||
|
||||
srcs: [
|
||||
"AudioHardwareInterface.cpp",
|
||||
"audio_hw_hal.cpp",
|
||||
],
|
||||
|
||||
name: "libaudiohw_legacy",
|
||||
static_libs: ["libmedia_helper"],
|
||||
cflags: [
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-gnu-designator",
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"libbase_headers",
|
||||
"libhardware_legacy_headers",
|
||||
],
|
||||
export_header_lib_headers: ["libhardware_legacy_headers"],
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
# Copyright 2011 The Android Open Source Project
|
||||
|
||||
#AUDIO_POLICY_TEST := true
|
||||
#ENABLE_AUDIO_DUMP := true
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
AudioHardwareInterface.cpp \
|
||||
audio_hw_hal.cpp
|
||||
|
||||
LOCAL_MODULE := libaudiohw_legacy
|
||||
LOCAL_SHARED_LIBRARIES := libmedia
|
||||
LOCAL_STATIC_LIBRARIES := libmedia_helper
|
||||
LOCAL_CFLAGS := -Wno-unused-parameter -Wno-gnu-designator
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
AudioPolicyManagerBase.cpp \
|
||||
AudioPolicyCompatClient.cpp \
|
||||
audio_policy_hal.cpp
|
||||
|
||||
ifeq ($(AUDIO_POLICY_TEST),true)
|
||||
LOCAL_CFLAGS += -DAUDIO_POLICY_TEST
|
||||
endif
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := libmedia
|
||||
LOCAL_STATIC_LIBRARIES := libmedia_helper
|
||||
LOCAL_MODULE := libaudiopolicy_legacy
|
||||
LOCAL_CFLAGS += -Wno-unused-parameter
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
# The default audio policy, for now still implemented on top of legacy
|
||||
# policy code
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
AudioPolicyManagerDefault.cpp
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libcutils \
|
||||
libmedia \
|
||||
libutils \
|
||||
liblog
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libmedia_helper
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := \
|
||||
libaudiopolicy_legacy
|
||||
|
||||
LOCAL_MODULE := audio_policy.default
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_CFLAGS := -Wno-unused-parameter
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "AudioPolicyCompatClient"
|
||||
//#define LOG_NDEBUG 0
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <system/audio.h>
|
||||
#include <system/audio_policy.h>
|
||||
#include <hardware/audio_policy.h>
|
||||
|
||||
#include <hardware_legacy/AudioSystemLegacy.h>
|
||||
|
||||
#include "AudioPolicyCompatClient.h"
|
||||
|
||||
namespace android_audio_legacy {
|
||||
|
||||
audio_module_handle_t AudioPolicyCompatClient::loadHwModule(const char *moduleName)
|
||||
{
|
||||
return mServiceOps->load_hw_module(mService, moduleName);
|
||||
}
|
||||
|
||||
audio_io_handle_t AudioPolicyCompatClient::openOutput(audio_module_handle_t module,
|
||||
audio_devices_t *pDevices,
|
||||
uint32_t *pSamplingRate,
|
||||
audio_format_t *pFormat,
|
||||
audio_channel_mask_t *pChannelMask,
|
||||
uint32_t *pLatencyMs,
|
||||
audio_output_flags_t flags,
|
||||
const audio_offload_info_t *offloadInfo)
|
||||
{
|
||||
return mServiceOps->open_output_on_module(mService, module, pDevices, pSamplingRate,
|
||||
pFormat, pChannelMask, pLatencyMs,
|
||||
flags, offloadInfo);
|
||||
}
|
||||
|
||||
audio_io_handle_t AudioPolicyCompatClient::openDuplicateOutput(audio_io_handle_t output1,
|
||||
audio_io_handle_t output2)
|
||||
{
|
||||
return mServiceOps->open_duplicate_output(mService, output1, output2);
|
||||
}
|
||||
|
||||
status_t AudioPolicyCompatClient::closeOutput(audio_io_handle_t output)
|
||||
{
|
||||
return mServiceOps->close_output(mService, output);
|
||||
}
|
||||
|
||||
status_t AudioPolicyCompatClient::suspendOutput(audio_io_handle_t output)
|
||||
{
|
||||
return mServiceOps->suspend_output(mService, output);
|
||||
}
|
||||
|
||||
status_t AudioPolicyCompatClient::restoreOutput(audio_io_handle_t output)
|
||||
{
|
||||
return mServiceOps->restore_output(mService, output);
|
||||
}
|
||||
|
||||
audio_io_handle_t AudioPolicyCompatClient::openInput(audio_module_handle_t module,
|
||||
audio_devices_t *pDevices,
|
||||
uint32_t *pSamplingRate,
|
||||
audio_format_t *pFormat,
|
||||
audio_channel_mask_t *pChannelMask)
|
||||
{
|
||||
return mServiceOps->open_input_on_module(mService, module, pDevices,
|
||||
pSamplingRate, pFormat, pChannelMask);
|
||||
}
|
||||
|
||||
status_t AudioPolicyCompatClient::closeInput(audio_io_handle_t input)
|
||||
{
|
||||
return mServiceOps->close_input(mService, input);
|
||||
}
|
||||
|
||||
status_t AudioPolicyCompatClient::invalidateStream(AudioSystem::stream_type stream)
|
||||
{
|
||||
return mServiceOps->invalidate_stream(mService, (audio_stream_type_t)stream);
|
||||
}
|
||||
|
||||
status_t AudioPolicyCompatClient::moveEffects(audio_session_t session, audio_io_handle_t srcOutput,
|
||||
audio_io_handle_t dstOutput)
|
||||
{
|
||||
return mServiceOps->move_effects(mService, session, srcOutput, dstOutput);
|
||||
}
|
||||
|
||||
String8 AudioPolicyCompatClient::getParameters(audio_io_handle_t ioHandle, const String8& keys)
|
||||
{
|
||||
char *str;
|
||||
String8 out_str8;
|
||||
|
||||
str = mServiceOps->get_parameters(mService, ioHandle, keys.string());
|
||||
out_str8 = String8(str);
|
||||
free(str);
|
||||
|
||||
return out_str8;
|
||||
}
|
||||
|
||||
void AudioPolicyCompatClient::setParameters(audio_io_handle_t ioHandle,
|
||||
const String8& keyValuePairs,
|
||||
int delayMs)
|
||||
{
|
||||
mServiceOps->set_parameters(mService, ioHandle, keyValuePairs.string(),
|
||||
delayMs);
|
||||
}
|
||||
|
||||
status_t AudioPolicyCompatClient::setStreamVolume(
|
||||
AudioSystem::stream_type stream,
|
||||
float volume,
|
||||
audio_io_handle_t output,
|
||||
int delayMs)
|
||||
{
|
||||
return mServiceOps->set_stream_volume(mService, (audio_stream_type_t)stream,
|
||||
volume, output, delayMs);
|
||||
}
|
||||
|
||||
status_t AudioPolicyCompatClient::startTone(ToneGenerator::tone_type tone,
|
||||
AudioSystem::stream_type stream)
|
||||
{
|
||||
return mServiceOps->start_tone(mService,
|
||||
AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION,
|
||||
(audio_stream_type_t)stream);
|
||||
}
|
||||
|
||||
status_t AudioPolicyCompatClient::stopTone()
|
||||
{
|
||||
return mServiceOps->stop_tone(mService);
|
||||
}
|
||||
|
||||
status_t AudioPolicyCompatClient::setVoiceVolume(float volume, int delayMs)
|
||||
{
|
||||
return mServiceOps->set_voice_volume(mService, volume, delayMs);
|
||||
}
|
||||
|
||||
}; // namespace android_audio_legacy
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_AUDIOPOLICYCLIENTLEGACY_H
|
||||
#define ANDROID_AUDIOPOLICYCLIENTLEGACY_H
|
||||
|
||||
#include <system/audio.h>
|
||||
#include <system/audio_policy.h>
|
||||
#include <hardware/audio_policy.h>
|
||||
|
||||
#include <hardware_legacy/AudioSystemLegacy.h>
|
||||
#include <hardware_legacy/AudioPolicyInterface.h>
|
||||
|
||||
/************************************/
|
||||
/* FOR BACKWARDS COMPATIBILITY ONLY */
|
||||
/************************************/
|
||||
namespace android_audio_legacy {
|
||||
|
||||
class AudioPolicyCompatClient : public AudioPolicyClientInterface {
|
||||
public:
|
||||
AudioPolicyCompatClient(struct audio_policy_service_ops *serviceOps,
|
||||
void *service) :
|
||||
mServiceOps(serviceOps) , mService(service) {}
|
||||
|
||||
virtual audio_module_handle_t loadHwModule(const char *moduleName);
|
||||
|
||||
virtual audio_io_handle_t openOutput(audio_module_handle_t module,
|
||||
audio_devices_t *pDevices,
|
||||
uint32_t *pSamplingRate,
|
||||
audio_format_t *pFormat,
|
||||
audio_channel_mask_t *pChannelMask,
|
||||
uint32_t *pLatencyMs,
|
||||
audio_output_flags_t flags,
|
||||
const audio_offload_info_t *offloadInfo);
|
||||
virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
|
||||
audio_io_handle_t output2);
|
||||
virtual status_t closeOutput(audio_io_handle_t output);
|
||||
virtual status_t suspendOutput(audio_io_handle_t output);
|
||||
virtual status_t restoreOutput(audio_io_handle_t output);
|
||||
virtual audio_io_handle_t openInput(audio_module_handle_t module,
|
||||
audio_devices_t *pDevices,
|
||||
uint32_t *pSamplingRate,
|
||||
audio_format_t *pFormat,
|
||||
audio_channel_mask_t *pChannelMask);
|
||||
virtual status_t closeInput(audio_io_handle_t input);
|
||||
virtual status_t invalidateStream(AudioSystem::stream_type stream);
|
||||
virtual status_t moveEffects(audio_session_t session,
|
||||
audio_io_handle_t srcOutput,
|
||||
audio_io_handle_t dstOutput);
|
||||
|
||||
virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys);
|
||||
virtual void setParameters(audio_io_handle_t ioHandle,
|
||||
const String8& keyValuePairs,
|
||||
int delayMs = 0);
|
||||
virtual status_t setStreamVolume(AudioSystem::stream_type stream,
|
||||
float volume,
|
||||
audio_io_handle_t output,
|
||||
int delayMs = 0);
|
||||
virtual status_t startTone(ToneGenerator::tone_type tone, AudioSystem::stream_type stream);
|
||||
virtual status_t stopTone();
|
||||
virtual status_t setVoiceVolume(float volume, int delayMs = 0);
|
||||
|
||||
private:
|
||||
struct audio_policy_service_ops* mServiceOps;
|
||||
void* mService;
|
||||
};
|
||||
|
||||
}; // namespace android_audio_legacy
|
||||
|
||||
#endif // ANDROID_AUDIOPOLICYCLIENTLEGACY_H
|
File diff suppressed because it is too large
Load diff
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "AudioPolicyManagerDefault"
|
||||
//#define LOG_NDEBUG 0
|
||||
|
||||
#include "AudioPolicyManagerDefault.h"
|
||||
|
||||
namespace android_audio_legacy {
|
||||
|
||||
extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface)
|
||||
{
|
||||
return new AudioPolicyManagerDefault(clientInterface);
|
||||
}
|
||||
|
||||
extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface)
|
||||
{
|
||||
delete interface;
|
||||
}
|
||||
|
||||
}; // namespace android
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <hardware_legacy/AudioPolicyManagerBase.h>
|
||||
|
||||
namespace android_audio_legacy {
|
||||
|
||||
class AudioPolicyManagerDefault: public AudioPolicyManagerBase
|
||||
{
|
||||
|
||||
public:
|
||||
explicit AudioPolicyManagerDefault(AudioPolicyClientInterface *clientInterface)
|
||||
: AudioPolicyManagerBase(clientInterface) {}
|
||||
|
||||
virtual ~AudioPolicyManagerDefault() {}
|
||||
|
||||
};
|
||||
};
|
|
@ -1,477 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "legacy_audio_policy_hal"
|
||||
//#define LOG_NDEBUG 0
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <system/audio.h>
|
||||
#include <system/audio_policy.h>
|
||||
#include <hardware/audio_policy.h>
|
||||
|
||||
#include <hardware_legacy/AudioPolicyInterface.h>
|
||||
#include <hardware_legacy/AudioSystemLegacy.h>
|
||||
|
||||
#include "AudioPolicyCompatClient.h"
|
||||
|
||||
namespace android_audio_legacy {
|
||||
|
||||
extern "C" {
|
||||
|
||||
struct legacy_ap_module {
|
||||
struct audio_policy_module module;
|
||||
};
|
||||
|
||||
struct legacy_ap_device {
|
||||
struct audio_policy_device device;
|
||||
};
|
||||
|
||||
struct legacy_audio_policy {
|
||||
struct audio_policy policy;
|
||||
|
||||
void *service;
|
||||
struct audio_policy_service_ops *aps_ops;
|
||||
AudioPolicyCompatClient *service_client;
|
||||
AudioPolicyInterface *apm;
|
||||
};
|
||||
|
||||
static inline struct legacy_audio_policy * to_lap(struct audio_policy *pol)
|
||||
{
|
||||
return reinterpret_cast<struct legacy_audio_policy *>(pol);
|
||||
}
|
||||
|
||||
static inline const struct legacy_audio_policy * to_clap(const struct audio_policy *pol)
|
||||
{
|
||||
return reinterpret_cast<const struct legacy_audio_policy *>(pol);
|
||||
}
|
||||
|
||||
|
||||
static int ap_set_device_connection_state(struct audio_policy *pol,
|
||||
audio_devices_t device,
|
||||
audio_policy_dev_state_t state,
|
||||
const char *device_address)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->setDeviceConnectionState(
|
||||
(AudioSystem::audio_devices)device,
|
||||
(AudioSystem::device_connection_state)state,
|
||||
device_address);
|
||||
}
|
||||
|
||||
static audio_policy_dev_state_t ap_get_device_connection_state(
|
||||
const struct audio_policy *pol,
|
||||
audio_devices_t device,
|
||||
const char *device_address)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return (audio_policy_dev_state_t)lap->apm->getDeviceConnectionState(
|
||||
(AudioSystem::audio_devices)device,
|
||||
device_address);
|
||||
}
|
||||
|
||||
static void ap_set_phone_state(struct audio_policy *pol, audio_mode_t state)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
// as this is the legacy API, don't change it to use audio_mode_t instead of int
|
||||
lap->apm->setPhoneState((int) state);
|
||||
}
|
||||
|
||||
/* indicate a change in ringer mode */
|
||||
static void ap_set_ringer_mode(struct audio_policy *pol, uint32_t mode,
|
||||
uint32_t mask)
|
||||
{
|
||||
// deprecated, never called
|
||||
}
|
||||
|
||||
/* force using a specific device category for the specified usage */
|
||||
static void ap_set_force_use(struct audio_policy *pol,
|
||||
audio_policy_force_use_t usage,
|
||||
audio_policy_forced_cfg_t config)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
lap->apm->setForceUse((AudioSystem::force_use)usage,
|
||||
(AudioSystem::forced_config)config);
|
||||
}
|
||||
|
||||
/* retreive current device category forced for a given usage */
|
||||
static audio_policy_forced_cfg_t ap_get_force_use(
|
||||
const struct audio_policy *pol,
|
||||
audio_policy_force_use_t usage)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return (audio_policy_forced_cfg_t)lap->apm->getForceUse(
|
||||
(AudioSystem::force_use)usage);
|
||||
}
|
||||
|
||||
/* if can_mute is true, then audio streams that are marked ENFORCED_AUDIBLE
|
||||
* can still be muted. */
|
||||
static void ap_set_can_mute_enforced_audible(struct audio_policy *pol,
|
||||
bool can_mute)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
lap->apm->setSystemProperty("ro.camera.sound.forced", can_mute ? "0" : "1");
|
||||
}
|
||||
|
||||
static int ap_init_check(const struct audio_policy *pol)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return lap->apm->initCheck();
|
||||
}
|
||||
|
||||
static audio_io_handle_t ap_get_output(struct audio_policy *pol,
|
||||
audio_stream_type_t stream,
|
||||
uint32_t sampling_rate,
|
||||
audio_format_t format,
|
||||
audio_channel_mask_t channelMask,
|
||||
audio_output_flags_t flags,
|
||||
const audio_offload_info_t *offloadInfo)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
|
||||
ALOGV("%s: tid %d", __func__, gettid());
|
||||
return lap->apm->getOutput((AudioSystem::stream_type)stream,
|
||||
sampling_rate, format, channelMask,
|
||||
(AudioSystem::output_flags)flags,
|
||||
offloadInfo);
|
||||
}
|
||||
|
||||
static int ap_start_output(struct audio_policy *pol, audio_io_handle_t output,
|
||||
audio_stream_type_t stream, audio_session_t session)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->startOutput(output, (AudioSystem::stream_type)stream,
|
||||
session);
|
||||
}
|
||||
|
||||
static int ap_stop_output(struct audio_policy *pol, audio_io_handle_t output,
|
||||
audio_stream_type_t stream, audio_session_t session)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->stopOutput(output, (AudioSystem::stream_type)stream,
|
||||
session);
|
||||
}
|
||||
|
||||
static void ap_release_output(struct audio_policy *pol,
|
||||
audio_io_handle_t output)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
lap->apm->releaseOutput(output);
|
||||
}
|
||||
|
||||
static audio_io_handle_t ap_get_input(struct audio_policy *pol, audio_source_t inputSource,
|
||||
uint32_t sampling_rate,
|
||||
audio_format_t format,
|
||||
audio_channel_mask_t channelMask,
|
||||
audio_in_acoustics_t acoustics)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->getInput((int) inputSource, sampling_rate, format, channelMask,
|
||||
(AudioSystem::audio_in_acoustics)acoustics);
|
||||
}
|
||||
|
||||
static int ap_start_input(struct audio_policy *pol, audio_io_handle_t input)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->startInput(input);
|
||||
}
|
||||
|
||||
static int ap_stop_input(struct audio_policy *pol, audio_io_handle_t input)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->stopInput(input);
|
||||
}
|
||||
|
||||
static void ap_release_input(struct audio_policy *pol, audio_io_handle_t input)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
lap->apm->releaseInput(input);
|
||||
}
|
||||
|
||||
static void ap_init_stream_volume(struct audio_policy *pol,
|
||||
audio_stream_type_t stream, int index_min,
|
||||
int index_max)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
lap->apm->initStreamVolume((AudioSystem::stream_type)stream, index_min,
|
||||
index_max);
|
||||
}
|
||||
|
||||
static int ap_set_stream_volume_index(struct audio_policy *pol,
|
||||
audio_stream_type_t stream,
|
||||
int index)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->setStreamVolumeIndex((AudioSystem::stream_type)stream,
|
||||
index,
|
||||
AUDIO_DEVICE_OUT_DEFAULT);
|
||||
}
|
||||
|
||||
static int ap_get_stream_volume_index(const struct audio_policy *pol,
|
||||
audio_stream_type_t stream,
|
||||
int *index)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return lap->apm->getStreamVolumeIndex((AudioSystem::stream_type)stream,
|
||||
index,
|
||||
AUDIO_DEVICE_OUT_DEFAULT);
|
||||
}
|
||||
|
||||
static int ap_set_stream_volume_index_for_device(struct audio_policy *pol,
|
||||
audio_stream_type_t stream,
|
||||
int index,
|
||||
audio_devices_t device)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->setStreamVolumeIndex((AudioSystem::stream_type)stream,
|
||||
index,
|
||||
device);
|
||||
}
|
||||
|
||||
static int ap_get_stream_volume_index_for_device(const struct audio_policy *pol,
|
||||
audio_stream_type_t stream,
|
||||
int *index,
|
||||
audio_devices_t device)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return lap->apm->getStreamVolumeIndex((AudioSystem::stream_type)stream,
|
||||
index,
|
||||
device);
|
||||
}
|
||||
|
||||
static uint32_t ap_get_strategy_for_stream(const struct audio_policy *pol,
|
||||
audio_stream_type_t stream)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return lap->apm->getStrategyForStream((AudioSystem::stream_type)stream);
|
||||
}
|
||||
|
||||
static audio_devices_t ap_get_devices_for_stream(const struct audio_policy *pol,
|
||||
audio_stream_type_t stream)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return lap->apm->getDevicesForStream((AudioSystem::stream_type)stream);
|
||||
}
|
||||
|
||||
static audio_io_handle_t ap_get_output_for_effect(struct audio_policy *pol,
|
||||
const struct effect_descriptor_s *desc)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->getOutputForEffect(desc);
|
||||
}
|
||||
|
||||
static int ap_register_effect(struct audio_policy *pol,
|
||||
const struct effect_descriptor_s *desc,
|
||||
audio_io_handle_t io,
|
||||
uint32_t strategy,
|
||||
audio_session_t session,
|
||||
int id)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->registerEffect(desc, io, strategy, session, id);
|
||||
}
|
||||
|
||||
static int ap_unregister_effect(struct audio_policy *pol, int id)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->unregisterEffect(id);
|
||||
}
|
||||
|
||||
static int ap_set_effect_enabled(struct audio_policy *pol, int id, bool enabled)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(pol);
|
||||
return lap->apm->setEffectEnabled(id, enabled);
|
||||
}
|
||||
|
||||
static bool ap_is_stream_active(const struct audio_policy *pol, audio_stream_type_t stream,
|
||||
uint32_t in_past_ms)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return lap->apm->isStreamActive((int) stream, in_past_ms);
|
||||
}
|
||||
|
||||
static bool ap_is_stream_active_remotely(const struct audio_policy *pol, audio_stream_type_t stream,
|
||||
uint32_t in_past_ms)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return lap->apm->isStreamActiveRemotely((int) stream, in_past_ms);
|
||||
}
|
||||
|
||||
static bool ap_is_source_active(const struct audio_policy *pol, audio_source_t source)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return lap->apm->isSourceActive(source);
|
||||
}
|
||||
|
||||
static int ap_dump(const struct audio_policy *pol, int fd)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return lap->apm->dump(fd);
|
||||
}
|
||||
|
||||
static bool ap_is_offload_supported(const struct audio_policy *pol,
|
||||
const audio_offload_info_t *info)
|
||||
{
|
||||
const struct legacy_audio_policy *lap = to_clap(pol);
|
||||
return lap->apm->isOffloadSupported(*info);
|
||||
}
|
||||
|
||||
static int create_legacy_ap(const struct audio_policy_device *device,
|
||||
struct audio_policy_service_ops *aps_ops,
|
||||
void *service,
|
||||
struct audio_policy **ap)
|
||||
{
|
||||
struct legacy_audio_policy *lap;
|
||||
int ret;
|
||||
|
||||
if (!service || !aps_ops)
|
||||
return -EINVAL;
|
||||
|
||||
lap = (struct legacy_audio_policy *)calloc(1, sizeof(*lap));
|
||||
if (!lap)
|
||||
return -ENOMEM;
|
||||
|
||||
lap->policy.set_device_connection_state = ap_set_device_connection_state;
|
||||
lap->policy.get_device_connection_state = ap_get_device_connection_state;
|
||||
lap->policy.set_phone_state = ap_set_phone_state;
|
||||
lap->policy.set_ringer_mode = ap_set_ringer_mode;
|
||||
lap->policy.set_force_use = ap_set_force_use;
|
||||
lap->policy.get_force_use = ap_get_force_use;
|
||||
lap->policy.set_can_mute_enforced_audible =
|
||||
ap_set_can_mute_enforced_audible;
|
||||
lap->policy.init_check = ap_init_check;
|
||||
lap->policy.get_output = ap_get_output;
|
||||
lap->policy.start_output = ap_start_output;
|
||||
lap->policy.stop_output = ap_stop_output;
|
||||
lap->policy.release_output = ap_release_output;
|
||||
lap->policy.get_input = ap_get_input;
|
||||
lap->policy.start_input = ap_start_input;
|
||||
lap->policy.stop_input = ap_stop_input;
|
||||
lap->policy.release_input = ap_release_input;
|
||||
lap->policy.init_stream_volume = ap_init_stream_volume;
|
||||
lap->policy.set_stream_volume_index = ap_set_stream_volume_index;
|
||||
lap->policy.get_stream_volume_index = ap_get_stream_volume_index;
|
||||
lap->policy.set_stream_volume_index_for_device = ap_set_stream_volume_index_for_device;
|
||||
lap->policy.get_stream_volume_index_for_device = ap_get_stream_volume_index_for_device;
|
||||
lap->policy.get_strategy_for_stream = ap_get_strategy_for_stream;
|
||||
lap->policy.get_devices_for_stream = ap_get_devices_for_stream;
|
||||
lap->policy.get_output_for_effect = ap_get_output_for_effect;
|
||||
lap->policy.register_effect = ap_register_effect;
|
||||
lap->policy.unregister_effect = ap_unregister_effect;
|
||||
lap->policy.set_effect_enabled = ap_set_effect_enabled;
|
||||
lap->policy.is_stream_active = ap_is_stream_active;
|
||||
lap->policy.is_stream_active_remotely = ap_is_stream_active_remotely;
|
||||
lap->policy.is_source_active = ap_is_source_active;
|
||||
lap->policy.dump = ap_dump;
|
||||
lap->policy.is_offload_supported = ap_is_offload_supported;
|
||||
|
||||
lap->service = service;
|
||||
lap->aps_ops = aps_ops;
|
||||
lap->service_client =
|
||||
new AudioPolicyCompatClient(aps_ops, service);
|
||||
if (!lap->service_client) {
|
||||
ret = -ENOMEM;
|
||||
goto err_new_compat_client;
|
||||
}
|
||||
|
||||
lap->apm = createAudioPolicyManager(lap->service_client);
|
||||
if (!lap->apm) {
|
||||
ret = -ENOMEM;
|
||||
goto err_create_apm;
|
||||
}
|
||||
|
||||
*ap = &lap->policy;
|
||||
return 0;
|
||||
|
||||
err_create_apm:
|
||||
delete lap->service_client;
|
||||
err_new_compat_client:
|
||||
free(lap);
|
||||
*ap = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int destroy_legacy_ap(const struct audio_policy_device *ap_dev,
|
||||
struct audio_policy *ap)
|
||||
{
|
||||
struct legacy_audio_policy *lap = to_lap(ap);
|
||||
|
||||
if (!lap)
|
||||
return 0;
|
||||
|
||||
if (lap->apm)
|
||||
destroyAudioPolicyManager(lap->apm);
|
||||
if (lap->service_client)
|
||||
delete lap->service_client;
|
||||
free(lap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int legacy_ap_dev_close(hw_device_t* device)
|
||||
{
|
||||
if (device)
|
||||
free(device);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int legacy_ap_dev_open(const hw_module_t* module, const char* name,
|
||||
hw_device_t** device)
|
||||
{
|
||||
struct legacy_ap_device *dev;
|
||||
|
||||
if (strcmp(name, AUDIO_POLICY_INTERFACE) != 0)
|
||||
return -EINVAL;
|
||||
|
||||
dev = (struct legacy_ap_device *)calloc(1, sizeof(*dev));
|
||||
if (!dev)
|
||||
return -ENOMEM;
|
||||
|
||||
dev->device.common.tag = HARDWARE_DEVICE_TAG;
|
||||
dev->device.common.version = 0;
|
||||
dev->device.common.module = const_cast<hw_module_t*>(module);
|
||||
dev->device.common.close = legacy_ap_dev_close;
|
||||
dev->device.create_audio_policy = create_legacy_ap;
|
||||
dev->device.destroy_audio_policy = destroy_legacy_ap;
|
||||
|
||||
*device = &dev->device.common;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct hw_module_methods_t legacy_ap_module_methods = {
|
||||
.open = legacy_ap_dev_open
|
||||
};
|
||||
|
||||
struct legacy_ap_module HAL_MODULE_INFO_SYM = {
|
||||
.module = {
|
||||
.common = {
|
||||
.tag = HARDWARE_MODULE_TAG,
|
||||
.version_major = 1,
|
||||
.version_minor = 0,
|
||||
.id = AUDIO_POLICY_HARDWARE_MODULE_ID,
|
||||
.name = "LEGACY Audio Policy HAL",
|
||||
.author = "The Android Open Source Project",
|
||||
.methods = &legacy_ap_module_methods,
|
||||
.dso = NULL,
|
||||
.reserved = {0},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
}; // extern "C"
|
||||
|
||||
}; // namespace android_audio_legacy
|
|
@ -1,3 +0,0 @@
|
|||
# Copyright 2006 The Android Open Source Project
|
||||
|
||||
LOCAL_SRC_FILES += power/power.c
|
|
@ -1,3 +0,0 @@
|
|||
# Copyright 2008 The Android Open Source Project
|
||||
|
||||
LOCAL_SRC_FILES += uevent/uevent.c
|
Loading…
Reference in a new issue