mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Merge pi-dev-plus-aosp-without-vendor into stage-aosp-master
Bug: 79597307 Change-Id: Ifa37597ef6090bfbf1b41307a60cf65cfa1f563d
This commit is contained in:
@@ -60,6 +60,9 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/hw/android.hardware.auto
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/hw/android.hardware.automotive*)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/hw/android.hardware.automotive*)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/android.hardware.automotive*)
|
||||
$(call add-clean-step, find $(PRODUCT_OUT)/system $(PRODUCT_OUT)/vendor -type f -name "android\.hardware\.configstore\@1\.1*" -print0 | xargs -0 rm -f)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/android.hardware.tests*)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/vndk/android.hardware.tests*)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/vndk-sp/android.hardware.graphics.allocator*)
|
||||
$(call add-clean-step, find $(PRODUCT_OUT)/system $(PRODUCT_OUT)/vendor -type f -name "android\.hardware\.configstore\@1\.1*" -print0 | xargs -0 rm -f)
|
||||
$(call add-clean-step, find $(PRODUCT_OUT)/system $(PRODUCT_OUT)/vendor -type f -name "android\.hardware\.configstore*" -print0 | xargs -0 rm -f)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/seccomp_policy/configstore@1.0.policy)
|
||||
|
||||
@@ -49,10 +49,6 @@
|
||||
<xs:selector xpath="modules/module"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:key>
|
||||
<xs:key name="devicePortNameGlobalKey">
|
||||
<xs:selector xpath="modules/module/devicePorts/devicePort"/>
|
||||
<xs:field xpath="@tagName"/>
|
||||
</xs:key>
|
||||
<xs:unique name="volumeTargetUniqueness">
|
||||
<xs:selector xpath="volumes/volume"/>
|
||||
<xs:field xpath="@stream"/>
|
||||
@@ -73,14 +69,28 @@
|
||||
<!-- Enum values of IDevicesFactory::Device
|
||||
TODO: generate from hidl to avoid manual sync. -->
|
||||
<xs:simpleType name="halName">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="primary"/>
|
||||
<xs:enumeration value="a2dp"/>
|
||||
<xs:enumeration value="usb"/>
|
||||
<xs:enumeration value="r_submix"/>
|
||||
<xs:enumeration value="codec_offload"/>
|
||||
<xs:enumeration value="stub"/>
|
||||
</xs:restriction>
|
||||
<xs:union>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="primary"/>
|
||||
<xs:enumeration value="a2dp"/>
|
||||
<xs:enumeration value="usb"/>
|
||||
<xs:enumeration value="r_submix"/>
|
||||
<xs:enumeration value="codec_offload"/>
|
||||
<xs:enumeration value="stub"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType>
|
||||
<!-- Vendor eXtension names must be in the vx namespace.
|
||||
Vendor are encouraged to namespace their module names.
|
||||
Example for an hypothetical Google virtual reality HAL:
|
||||
<module name="vx_google_vr" halVersion="3.0">
|
||||
-->
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="vx_[_a-zA-Z0-9]+"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:union>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="modules">
|
||||
<xs:annotation>
|
||||
@@ -127,13 +137,15 @@
|
||||
<xs:selector xpath="mixPorts/mixPort"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:unique>
|
||||
<!-- Although this key constraint is redundant with devicePortNameGlobalKey,
|
||||
the set is used to constraint defaultOutputDevice and attachedDevice
|
||||
to reference a devicePort of the same module. -->
|
||||
<xs:key name="devicePortNameKey">
|
||||
<xs:selector xpath="devicePorts/devicePort"/>
|
||||
<xs:field xpath="@tagName"/>
|
||||
</xs:key>
|
||||
<xs:unique name="devicePortUniqueness">
|
||||
<xs:selector xpath="devicePorts/devicePort"/>
|
||||
<xs:field xpath="@type"/>
|
||||
<xs:field xpath="@address"/>
|
||||
</xs:unique>
|
||||
<xs:keyref name="defaultOutputDeviceRef" refer="devicePortNameKey">
|
||||
<xs:selector xpath="defaultOutputDevice"/>
|
||||
<xs:field xpath="."/>
|
||||
@@ -405,7 +417,7 @@
|
||||
<xs:attribute name="tagName" type="xs:token" use="required"/>
|
||||
<xs:attribute name="type" type="audioDevice" use="required"/>
|
||||
<xs:attribute name="role" type="role" use="required"/>
|
||||
<xs:attribute name="address" type="xs:string" use="optional"/>
|
||||
<xs:attribute name="address" type="xs:string" use="optional" default=""/>
|
||||
</xs:complexType>
|
||||
<xs:unique name="devicePortProfileUniqueness">
|
||||
<xs:selector xpath="profile"/>
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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 <stdio.h>
|
||||
|
||||
#include "Conversions.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
std::string deviceAddressToHal(const DeviceAddress& address) {
|
||||
// HAL assumes that the address is NUL-terminated.
|
||||
char halAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
|
||||
memset(halAddress, 0, sizeof(halAddress));
|
||||
uint32_t halDevice = static_cast<uint32_t>(address.device);
|
||||
const bool isInput = (halDevice & AUDIO_DEVICE_BIT_IN) != 0;
|
||||
if (isInput) halDevice &= ~AUDIO_DEVICE_BIT_IN;
|
||||
if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_ALL_A2DP) != 0)
|
||||
|| (isInput && (halDevice & AUDIO_DEVICE_IN_BLUETOOTH_A2DP) != 0)) {
|
||||
snprintf(halAddress, sizeof(halAddress),
|
||||
"%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
address.address.mac[0], address.address.mac[1], address.address.mac[2],
|
||||
address.address.mac[3], address.address.mac[4], address.address.mac[5]);
|
||||
} else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_IP) != 0)
|
||||
|| (isInput && (halDevice & AUDIO_DEVICE_IN_IP) != 0)) {
|
||||
snprintf(halAddress, sizeof(halAddress),
|
||||
"%d.%d.%d.%d",
|
||||
address.address.ipv4[0], address.address.ipv4[1],
|
||||
address.address.ipv4[2], address.address.ipv4[3]);
|
||||
} else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_ALL_USB) != 0)
|
||||
|| (isInput && (halDevice & AUDIO_DEVICE_IN_ALL_USB) != 0)) {
|
||||
snprintf(halAddress, sizeof(halAddress),
|
||||
"card=%d;device=%d",
|
||||
address.address.alsa.card, address.address.alsa.device);
|
||||
} else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_BUS) != 0)
|
||||
|| (isInput && (halDevice & AUDIO_DEVICE_IN_BUS) != 0)) {
|
||||
snprintf(halAddress, sizeof(halAddress),
|
||||
"%s", address.busAddress.c_str());
|
||||
} else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_REMOTE_SUBMIX)) != 0
|
||||
|| (isInput && (halDevice & AUDIO_DEVICE_IN_REMOTE_SUBMIX) != 0)) {
|
||||
snprintf(halAddress, sizeof(halAddress),
|
||||
"%s", address.rSubmixAddress.c_str());
|
||||
}
|
||||
return halAddress;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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_HARDWARE_AUDIO_V2_0_DEVICE_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <media/AudioParameter.h>
|
||||
#include <hardware/audio.h>
|
||||
|
||||
#include <android/hardware/audio/2.0/IDevice.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include <hidl/MQDescriptor.h>
|
||||
|
||||
#include "ParametersUtil.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::common::V2_0::AudioConfig;
|
||||
using ::android::hardware::audio::common::V2_0::AudioHwSync;
|
||||
using ::android::hardware::audio::common::V2_0::AudioInputFlag;
|
||||
using ::android::hardware::audio::common::V2_0::AudioOutputFlag;
|
||||
using ::android::hardware::audio::common::V2_0::AudioPatchHandle;
|
||||
using ::android::hardware::audio::common::V2_0::AudioPort;
|
||||
using ::android::hardware::audio::common::V2_0::AudioPortConfig;
|
||||
using ::android::hardware::audio::common::V2_0::AudioSource;
|
||||
using ::android::hardware::audio::V2_0::DeviceAddress;
|
||||
using ::android::hardware::audio::V2_0::IDevice;
|
||||
using ::android::hardware::audio::V2_0::IStreamIn;
|
||||
using ::android::hardware::audio::V2_0::IStreamOut;
|
||||
using ::android::hardware::audio::V2_0::ParameterValue;
|
||||
using ::android::hardware::audio::V2_0::Result;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
|
||||
struct Device : public IDevice, public ParametersUtil {
|
||||
explicit Device(audio_hw_device_t* device);
|
||||
|
||||
// Methods from ::android::hardware::audio::V2_0::IDevice follow.
|
||||
Return<Result> initCheck() override;
|
||||
Return<Result> setMasterVolume(float volume) override;
|
||||
Return<void> getMasterVolume(getMasterVolume_cb _hidl_cb) override;
|
||||
Return<Result> setMicMute(bool mute) override;
|
||||
Return<void> getMicMute(getMicMute_cb _hidl_cb) override;
|
||||
Return<Result> setMasterMute(bool mute) override;
|
||||
Return<void> getMasterMute(getMasterMute_cb _hidl_cb) override;
|
||||
Return<void> getInputBufferSize(
|
||||
const AudioConfig& config, getInputBufferSize_cb _hidl_cb) override;
|
||||
Return<void> openOutputStream(
|
||||
int32_t ioHandle,
|
||||
const DeviceAddress& device,
|
||||
const AudioConfig& config,
|
||||
AudioOutputFlag flags,
|
||||
openOutputStream_cb _hidl_cb) override;
|
||||
Return<void> openInputStream(
|
||||
int32_t ioHandle,
|
||||
const DeviceAddress& device,
|
||||
const AudioConfig& config,
|
||||
AudioInputFlag flags,
|
||||
AudioSource source,
|
||||
openInputStream_cb _hidl_cb) override;
|
||||
Return<bool> supportsAudioPatches() override;
|
||||
Return<void> createAudioPatch(
|
||||
const hidl_vec<AudioPortConfig>& sources,
|
||||
const hidl_vec<AudioPortConfig>& sinks,
|
||||
createAudioPatch_cb _hidl_cb) override;
|
||||
Return<Result> releaseAudioPatch(int32_t patch) override;
|
||||
Return<void> getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb) override;
|
||||
Return<Result> setAudioPortConfig(const AudioPortConfig& config) override;
|
||||
Return<AudioHwSync> getHwAvSync() override;
|
||||
Return<Result> setScreenState(bool turnedOn) override;
|
||||
Return<void> getParameters(
|
||||
const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override;
|
||||
Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
|
||||
Return<void> debugDump(const hidl_handle& fd) override;
|
||||
|
||||
// Utility methods for extending interfaces.
|
||||
Result analyzeStatus(const char* funcName, int status);
|
||||
void closeInputStream(audio_stream_in_t* stream);
|
||||
void closeOutputStream(audio_stream_out_t* stream);
|
||||
audio_hw_device_t* device() const { return mDevice; }
|
||||
|
||||
private:
|
||||
audio_hw_device_t *mDevice;
|
||||
|
||||
virtual ~Device();
|
||||
|
||||
// Methods from ParametersUtil.
|
||||
char* halGetParameters(const char* keys) override;
|
||||
int halSetParameters(const char* keysAndValues) override;
|
||||
|
||||
uint32_t version() const { return mDevice->common.version; }
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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 "DevicesFactoryHAL"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include "Device.h"
|
||||
#include "DevicesFactory.h"
|
||||
#include "PrimaryDevice.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
// static
|
||||
const char* DevicesFactory::deviceToString(IDevicesFactory::Device device) {
|
||||
switch (device) {
|
||||
case IDevicesFactory::Device::PRIMARY: return AUDIO_HARDWARE_MODULE_ID_PRIMARY;
|
||||
case IDevicesFactory::Device::A2DP: return AUDIO_HARDWARE_MODULE_ID_A2DP;
|
||||
case IDevicesFactory::Device::USB: return AUDIO_HARDWARE_MODULE_ID_USB;
|
||||
case IDevicesFactory::Device::R_SUBMIX: return AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX;
|
||||
case IDevicesFactory::Device::STUB: return AUDIO_HARDWARE_MODULE_ID_STUB;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
int DevicesFactory::loadAudioInterface(const char *if_name, audio_hw_device_t **dev)
|
||||
{
|
||||
const hw_module_t *mod;
|
||||
int rc;
|
||||
|
||||
rc = hw_get_module_by_class(AUDIO_HARDWARE_MODULE_ID, if_name, &mod);
|
||||
if (rc) {
|
||||
ALOGE("%s couldn't load audio hw module %s.%s (%s)", __func__,
|
||||
AUDIO_HARDWARE_MODULE_ID, if_name, strerror(-rc));
|
||||
goto out;
|
||||
}
|
||||
rc = audio_hw_device_open(mod, dev);
|
||||
if (rc) {
|
||||
ALOGE("%s couldn't open audio hw device in %s.%s (%s)", __func__,
|
||||
AUDIO_HARDWARE_MODULE_ID, if_name, strerror(-rc));
|
||||
goto out;
|
||||
}
|
||||
if ((*dev)->common.version < AUDIO_DEVICE_API_VERSION_MIN) {
|
||||
ALOGE("%s wrong audio hw device version %04x", __func__, (*dev)->common.version);
|
||||
rc = -EINVAL;
|
||||
audio_hw_device_close(*dev);
|
||||
goto out;
|
||||
}
|
||||
return OK;
|
||||
|
||||
out:
|
||||
*dev = NULL;
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::audio::V2_0::IDevicesFactory follow.
|
||||
Return<void> DevicesFactory::openDevice(IDevicesFactory::Device device, openDevice_cb _hidl_cb) {
|
||||
audio_hw_device_t *halDevice;
|
||||
Result retval(Result::INVALID_ARGUMENTS);
|
||||
sp<IDevice> result;
|
||||
const char* moduleName = deviceToString(device);
|
||||
if (moduleName != nullptr) {
|
||||
int halStatus = loadAudioInterface(moduleName, &halDevice);
|
||||
if (halStatus == OK) {
|
||||
if (device == IDevicesFactory::Device::PRIMARY) {
|
||||
result = new PrimaryDevice(halDevice);
|
||||
} else {
|
||||
result = new ::android::hardware::audio::V2_0::implementation::
|
||||
Device(halDevice);
|
||||
}
|
||||
retval = Result::OK;
|
||||
} else if (halStatus == -EINVAL) {
|
||||
retval = Result::NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
_hidl_cb(retval, result);
|
||||
return Void();
|
||||
}
|
||||
|
||||
IDevicesFactory* HIDL_FETCH_IDevicesFactory(const char* /* name */) {
|
||||
return new DevicesFactory();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H
|
||||
|
||||
#include <android/hardware/audio/2.0/IPrimaryDevice.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include <hidl/MQDescriptor.h>
|
||||
|
||||
#include "Device.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::common::V2_0::AudioConfig;
|
||||
using ::android::hardware::audio::common::V2_0::AudioInputFlag;
|
||||
using ::android::hardware::audio::common::V2_0::AudioMode;
|
||||
using ::android::hardware::audio::common::V2_0::AudioOutputFlag;
|
||||
using ::android::hardware::audio::common::V2_0::AudioPort;
|
||||
using ::android::hardware::audio::common::V2_0::AudioPortConfig;
|
||||
using ::android::hardware::audio::common::V2_0::AudioSource;
|
||||
using ::android::hardware::audio::V2_0::DeviceAddress;
|
||||
using ::android::hardware::audio::V2_0::IDevice;
|
||||
using ::android::hardware::audio::V2_0::IPrimaryDevice;
|
||||
using ::android::hardware::audio::V2_0::IStreamIn;
|
||||
using ::android::hardware::audio::V2_0::IStreamOut;
|
||||
using ::android::hardware::audio::V2_0::ParameterValue;
|
||||
using ::android::hardware::audio::V2_0::Result;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
|
||||
struct PrimaryDevice : public IPrimaryDevice {
|
||||
explicit PrimaryDevice(audio_hw_device_t* device);
|
||||
|
||||
// Methods from ::android::hardware::audio::V2_0::IDevice follow.
|
||||
Return<Result> initCheck() override;
|
||||
Return<Result> setMasterVolume(float volume) override;
|
||||
Return<void> getMasterVolume(getMasterVolume_cb _hidl_cb) override;
|
||||
Return<Result> setMicMute(bool mute) override;
|
||||
Return<void> getMicMute(getMicMute_cb _hidl_cb) override;
|
||||
Return<Result> setMasterMute(bool mute) override;
|
||||
Return<void> getMasterMute(getMasterMute_cb _hidl_cb) override;
|
||||
Return<void> getInputBufferSize(
|
||||
const AudioConfig& config, getInputBufferSize_cb _hidl_cb) override;
|
||||
Return<void> openOutputStream(
|
||||
int32_t ioHandle,
|
||||
const DeviceAddress& device,
|
||||
const AudioConfig& config,
|
||||
AudioOutputFlag flags,
|
||||
openOutputStream_cb _hidl_cb) override;
|
||||
Return<void> openInputStream(
|
||||
int32_t ioHandle,
|
||||
const DeviceAddress& device,
|
||||
const AudioConfig& config,
|
||||
AudioInputFlag flags,
|
||||
AudioSource source,
|
||||
openInputStream_cb _hidl_cb) override;
|
||||
Return<bool> supportsAudioPatches() override;
|
||||
Return<void> createAudioPatch(
|
||||
const hidl_vec<AudioPortConfig>& sources,
|
||||
const hidl_vec<AudioPortConfig>& sinks,
|
||||
createAudioPatch_cb _hidl_cb) override;
|
||||
Return<Result> releaseAudioPatch(int32_t patch) override;
|
||||
Return<void> getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb) override;
|
||||
Return<Result> setAudioPortConfig(const AudioPortConfig& config) override;
|
||||
Return<AudioHwSync> getHwAvSync() override;
|
||||
Return<Result> setScreenState(bool turnedOn) override;
|
||||
Return<void> getParameters(
|
||||
const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override;
|
||||
Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
|
||||
Return<void> debugDump(const hidl_handle& fd) override;
|
||||
|
||||
// Methods from ::android::hardware::audio::V2_0::IPrimaryDevice follow.
|
||||
Return<Result> setVoiceVolume(float volume) override;
|
||||
Return<Result> setMode(AudioMode mode) override;
|
||||
Return<void> getBtScoNrecEnabled(getBtScoNrecEnabled_cb _hidl_cb) override;
|
||||
Return<Result> setBtScoNrecEnabled(bool enabled) override;
|
||||
Return<void> getBtScoWidebandEnabled(getBtScoWidebandEnabled_cb _hidl_cb) override;
|
||||
Return<Result> setBtScoWidebandEnabled(bool enabled) override;
|
||||
Return<void> getTtyMode(getTtyMode_cb _hidl_cb) override;
|
||||
Return<Result> setTtyMode(IPrimaryDevice::TtyMode mode) override;
|
||||
Return<void> getHacEnabled(getHacEnabled_cb _hidl_cb) override;
|
||||
Return<Result> setHacEnabled(bool enabled) override;
|
||||
|
||||
private:
|
||||
sp<Device> mDevice;
|
||||
|
||||
virtual ~PrimaryDevice();
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H
|
||||
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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_HARDWARE_AUDIO_V2_0_STREAMIN_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_STREAMIN_H
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
#include <android/hardware/audio/2.0/IStreamIn.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <fmq/EventFlag.h>
|
||||
#include <fmq/MessageQueue.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <utils/Thread.h>
|
||||
|
||||
#include "Device.h"
|
||||
#include "Stream.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::common::V2_0::AudioChannelMask;
|
||||
using ::android::hardware::audio::common::V2_0::AudioDevice;
|
||||
using ::android::hardware::audio::common::V2_0::AudioFormat;
|
||||
using ::android::hardware::audio::common::V2_0::AudioSource;
|
||||
using ::android::hardware::audio::V2_0::DeviceAddress;
|
||||
using ::android::hardware::audio::V2_0::IStream;
|
||||
using ::android::hardware::audio::V2_0::IStreamIn;
|
||||
using ::android::hardware::audio::V2_0::ParameterValue;
|
||||
using ::android::hardware::audio::V2_0::Result;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
|
||||
struct StreamIn : public IStreamIn {
|
||||
typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ;
|
||||
typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ;
|
||||
typedef MessageQueue<ReadStatus, kSynchronizedReadWrite> StatusMQ;
|
||||
|
||||
StreamIn(const sp<Device>& device, audio_stream_in_t* stream);
|
||||
|
||||
// Methods from ::android::hardware::audio::V2_0::IStream follow.
|
||||
Return<uint64_t> getFrameSize() override;
|
||||
Return<uint64_t> getFrameCount() override;
|
||||
Return<uint64_t> getBufferSize() override;
|
||||
Return<uint32_t> getSampleRate() override;
|
||||
Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
|
||||
Return<Result> setSampleRate(uint32_t sampleRateHz) override;
|
||||
Return<AudioChannelMask> getChannelMask() override;
|
||||
Return<void> getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override;
|
||||
Return<Result> setChannelMask(AudioChannelMask mask) override;
|
||||
Return<AudioFormat> getFormat() override;
|
||||
Return<void> getSupportedFormats(getSupportedFormats_cb _hidl_cb) override;
|
||||
Return<Result> setFormat(AudioFormat format) override;
|
||||
Return<void> getAudioProperties(getAudioProperties_cb _hidl_cb) override;
|
||||
Return<Result> addEffect(uint64_t effectId) override;
|
||||
Return<Result> removeEffect(uint64_t effectId) override;
|
||||
Return<Result> standby() override;
|
||||
Return<AudioDevice> getDevice() override;
|
||||
Return<Result> setDevice(const DeviceAddress& address) override;
|
||||
Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override;
|
||||
Return<Result> setHwAvSync(uint32_t hwAvSync) override;
|
||||
Return<void> getParameters(
|
||||
const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override;
|
||||
Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
|
||||
Return<void> debugDump(const hidl_handle& fd) override;
|
||||
Return<Result> close() override;
|
||||
|
||||
// Methods from ::android::hardware::audio::V2_0::IStreamIn follow.
|
||||
Return<void> getAudioSource(getAudioSource_cb _hidl_cb) override;
|
||||
Return<Result> setGain(float gain) override;
|
||||
Return<void> prepareForReading(
|
||||
uint32_t frameSize, uint32_t framesCount, prepareForReading_cb _hidl_cb) override;
|
||||
Return<uint32_t> getInputFramesLost() override;
|
||||
Return<void> getCapturePosition(getCapturePosition_cb _hidl_cb) override;
|
||||
Return<Result> start() override;
|
||||
Return<Result> stop() override;
|
||||
Return<void> createMmapBuffer(int32_t minSizeFrames, createMmapBuffer_cb _hidl_cb) override;
|
||||
Return<void> getMmapPosition(getMmapPosition_cb _hidl_cb) override;
|
||||
|
||||
static Result getCapturePositionImpl(
|
||||
audio_stream_in_t *stream, uint64_t *frames, uint64_t *time);
|
||||
|
||||
private:
|
||||
bool mIsClosed;
|
||||
const sp<Device> mDevice;
|
||||
audio_stream_in_t *mStream;
|
||||
const sp<Stream> mStreamCommon;
|
||||
const sp<StreamMmap<audio_stream_in_t>> mStreamMmap;
|
||||
std::unique_ptr<CommandMQ> mCommandMQ;
|
||||
std::unique_ptr<DataMQ> mDataMQ;
|
||||
std::unique_ptr<StatusMQ> mStatusMQ;
|
||||
EventFlag* mEfGroup;
|
||||
std::atomic<bool> mStopReadThread;
|
||||
sp<Thread> mReadThread;
|
||||
|
||||
virtual ~StreamIn();
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_STREAMIN_H
|
||||
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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_HARDWARE_AUDIO_V2_0_STREAMOUT_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_STREAMOUT_H
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
#include <android/hardware/audio/2.0/IStreamOut.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <fmq/EventFlag.h>
|
||||
#include <fmq/MessageQueue.h>
|
||||
#include <utils/Thread.h>
|
||||
|
||||
#include "Device.h"
|
||||
#include "Stream.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::common::V2_0::AudioChannelMask;
|
||||
using ::android::hardware::audio::common::V2_0::AudioDevice;
|
||||
using ::android::hardware::audio::common::V2_0::AudioFormat;
|
||||
using ::android::hardware::audio::V2_0::AudioDrain;
|
||||
using ::android::hardware::audio::V2_0::DeviceAddress;
|
||||
using ::android::hardware::audio::V2_0::IStream;
|
||||
using ::android::hardware::audio::V2_0::IStreamOut;
|
||||
using ::android::hardware::audio::V2_0::IStreamOutCallback;
|
||||
using ::android::hardware::audio::V2_0::ParameterValue;
|
||||
using ::android::hardware::audio::V2_0::Result;
|
||||
using ::android::hardware::audio::V2_0::TimeSpec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
|
||||
struct StreamOut : public IStreamOut {
|
||||
typedef MessageQueue<WriteCommand, kSynchronizedReadWrite> CommandMQ;
|
||||
typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ;
|
||||
typedef MessageQueue<WriteStatus, kSynchronizedReadWrite> StatusMQ;
|
||||
|
||||
StreamOut(const sp<Device>& device, audio_stream_out_t* stream);
|
||||
|
||||
// Methods from ::android::hardware::audio::V2_0::IStream follow.
|
||||
Return<uint64_t> getFrameSize() override;
|
||||
Return<uint64_t> getFrameCount() override;
|
||||
Return<uint64_t> getBufferSize() override;
|
||||
Return<uint32_t> getSampleRate() override;
|
||||
Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
|
||||
Return<Result> setSampleRate(uint32_t sampleRateHz) override;
|
||||
Return<AudioChannelMask> getChannelMask() override;
|
||||
Return<void> getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override;
|
||||
Return<Result> setChannelMask(AudioChannelMask mask) override;
|
||||
Return<AudioFormat> getFormat() override;
|
||||
Return<void> getSupportedFormats(getSupportedFormats_cb _hidl_cb) override;
|
||||
Return<Result> setFormat(AudioFormat format) override;
|
||||
Return<void> getAudioProperties(getAudioProperties_cb _hidl_cb) override;
|
||||
Return<Result> addEffect(uint64_t effectId) override;
|
||||
Return<Result> removeEffect(uint64_t effectId) override;
|
||||
Return<Result> standby() override;
|
||||
Return<AudioDevice> getDevice() override;
|
||||
Return<Result> setDevice(const DeviceAddress& address) override;
|
||||
Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override;
|
||||
Return<Result> setHwAvSync(uint32_t hwAvSync) override;
|
||||
Return<void> getParameters(
|
||||
const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override;
|
||||
Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
|
||||
Return<void> debugDump(const hidl_handle& fd) override;
|
||||
Return<Result> close() override;
|
||||
|
||||
// Methods from ::android::hardware::audio::V2_0::IStreamOut follow.
|
||||
Return<uint32_t> getLatency() override;
|
||||
Return<Result> setVolume(float left, float right) override;
|
||||
Return<void> prepareForWriting(
|
||||
uint32_t frameSize, uint32_t framesCount, prepareForWriting_cb _hidl_cb) override;
|
||||
Return<void> getRenderPosition(getRenderPosition_cb _hidl_cb) override;
|
||||
Return<void> getNextWriteTimestamp(getNextWriteTimestamp_cb _hidl_cb) override;
|
||||
Return<Result> setCallback(const sp<IStreamOutCallback>& callback) override;
|
||||
Return<Result> clearCallback() override;
|
||||
Return<void> supportsPauseAndResume(supportsPauseAndResume_cb _hidl_cb) override;
|
||||
Return<Result> pause() override;
|
||||
Return<Result> resume() override;
|
||||
Return<bool> supportsDrain() override;
|
||||
Return<Result> drain(AudioDrain type) override;
|
||||
Return<Result> flush() override;
|
||||
Return<void> getPresentationPosition(getPresentationPosition_cb _hidl_cb) override;
|
||||
Return<Result> start() override;
|
||||
Return<Result> stop() override;
|
||||
Return<void> createMmapBuffer(int32_t minSizeFrames, createMmapBuffer_cb _hidl_cb) override;
|
||||
Return<void> getMmapPosition(getMmapPosition_cb _hidl_cb) override;
|
||||
|
||||
static Result getPresentationPositionImpl(
|
||||
audio_stream_out_t *stream, uint64_t *frames, TimeSpec *timeStamp);
|
||||
|
||||
private:
|
||||
bool mIsClosed;
|
||||
const sp<Device> mDevice;
|
||||
audio_stream_out_t *mStream;
|
||||
const sp<Stream> mStreamCommon;
|
||||
const sp<StreamMmap<audio_stream_out_t>> mStreamMmap;
|
||||
sp<IStreamOutCallback> mCallback;
|
||||
std::unique_ptr<CommandMQ> mCommandMQ;
|
||||
std::unique_ptr<DataMQ> mDataMQ;
|
||||
std::unique_ptr<StatusMQ> mStatusMQ;
|
||||
EventFlag* mEfGroup;
|
||||
std::atomic<bool> mStopWriteThread;
|
||||
sp<Thread> mWriteThread;
|
||||
|
||||
virtual ~StreamOut();
|
||||
|
||||
static int asyncCallback(stream_callback_event_t event, void *param, void *cookie);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_STREAMOUT_H
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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 "audiohalservice"
|
||||
|
||||
#include <android/hardware/audio/2.0/IDevicesFactory.h>
|
||||
#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
|
||||
#include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioOffload.h>
|
||||
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
using android::hardware::registerPassthroughServiceImplementation;
|
||||
|
||||
using android::hardware::audio::effect::V2_0::IEffectsFactory;
|
||||
using android::hardware::audio::V2_0::IDevicesFactory;
|
||||
using android::hardware::soundtrigger::V2_0::ISoundTriggerHw;
|
||||
using android::hardware::registerPassthroughServiceImplementation;
|
||||
using android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload;
|
||||
|
||||
using android::OK;
|
||||
|
||||
int main(int /* argc */, char* /* argv */ []) {
|
||||
configureRpcThreadpool(16, true /*callerWillJoin*/);
|
||||
android::status_t status;
|
||||
status = registerPassthroughServiceImplementation<IDevicesFactory>();
|
||||
LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio service: %d", status);
|
||||
status = registerPassthroughServiceImplementation<IEffectsFactory>();
|
||||
LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio effects service: %d", status);
|
||||
// Soundtrigger might be not present.
|
||||
status = registerPassthroughServiceImplementation<ISoundTriggerHw>();
|
||||
ALOGE_IF(status != OK, "Error while registering soundtrigger service: %d", status);
|
||||
status = registerPassthroughServiceImplementation<IBluetoothAudioOffload>();
|
||||
ALOGE_IF(status != OK, "Error while registering bluetooth_audio service: %d", status);
|
||||
joinRpcThreadpool();
|
||||
return status;
|
||||
}
|
||||
48
audio/4.0/Android.bp
Normal file
48
audio/4.0/Android.bp
Normal file
@@ -0,0 +1,48 @@
|
||||
// This file is autogenerated by hidl-gen -Landroidbp.
|
||||
|
||||
hidl_interface {
|
||||
name: "android.hardware.audio@4.0",
|
||||
root: "android.hardware",
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IDevice.hal",
|
||||
"IDevicesFactory.hal",
|
||||
"IPrimaryDevice.hal",
|
||||
"IStream.hal",
|
||||
"IStreamIn.hal",
|
||||
"IStreamOut.hal",
|
||||
"IStreamOutCallback.hal",
|
||||
],
|
||||
interfaces: [
|
||||
"android.hardware.audio.common@4.0",
|
||||
"android.hardware.audio.effect@4.0",
|
||||
"android.hidl.base@1.0",
|
||||
],
|
||||
types: [
|
||||
"AudioDrain",
|
||||
"AudioFrequencyResponsePoint",
|
||||
"AudioMicrophoneChannelMapping",
|
||||
"AudioMicrophoneCoordinate",
|
||||
"AudioMicrophoneDirectionality",
|
||||
"AudioMicrophoneLocation",
|
||||
"DeviceAddress",
|
||||
"MessageQueueFlagBits",
|
||||
"MicrophoneInfo",
|
||||
"MmapBufferFlag",
|
||||
"MmapBufferInfo",
|
||||
"MmapPosition",
|
||||
"ParameterValue",
|
||||
"PlaybackTrackMetadata",
|
||||
"RecordTrackMetadata",
|
||||
"Result",
|
||||
"SinkMetadata",
|
||||
"SourceMetadata",
|
||||
"TimeSpec",
|
||||
],
|
||||
gen_java: false,
|
||||
gen_java_constants: true,
|
||||
}
|
||||
|
||||
282
audio/4.0/IDevice.hal
Normal file
282
audio/4.0/IDevice.hal
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package android.hardware.audio@4.0;
|
||||
|
||||
import android.hardware.audio.common@4.0;
|
||||
import IStreamIn;
|
||||
import IStreamOut;
|
||||
|
||||
interface IDevice {
|
||||
/**
|
||||
* Returns whether the audio hardware interface has been initialized.
|
||||
*
|
||||
* @return retval OK on success, NOT_INITIALIZED on failure.
|
||||
*/
|
||||
initCheck() generates (Result retval);
|
||||
|
||||
/**
|
||||
* Sets the audio volume for all audio activities other than voice call. If
|
||||
* NOT_SUPPORTED is returned, the software mixer will emulate this
|
||||
* capability.
|
||||
*
|
||||
* @param volume 1.0f means unity, 0.0f is zero.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setMasterVolume(float volume) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Get the current master volume value for the HAL, if the HAL supports
|
||||
* master volume control. For example, AudioFlinger will query this value
|
||||
* from the primary audio HAL when the service starts and use the value for
|
||||
* setting the initial master volume across all HALs. HALs which do not
|
||||
* support this method must return NOT_SUPPORTED in 'retval'.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return volume 1.0f means unity, 0.0f is zero.
|
||||
*/
|
||||
getMasterVolume() generates (Result retval, float volume);
|
||||
|
||||
/**
|
||||
* Sets microphone muting state.
|
||||
*
|
||||
* @param mute whether microphone is muted.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setMicMute(bool mute) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Gets whether microphone is muted.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return mute whether microphone is muted.
|
||||
*/
|
||||
getMicMute() generates (Result retval, bool mute);
|
||||
|
||||
/**
|
||||
* Set the audio mute status for all audio activities. If the return value
|
||||
* is NOT_SUPPORTED, the software mixer will emulate this capability.
|
||||
*
|
||||
* @param mute whether audio is muted.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setMasterMute(bool mute) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Get the current master mute status for the HAL, if the HAL supports
|
||||
* master mute control. AudioFlinger will query this value from the primary
|
||||
* audio HAL when the service starts and use the value for setting the
|
||||
* initial master mute across all HALs. HAL must indicate that the feature
|
||||
* is not supported by returning NOT_SUPPORTED status.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return mute whether audio is muted.
|
||||
*/
|
||||
getMasterMute() generates (Result retval, bool mute);
|
||||
|
||||
/**
|
||||
* Returns audio input buffer size according to parameters passed or
|
||||
* INVALID_ARGUMENTS if one of the parameters is not supported.
|
||||
*
|
||||
* @param config audio configuration.
|
||||
* @return retval operation completion status.
|
||||
* @return bufferSize input buffer size in bytes.
|
||||
*/
|
||||
getInputBufferSize(AudioConfig config)
|
||||
generates (Result retval, uint64_t bufferSize);
|
||||
|
||||
/**
|
||||
* This method creates and opens the audio hardware output stream.
|
||||
* If the stream can not be opened with the proposed audio config,
|
||||
* HAL must provide suggested values for the audio config.
|
||||
*
|
||||
* @param ioHandle handle assigned by AudioFlinger.
|
||||
* @param device device type and (if needed) address.
|
||||
* @param config stream configuration.
|
||||
* @param flags additional flags.
|
||||
* @param sourceMetadata Description of the audio that will be played.
|
||||
May be used by implementations to configure hardware effects.
|
||||
* @return retval operation completion status.
|
||||
* @return outStream created output stream.
|
||||
* @return suggestedConfig in case of invalid parameters, suggested config.
|
||||
*/
|
||||
openOutputStream(
|
||||
AudioIoHandle ioHandle,
|
||||
DeviceAddress device,
|
||||
AudioConfig config,
|
||||
bitfield<AudioOutputFlag> flags,
|
||||
SourceMetadata sourceMetadata) generates (
|
||||
Result retval,
|
||||
IStreamOut outStream,
|
||||
AudioConfig suggestedConfig);
|
||||
|
||||
/**
|
||||
* This method creates and opens the audio hardware input stream.
|
||||
* If the stream can not be opened with the proposed audio config,
|
||||
* HAL must provide suggested values for the audio config.
|
||||
*
|
||||
* @param ioHandle handle assigned by AudioFlinger.
|
||||
* @param device device type and (if needed) address.
|
||||
* @param config stream configuration.
|
||||
* @param flags additional flags.
|
||||
* @param sinkMetadata Description of the audio that is suggested by the client.
|
||||
* May be used by implementations to configure hardware effects.
|
||||
* @return retval operation completion status.
|
||||
* @return inStream in case of success, created input stream.
|
||||
* @return suggestedConfig in case of invalid parameters, suggested config.
|
||||
*/
|
||||
openInputStream(
|
||||
AudioIoHandle ioHandle,
|
||||
DeviceAddress device,
|
||||
AudioConfig config,
|
||||
bitfield<AudioInputFlag> flags,
|
||||
SinkMetadata sinkMetadata) generates (
|
||||
Result retval,
|
||||
IStreamIn inStream,
|
||||
AudioConfig suggestedConfig);
|
||||
|
||||
/**
|
||||
* Returns whether HAL supports audio patches.
|
||||
*
|
||||
* @return supports true if audio patches are supported.
|
||||
*/
|
||||
supportsAudioPatches() generates (bool supports);
|
||||
|
||||
/**
|
||||
* Creates an audio patch between several source and sink ports. The handle
|
||||
* is allocated by the HAL and must be unique for this audio HAL module.
|
||||
*
|
||||
* @param sources patch sources.
|
||||
* @param sinks patch sinks.
|
||||
* @return retval operation completion status.
|
||||
* @return patch created patch handle.
|
||||
*/
|
||||
createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks)
|
||||
generates (Result retval, AudioPatchHandle patch);
|
||||
|
||||
/**
|
||||
* Release an audio patch.
|
||||
*
|
||||
* @param patch patch handle.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
releaseAudioPatch(AudioPatchHandle patch) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Returns the list of supported attributes for a given audio port.
|
||||
*
|
||||
* As input, 'port' contains the information (type, role, address etc...)
|
||||
* needed by the HAL to identify the port.
|
||||
*
|
||||
* As output, 'resultPort' contains possible attributes (sampling rates,
|
||||
* formats, channel masks, gain controllers...) for this port.
|
||||
*
|
||||
* @param port port identifier.
|
||||
* @return retval operation completion status.
|
||||
* @return resultPort port descriptor with all parameters filled up.
|
||||
*/
|
||||
getAudioPort(AudioPort port)
|
||||
generates (Result retval, AudioPort resultPort);
|
||||
|
||||
/**
|
||||
* Set audio port configuration.
|
||||
*
|
||||
* @param config audio port configuration.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setAudioPortConfig(AudioPortConfig config) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Gets the HW synchronization source of the device. Calling this method is
|
||||
* equivalent to getting AUDIO_PARAMETER_HW_AV_SYNC on the legacy HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @return retval operation completion status: OK or NOT_SUPPORTED.
|
||||
* @return hwAvSync HW synchronization source
|
||||
*/
|
||||
getHwAvSync() generates (Result retval, AudioHwSync hwAvSync);
|
||||
|
||||
/**
|
||||
* Sets whether the screen is on. Calling this method is equivalent to
|
||||
* setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @param turnedOn whether the screen is turned on.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setScreenState(bool turnedOn) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Generic method for retrieving vendor-specific parameter values.
|
||||
* The framework does not interpret the parameters, they are passed
|
||||
* in an opaque manner between a vendor application and HAL.
|
||||
*
|
||||
* Multiple parameters can be retrieved at the same time.
|
||||
* The implementation should return as many requested parameters
|
||||
* as possible, even if one or more is not supported
|
||||
*
|
||||
* @param context provides more information about the request
|
||||
* @param keys keys of the requested parameters
|
||||
* @return retval operation completion status.
|
||||
* OK must be returned if keys is empty.
|
||||
* NOT_SUPPORTED must be returned if at least one key is unknown.
|
||||
* @return parameters parameter key value pairs.
|
||||
* Must contain the value of all requested keys if retval == OK
|
||||
*/
|
||||
getParameters(vec<ParameterValue> context, vec<string> keys)
|
||||
generates (Result retval, vec<ParameterValue> parameters);
|
||||
|
||||
/**
|
||||
* Generic method for setting vendor-specific parameter values.
|
||||
* The framework does not interpret the parameters, they are passed
|
||||
* in an opaque manner between a vendor application and HAL.
|
||||
*
|
||||
* Multiple parameters can be set at the same time though this is
|
||||
* discouraged as it make failure analysis harder.
|
||||
*
|
||||
* If possible, a failed setParameters should not impact the platform state.
|
||||
*
|
||||
* @param context provides more information about the request
|
||||
* @param parameters parameter key value pairs.
|
||||
* @return retval operation completion status.
|
||||
* All parameters must be successfully set for OK to be returned
|
||||
*/
|
||||
setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
|
||||
generates (Result retval);
|
||||
|
||||
/**
|
||||
* Returns an array with available microphones in device.
|
||||
*
|
||||
* @return retval INVALID_STATE if the call is not successful,
|
||||
* OK otherwise.
|
||||
*
|
||||
* @return microphones array with microphones info
|
||||
*/
|
||||
getMicrophones()
|
||||
generates(Result retval, vec<MicrophoneInfo> microphones);
|
||||
|
||||
/**
|
||||
* Notifies the device module about the connection state of an input/output
|
||||
* device attached to it. Calling this method is equivalent to setting
|
||||
* AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy HAL.
|
||||
*
|
||||
* @param address audio device specification.
|
||||
* @param connected whether the device is connected.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setConnectedState(DeviceAddress address, bool connected)
|
||||
generates (Result retval);
|
||||
};
|
||||
70
audio/4.0/IDevicesFactory.hal
Normal file
70
audio/4.0/IDevicesFactory.hal
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package android.hardware.audio@4.0;
|
||||
|
||||
import android.hardware.audio.common@4.0;
|
||||
import IDevice;
|
||||
import IPrimaryDevice;
|
||||
|
||||
/** This factory allows a HAL implementation to be split in multiple independent
|
||||
* devices (called module in the pre-treble API).
|
||||
* Note that this division is arbitrary and implementation are free
|
||||
* to only have a Primary.
|
||||
* The framework will query the devices according to audio_policy_configuration.xml
|
||||
*
|
||||
* Each device name is arbitrary, provided by the vendor's audio_policy_configuration.xml
|
||||
* and only used to identify a device in this factory.
|
||||
* The framework must not interpret the name, treating it as a vendor opaque data
|
||||
* with the following exception:
|
||||
* - the "r_submix" device that must be present to support policyMixes (Eg: Android projected).
|
||||
* Note that this Device is included by default in a build derived from AOSP.
|
||||
*
|
||||
* Note that on AOSP Oreo (including MR1) the "a2dp" module is not using this API
|
||||
* but is loaded directly from the system partition using the legacy API
|
||||
* due to limitations with the Bluetooth framework.
|
||||
*/
|
||||
interface IDevicesFactory {
|
||||
|
||||
/**
|
||||
* Opens an audio device. To close the device, it is necessary to release
|
||||
* references to the returned device object.
|
||||
*
|
||||
* @param device device name.
|
||||
* @return retval operation completion status. Returns INVALID_ARGUMENTS
|
||||
* if there is no corresponding hardware module found,
|
||||
* NOT_INITIALIZED if an error occured while opening the hardware
|
||||
* module.
|
||||
* @return result the interface for the created device.
|
||||
*/
|
||||
openDevice(string device) generates (Result retval, IDevice result);
|
||||
|
||||
/**
|
||||
* Opens the Primary audio device that must be present.
|
||||
* This function is not optional and must return successfully the primary device.
|
||||
*
|
||||
* This device must have the name "primary".
|
||||
*
|
||||
* The telephony stack uses this device to control the audio during a voice call.
|
||||
*
|
||||
* @return retval operation completion status. Must be SUCCESS.
|
||||
* For debuging, return INVALID_ARGUMENTS if there is no corresponding
|
||||
* hardware module found, NOT_INITIALIZED if an error occurred
|
||||
* while opening the hardware module.
|
||||
* @return result the interface for the created device.
|
||||
*/
|
||||
openPrimaryDevice() generates (Result retval, IPrimaryDevice result);
|
||||
};
|
||||
195
audio/4.0/IPrimaryDevice.hal
Normal file
195
audio/4.0/IPrimaryDevice.hal
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package android.hardware.audio@4.0;
|
||||
|
||||
import android.hardware.audio.common@4.0;
|
||||
import IDevice;
|
||||
|
||||
interface IPrimaryDevice extends IDevice {
|
||||
/**
|
||||
* Sets the audio volume of a voice call.
|
||||
*
|
||||
* @param volume 1.0f means unity, 0.0f is zero.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setVoiceVolume(float volume) generates (Result retval);
|
||||
|
||||
/**
|
||||
* This method is used to notify the HAL about audio mode changes.
|
||||
*
|
||||
* @param mode new mode.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setMode(AudioMode mode) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Sets the name of the current BT SCO headset. Calling this method
|
||||
* is equivalent to setting legacy "bt_headset_name" parameter.
|
||||
* The BT SCO headset name must only be used for debugging purposes.
|
||||
* Optional method
|
||||
*
|
||||
* @param name the name of the current BT SCO headset (can be empty).
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setBtScoHeadsetDebugName(string name) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Gets whether BT SCO Noise Reduction and Echo Cancellation are enabled.
|
||||
* Calling this method is equivalent to getting AUDIO_PARAMETER_KEY_BT_NREC
|
||||
* on the legacy HAL.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return enabled whether BT SCO NR + EC are enabled.
|
||||
*/
|
||||
getBtScoNrecEnabled() generates (Result retval, bool enabled);
|
||||
|
||||
/**
|
||||
* Sets whether BT SCO Noise Reduction and Echo Cancellation are enabled.
|
||||
* Calling this method is equivalent to setting AUDIO_PARAMETER_KEY_BT_NREC
|
||||
* on the legacy HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @param enabled whether BT SCO NR + EC are enabled.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setBtScoNrecEnabled(bool enabled) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Gets whether BT SCO Wideband mode is enabled. Calling this method is
|
||||
* equivalent to getting AUDIO_PARAMETER_KEY_BT_SCO_WB on the legacy HAL.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return enabled whether BT Wideband is enabled.
|
||||
*/
|
||||
getBtScoWidebandEnabled() generates (Result retval, bool enabled);
|
||||
|
||||
/**
|
||||
* Sets whether BT SCO Wideband mode is enabled. Calling this method is
|
||||
* equivalent to setting AUDIO_PARAMETER_KEY_BT_SCO_WB on the legacy HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @param enabled whether BT Wideband is enabled.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setBtScoWidebandEnabled(bool enabled) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Gets whether BT HFP (Hands-Free Profile) is enabled. Calling this method
|
||||
* is equivalent to getting "hfp_enable" parameter value on the legacy HAL.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return enabled whether BT HFP is enabled.
|
||||
*/
|
||||
getBtHfpEnabled() generates (Result retval, bool enabled);
|
||||
|
||||
/**
|
||||
* Sets whether BT HFP (Hands-Free Profile) is enabled. Calling this method
|
||||
* is equivalent to setting "hfp_enable" parameter on the legacy HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @param enabled whether BT HFP is enabled.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setBtHfpEnabled(bool enabled) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Sets the sampling rate of BT HFP (Hands-Free Profile). Calling this
|
||||
* method is equivalent to setting "hfp_set_sampling_rate" parameter
|
||||
* on the legacy HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @param sampleRateHz sample rate in Hz.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setBtHfpSampleRate(uint32_t sampleRateHz) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Sets the current output volume Hz for BT HFP (Hands-Free Profile).
|
||||
* Calling this method is equivalent to setting "hfp_volume" parameter value
|
||||
* on the legacy HAL (except that legacy HAL implementations expect
|
||||
* an integer value in the range from 0 to 15.)
|
||||
* Optional method
|
||||
*
|
||||
* @param volume 1.0f means unity, 0.0f is zero.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setBtHfpVolume(float volume) generates (Result retval);
|
||||
|
||||
enum TtyMode : int32_t {
|
||||
OFF,
|
||||
VCO,
|
||||
HCO,
|
||||
FULL
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets current TTY mode selection. Calling this method is equivalent to
|
||||
* getting AUDIO_PARAMETER_KEY_TTY_MODE on the legacy HAL.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return mode TTY mode.
|
||||
*/
|
||||
getTtyMode() generates (Result retval, TtyMode mode);
|
||||
|
||||
/**
|
||||
* Sets current TTY mode. Calling this method is equivalent to setting
|
||||
* AUDIO_PARAMETER_KEY_TTY_MODE on the legacy HAL.
|
||||
*
|
||||
* @param mode TTY mode.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setTtyMode(TtyMode mode) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Gets whether Hearing Aid Compatibility - Telecoil (HAC-T) mode is
|
||||
* enabled. Calling this method is equivalent to getting
|
||||
* AUDIO_PARAMETER_KEY_HAC on the legacy HAL.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return enabled whether HAC mode is enabled.
|
||||
*/
|
||||
getHacEnabled() generates (Result retval, bool enabled);
|
||||
|
||||
/**
|
||||
* Sets whether Hearing Aid Compatibility - Telecoil (HAC-T) mode is
|
||||
* enabled. Calling this method is equivalent to setting
|
||||
* AUDIO_PARAMETER_KEY_HAC on the legacy HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @param enabled whether HAC mode is enabled.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setHacEnabled(bool enabled) generates (Result retval);
|
||||
|
||||
enum Rotation : int32_t {
|
||||
DEG_0,
|
||||
DEG_90,
|
||||
DEG_180,
|
||||
DEG_270
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates HAL on the current rotation of the device relative to natural
|
||||
* orientation. Calling this method is equivalent to setting legacy
|
||||
* parameter "rotation".
|
||||
*
|
||||
* @param rotation rotation in degrees relative to natural device
|
||||
* orientation.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
updateRotation(Rotation rotation) generates (Result retval);
|
||||
};
|
||||
310
audio/4.0/IStream.hal
Normal file
310
audio/4.0/IStream.hal
Normal file
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package android.hardware.audio@4.0;
|
||||
|
||||
import android.hardware.audio.common@4.0;
|
||||
import android.hardware.audio.effect@4.0::IEffect;
|
||||
|
||||
interface IStream {
|
||||
/**
|
||||
* Return the frame size (number of bytes per sample).
|
||||
*
|
||||
* @return frameSize frame size in bytes.
|
||||
*/
|
||||
getFrameSize() generates (uint64_t frameSize);
|
||||
|
||||
/**
|
||||
* Return the frame count of the buffer. Calling this method is equivalent
|
||||
* to getting AUDIO_PARAMETER_STREAM_FRAME_COUNT on the legacy HAL.
|
||||
*
|
||||
* @return count frame count.
|
||||
*/
|
||||
getFrameCount() generates (uint64_t count);
|
||||
|
||||
/**
|
||||
* Return the size of input/output buffer in bytes for this stream.
|
||||
* It must be a multiple of the frame size.
|
||||
*
|
||||
* @return buffer buffer size in bytes.
|
||||
*/
|
||||
getBufferSize() generates (uint64_t bufferSize);
|
||||
|
||||
/**
|
||||
* Return the sampling rate in Hz.
|
||||
*
|
||||
* @return sampleRateHz sample rate in Hz.
|
||||
*/
|
||||
getSampleRate() generates (uint32_t sampleRateHz);
|
||||
|
||||
/**
|
||||
* Return supported native sampling rates of the stream for a given format.
|
||||
* A supported native sample rate is a sample rate that can be efficiently
|
||||
* played by the hardware (typically without sample-rate conversions).
|
||||
*
|
||||
* This function is only called for dynamic profile. If called for
|
||||
* non-dynamic profile is should return NOT_SUPPORTED or the same list
|
||||
* as in audio_policy_configuration.xml.
|
||||
*
|
||||
* Calling this method is equivalent to getting
|
||||
* AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES on the legacy HAL.
|
||||
*
|
||||
*
|
||||
* @param format audio format for which the sample rates are supported.
|
||||
* @return retval operation completion status.
|
||||
* Must be OK if the format is supported.
|
||||
* @return sampleRateHz supported sample rates.
|
||||
*/
|
||||
getSupportedSampleRates(AudioFormat format)
|
||||
generates (Result retval, vec<uint32_t> sampleRates);
|
||||
|
||||
/**
|
||||
* Sets the sampling rate of the stream. Calling this method is equivalent
|
||||
* to setting AUDIO_PARAMETER_STREAM_SAMPLING_RATE on the legacy HAL.
|
||||
* Optional method. If implemented, only called on a stopped stream.
|
||||
*
|
||||
* @param sampleRateHz sample rate in Hz.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setSampleRate(uint32_t sampleRateHz) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Return the channel mask of the stream.
|
||||
*
|
||||
* @return mask channel mask.
|
||||
*/
|
||||
getChannelMask() generates (bitfield<AudioChannelMask> mask);
|
||||
|
||||
/**
|
||||
* Return supported channel masks of the stream. Calling this method is
|
||||
* equivalent to getting AUDIO_PARAMETER_STREAM_SUP_CHANNELS on the legacy
|
||||
* HAL.
|
||||
*
|
||||
* @param format audio format for which the channel masks are supported.
|
||||
* @return retval operation completion status.
|
||||
* Must be OK if the format is supported.
|
||||
* @return masks supported audio masks.
|
||||
*/
|
||||
getSupportedChannelMasks(AudioFormat format)
|
||||
generates (Result retval, vec<bitfield<AudioChannelMask>> masks);
|
||||
|
||||
/**
|
||||
* Sets the channel mask of the stream. Calling this method is equivalent to
|
||||
* setting AUDIO_PARAMETER_STREAM_CHANNELS on the legacy HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @param format audio format.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setChannelMask(bitfield<AudioChannelMask> mask) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Return the audio format of the stream.
|
||||
*
|
||||
* @return format audio format.
|
||||
*/
|
||||
getFormat() generates (AudioFormat format);
|
||||
|
||||
/**
|
||||
* Return supported audio formats of the stream. Calling this method is
|
||||
* equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy
|
||||
* HAL.
|
||||
*
|
||||
* @return formats supported audio formats.
|
||||
*/
|
||||
getSupportedFormats() generates (vec<AudioFormat> formats);
|
||||
|
||||
/**
|
||||
* Sets the audio format of the stream. Calling this method is equivalent to
|
||||
* setting AUDIO_PARAMETER_STREAM_FORMAT on the legacy HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @param format audio format.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setFormat(AudioFormat format) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Convenience method for retrieving several stream parameters in
|
||||
* one transaction.
|
||||
*
|
||||
* @return sampleRateHz sample rate in Hz.
|
||||
* @return mask channel mask.
|
||||
* @return format audio format.
|
||||
*/
|
||||
getAudioProperties() generates (
|
||||
uint32_t sampleRateHz, bitfield<AudioChannelMask> mask, AudioFormat format);
|
||||
|
||||
/**
|
||||
* Applies audio effect to the stream.
|
||||
*
|
||||
* @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
|
||||
* the effect to apply.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
addEffect(uint64_t effectId) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Stops application of the effect to the stream.
|
||||
*
|
||||
* @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
|
||||
* the effect to remove.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
removeEffect(uint64_t effectId) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Put the audio hardware input/output into standby mode.
|
||||
* Driver must exit from standby mode at the next I/O operation.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
standby() generates (Result retval);
|
||||
|
||||
/**
|
||||
* Return the set of devices which this stream is connected to.
|
||||
* Optional method
|
||||
*
|
||||
* @return retval operation completion status: OK or NOT_SUPPORTED.
|
||||
* @return device set of devices which this stream is connected to.
|
||||
*/
|
||||
getDevices() generates (Result retval, vec<DeviceAddress> devices);
|
||||
|
||||
/**
|
||||
* Connects the stream to one or multiple devices.
|
||||
*
|
||||
* This method must only be used for HALs that do not support
|
||||
* 'IDevice.createAudioPatch' method. Calling this method is
|
||||
* equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING preceeded
|
||||
* with a device address in the legacy HAL interface.
|
||||
*
|
||||
* @param address device to connect the stream to.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setDevices(vec<DeviceAddress> devices) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Sets the HW synchronization source. Calling this method is equivalent to
|
||||
* setting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @param hwAvSync HW synchronization source
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setHwAvSync(AudioHwSync hwAvSync) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Generic method for retrieving vendor-specific parameter values.
|
||||
* The framework does not interpret the parameters, they are passed
|
||||
* in an opaque manner between a vendor application and HAL.
|
||||
*
|
||||
* Multiple parameters can be retrieved at the same time.
|
||||
* The implementation should return as many requested parameters
|
||||
* as possible, even if one or more is not supported
|
||||
*
|
||||
* @param context provides more information about the request
|
||||
* @param keys keys of the requested parameters
|
||||
* @return retval operation completion status.
|
||||
* OK must be returned if keys is empty.
|
||||
* NOT_SUPPORTED must be returned if at least one key is unknown.
|
||||
* @return parameters parameter key value pairs.
|
||||
* Must contain the value of all requested keys if retval == OK
|
||||
*/
|
||||
getParameters(vec<ParameterValue> context, vec<string> keys)
|
||||
generates (Result retval, vec<ParameterValue> parameters);
|
||||
|
||||
/**
|
||||
* Generic method for setting vendor-specific parameter values.
|
||||
* The framework does not interpret the parameters, they are passed
|
||||
* in an opaque manner between a vendor application and HAL.
|
||||
*
|
||||
* Multiple parameters can be set at the same time though this is
|
||||
* discouraged as it make failure analysis harder.
|
||||
*
|
||||
* If possible, a failed setParameters should not impact the platform state.
|
||||
*
|
||||
* @param context provides more information about the request
|
||||
* @param parameters parameter key value pairs.
|
||||
* @return retval operation completion status.
|
||||
* All parameters must be successfully set for OK to be returned
|
||||
*/
|
||||
setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
|
||||
generates (Result retval);
|
||||
|
||||
/**
|
||||
* Called by the framework to start a stream operating in mmap mode.
|
||||
* createMmapBuffer() must be called before calling start().
|
||||
* Function only implemented by streams operating in mmap mode.
|
||||
*
|
||||
* @return retval OK in case the success.
|
||||
* NOT_SUPPORTED on non mmap mode streams
|
||||
* INVALID_STATE if called out of sequence
|
||||
*/
|
||||
start() generates (Result retval);
|
||||
|
||||
/**
|
||||
* Called by the framework to stop a stream operating in mmap mode.
|
||||
* Function only implemented by streams operating in mmap mode.
|
||||
*
|
||||
* @return retval OK in case the succes.
|
||||
* NOT_SUPPORTED on non mmap mode streams
|
||||
* INVALID_STATE if called out of sequence
|
||||
*/
|
||||
stop() generates (Result retval) ;
|
||||
|
||||
/**
|
||||
* Called by the framework to retrieve information on the mmap buffer used for audio
|
||||
* samples transfer.
|
||||
* Function only implemented by streams operating in mmap mode.
|
||||
*
|
||||
* @param minSizeFrames minimum buffer size requested. The actual buffer
|
||||
* size returned in struct MmapBufferInfo can be larger.
|
||||
* @return retval OK in case the success.
|
||||
* NOT_SUPPORTED on non mmap mode streams
|
||||
* NOT_INITIALIZED in case of memory allocation error
|
||||
* INVALID_ARGUMENTS if the requested buffer size is too large
|
||||
* INVALID_STATE if called out of sequence
|
||||
* @return info a MmapBufferInfo struct containing information on the MMMAP buffer created.
|
||||
*/
|
||||
createMmapBuffer(int32_t minSizeFrames)
|
||||
generates (Result retval, MmapBufferInfo info);
|
||||
|
||||
/**
|
||||
* Called by the framework to read current read/write position in the mmap buffer
|
||||
* with associated time stamp.
|
||||
* Function only implemented by streams operating in mmap mode.
|
||||
*
|
||||
* @return retval OK in case the success.
|
||||
* NOT_SUPPORTED on non mmap mode streams
|
||||
* INVALID_STATE if called out of sequence
|
||||
* @return position a MmapPosition struct containing current HW read/write position in frames
|
||||
* with associated time stamp.
|
||||
*/
|
||||
getMmapPosition()
|
||||
generates (Result retval, MmapPosition position);
|
||||
|
||||
/**
|
||||
* Called by the framework to deinitialize the stream and free up
|
||||
* all the currently allocated resources. It is recommended to close
|
||||
* the stream on the client side as soon as it is becomes unused.
|
||||
*
|
||||
* @return retval OK in case the success.
|
||||
* NOT_SUPPORTED if called on IStream instead of input or
|
||||
* output stream interface.
|
||||
* INVALID_STATE if the stream was already closed.
|
||||
*/
|
||||
close() generates (Result retval);
|
||||
};
|
||||
168
audio/4.0/IStreamIn.hal
Normal file
168
audio/4.0/IStreamIn.hal
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package android.hardware.audio@4.0;
|
||||
|
||||
import android.hardware.audio.common@4.0;
|
||||
import IStream;
|
||||
|
||||
interface IStreamIn extends IStream {
|
||||
/**
|
||||
* Returns the source descriptor of the input stream. Calling this method is
|
||||
* equivalent to getting AUDIO_PARAMETER_STREAM_INPUT_SOURCE on the legacy
|
||||
* HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return source audio source.
|
||||
*/
|
||||
getAudioSource() generates (Result retval, AudioSource source);
|
||||
|
||||
/**
|
||||
* Set the input gain for the audio driver.
|
||||
* Optional method
|
||||
*
|
||||
* @param gain 1.0f is unity, 0.0f is zero.
|
||||
* @result retval operation completion status.
|
||||
*/
|
||||
setGain(float gain) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Commands that can be executed on the driver reader thread.
|
||||
*/
|
||||
enum ReadCommand : int32_t {
|
||||
READ,
|
||||
GET_CAPTURE_POSITION
|
||||
};
|
||||
|
||||
/**
|
||||
* Data structure passed to the driver for executing commands
|
||||
* on the driver reader thread.
|
||||
*/
|
||||
struct ReadParameters {
|
||||
ReadCommand command; // discriminator
|
||||
union Params {
|
||||
uint64_t read; // READ command, amount of bytes to read, >= 0.
|
||||
// No parameters for GET_CAPTURE_POSITION.
|
||||
} params;
|
||||
};
|
||||
|
||||
/**
|
||||
* Data structure passed back to the client via status message queue
|
||||
* of 'read' operation.
|
||||
*
|
||||
* Possible values of 'retval' field:
|
||||
* - OK, read operation was successful;
|
||||
* - INVALID_ARGUMENTS, stream was not configured properly;
|
||||
* - INVALID_STATE, stream is in a state that doesn't allow reads.
|
||||
*/
|
||||
struct ReadStatus {
|
||||
Result retval;
|
||||
ReadCommand replyTo; // discriminator
|
||||
union Reply {
|
||||
uint64_t read; // READ command, amount of bytes read, >= 0.
|
||||
struct CapturePosition { // same as generated by getCapturePosition.
|
||||
uint64_t frames;
|
||||
uint64_t time;
|
||||
} capturePosition;
|
||||
} reply;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when the metadata of the stream's sink has been changed.
|
||||
* @param sinkMetadata Description of the audio that is suggested by the clients.
|
||||
*/
|
||||
updateSinkMetadata(SinkMetadata sinkMetadata);
|
||||
|
||||
/**
|
||||
* Set up required transports for receiving audio buffers from the driver.
|
||||
*
|
||||
* The transport consists of three message queues:
|
||||
* -- command queue is used to instruct the reader thread what operation
|
||||
* to perform;
|
||||
* -- data queue is used for passing audio data from the driver
|
||||
* to the client;
|
||||
* -- status queue is used for reporting operation status
|
||||
* (e.g. amount of bytes actually read or error code).
|
||||
*
|
||||
* The driver operates on a dedicated thread. The client must ensure that
|
||||
* the thread is given an appropriate priority and assigned to correct
|
||||
* scheduler and cgroup. For this purpose, the method returns identifiers
|
||||
* of the driver thread.
|
||||
*
|
||||
* @param frameSize the size of a single frame, in bytes.
|
||||
* @param framesCount the number of frames in a buffer.
|
||||
* @param threadPriority priority of the driver thread.
|
||||
* @return retval OK if both message queues were created successfully.
|
||||
* INVALID_STATE if the method was already called.
|
||||
* INVALID_ARGUMENTS if there was a problem setting up
|
||||
* the queues.
|
||||
* @return commandMQ a message queue used for passing commands.
|
||||
* @return dataMQ a message queue used for passing audio data in the format
|
||||
* specified at the stream opening.
|
||||
* @return statusMQ a message queue used for passing status from the driver
|
||||
* using ReadStatus structures.
|
||||
* @return threadInfo identifiers of the driver's dedicated thread.
|
||||
*/
|
||||
prepareForReading(uint32_t frameSize, uint32_t framesCount)
|
||||
generates (
|
||||
Result retval,
|
||||
fmq_sync<ReadParameters> commandMQ,
|
||||
fmq_sync<uint8_t> dataMQ,
|
||||
fmq_sync<ReadStatus> statusMQ,
|
||||
ThreadInfo threadInfo);
|
||||
|
||||
/**
|
||||
* Return the amount of input frames lost in the audio driver since the last
|
||||
* call of this function.
|
||||
*
|
||||
* Audio driver is expected to reset the value to 0 and restart counting
|
||||
* upon returning the current value by this function call. Such loss
|
||||
* typically occurs when the user space process is blocked longer than the
|
||||
* capacity of audio driver buffers.
|
||||
*
|
||||
* @return framesLost the number of input audio frames lost.
|
||||
*/
|
||||
getInputFramesLost() generates (uint32_t framesLost);
|
||||
|
||||
/**
|
||||
* Return a recent count of the number of audio frames received and the
|
||||
* clock time associated with that frame count.
|
||||
*
|
||||
* @return retval INVALID_STATE if the device is not ready/available,
|
||||
* NOT_SUPPORTED if the command is not supported,
|
||||
* OK otherwise.
|
||||
* @return frames the total frame count received. This must be as early in
|
||||
* the capture pipeline as possible. In general, frames
|
||||
* must be non-negative and must not go "backwards".
|
||||
* @return time is the clock monotonic time when frames was measured. In
|
||||
* general, time must be a positive quantity and must not
|
||||
* go "backwards".
|
||||
*/
|
||||
getCapturePosition()
|
||||
generates (Result retval, uint64_t frames, uint64_t time);
|
||||
|
||||
/**
|
||||
* Returns an array with active microphones in the stream.
|
||||
*
|
||||
* @return retval INVALID_STATE if the call is not successful,
|
||||
* OK otherwise.
|
||||
*
|
||||
* @return microphones array with microphones info
|
||||
*/
|
||||
getActiveMicrophones()
|
||||
generates(Result retval, vec<MicrophoneInfo> microphones);
|
||||
};
|
||||
279
audio/4.0/IStreamOut.hal
Normal file
279
audio/4.0/IStreamOut.hal
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package android.hardware.audio@4.0;
|
||||
|
||||
import android.hardware.audio.common@4.0;
|
||||
import IStream;
|
||||
import IStreamOutCallback;
|
||||
|
||||
interface IStreamOut extends IStream {
|
||||
/**
|
||||
* Return the audio hardware driver estimated latency in milliseconds.
|
||||
*
|
||||
* @return latencyMs latency in milliseconds.
|
||||
*/
|
||||
getLatency() generates (uint32_t latencyMs);
|
||||
|
||||
/**
|
||||
* This method is used in situations where audio mixing is done in the
|
||||
* hardware. This method serves as a direct interface with hardware,
|
||||
* allowing to directly set the volume as apposed to via the framework.
|
||||
* This method might produce multiple PCM outputs or hardware accelerated
|
||||
* codecs, such as MP3 or AAC.
|
||||
* Optional method
|
||||
*
|
||||
* @param left left channel attenuation, 1.0f is unity, 0.0f is zero.
|
||||
* @param right right channel attenuation, 1.0f is unity, 0.0f is zero.
|
||||
* @return retval operation completion status.
|
||||
* If a volume is outside [0,1], return INVALID_ARGUMENTS
|
||||
*/
|
||||
setVolume(float left, float right) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Commands that can be executed on the driver writer thread.
|
||||
*/
|
||||
enum WriteCommand : int32_t {
|
||||
WRITE,
|
||||
GET_PRESENTATION_POSITION,
|
||||
GET_LATENCY
|
||||
};
|
||||
|
||||
/**
|
||||
* Data structure passed back to the client via status message queue
|
||||
* of 'write' operation.
|
||||
*
|
||||
* Possible values of 'retval' field:
|
||||
* - OK, write operation was successful;
|
||||
* - INVALID_ARGUMENTS, stream was not configured properly;
|
||||
* - INVALID_STATE, stream is in a state that doesn't allow writes;
|
||||
* - INVALID_OPERATION, retrieving presentation position isn't supported.
|
||||
*/
|
||||
struct WriteStatus {
|
||||
Result retval;
|
||||
WriteCommand replyTo; // discriminator
|
||||
union Reply {
|
||||
uint64_t written; // WRITE command, amount of bytes written, >= 0.
|
||||
struct PresentationPosition { // same as generated by
|
||||
uint64_t frames; // getPresentationPosition.
|
||||
TimeSpec timeStamp;
|
||||
} presentationPosition;
|
||||
uint32_t latencyMs; // Same as generated by getLatency.
|
||||
} reply;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when the metadata of the stream's source has been changed.
|
||||
* @param sourceMetadata Description of the audio that is played by the clients.
|
||||
*/
|
||||
updateSourceMetadata(SourceMetadata sourceMetadata);
|
||||
|
||||
/**
|
||||
* Set up required transports for passing audio buffers to the driver.
|
||||
*
|
||||
* The transport consists of three message queues:
|
||||
* -- command queue is used to instruct the writer thread what operation
|
||||
* to perform;
|
||||
* -- data queue is used for passing audio data from the client
|
||||
* to the driver;
|
||||
* -- status queue is used for reporting operation status
|
||||
* (e.g. amount of bytes actually written or error code).
|
||||
*
|
||||
* The driver operates on a dedicated thread. The client must ensure that
|
||||
* the thread is given an appropriate priority and assigned to correct
|
||||
* scheduler and cgroup. For this purpose, the method returns identifiers
|
||||
* of the driver thread.
|
||||
*
|
||||
* @param frameSize the size of a single frame, in bytes.
|
||||
* @param framesCount the number of frames in a buffer.
|
||||
* @return retval OK if both message queues were created successfully.
|
||||
* INVALID_STATE if the method was already called.
|
||||
* INVALID_ARGUMENTS if there was a problem setting up
|
||||
* the queues.
|
||||
* @return commandMQ a message queue used for passing commands.
|
||||
* @return dataMQ a message queue used for passing audio data in the format
|
||||
* specified at the stream opening.
|
||||
* @return statusMQ a message queue used for passing status from the driver
|
||||
* using WriteStatus structures.
|
||||
* @return threadInfo identifiers of the driver's dedicated thread.
|
||||
*/
|
||||
prepareForWriting(uint32_t frameSize, uint32_t framesCount)
|
||||
generates (
|
||||
Result retval,
|
||||
fmq_sync<WriteCommand> commandMQ,
|
||||
fmq_sync<uint8_t> dataMQ,
|
||||
fmq_sync<WriteStatus> statusMQ,
|
||||
ThreadInfo threadInfo);
|
||||
|
||||
/**
|
||||
* Return the number of audio frames written by the audio DSP to DAC since
|
||||
* the output has exited standby.
|
||||
* Optional method
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return dspFrames number of audio frames written.
|
||||
*/
|
||||
getRenderPosition() generates (Result retval, uint32_t dspFrames);
|
||||
|
||||
/**
|
||||
* Get the local time at which the next write to the audio driver will be
|
||||
* presented. The units are microseconds, where the epoch is decided by the
|
||||
* local audio HAL.
|
||||
* Optional method
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return timestampUs time of the next write.
|
||||
*/
|
||||
getNextWriteTimestamp() generates (Result retval, int64_t timestampUs);
|
||||
|
||||
/**
|
||||
* Set the callback interface for notifying completion of non-blocking
|
||||
* write and drain.
|
||||
*
|
||||
* Calling this function implies that all future 'write' and 'drain'
|
||||
* must be non-blocking and use the callback to signal completion.
|
||||
*
|
||||
* 'clearCallback' method needs to be called in order to release the local
|
||||
* callback proxy on the server side and thus dereference the callback
|
||||
* implementation on the client side.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
setCallback(IStreamOutCallback callback) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Clears the callback previously set via 'setCallback' method.
|
||||
*
|
||||
* Warning: failure to call this method results in callback implementation
|
||||
* on the client side being held until the HAL server termination.
|
||||
*
|
||||
* If no callback was previously set, the method should be a no-op
|
||||
* and return OK.
|
||||
*
|
||||
* @return retval operation completion status: OK or NOT_SUPPORTED.
|
||||
*/
|
||||
clearCallback() generates (Result retval);
|
||||
|
||||
/**
|
||||
* Returns whether HAL supports pausing and resuming of streams.
|
||||
*
|
||||
* @return supportsPause true if pausing is supported.
|
||||
* @return supportsResume true if resume is supported.
|
||||
*/
|
||||
supportsPauseAndResume()
|
||||
generates (bool supportsPause, bool supportsResume);
|
||||
|
||||
/**
|
||||
* Notifies to the audio driver to stop playback however the queued buffers
|
||||
* are retained by the hardware. Useful for implementing pause/resume. Empty
|
||||
* implementation if not supported however must be implemented for hardware
|
||||
* with non-trivial latency. In the pause state, some audio hardware may
|
||||
* still be using power. Client code may consider calling 'suspend' after a
|
||||
* timeout to prevent that excess power usage.
|
||||
*
|
||||
* Implementation of this function is mandatory for offloaded playback.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
pause() generates (Result retval);
|
||||
|
||||
/**
|
||||
* Notifies to the audio driver to resume playback following a pause.
|
||||
* Returns error INVALID_STATE if called without matching pause.
|
||||
*
|
||||
* Implementation of this function is mandatory for offloaded playback.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
resume() generates (Result retval);
|
||||
|
||||
/**
|
||||
* Returns whether HAL supports draining of streams.
|
||||
*
|
||||
* @return supports true if draining is supported.
|
||||
*/
|
||||
supportsDrain() generates (bool supports);
|
||||
|
||||
/**
|
||||
* Requests notification when data buffered by the driver/hardware has been
|
||||
* played. If 'setCallback' has previously been called to enable
|
||||
* non-blocking mode, then 'drain' must not block, instead it must return
|
||||
* quickly and completion of the drain is notified through the callback. If
|
||||
* 'setCallback' has not been called, then 'drain' must block until
|
||||
* completion.
|
||||
*
|
||||
* If 'type' is 'ALL', the drain completes when all previously written data
|
||||
* has been played.
|
||||
*
|
||||
* If 'type' is 'EARLY_NOTIFY', the drain completes shortly before all data
|
||||
* for the current track has played to allow time for the framework to
|
||||
* perform a gapless track switch.
|
||||
*
|
||||
* Drain must return immediately on 'stop' and 'flush' calls.
|
||||
*
|
||||
* Implementation of this function is mandatory for offloaded playback.
|
||||
*
|
||||
* @param type type of drain.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
drain(AudioDrain type) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Notifies to the audio driver to flush the queued data. Stream must
|
||||
* already be paused before calling 'flush'.
|
||||
* Optional method
|
||||
*
|
||||
* Implementation of this function is mandatory for offloaded playback.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
flush() generates (Result retval);
|
||||
|
||||
/**
|
||||
* Return a recent count of the number of audio frames presented to an
|
||||
* external observer. This excludes frames which have been written but are
|
||||
* still in the pipeline. The count is not reset to zero when output enters
|
||||
* standby. Also returns the value of CLOCK_MONOTONIC as of this
|
||||
* presentation count. The returned count is expected to be 'recent', but
|
||||
* does not need to be the most recent possible value. However, the
|
||||
* associated time must correspond to whatever count is returned.
|
||||
*
|
||||
* Example: assume that N+M frames have been presented, where M is a 'small'
|
||||
* number. Then it is permissible to return N instead of N+M, and the
|
||||
* timestamp must correspond to N rather than N+M. The terms 'recent' and
|
||||
* 'small' are not defined. They reflect the quality of the implementation.
|
||||
*
|
||||
* Optional method
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return frames count of presented audio frames.
|
||||
* @return timeStamp associated clock time.
|
||||
*/
|
||||
getPresentationPosition()
|
||||
generates (Result retval, uint64_t frames, TimeSpec timeStamp);
|
||||
|
||||
/**
|
||||
* Selects a presentation for decoding from a next generation media stream
|
||||
* (as defined per ETSI TS 103 190-2) and a program within the presentation.
|
||||
* Optional method
|
||||
*
|
||||
* @param presentationId selected audio presentation.
|
||||
* @param programId refinement for the presentation.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
selectPresentation(int32_t presentationId, int32_t programId)
|
||||
generates (Result retval);
|
||||
};
|
||||
37
audio/4.0/IStreamOutCallback.hal
Normal file
37
audio/4.0/IStreamOutCallback.hal
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package android.hardware.audio@4.0;
|
||||
|
||||
/**
|
||||
* Asynchronous write callback interface.
|
||||
*/
|
||||
interface IStreamOutCallback {
|
||||
/**
|
||||
* Non blocking write completed.
|
||||
*/
|
||||
oneway onWriteReady();
|
||||
|
||||
/**
|
||||
* Drain completed.
|
||||
*/
|
||||
oneway onDrainReady();
|
||||
|
||||
/**
|
||||
* Stream hit an error.
|
||||
*/
|
||||
oneway onError();
|
||||
};
|
||||
564
audio/4.0/config/audio_policy_configuration.xsd
Normal file
564
audio/4.0/config/audio_policy_configuration.xsd
Normal file
@@ -0,0 +1,564 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (C) 2017 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.
|
||||
-->
|
||||
<!-- TODO: define a targetNamespace. Note that it will break retrocompatibility -->
|
||||
<xs:schema version="2.0"
|
||||
elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- List the config versions supported by audio policy. -->
|
||||
<xs:simpleType name="version">
|
||||
<xs:restriction base="xs:decimal">
|
||||
<xs:enumeration value="1.0"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="halVersion">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">
|
||||
Version of the interface the hal implements.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:restriction base="xs:decimal">
|
||||
<!-- List of HAL versions supported by the framework. -->
|
||||
<xs:enumeration value="2.0"/>
|
||||
<xs:enumeration value="3.0"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:element name="audioPolicyConfiguration">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="globalConfiguration" type="globalConfiguration"/>
|
||||
<xs:element name="modules" type="modules" maxOccurs="unbounded"/>
|
||||
<xs:element name="volumes" type="volumes" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="version" type="version"/>
|
||||
</xs:complexType>
|
||||
<xs:key name="moduleNameKey">
|
||||
<xs:selector xpath="modules/module"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:key>
|
||||
<xs:unique name="volumeTargetUniqueness">
|
||||
<xs:selector xpath="volumes/volume"/>
|
||||
<xs:field xpath="@stream"/>
|
||||
<xs:field xpath="@deviceCategory"/>
|
||||
</xs:unique>
|
||||
<xs:key name="volumeCurveNameKey">
|
||||
<xs:selector xpath="volumes/reference"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:key>
|
||||
<xs:keyref name="volumeCurveRef" refer="volumeCurveNameKey">
|
||||
<xs:selector xpath="volumes/volume"/>
|
||||
<xs:field xpath="@ref"/>
|
||||
</xs:keyref>
|
||||
</xs:element>
|
||||
<xs:complexType name="globalConfiguration">
|
||||
<xs:attribute name="speaker_drc_enabled" type="xs:boolean" use="required"/>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="modules">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">
|
||||
There should be one section per audio HW module present on the platform.
|
||||
Each <module/> contains two mandatory tags: “halVersion” and “name”.
|
||||
The module "name" is the same as in previous .conf file.
|
||||
Each module must contain the following sections:
|
||||
- <devicePorts/>: a list of device descriptors for all
|
||||
input and output devices accessible via this module.
|
||||
This contains both permanently attached devices and removable devices.
|
||||
- <mixPorts/>: listing all output and input streams exposed by the audio HAL
|
||||
- <routes/>: list of possible connections between input
|
||||
and output devices or between stream and devices.
|
||||
A <route/> is defined by a set of 3 attributes:
|
||||
-"type": mux|mix means all sources are mutual exclusive (mux) or can be mixed (mix)
|
||||
-"sink": the sink involved in this route
|
||||
-"sources": all the sources than can be connected to the sink via this route
|
||||
- <attachedDevices/>: permanently attached devices.
|
||||
The attachedDevices section is a list of devices names.
|
||||
Their names correspond to device names defined in "devicePorts" section.
|
||||
- <defaultOutputDevice/> is the device to be used when no policy rule applies
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:sequence>
|
||||
<xs:element name="module" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="attachedDevices" type="attachedDevices" minOccurs="0">
|
||||
<xs:unique name="attachedDevicesUniqueness">
|
||||
<xs:selector xpath="item"/>
|
||||
<xs:field xpath="."/>
|
||||
</xs:unique>
|
||||
</xs:element>
|
||||
<xs:element name="defaultOutputDevice" type="xs:token" minOccurs="0"/>
|
||||
<xs:element name="mixPorts" type="mixPorts" minOccurs="0"/>
|
||||
<xs:element name="devicePorts" type="devicePorts" minOccurs="0"/>
|
||||
<xs:element name="routes" type="routes" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:string" use="required"/>
|
||||
<xs:attribute name="halVersion" type="halVersion" use="required"/>
|
||||
</xs:complexType>
|
||||
<xs:unique name="mixPortNameUniqueness">
|
||||
<xs:selector xpath="mixPorts/mixPort"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:unique>
|
||||
<xs:key name="devicePortNameKey">
|
||||
<xs:selector xpath="devicePorts/devicePort"/>
|
||||
<xs:field xpath="@tagName"/>
|
||||
</xs:key>
|
||||
<xs:unique name="devicePortUniqueness">
|
||||
<xs:selector xpath="devicePorts/devicePort"/>
|
||||
<xs:field xpath="@type"/>
|
||||
<xs:field xpath="@address"/>
|
||||
</xs:unique>
|
||||
<xs:keyref name="defaultOutputDeviceRef" refer="devicePortNameKey">
|
||||
<xs:selector xpath="defaultOutputDevice"/>
|
||||
<xs:field xpath="."/>
|
||||
</xs:keyref>
|
||||
<xs:keyref name="attachedDeviceRef" refer="devicePortNameKey">
|
||||
<xs:selector xpath="attachedDevices/item"/>
|
||||
<xs:field xpath="."/>
|
||||
</xs:keyref>
|
||||
<!-- The following 3 constraints try to make sure each sink port
|
||||
is reference in one an only one route. -->
|
||||
<xs:key name="routeSinkKey">
|
||||
<!-- predicate [@type='sink'] does not work in xsd 1.0 -->
|
||||
<xs:selector xpath="devicePorts/devicePort|mixPorts/mixPort"/>
|
||||
<xs:field xpath="@tagName|@name"/>
|
||||
</xs:key>
|
||||
<xs:keyref name="routeSinkRef" refer="routeSinkKey">
|
||||
<xs:selector xpath="routes/route"/>
|
||||
<xs:field xpath="@sink"/>
|
||||
</xs:keyref>
|
||||
<xs:unique name="routeUniqueness">
|
||||
<xs:selector xpath="routes/route"/>
|
||||
<xs:field xpath="@sink"/>
|
||||
</xs:unique>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="attachedDevices">
|
||||
<xs:sequence>
|
||||
<xs:element name="item" type="xs:token" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<!-- TODO: separate values by space for better xsd validations. -->
|
||||
<xs:simpleType name="audioInOutFlags">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">
|
||||
"|" separated list of audio_output_flags_t or audio_input_flags_t.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="|[_A-Z]+(\|[_A-Z]+)*"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="role">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="sink"/>
|
||||
<xs:enumeration value="source"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="mixPorts">
|
||||
<xs:sequence>
|
||||
<xs:element name="mixPort" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="profile" type="profile" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="gains" type="gains" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:token" use="required"/>
|
||||
<xs:attribute name="role" type="role" use="required"/>
|
||||
<xs:attribute name="flags" type="audioInOutFlags"/>
|
||||
<xs:attribute name="maxOpenCount" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="maxActiveCount" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="preferredUsage" type="audioUsageList">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">
|
||||
When choosing the mixPort of an audio track, the audioPolicy
|
||||
first considers the mixPorts with a preferredUsage including
|
||||
the track AudioUsage preferred .
|
||||
If non support the track format, the other mixPorts are considered.
|
||||
Eg: a <mixPort preferredUsage="AUDIO_USAGE_MEDIA" /> will receive
|
||||
the audio of all apps playing with a MEDIA usage.
|
||||
It may receive audio from ALARM if there are no audio compatible
|
||||
<mixPort preferredUsage="AUDIO_USAGE_ALARM" />.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
<xs:unique name="mixPortProfileUniqueness">
|
||||
<xs:selector xpath="profile"/>
|
||||
<xs:field xpath="format"/>
|
||||
<xs:field xpath="samplingRate"/>
|
||||
<xs:field xpath="channelMasks"/>
|
||||
</xs:unique>
|
||||
<xs:unique name="mixPortGainUniqueness">
|
||||
<xs:selector xpath="gains/gain"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:unique>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<!-- Enum values of audio_device_t in audio.h
|
||||
TODO: generate from hidl to avoid manual sync.
|
||||
TODO: separate source and sink in the xml for better xsd validations. -->
|
||||
<xs:simpleType name="audioDevice">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="AUDIO_DEVICE_NONE"/>
|
||||
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_EARPIECE"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_SPEAKER"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_WIRED_HEADSET"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_WIRED_HEADPHONE"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_AUX_DIGITAL"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_HDMI"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_USB_ACCESSORY"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_USB_DEVICE"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_REMOTE_SUBMIX"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_TELEPHONY_TX"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_LINE"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_HDMI_ARC"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_SPDIF"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_FM"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_AUX_LINE"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_SPEAKER_SAFE"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_IP"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_BUS"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_PROXY"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_USB_HEADSET"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_HEARING_AID"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_ECHO_CANCELLER"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_DEFAULT"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_OUT_STUB"/>
|
||||
|
||||
<!-- Due to the xml format, IN types can not be a separated from OUT types -->
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_COMMUNICATION"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_AMBIENT"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_BUILTIN_MIC"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_WIRED_HEADSET"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_AUX_DIGITAL"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_HDMI"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_VOICE_CALL"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_TELEPHONY_RX"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_BACK_MIC"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_REMOTE_SUBMIX"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_USB_ACCESSORY"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_USB_DEVICE"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_FM_TUNER"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_TV_TUNER"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_LINE"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_SPDIF"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_A2DP"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_LOOPBACK"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_IP"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_BUS"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_PROXY"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_USB_HEADSET"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_BLE"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_DEFAULT"/>
|
||||
<xs:enumeration value="AUDIO_DEVICE_IN_STUB"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<!-- Enum values of audio_format_t in audio.h
|
||||
TODO: generate from hidl to avoid manual sync. -->
|
||||
<xs:simpleType name="audioFormat">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="AUDIO_FORMAT_PCM_16_BIT" />
|
||||
<xs:enumeration value="AUDIO_FORMAT_PCM_8_BIT"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_PCM_32_BIT"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_PCM_8_24_BIT"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_PCM_FLOAT"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_PCM_24_BIT_PACKED"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_MP3"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AMR_NB"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AMR_WB"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_MAIN"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_LC"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_SSR"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_LTP"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_HE_V1"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_SCALABLE"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ERLC"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_LD"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_HE_V2"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ELD"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_MAIN"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_LC"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_SSR"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_LTP"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_HE_V1"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_SCALABLE"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_ERLC"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_LD"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_HE_V2"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_ELD"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_VORBIS"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_HE_AAC_V1"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_HE_AAC_V2"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_OPUS"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AC3"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_E_AC3"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_DTS"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_DTS_HD"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_IEC61937"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_DOLBY_TRUEHD"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_EVRC"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_EVRCB"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_EVRCWB"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_EVRCNW"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADIF"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_WMA"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_WMA_PRO"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AMR_WB_PLUS"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_MP2"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_QCELP"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_DSD"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_FLAC"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_ALAC"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_APE"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_SBC"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_APTX"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_APTX_HD"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_AC4"/>
|
||||
<xs:enumeration value="AUDIO_FORMAT_LDAC"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<!-- Enum values of audio::common::4_0::AudioUsage
|
||||
TODO: generate from HIDL to avoid manual sync. -->
|
||||
<xs:simpleType name="audioUsage">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="AUDIO_USAGE_UNKNOWN" />
|
||||
<xs:enumeration value="AUDIO_USAGE_MEDIA" />
|
||||
<xs:enumeration value="AUDIO_USAGE_VOICE_COMMUNICATION" />
|
||||
<xs:enumeration value="AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING" />
|
||||
<xs:enumeration value="AUDIO_USAGE_ALARM" />
|
||||
<xs:enumeration value="AUDIO_USAGE_NOTIFICATION" />
|
||||
<xs:enumeration value="AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE" />
|
||||
<xs:enumeration value="AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY" />
|
||||
<xs:enumeration value="AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE" />
|
||||
<xs:enumeration value="AUDIO_USAGE_ASSISTANCE_SONIFICATION" />
|
||||
<xs:enumeration value="AUDIO_USAGE_GAME" />
|
||||
<xs:enumeration value="AUDIO_USAGE_VIRTUAL_SOURCE" />
|
||||
<xs:enumeration value="AUDIO_USAGE_ASSISTANT" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="audioUsageList">
|
||||
<xs:list itemType="audioUsage"/>
|
||||
</xs:simpleType>
|
||||
<!-- TODO: Change to a space separated list to xsd enforce correctness. -->
|
||||
<xs:simpleType name="samplingRates">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[0-9]+(,[0-9]+)*"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<!-- TODO: Change to a space separated list to xsd enforce correctness. -->
|
||||
<xs:simpleType name="channelMask">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">
|
||||
Comma (",") separated list of channel flags
|
||||
from audio_channel_mask_t.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[_A-Z][_A-Z0-9]*(,[_A-Z][_A-Z0-9]*)*"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="profile">
|
||||
<xs:attribute name="name" type="xs:token" use="optional"/>
|
||||
<xs:attribute name="format" type="audioFormat" use="optional"/>
|
||||
<xs:attribute name="samplingRates" type="samplingRates" use="optional"/>
|
||||
<xs:attribute name="channelMasks" type="channelMask" use="optional"/>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="gainMode">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="AUDIO_GAIN_MODE_JOINT"/>
|
||||
<xs:enumeration value="AUDIO_GAIN_MODE_CHANNELS"/>
|
||||
<xs:enumeration value="AUDIO_GAIN_MODE_RAMP"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="gains">
|
||||
<xs:sequence>
|
||||
<xs:element name="gain" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="name" type="xs:token" use="required"/>
|
||||
<xs:attribute name="mode" type="gainMode" use="required"/>
|
||||
<xs:attribute name="channel_mask" type="channelMask" use="optional"/>
|
||||
<xs:attribute name="minValueMB" type="xs:int" use="optional"/>
|
||||
<xs:attribute name="maxValueMB" type="xs:int" use="optional"/>
|
||||
<xs:attribute name="defaultValueMB" type="xs:int" use="optional"/>
|
||||
<xs:attribute name="stepValueMB" type="xs:int" use="optional"/>
|
||||
<xs:attribute name="minRampMs" type="xs:int" use="optional"/>
|
||||
<xs:attribute name="maxRampMs" type="xs:int" use="optional"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="devicePorts">
|
||||
<xs:sequence>
|
||||
<xs:element name="devicePort" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="profile" type="profile" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="gains" type="gains" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="tagName" type="xs:token" use="required"/>
|
||||
<xs:attribute name="type" type="audioDevice" use="required"/>
|
||||
<xs:attribute name="role" type="role" use="required"/>
|
||||
<xs:attribute name="address" type="xs:string" use="optional" default=""/>
|
||||
<!-- Note that XSD 1.0 can not check that a type only has one default. -->
|
||||
<xs:attribute name="default" type="xs:boolean" use="optional">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">
|
||||
The default device will be used if multiple have the same type
|
||||
and no explicit route request exists for a specific device of
|
||||
that type.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
<xs:unique name="devicePortProfileUniqueness">
|
||||
<xs:selector xpath="profile"/>
|
||||
<xs:field xpath="format"/>
|
||||
<xs:field xpath="samplingRate"/>
|
||||
<xs:field xpath="channelMasks"/>
|
||||
</xs:unique>
|
||||
<xs:unique name="devicePortGainUniqueness">
|
||||
<xs:selector xpath="gains/gain"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:unique>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="mixType">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="mix"/>
|
||||
<xs:enumeration value="mux"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="routes">
|
||||
<xs:sequence>
|
||||
<xs:element name="route" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">
|
||||
List all available sources for a given sink.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:complexType>
|
||||
<xs:attribute name="type" type="mixType" use="required"/>
|
||||
<xs:attribute name="sink" type="xs:string" use="required"/>
|
||||
<xs:attribute name="sources" type="xs:string" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="volumes">
|
||||
<xs:sequence>
|
||||
<xs:element name="volume" type="volume" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="reference" type="reference" minOccurs="0" maxOccurs="unbounded">
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<!-- TODO: Always require a ref for better xsd validations.
|
||||
Currently a volume could have no points nor ref
|
||||
as it can not be forbidden by xsd 1.0.-->
|
||||
<xs:simpleType name="volumePoint">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">
|
||||
Comma separated pair of number.
|
||||
The fist one is the framework level (between 0 and 100).
|
||||
The second one is the volume to send to the HAL.
|
||||
The framework will interpolate volumes not specified.
|
||||
Their MUST be at least 2 points specified.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="([0-9]{1,2}|100),-?[0-9]+"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<!-- Enum values of audio_stream_type_t in audio-base.h
|
||||
TODO: generate from hidl to avoid manual sync. -->
|
||||
<xs:simpleType name="stream">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="AUDIO_STREAM_VOICE_CALL"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_SYSTEM"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_RING"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_MUSIC"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_ALARM"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_NOTIFICATION"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_BLUETOOTH_SCO"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_ENFORCED_AUDIBLE"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_DTMF"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_TTS"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_ACCESSIBILITY"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_REROUTING"/>
|
||||
<xs:enumeration value="AUDIO_STREAM_PATCH"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<!-- Enum values of device_category from Volume.h.
|
||||
TODO: generate from hidl to avoid manual sync. -->
|
||||
<xs:simpleType name="deviceCategory">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="DEVICE_CATEGORY_HEADSET"/>
|
||||
<xs:enumeration value="DEVICE_CATEGORY_SPEAKER"/>
|
||||
<xs:enumeration value="DEVICE_CATEGORY_EARPIECE"/>
|
||||
<xs:enumeration value="DEVICE_CATEGORY_EXT_MEDIA"/>
|
||||
<xs:enumeration value="DEVICE_CATEGORY_HEARING_AID"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="volume">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">
|
||||
Volume section defines a volume curve for a given use case and device category.
|
||||
It contains a list of points of this curve expressing the attenuation in Millibels
|
||||
for a given volume index from 0 to 100.
|
||||
<volume stream="AUDIO_STREAM_MUSIC" deviceCategory="DEVICE_CATEGORY_SPEAKER">
|
||||
<point>0,-9600</point>
|
||||
<point>100,0</point>
|
||||
</volume>
|
||||
|
||||
It may also reference a reference/@name to avoid duplicating curves.
|
||||
<volume stream="AUDIO_STREAM_MUSIC" deviceCategory="DEVICE_CATEGORY_SPEAKER"
|
||||
ref="DEFAULT_MEDIA_VOLUME_CURVE"/>
|
||||
<reference name="DEFAULT_MEDIA_VOLUME_CURVE">
|
||||
<point>0,-9600</point>
|
||||
<point>100,0</point>
|
||||
</reference>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:sequence>
|
||||
<xs:element name="point" type="volumePoint" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="stream" type="stream"/>
|
||||
<xs:attribute name="deviceCategory" type="deviceCategory"/>
|
||||
<xs:attribute name="ref" type="xs:token" use="optional"/>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="reference">
|
||||
<xs:sequence>
|
||||
<xs:element name="point" type="volumePoint" minOccurs="2" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:token" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
||||
279
audio/4.0/types.hal
Normal file
279
audio/4.0/types.hal
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package android.hardware.audio@4.0;
|
||||
|
||||
import android.hardware.audio.common@4.0;
|
||||
|
||||
enum Result : int32_t {
|
||||
OK,
|
||||
NOT_INITIALIZED,
|
||||
INVALID_ARGUMENTS,
|
||||
INVALID_STATE,
|
||||
/**
|
||||
* Methods marked as "Optional method" must return this result value
|
||||
* if the operation is not supported by HAL.
|
||||
*/
|
||||
NOT_SUPPORTED
|
||||
};
|
||||
|
||||
@export(name="audio_drain_type_t", value_prefix="AUDIO_DRAIN_")
|
||||
enum AudioDrain : int32_t {
|
||||
/** drain() returns when all data has been played. */
|
||||
ALL,
|
||||
/**
|
||||
* drain() returns a short time before all data from the current track has
|
||||
* been played to give time for gapless track switch.
|
||||
*/
|
||||
EARLY_NOTIFY
|
||||
};
|
||||
|
||||
/**
|
||||
* A substitute for POSIX timespec.
|
||||
*/
|
||||
struct TimeSpec {
|
||||
uint64_t tvSec; // seconds
|
||||
uint64_t tvNSec; // nanoseconds
|
||||
};
|
||||
|
||||
/**
|
||||
* IEEE 802 MAC address.
|
||||
*/
|
||||
typedef uint8_t[6] MacAddress;
|
||||
|
||||
struct ParameterValue {
|
||||
string key;
|
||||
string value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Specifies a device in case when several devices of the same type
|
||||
* can be connected (e.g. BT A2DP, USB).
|
||||
*/
|
||||
struct DeviceAddress {
|
||||
AudioDevice device; // discriminator
|
||||
union Address {
|
||||
MacAddress mac; // used for BLUETOOTH_A2DP_*
|
||||
uint8_t[4] ipv4; // used for IP
|
||||
struct Alsa {
|
||||
int32_t card;
|
||||
int32_t device;
|
||||
} alsa; // used for USB_*
|
||||
} address;
|
||||
string busAddress; // used for BUS
|
||||
string rSubmixAddress; // used for REMOTE_SUBMIX
|
||||
};
|
||||
|
||||
enum MmapBufferFlag : uint32_t {
|
||||
NONE = 0x0,
|
||||
/**
|
||||
* If the buffer can be securely shared to untrusted applications
|
||||
* through the AAudio exclusive mode.
|
||||
* Only set this flag if applications are restricted from accessing the
|
||||
* memory surrounding the audio data buffer by a kernel mechanism.
|
||||
* See Linux kernel's dma_buf.
|
||||
*/
|
||||
APPLICATION_SHAREABLE = 0x1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Mmap buffer descriptor returned by IStream.createMmapBuffer().
|
||||
* Used by streams opened in mmap mode.
|
||||
*/
|
||||
struct MmapBufferInfo {
|
||||
/** Mmap memory buffer */
|
||||
memory sharedMemory;
|
||||
/** Total buffer size in frames */
|
||||
uint32_t bufferSizeFrames;
|
||||
/** Transfer size granularity in frames */
|
||||
uint32_t burstSizeFrames;
|
||||
/** Attributes describing the buffer. */
|
||||
bitfield<MmapBufferFlag> flags;
|
||||
};
|
||||
|
||||
/**
|
||||
* Mmap buffer read/write position returned by IStream.getMmapPosition().
|
||||
* Used by streams opened in mmap mode.
|
||||
*/
|
||||
struct MmapPosition {
|
||||
int64_t timeNanoseconds; // time stamp in ns, CLOCK_MONOTONIC
|
||||
int32_t positionFrames; // increasing 32 bit frame count reset when IStream.stop() is called
|
||||
};
|
||||
|
||||
/**
|
||||
* The message queue flags used to synchronize reads and writes from
|
||||
* message queues used by StreamIn and StreamOut.
|
||||
*/
|
||||
enum MessageQueueFlagBits : uint32_t {
|
||||
NOT_EMPTY = 1 << 0,
|
||||
NOT_FULL = 1 << 1
|
||||
};
|
||||
|
||||
/** Metadata of a playback track for a StreamOut. */
|
||||
struct PlaybackTrackMetadata {
|
||||
AudioUsage usage;
|
||||
AudioContentType contentType;
|
||||
/**
|
||||
* Positive linear gain applied to the track samples. 0 being muted and 1 is no attenuation,
|
||||
* 2 means double amplification...
|
||||
* Must not be negative.
|
||||
*/
|
||||
float gain;
|
||||
};
|
||||
|
||||
/** Metadatas of the source of a StreamOut. */
|
||||
struct SourceMetadata {
|
||||
vec<PlaybackTrackMetadata> tracks;
|
||||
};
|
||||
|
||||
/** Metadata of a record track for a StreamIn. */
|
||||
struct RecordTrackMetadata {
|
||||
AudioSource source;
|
||||
/**
|
||||
* Positive linear gain applied to the track samples. 0 being muted and 1 is no attenuation,
|
||||
* 2 means double amplification...
|
||||
* Must not be negative.
|
||||
*/
|
||||
float gain;
|
||||
};
|
||||
|
||||
/** Metadatas of the source of a StreamIn. */
|
||||
struct SinkMetadata {
|
||||
vec<RecordTrackMetadata> tracks;
|
||||
};
|
||||
|
||||
/*
|
||||
* Microphone information
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A 3D point used to represent position or orientation of a microphone.
|
||||
*
|
||||
* Position: Coordinates of the microphone's capsule, in meters, from the
|
||||
* bottom-left-back corner of the bounding box of android device in natural
|
||||
* orientation (PORTRAIT for phones, LANDSCAPE for tablets, tvs, etc).
|
||||
* The orientation musth match the reported by the api Display.getRotation().
|
||||
*
|
||||
* Orientation: Normalized vector to signal the main orientation of the
|
||||
* microphone's capsule. Magnitude = sqrt(x^2 + y^2 + z^2) = 1
|
||||
*/
|
||||
struct AudioMicrophoneCoordinate {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum to identify the type of channel mapping for active microphones.
|
||||
* Used channels further identify if the microphone has any significative
|
||||
* process (e.g. High Pass Filtering, dynamic compression)
|
||||
* Simple processing as constant gain adjustment must be DIRECT.
|
||||
*/
|
||||
enum AudioMicrophoneChannelMapping : uint32_t {
|
||||
UNUSED = 0, /* Channel not used */
|
||||
DIRECT = 1, /* Channel used and signal not processed */
|
||||
PROCESSED = 2, /* Channel used and signal has some process */
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum to identify locations of microphones in regards to the body of the
|
||||
* android device.
|
||||
*/
|
||||
enum AudioMicrophoneLocation : uint32_t {
|
||||
UNKNOWN = 0,
|
||||
MAINBODY = 1,
|
||||
MAINBODY_MOVABLE = 2,
|
||||
PERIPHERAL = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* Identifier to help group related microphones together
|
||||
* e.g. microphone arrays should belong to the same group
|
||||
*/
|
||||
typedef int32_t AudioMicrophoneGroup;
|
||||
|
||||
/**
|
||||
* Enum with standard polar patterns of microphones
|
||||
*/
|
||||
enum AudioMicrophoneDirectionality : uint32_t {
|
||||
UNKNOWN = 0,
|
||||
OMNI = 1,
|
||||
BI_DIRECTIONAL = 2,
|
||||
CARDIOID = 3,
|
||||
HYPER_CARDIOID = 4,
|
||||
SUPER_CARDIOID = 5,
|
||||
};
|
||||
|
||||
/**
|
||||
* A (frequency, level) pair. Used to represent frequency response.
|
||||
*/
|
||||
struct AudioFrequencyResponsePoint {
|
||||
/** In Hz */
|
||||
float frequency;
|
||||
/** In dB */
|
||||
float level;
|
||||
};
|
||||
|
||||
/**
|
||||
* Structure used by the HAL to describe microphone's characteristics
|
||||
* Used by StreamIn and Device
|
||||
*/
|
||||
struct MicrophoneInfo {
|
||||
/** Unique alphanumeric id for microphone. Guaranteed to be the same
|
||||
* even after rebooting.
|
||||
*/
|
||||
string deviceId;
|
||||
/**
|
||||
* Device specific information
|
||||
*/
|
||||
DeviceAddress deviceAddress;
|
||||
/** Each element of the vector must describe the channel with the same
|
||||
* index.
|
||||
*/
|
||||
vec<AudioMicrophoneChannelMapping> channelMapping;
|
||||
/** Location of the microphone in regard to the body of the device */
|
||||
AudioMicrophoneLocation location;
|
||||
/** Identifier to help group related microphones together
|
||||
* e.g. microphone arrays should belong to the same group
|
||||
*/
|
||||
AudioMicrophoneGroup group;
|
||||
/** Index of this microphone within the group.
|
||||
* (group, index) must be unique within the same device.
|
||||
*/
|
||||
uint32_t indexInTheGroup;
|
||||
/** Level in dBFS produced by a 1000 Hz tone at 94 dB SPL */
|
||||
float sensitivity;
|
||||
/** Level in dB of the max SPL supported at 1000 Hz */
|
||||
float maxSpl;
|
||||
/** Level in dB of the min SPL supported at 1000 Hz */
|
||||
float minSpl;
|
||||
/** Standard polar pattern of the microphone */
|
||||
AudioMicrophoneDirectionality directionality;
|
||||
/** Vector with ordered frequency responses (from low to high frequencies)
|
||||
* with the frequency response of the microphone.
|
||||
* Levels are in dB, relative to level at 1000 Hz
|
||||
*/
|
||||
vec<AudioFrequencyResponsePoint> frequencyResponse;
|
||||
/** Position of the microphone's capsule in meters, from the
|
||||
* bottom-left-back corner of the bounding box of device.
|
||||
*/
|
||||
AudioMicrophoneCoordinate position;
|
||||
/** Normalized point to signal the main orientation of the microphone's
|
||||
* capsule. sqrt(x^2 + y^2 + z^2) = 1
|
||||
*/
|
||||
AudioMicrophoneCoordinate orientation;
|
||||
};
|
||||
48
audio/README
Normal file
48
audio/README
Normal file
@@ -0,0 +1,48 @@
|
||||
Directory structure of the audio HIDL related code.
|
||||
|
||||
audio
|
||||
|-- 2.0 <== HIDL (.hal) can not be moved to fit the directory structure
|
||||
| because that would create a separate HAL
|
||||
|-- 4.0 <== Version 4.0 of the core API
|
||||
|
|
||||
|-- common <== code common to audio core and effect API
|
||||
| |-- 2.0
|
||||
| | |-- default <== code that wraps the legacy API
|
||||
| | `-- vts <== vts of 2.0 core and effect API common code
|
||||
| |-- 4.0
|
||||
| | |-- default
|
||||
| | `-- vts
|
||||
| |-- ... <== The future versions should continue this structure
|
||||
| | |-- default
|
||||
| | `-- vts
|
||||
| `-- all_versions <== code common to all version of both core and effect API
|
||||
| |-- default
|
||||
| `-- vts <== vts of core and effect API common version independent code
|
||||
|
|
||||
|-- core <== code relative to the core API
|
||||
| |-- 2.0 <== 2.0 core API code (except .hal, see audio/2.0)
|
||||
| | |-- default
|
||||
| | `-- vts
|
||||
| |-- 4.0
|
||||
| | |-- default <== default implementation of the core 4.0 api
|
||||
| | `-- vts <== vts code of the 4.0 API
|
||||
| |-- ...
|
||||
| | |-- default
|
||||
| | `-- vts
|
||||
| `-- all_versions
|
||||
| |-- default
|
||||
| `-- vts <== vts of core API common version independent code
|
||||
|
|
||||
`-- effect <== idem for the effect API
|
||||
|-- 2.0
|
||||
| |-- default
|
||||
| `-- vts
|
||||
|-- 4.0
|
||||
| |-- default
|
||||
| `-- vts
|
||||
|-- ...
|
||||
| |-- default
|
||||
| `-- vts
|
||||
`-- all_versions
|
||||
|-- default
|
||||
`-- vts
|
||||
@@ -21,18 +21,24 @@ cc_library_shared {
|
||||
enabled: true,
|
||||
},
|
||||
srcs: [
|
||||
"EffectMap.cpp",
|
||||
"HidlUtils.cpp",
|
||||
],
|
||||
|
||||
export_include_dirs: ["."],
|
||||
|
||||
static_libs: [
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libhidlbase",
|
||||
"android.hardware.audio.common-util",
|
||||
"android.hardware.audio.common@2.0",
|
||||
],
|
||||
export_shared_lib_headers: [
|
||||
"android.hardware.audio.common-util"
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"libaudio_system_headers",
|
||||
|
||||
@@ -14,324 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "HidlUtils.h"
|
||||
|
||||
using ::android::hardware::audio::common::V2_0::AudioChannelMask;
|
||||
using ::android::hardware::audio::common::V2_0::AudioDevice;
|
||||
using ::android::hardware::audio::common::V2_0::AudioFormat;
|
||||
using ::android::hardware::audio::common::V2_0::AudioGainMode;
|
||||
using ::android::hardware::audio::common::V2_0::AudioMixLatencyClass;
|
||||
using ::android::hardware::audio::common::V2_0::AudioPortConfigMask;
|
||||
using ::android::hardware::audio::common::V2_0::AudioPortRole;
|
||||
using ::android::hardware::audio::common::V2_0::AudioPortType;
|
||||
using ::android::hardware::audio::common::V2_0::AudioSource;
|
||||
using ::android::hardware::audio::common::V2_0::AudioStreamType;
|
||||
using ::android::hardware::audio::common::V2_0::AudioUsage;
|
||||
|
||||
namespace android {
|
||||
|
||||
void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) {
|
||||
config->sampleRateHz = halConfig.sample_rate;
|
||||
config->channelMask = AudioChannelMask(halConfig.channel_mask);
|
||||
config->format = AudioFormat(halConfig.format);
|
||||
audioOffloadInfoFromHal(halConfig.offload_info, &config->offloadInfo);
|
||||
config->frameCount = halConfig.frame_count;
|
||||
}
|
||||
|
||||
void HidlUtils::audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig) {
|
||||
memset(halConfig, 0, sizeof(audio_config_t));
|
||||
halConfig->sample_rate = config.sampleRateHz;
|
||||
halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
|
||||
halConfig->format = static_cast<audio_format_t>(config.format);
|
||||
audioOffloadInfoToHal(config.offloadInfo, &halConfig->offload_info);
|
||||
halConfig->frame_count = config.frameCount;
|
||||
}
|
||||
|
||||
void HidlUtils::audioGainConfigFromHal(
|
||||
const struct audio_gain_config& halConfig, AudioGainConfig* config) {
|
||||
config->index = halConfig.index;
|
||||
config->mode = AudioGainMode(halConfig.mode);
|
||||
config->channelMask = AudioChannelMask(halConfig.channel_mask);
|
||||
for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) {
|
||||
config->values[i] = halConfig.values[i];
|
||||
}
|
||||
config->rampDurationMs = halConfig.ramp_duration_ms;
|
||||
}
|
||||
|
||||
void HidlUtils::audioGainConfigToHal(
|
||||
const AudioGainConfig& config, struct audio_gain_config* halConfig) {
|
||||
halConfig->index = config.index;
|
||||
halConfig->mode = static_cast<audio_gain_mode_t>(config.mode);
|
||||
halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
|
||||
memset(halConfig->values, 0, sizeof(halConfig->values));
|
||||
for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) {
|
||||
halConfig->values[i] = config.values[i];
|
||||
}
|
||||
halConfig->ramp_duration_ms = config.rampDurationMs;
|
||||
}
|
||||
|
||||
void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) {
|
||||
gain->mode = AudioGainMode(halGain.mode);
|
||||
gain->channelMask = AudioChannelMask(halGain.channel_mask);
|
||||
gain->minValue = halGain.min_value;
|
||||
gain->maxValue = halGain.max_value;
|
||||
gain->defaultValue = halGain.default_value;
|
||||
gain->stepValue = halGain.step_value;
|
||||
gain->minRampMs = halGain.min_ramp_ms;
|
||||
gain->maxRampMs = halGain.max_ramp_ms;
|
||||
}
|
||||
|
||||
void HidlUtils::audioGainToHal(const AudioGain& gain, struct audio_gain* halGain) {
|
||||
halGain->mode = static_cast<audio_gain_mode_t>(gain.mode);
|
||||
halGain->channel_mask = static_cast<audio_channel_mask_t>(gain.channelMask);
|
||||
halGain->min_value = gain.minValue;
|
||||
halGain->max_value = gain.maxValue;
|
||||
halGain->default_value = gain.defaultValue;
|
||||
halGain->step_value = gain.stepValue;
|
||||
halGain->min_ramp_ms = gain.minRampMs;
|
||||
halGain->max_ramp_ms = gain.maxRampMs;
|
||||
}
|
||||
|
||||
void HidlUtils::audioOffloadInfoFromHal(
|
||||
const audio_offload_info_t& halOffload, AudioOffloadInfo* offload) {
|
||||
offload->sampleRateHz = halOffload.sample_rate;
|
||||
offload->channelMask = AudioChannelMask(halOffload.channel_mask);
|
||||
offload->format = AudioFormat(halOffload.format);
|
||||
offload->streamType = AudioStreamType(halOffload.stream_type);
|
||||
offload->bitRatePerSecond = halOffload.bit_rate;
|
||||
offload->durationMicroseconds = halOffload.duration_us;
|
||||
offload->hasVideo = halOffload.has_video;
|
||||
offload->isStreaming = halOffload.is_streaming;
|
||||
offload->bitWidth = halOffload.bit_width;
|
||||
offload->bufferSize = halOffload.offload_buffer_size;
|
||||
offload->usage = static_cast<AudioUsage>(halOffload.usage);
|
||||
}
|
||||
|
||||
void HidlUtils::audioOffloadInfoToHal(
|
||||
const AudioOffloadInfo& offload, audio_offload_info_t* halOffload) {
|
||||
*halOffload = AUDIO_INFO_INITIALIZER;
|
||||
halOffload->sample_rate = offload.sampleRateHz;
|
||||
halOffload->channel_mask = static_cast<audio_channel_mask_t>(offload.channelMask);
|
||||
halOffload->format = static_cast<audio_format_t>(offload.format);
|
||||
halOffload->stream_type = static_cast<audio_stream_type_t>(offload.streamType);
|
||||
halOffload->bit_rate = offload.bitRatePerSecond;
|
||||
halOffload->duration_us = offload.durationMicroseconds;
|
||||
halOffload->has_video = offload.hasVideo;
|
||||
halOffload->is_streaming = offload.isStreaming;
|
||||
halOffload->bit_width = offload.bitWidth;
|
||||
halOffload->offload_buffer_size = offload.bufferSize;
|
||||
halOffload->usage = static_cast<audio_usage_t>(offload.usage);
|
||||
}
|
||||
|
||||
void HidlUtils::audioPortConfigFromHal(
|
||||
const struct audio_port_config& halConfig, AudioPortConfig* config) {
|
||||
config->id = halConfig.id;
|
||||
config->role = AudioPortRole(halConfig.role);
|
||||
config->type = AudioPortType(halConfig.type);
|
||||
config->configMask = AudioPortConfigMask(halConfig.config_mask);
|
||||
config->sampleRateHz = halConfig.sample_rate;
|
||||
config->channelMask = AudioChannelMask(halConfig.channel_mask);
|
||||
config->format = AudioFormat(halConfig.format);
|
||||
audioGainConfigFromHal(halConfig.gain, &config->gain);
|
||||
switch (halConfig.type) {
|
||||
case AUDIO_PORT_TYPE_NONE: break;
|
||||
case AUDIO_PORT_TYPE_DEVICE: {
|
||||
config->ext.device.hwModule = halConfig.ext.device.hw_module;
|
||||
config->ext.device.type = AudioDevice(halConfig.ext.device.type);
|
||||
memcpy(config->ext.device.address.data(),
|
||||
halConfig.ext.device.address,
|
||||
AUDIO_DEVICE_MAX_ADDRESS_LEN);
|
||||
break;
|
||||
}
|
||||
case AUDIO_PORT_TYPE_MIX: {
|
||||
config->ext.mix.hwModule = halConfig.ext.mix.hw_module;
|
||||
config->ext.mix.ioHandle = halConfig.ext.mix.handle;
|
||||
if (halConfig.role == AUDIO_PORT_ROLE_SOURCE) {
|
||||
config->ext.mix.useCase.source = AudioSource(halConfig.ext.mix.usecase.source);
|
||||
} else if (halConfig.role == AUDIO_PORT_ROLE_SINK) {
|
||||
config->ext.mix.useCase.stream = AudioStreamType(halConfig.ext.mix.usecase.stream);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AUDIO_PORT_TYPE_SESSION: {
|
||||
config->ext.session.session = halConfig.ext.session.session;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HidlUtils::audioPortConfigToHal(
|
||||
const AudioPortConfig& config, struct audio_port_config* halConfig) {
|
||||
memset(halConfig, 0, sizeof(audio_port_config));
|
||||
halConfig->id = config.id;
|
||||
halConfig->role = static_cast<audio_port_role_t>(config.role);
|
||||
halConfig->type = static_cast<audio_port_type_t>(config.type);
|
||||
halConfig->config_mask = static_cast<unsigned int>(config.configMask);
|
||||
halConfig->sample_rate = config.sampleRateHz;
|
||||
halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
|
||||
halConfig->format = static_cast<audio_format_t>(config.format);
|
||||
audioGainConfigToHal(config.gain, &halConfig->gain);
|
||||
switch (config.type) {
|
||||
case AudioPortType::NONE: break;
|
||||
case AudioPortType::DEVICE: {
|
||||
halConfig->ext.device.hw_module = config.ext.device.hwModule;
|
||||
halConfig->ext.device.type = static_cast<audio_devices_t>(config.ext.device.type);
|
||||
memcpy(halConfig->ext.device.address,
|
||||
config.ext.device.address.data(),
|
||||
AUDIO_DEVICE_MAX_ADDRESS_LEN);
|
||||
break;
|
||||
}
|
||||
case AudioPortType::MIX: {
|
||||
halConfig->ext.mix.hw_module = config.ext.mix.hwModule;
|
||||
halConfig->ext.mix.handle = config.ext.mix.ioHandle;
|
||||
if (config.role == AudioPortRole::SOURCE) {
|
||||
halConfig->ext.mix.usecase.source =
|
||||
static_cast<audio_source_t>(config.ext.mix.useCase.source);
|
||||
} else if (config.role == AudioPortRole::SINK) {
|
||||
halConfig->ext.mix.usecase.stream =
|
||||
static_cast<audio_stream_type_t>(config.ext.mix.useCase.stream);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AudioPortType::SESSION: {
|
||||
halConfig->ext.session.session =
|
||||
static_cast<audio_session_t>(config.ext.session.session);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HidlUtils::audioPortConfigsFromHal(
|
||||
unsigned int numHalConfigs, const struct audio_port_config *halConfigs,
|
||||
hidl_vec<AudioPortConfig> *configs) {
|
||||
configs->resize(numHalConfigs);
|
||||
for (unsigned int i = 0; i < numHalConfigs; ++i) {
|
||||
audioPortConfigFromHal(halConfigs[i], &(*configs)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<audio_port_config[]> HidlUtils::audioPortConfigsToHal(
|
||||
const hidl_vec<AudioPortConfig>& configs) {
|
||||
std::unique_ptr<audio_port_config[]> halConfigs(new audio_port_config[configs.size()]);
|
||||
for (size_t i = 0; i < configs.size(); ++i) {
|
||||
audioPortConfigToHal(configs[i], &halConfigs[i]);
|
||||
}
|
||||
return halConfigs;
|
||||
}
|
||||
|
||||
void HidlUtils::audioPortFromHal(const struct audio_port& halPort, AudioPort* port) {
|
||||
port->id = halPort.id;
|
||||
port->role = AudioPortRole(halPort.role);
|
||||
port->type = AudioPortType(halPort.type);
|
||||
port->name.setToExternal(halPort.name, strlen(halPort.name));
|
||||
port->sampleRates.resize(halPort.num_sample_rates);
|
||||
for (size_t i = 0; i < halPort.num_sample_rates; ++i) {
|
||||
port->sampleRates[i] = halPort.sample_rates[i];
|
||||
}
|
||||
port->channelMasks.resize(halPort.num_channel_masks);
|
||||
for (size_t i = 0; i < halPort.num_channel_masks; ++i) {
|
||||
port->channelMasks[i] = AudioChannelMask(halPort.channel_masks[i]);
|
||||
}
|
||||
port->formats.resize(halPort.num_formats);
|
||||
for (size_t i = 0; i < halPort.num_formats; ++i) {
|
||||
port->formats[i] = AudioFormat(halPort.formats[i]);
|
||||
}
|
||||
port->gains.resize(halPort.num_gains);
|
||||
for (size_t i = 0; i < halPort.num_gains; ++i) {
|
||||
audioGainFromHal(halPort.gains[i], &port->gains[i]);
|
||||
}
|
||||
audioPortConfigFromHal(halPort.active_config, &port->activeConfig);
|
||||
switch (halPort.type) {
|
||||
case AUDIO_PORT_TYPE_NONE: break;
|
||||
case AUDIO_PORT_TYPE_DEVICE: {
|
||||
port->ext.device.hwModule = halPort.ext.device.hw_module;
|
||||
port->ext.device.type = AudioDevice(halPort.ext.device.type);
|
||||
memcpy(port->ext.device.address.data(),
|
||||
halPort.ext.device.address,
|
||||
AUDIO_DEVICE_MAX_ADDRESS_LEN);
|
||||
break;
|
||||
}
|
||||
case AUDIO_PORT_TYPE_MIX: {
|
||||
port->ext.mix.hwModule = halPort.ext.mix.hw_module;
|
||||
port->ext.mix.ioHandle = halPort.ext.mix.handle;
|
||||
port->ext.mix.latencyClass = AudioMixLatencyClass(halPort.ext.mix.latency_class);
|
||||
break;
|
||||
}
|
||||
case AUDIO_PORT_TYPE_SESSION: {
|
||||
port->ext.session.session = halPort.ext.session.session;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HidlUtils::audioPortToHal(const AudioPort& port, struct audio_port* halPort) {
|
||||
memset(halPort, 0, sizeof(audio_port));
|
||||
halPort->id = port.id;
|
||||
halPort->role = static_cast<audio_port_role_t>(port.role);
|
||||
halPort->type = static_cast<audio_port_type_t>(port.type);
|
||||
memcpy(halPort->name,
|
||||
port.name.c_str(),
|
||||
std::min(port.name.size(), static_cast<size_t>(AUDIO_PORT_MAX_NAME_LEN)));
|
||||
halPort->num_sample_rates =
|
||||
std::min(port.sampleRates.size(), static_cast<size_t>(AUDIO_PORT_MAX_SAMPLING_RATES));
|
||||
for (size_t i = 0; i < halPort->num_sample_rates; ++i) {
|
||||
halPort->sample_rates[i] = port.sampleRates[i];
|
||||
}
|
||||
halPort->num_channel_masks =
|
||||
std::min(port.channelMasks.size(), static_cast<size_t>(AUDIO_PORT_MAX_CHANNEL_MASKS));
|
||||
for (size_t i = 0; i < halPort->num_channel_masks; ++i) {
|
||||
halPort->channel_masks[i] = static_cast<audio_channel_mask_t>(port.channelMasks[i]);
|
||||
}
|
||||
halPort->num_formats =
|
||||
std::min(port.formats.size(), static_cast<size_t>(AUDIO_PORT_MAX_FORMATS));
|
||||
for (size_t i = 0; i < halPort->num_formats; ++i) {
|
||||
halPort->formats[i] = static_cast<audio_format_t>(port.formats[i]);
|
||||
}
|
||||
halPort->num_gains = std::min(port.gains.size(), static_cast<size_t>(AUDIO_PORT_MAX_GAINS));
|
||||
for (size_t i = 0; i < halPort->num_gains; ++i) {
|
||||
audioGainToHal(port.gains[i], &halPort->gains[i]);
|
||||
}
|
||||
audioPortConfigToHal(port.activeConfig, &halPort->active_config);
|
||||
switch (port.type) {
|
||||
case AudioPortType::NONE: break;
|
||||
case AudioPortType::DEVICE: {
|
||||
halPort->ext.device.hw_module = port.ext.device.hwModule;
|
||||
halPort->ext.device.type = static_cast<audio_devices_t>(port.ext.device.type);
|
||||
memcpy(halPort->ext.device.address,
|
||||
port.ext.device.address.data(),
|
||||
AUDIO_DEVICE_MAX_ADDRESS_LEN);
|
||||
break;
|
||||
}
|
||||
case AudioPortType::MIX: {
|
||||
halPort->ext.mix.hw_module = port.ext.mix.hwModule;
|
||||
halPort->ext.mix.handle = port.ext.mix.ioHandle;
|
||||
halPort->ext.mix.latency_class =
|
||||
static_cast<audio_mix_latency_class_t>(port.ext.mix.latencyClass);
|
||||
break;
|
||||
}
|
||||
case AudioPortType::SESSION: {
|
||||
halPort->ext.session.session = static_cast<audio_session_t>(port.ext.session.session);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HidlUtils::uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid) {
|
||||
uuid->timeLow = halUuid.timeLow;
|
||||
uuid->timeMid = halUuid.timeMid;
|
||||
uuid->versionAndTimeHigh = halUuid.timeHiAndVersion;
|
||||
uuid->variantAndClockSeqHigh = halUuid.clockSeq;
|
||||
memcpy(uuid->node.data(), halUuid.node, uuid->node.size());
|
||||
}
|
||||
|
||||
void HidlUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) {
|
||||
halUuid->timeLow = uuid.timeLow;
|
||||
halUuid->timeMid = uuid.timeMid;
|
||||
halUuid->timeHiAndVersion = uuid.versionAndTimeHigh;
|
||||
halUuid->clockSeq = uuid.variantAndClockSeqHigh;
|
||||
memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <common/all-versions/default/HidlUtils.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
@@ -17,51 +17,10 @@
|
||||
#ifndef android_hardware_audio_V2_0_Hidl_Utils_H_
|
||||
#define android_hardware_audio_V2_0_Hidl_Utils_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <android/hardware/audio/common/2.0/types.h>
|
||||
#include <system/audio.h>
|
||||
|
||||
using ::android::hardware::audio::common::V2_0::AudioConfig;
|
||||
using ::android::hardware::audio::common::V2_0::AudioGain;
|
||||
using ::android::hardware::audio::common::V2_0::AudioGainConfig;
|
||||
using ::android::hardware::audio::common::V2_0::AudioOffloadInfo;
|
||||
using ::android::hardware::audio::common::V2_0::AudioPort;
|
||||
using ::android::hardware::audio::common::V2_0::AudioPortConfig;
|
||||
using ::android::hardware::audio::common::V2_0::Uuid;
|
||||
using ::android::hardware::hidl_vec;
|
||||
|
||||
namespace android {
|
||||
|
||||
class HidlUtils {
|
||||
public:
|
||||
static void audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config);
|
||||
static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig);
|
||||
static void audioGainConfigFromHal(
|
||||
const struct audio_gain_config& halConfig, AudioGainConfig* config);
|
||||
static void audioGainConfigToHal(
|
||||
const AudioGainConfig& config, struct audio_gain_config* halConfig);
|
||||
static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain);
|
||||
static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain);
|
||||
static void audioOffloadInfoFromHal(
|
||||
const audio_offload_info_t& halOffload, AudioOffloadInfo* offload);
|
||||
static void audioOffloadInfoToHal(
|
||||
const AudioOffloadInfo& offload, audio_offload_info_t* halOffload);
|
||||
static void audioPortConfigFromHal(
|
||||
const struct audio_port_config& halConfig, AudioPortConfig* config);
|
||||
static void audioPortConfigToHal(
|
||||
const AudioPortConfig& config, struct audio_port_config* halConfig);
|
||||
static void audioPortConfigsFromHal(
|
||||
unsigned int numHalConfigs, const struct audio_port_config *halConfigs,
|
||||
hidl_vec<AudioPortConfig> *configs);
|
||||
static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal(
|
||||
const hidl_vec<AudioPortConfig>& configs);
|
||||
static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port);
|
||||
static void audioPortToHal(const AudioPort& port, struct audio_port* halPort);
|
||||
static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid);
|
||||
static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <common/all-versions/default/HidlUtils.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // android_hardware_audio_V2_0_Hidl_Utils_H_
|
||||
|
||||
41
audio/common/2.0/default/VersionUtils.h
Normal file
41
audio/common/2.0/default/VersionUtils.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
|
||||
#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
|
||||
|
||||
#include <android/hardware/audio/common/2.0/types.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace common {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
typedef common::V2_0::AudioDevice AudioDeviceBitfield;
|
||||
typedef common::V2_0::AudioChannelMask AudioChannelBitfield;
|
||||
typedef common::V2_0::AudioOutputFlag AudioOutputFlagBitfield;
|
||||
typedef common::V2_0::AudioInputFlag AudioInputFlagBitfield;
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
|
||||
48
audio/common/4.0/Android.bp
Normal file
48
audio/common/4.0/Android.bp
Normal file
@@ -0,0 +1,48 @@
|
||||
// This file is autogenerated by hidl-gen -Landroidbp.
|
||||
|
||||
hidl_interface {
|
||||
name: "android.hardware.audio.common@4.0",
|
||||
root: "android.hardware",
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
srcs: [
|
||||
"types.hal",
|
||||
],
|
||||
types: [
|
||||
"AudioChannelMask",
|
||||
"AudioConfig",
|
||||
"AudioContentType",
|
||||
"AudioDevice",
|
||||
"AudioFormat",
|
||||
"AudioGain",
|
||||
"AudioGainConfig",
|
||||
"AudioGainMode",
|
||||
"AudioHandleConsts",
|
||||
"AudioInputFlag",
|
||||
"AudioMixLatencyClass",
|
||||
"AudioMode",
|
||||
"AudioOffloadInfo",
|
||||
"AudioOutputFlag",
|
||||
"AudioPort",
|
||||
"AudioPortConfig",
|
||||
"AudioPortConfigDeviceExt",
|
||||
"AudioPortConfigMask",
|
||||
"AudioPortConfigSessionExt",
|
||||
"AudioPortDeviceExt",
|
||||
"AudioPortMixExt",
|
||||
"AudioPortRole",
|
||||
"AudioPortSessionExt",
|
||||
"AudioPortType",
|
||||
"AudioSessionConsts",
|
||||
"AudioSource",
|
||||
"AudioStreamType",
|
||||
"AudioUsage",
|
||||
"FixedChannelCount",
|
||||
"ThreadInfo",
|
||||
"Uuid",
|
||||
],
|
||||
gen_java: false,
|
||||
gen_java_constants: true,
|
||||
}
|
||||
|
||||
47
audio/common/4.0/default/Android.bp
Normal file
47
audio/common/4.0/default/Android.bp
Normal file
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright (C) 2018 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.
|
||||
|
||||
cc_library_shared {
|
||||
name: "android.hardware.audio.common@4.0-util",
|
||||
defaults: ["hidl_defaults"],
|
||||
vendor_available: true,
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
srcs: [
|
||||
"HidlUtils.cpp",
|
||||
],
|
||||
|
||||
export_include_dirs: ["."],
|
||||
|
||||
static_libs: [
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libhidlbase",
|
||||
"android.hardware.audio.common-util",
|
||||
"android.hardware.audio.common@4.0",
|
||||
],
|
||||
export_shared_lib_headers: [
|
||||
"android.hardware.audio.common-util"
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"libaudio_system_headers",
|
||||
"libhardware_headers",
|
||||
],
|
||||
}
|
||||
21
audio/common/4.0/default/HidlUtils.cpp
Normal file
21
audio/common/4.0/default/HidlUtils.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 "HidlUtils.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <common/all-versions/default/HidlUtils.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
26
audio/common/4.0/default/HidlUtils.h
Normal file
26
audio/common/4.0/default/HidlUtils.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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_hardware_audio_V4_0_Hidl_Utils_H_
|
||||
#define android_hardware_audio_V4_0_Hidl_Utils_H_
|
||||
|
||||
#include <android/hardware/audio/common/4.0/types.h>
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <common/all-versions/default/HidlUtils.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // android_hardware_audio_V4_0_Hidl_Utils_H_
|
||||
41
audio/common/4.0/default/VersionUtils.h
Normal file
41
audio/common/4.0/default/VersionUtils.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
|
||||
#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
|
||||
|
||||
#include <android/hardware/audio/common/4.0/types.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace common {
|
||||
namespace V4_0 {
|
||||
namespace implementation {
|
||||
|
||||
typedef hidl_bitfield<common::V4_0::AudioDevice> AudioDeviceBitfield;
|
||||
typedef hidl_bitfield<common::V4_0::AudioChannelMask> AudioChannelBitfield;
|
||||
typedef hidl_bitfield<common::V4_0::AudioOutputFlag> AudioOutputFlagBitfield;
|
||||
typedef hidl_bitfield<common::V4_0::AudioInputFlag> AudioInputFlagBitfield;
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V4_0
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
|
||||
903
audio/common/4.0/types.hal
Normal file
903
audio/common/4.0/types.hal
Normal file
@@ -0,0 +1,903 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package android.hardware.audio.common@4.0;
|
||||
|
||||
/*
|
||||
*
|
||||
* IDs and Handles
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle type for identifying audio sources and sinks.
|
||||
*/
|
||||
typedef int32_t AudioIoHandle;
|
||||
|
||||
/**
|
||||
* Audio hw module handle functions or structures referencing a module.
|
||||
*/
|
||||
typedef int32_t AudioModuleHandle;
|
||||
|
||||
/**
|
||||
* Each port has a unique ID or handle allocated by policy manager.
|
||||
*/
|
||||
typedef int32_t AudioPortHandle;
|
||||
|
||||
/**
|
||||
* Each patch is identified by a handle at the interface used to create that
|
||||
* patch. For instance, when a patch is created by the audio HAL, the HAL
|
||||
* allocates and returns a handle. This handle is unique to a given audio HAL
|
||||
* hardware module. But the same patch receives another system wide unique
|
||||
* handle allocated by the framework. This unique handle is used for all
|
||||
* transactions inside the framework.
|
||||
*/
|
||||
typedef int32_t AudioPatchHandle;
|
||||
|
||||
/**
|
||||
* A HW synchronization source returned by the audio HAL.
|
||||
*/
|
||||
typedef uint32_t AudioHwSync;
|
||||
|
||||
/**
|
||||
* Each port has a unique ID or handle allocated by policy manager.
|
||||
*/
|
||||
@export(name="")
|
||||
enum AudioHandleConsts : int32_t {
|
||||
AUDIO_IO_HANDLE_NONE = 0,
|
||||
AUDIO_MODULE_HANDLE_NONE = 0,
|
||||
AUDIO_PORT_HANDLE_NONE = 0,
|
||||
AUDIO_PATCH_HANDLE_NONE = 0,
|
||||
};
|
||||
|
||||
/**
|
||||
* Commonly used structure for passing unique identifieds (UUID).
|
||||
* For the definition of UUID, refer to ITU-T X.667 spec.
|
||||
*/
|
||||
struct Uuid {
|
||||
uint32_t timeLow;
|
||||
uint16_t timeMid;
|
||||
uint16_t versionAndTimeHigh;
|
||||
uint16_t variantAndClockSeqHigh;
|
||||
uint8_t[6] node;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Audio streams
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Audio stream type describing the intended use case of a stream.
|
||||
*/
|
||||
@export(name="audio_stream_type_t", value_prefix="AUDIO_STREAM_")
|
||||
enum AudioStreamType : int32_t {
|
||||
// These values must kept in sync with
|
||||
// frameworks/base/media/java/android/media/AudioSystem.java
|
||||
DEFAULT = -1,
|
||||
MIN = 0,
|
||||
VOICE_CALL = 0,
|
||||
SYSTEM = 1,
|
||||
RING = 2,
|
||||
MUSIC = 3,
|
||||
ALARM = 4,
|
||||
NOTIFICATION = 5,
|
||||
BLUETOOTH_SCO = 6,
|
||||
ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be
|
||||
// routed to speaker
|
||||
DTMF = 8,
|
||||
TTS = 9, // Transmitted Through Speaker. Plays over speaker
|
||||
// only, silent on other devices
|
||||
ACCESSIBILITY = 10, // For accessibility talk back prompts
|
||||
};
|
||||
|
||||
@export(name="audio_source_t", value_prefix="AUDIO_SOURCE_")
|
||||
enum AudioSource : int32_t {
|
||||
// These values must kept in sync with
|
||||
// frameworks/base/media/java/android/media/MediaRecorder.java,
|
||||
// frameworks/av/services/audiopolicy/AudioPolicyService.cpp,
|
||||
// system/media/audio_effects/include/audio_effects/audio_effects_conf.h
|
||||
DEFAULT = 0,
|
||||
MIC = 1,
|
||||
VOICE_UPLINK = 2,
|
||||
VOICE_DOWNLINK = 3,
|
||||
VOICE_CALL = 4,
|
||||
CAMCORDER = 5,
|
||||
VOICE_RECOGNITION = 6,
|
||||
VOICE_COMMUNICATION = 7,
|
||||
/**
|
||||
* Source for the mix to be presented remotely. An example of remote
|
||||
* presentation is Wifi Display where a dongle attached to a TV can be used
|
||||
* to play the mix captured by this audio source.
|
||||
*/
|
||||
REMOTE_SUBMIX = 8,
|
||||
/**
|
||||
* Source for unprocessed sound. Usage examples include level measurement
|
||||
* and raw signal analysis.
|
||||
*/
|
||||
UNPROCESSED = 9,
|
||||
|
||||
FM_TUNER = 1998,
|
||||
};
|
||||
|
||||
typedef int32_t AudioSession;
|
||||
/**
|
||||
* Special audio session values.
|
||||
*/
|
||||
@export(name="audio_session_t", value_prefix="AUDIO_SESSION_")
|
||||
enum AudioSessionConsts : int32_t {
|
||||
/**
|
||||
* Session for effects attached to a particular output stream
|
||||
* (value must be less than 0)
|
||||
*/
|
||||
OUTPUT_STAGE = -1,
|
||||
/**
|
||||
* Session for effects applied to output mix. These effects can
|
||||
* be moved by audio policy manager to another output stream
|
||||
* (value must be 0)
|
||||
*/
|
||||
OUTPUT_MIX = 0,
|
||||
/**
|
||||
* Application does not specify an explicit session ID to be used, and
|
||||
* requests a new session ID to be allocated. Corresponds to
|
||||
* AudioManager.AUDIO_SESSION_ID_GENERATE and
|
||||
* AudioSystem.AUDIO_SESSION_ALLOCATE.
|
||||
*/
|
||||
ALLOCATE = 0,
|
||||
/**
|
||||
* For use with AudioRecord::start(), this indicates no trigger session.
|
||||
* It is also used with output tracks and patch tracks, which never have a
|
||||
* session.
|
||||
*/
|
||||
NONE = 0
|
||||
};
|
||||
|
||||
/**
|
||||
* Audio format is a 32-bit word that consists of:
|
||||
* main format field (upper 8 bits)
|
||||
* sub format field (lower 24 bits).
|
||||
*
|
||||
* The main format indicates the main codec type. The sub format field indicates
|
||||
* options and parameters for each format. The sub format is mainly used for
|
||||
* record to indicate for instance the requested bitrate or profile. It can
|
||||
* also be used for certain formats to give informations not present in the
|
||||
* encoded audio stream (e.g. octet alignement for AMR).
|
||||
*/
|
||||
@export(name="audio_format_t", value_prefix="AUDIO_FORMAT_")
|
||||
enum AudioFormat : uint32_t {
|
||||
INVALID = 0xFFFFFFFFUL,
|
||||
DEFAULT = 0,
|
||||
PCM = 0x00000000UL,
|
||||
MP3 = 0x01000000UL,
|
||||
AMR_NB = 0x02000000UL,
|
||||
AMR_WB = 0x03000000UL,
|
||||
AAC = 0x04000000UL,
|
||||
/** Deprecated, Use AAC_HE_V1 */
|
||||
HE_AAC_V1 = 0x05000000UL,
|
||||
/** Deprecated, Use AAC_HE_V2 */
|
||||
HE_AAC_V2 = 0x06000000UL,
|
||||
VORBIS = 0x07000000UL,
|
||||
OPUS = 0x08000000UL,
|
||||
AC3 = 0x09000000UL,
|
||||
E_AC3 = 0x0A000000UL,
|
||||
DTS = 0x0B000000UL,
|
||||
DTS_HD = 0x0C000000UL,
|
||||
/** IEC61937 is encoded audio wrapped in 16-bit PCM. */
|
||||
IEC61937 = 0x0D000000UL,
|
||||
DOLBY_TRUEHD = 0x0E000000UL,
|
||||
EVRC = 0x10000000UL,
|
||||
EVRCB = 0x11000000UL,
|
||||
EVRCWB = 0x12000000UL,
|
||||
EVRCNW = 0x13000000UL,
|
||||
AAC_ADIF = 0x14000000UL,
|
||||
WMA = 0x15000000UL,
|
||||
WMA_PRO = 0x16000000UL,
|
||||
AMR_WB_PLUS = 0x17000000UL,
|
||||
MP2 = 0x18000000UL,
|
||||
QCELP = 0x19000000UL,
|
||||
DSD = 0x1A000000UL,
|
||||
FLAC = 0x1B000000UL,
|
||||
ALAC = 0x1C000000UL,
|
||||
APE = 0x1D000000UL,
|
||||
AAC_ADTS = 0x1E000000UL,
|
||||
SBC = 0x1F000000UL,
|
||||
APTX = 0x20000000UL,
|
||||
APTX_HD = 0x21000000UL,
|
||||
AC4 = 0x22000000UL,
|
||||
LDAC = 0x23000000UL,
|
||||
/** Dolby Metadata-enhanced Audio Transmission */
|
||||
MAT = 0x24000000UL,
|
||||
/** Deprecated */
|
||||
MAIN_MASK = 0xFF000000UL,
|
||||
SUB_MASK = 0x00FFFFFFUL,
|
||||
|
||||
/* Subformats */
|
||||
PCM_SUB_16_BIT = 0x1, // PCM signed 16 bits
|
||||
PCM_SUB_8_BIT = 0x2, // PCM unsigned 8 bits
|
||||
PCM_SUB_32_BIT = 0x3, // PCM signed .31 fixed point
|
||||
PCM_SUB_8_24_BIT = 0x4, // PCM signed 8.23 fixed point
|
||||
PCM_SUB_FLOAT = 0x5, // PCM single-precision float pt
|
||||
PCM_SUB_24_BIT_PACKED = 0x6, // PCM signed .23 fix pt (3 bytes)
|
||||
|
||||
MP3_SUB_NONE = 0x0,
|
||||
|
||||
AMR_SUB_NONE = 0x0,
|
||||
|
||||
AAC_SUB_MAIN = 0x1,
|
||||
AAC_SUB_LC = 0x2,
|
||||
AAC_SUB_SSR = 0x4,
|
||||
AAC_SUB_LTP = 0x8,
|
||||
AAC_SUB_HE_V1 = 0x10,
|
||||
AAC_SUB_SCALABLE = 0x20,
|
||||
AAC_SUB_ERLC = 0x40,
|
||||
AAC_SUB_LD = 0x80,
|
||||
AAC_SUB_HE_V2 = 0x100,
|
||||
AAC_SUB_ELD = 0x200,
|
||||
AAC_SUB_XHE = 0x300,
|
||||
|
||||
VORBIS_SUB_NONE = 0x0,
|
||||
|
||||
E_AC3_SUB_JOC = 0x1,
|
||||
|
||||
MAT_SUB_1_0 = 0x1,
|
||||
MAT_SUB_2_0 = 0x2,
|
||||
MAT_SUB_2_1 = 0x3,
|
||||
|
||||
/* Aliases */
|
||||
/** note != AudioFormat.ENCODING_PCM_16BIT */
|
||||
PCM_16_BIT = (PCM | PCM_SUB_16_BIT),
|
||||
/** note != AudioFormat.ENCODING_PCM_8BIT */
|
||||
PCM_8_BIT = (PCM | PCM_SUB_8_BIT),
|
||||
PCM_32_BIT = (PCM | PCM_SUB_32_BIT),
|
||||
PCM_8_24_BIT = (PCM | PCM_SUB_8_24_BIT),
|
||||
PCM_FLOAT = (PCM | PCM_SUB_FLOAT),
|
||||
PCM_24_BIT_PACKED = (PCM | PCM_SUB_24_BIT_PACKED),
|
||||
AAC_MAIN = (AAC | AAC_SUB_MAIN),
|
||||
AAC_LC = (AAC | AAC_SUB_LC),
|
||||
AAC_SSR = (AAC | AAC_SUB_SSR),
|
||||
AAC_LTP = (AAC | AAC_SUB_LTP),
|
||||
AAC_HE_V1 = (AAC | AAC_SUB_HE_V1),
|
||||
AAC_SCALABLE = (AAC | AAC_SUB_SCALABLE),
|
||||
AAC_ERLC = (AAC | AAC_SUB_ERLC),
|
||||
AAC_LD = (AAC | AAC_SUB_LD),
|
||||
AAC_HE_V2 = (AAC | AAC_SUB_HE_V2),
|
||||
AAC_ELD = (AAC | AAC_SUB_ELD),
|
||||
AAC_XHE = (AAC | AAC_SUB_XHE),
|
||||
AAC_ADTS_MAIN = (AAC_ADTS | AAC_SUB_MAIN),
|
||||
AAC_ADTS_LC = (AAC_ADTS | AAC_SUB_LC),
|
||||
AAC_ADTS_SSR = (AAC_ADTS | AAC_SUB_SSR),
|
||||
AAC_ADTS_LTP = (AAC_ADTS | AAC_SUB_LTP),
|
||||
AAC_ADTS_HE_V1 = (AAC_ADTS | AAC_SUB_HE_V1),
|
||||
AAC_ADTS_SCALABLE = (AAC_ADTS | AAC_SUB_SCALABLE),
|
||||
AAC_ADTS_ERLC = (AAC_ADTS | AAC_SUB_ERLC),
|
||||
AAC_ADTS_LD = (AAC_ADTS | AAC_SUB_LD),
|
||||
AAC_ADTS_HE_V2 = (AAC_ADTS | AAC_SUB_HE_V2),
|
||||
AAC_ADTS_ELD = (AAC_ADTS | AAC_SUB_ELD),
|
||||
AAC_ADTS_XHE = (AAC_ADTS | AAC_SUB_XHE),
|
||||
E_AC3_JOC = (E_AC3 | E_AC3_SUB_JOC),
|
||||
MAT_1_0 = (MAT | MAT_SUB_1_0),
|
||||
MAT_2_0 = (MAT | MAT_SUB_2_0),
|
||||
MAT_2_1 = (MAT | MAT_SUB_2_1),
|
||||
};
|
||||
|
||||
/**
|
||||
* Usage of these values highlights places in the code that use 2- or 8- channel
|
||||
* assumptions.
|
||||
*/
|
||||
@export(name="")
|
||||
enum FixedChannelCount : int32_t {
|
||||
FCC_2 = 2, // This is typically due to legacy implementation of stereo I/O
|
||||
FCC_8 = 8 // This is typically due to audio mixer and resampler limitations
|
||||
};
|
||||
|
||||
/**
|
||||
* A channel mask per se only defines the presence or absence of a channel, not
|
||||
* the order. See AUDIO_INTERLEAVE_* for the platform convention of order.
|
||||
*
|
||||
* AudioChannelMask is an opaque type and its internal layout should not be
|
||||
* assumed as it may change in the future. Instead, always use functions
|
||||
* to examine it.
|
||||
*
|
||||
* These are the current representations:
|
||||
*
|
||||
* REPRESENTATION_POSITION
|
||||
* is a channel mask representation for position assignment. Each low-order
|
||||
* bit corresponds to the spatial position of a transducer (output), or
|
||||
* interpretation of channel (input). The user of a channel mask needs to
|
||||
* know the context of whether it is for output or input. The constants
|
||||
* OUT_* or IN_* apply to the bits portion. It is not permitted for no bits
|
||||
* to be set.
|
||||
*
|
||||
* REPRESENTATION_INDEX
|
||||
* is a channel mask representation for index assignment. Each low-order
|
||||
* bit corresponds to a selected channel. There is no platform
|
||||
* interpretation of the various bits. There is no concept of output or
|
||||
* input. It is not permitted for no bits to be set.
|
||||
*
|
||||
* All other representations are reserved for future use.
|
||||
*
|
||||
* Warning: current representation distinguishes between input and output, but
|
||||
* this will not the be case in future revisions of the platform. Wherever there
|
||||
* is an ambiguity between input and output that is currently resolved by
|
||||
* checking the channel mask, the implementer should look for ways to fix it
|
||||
* with additional information outside of the mask.
|
||||
*/
|
||||
@export(name="", value_prefix="AUDIO_CHANNEL_")
|
||||
enum AudioChannelMask : uint32_t {
|
||||
/** must be 0 for compatibility */
|
||||
REPRESENTATION_POSITION = 0,
|
||||
/** 1 is reserved for future use */
|
||||
REPRESENTATION_INDEX = 2,
|
||||
/* 3 is reserved for future use */
|
||||
|
||||
/** These can be a complete value of AudioChannelMask */
|
||||
NONE = 0x0,
|
||||
INVALID = 0xC0000000,
|
||||
|
||||
/*
|
||||
* These can be the bits portion of an AudioChannelMask
|
||||
* with representation REPRESENTATION_POSITION.
|
||||
*/
|
||||
|
||||
/** output channels */
|
||||
OUT_FRONT_LEFT = 0x1,
|
||||
OUT_FRONT_RIGHT = 0x2,
|
||||
OUT_FRONT_CENTER = 0x4,
|
||||
OUT_LOW_FREQUENCY = 0x8,
|
||||
OUT_BACK_LEFT = 0x10,
|
||||
OUT_BACK_RIGHT = 0x20,
|
||||
OUT_FRONT_LEFT_OF_CENTER = 0x40,
|
||||
OUT_FRONT_RIGHT_OF_CENTER = 0x80,
|
||||
OUT_BACK_CENTER = 0x100,
|
||||
OUT_SIDE_LEFT = 0x200,
|
||||
OUT_SIDE_RIGHT = 0x400,
|
||||
OUT_TOP_CENTER = 0x800,
|
||||
OUT_TOP_FRONT_LEFT = 0x1000,
|
||||
OUT_TOP_FRONT_CENTER = 0x2000,
|
||||
OUT_TOP_FRONT_RIGHT = 0x4000,
|
||||
OUT_TOP_BACK_LEFT = 0x8000,
|
||||
OUT_TOP_BACK_CENTER = 0x10000,
|
||||
OUT_TOP_BACK_RIGHT = 0x20000,
|
||||
OUT_TOP_SIDE_LEFT = 0x40000,
|
||||
OUT_TOP_SIDE_RIGHT = 0x80000,
|
||||
|
||||
OUT_MONO = OUT_FRONT_LEFT,
|
||||
OUT_STEREO = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT),
|
||||
OUT_2POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_LOW_FREQUENCY),
|
||||
OUT_2POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
|
||||
OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
|
||||
OUT_2POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
|
||||
OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT |
|
||||
OUT_LOW_FREQUENCY),
|
||||
OUT_3POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT |
|
||||
OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
|
||||
OUT_3POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT |
|
||||
OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT |
|
||||
OUT_LOW_FREQUENCY),
|
||||
OUT_QUAD = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
|
||||
OUT_BACK_LEFT | OUT_BACK_RIGHT),
|
||||
OUT_QUAD_BACK = OUT_QUAD,
|
||||
/** like OUT_QUAD_BACK with *_SIDE_* instead of *_BACK_* */
|
||||
OUT_QUAD_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
|
||||
OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
|
||||
OUT_SURROUND = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
|
||||
OUT_FRONT_CENTER | OUT_BACK_CENTER),
|
||||
OUT_PENTA = (OUT_QUAD | OUT_FRONT_CENTER),
|
||||
OUT_5POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
|
||||
OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
|
||||
OUT_BACK_LEFT | OUT_BACK_RIGHT),
|
||||
OUT_5POINT1_BACK = OUT_5POINT1,
|
||||
/** like OUT_5POINT1_BACK with *_SIDE_* instead of *_BACK_* */
|
||||
OUT_5POINT1_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
|
||||
OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
|
||||
OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
|
||||
OUT_5POINT1POINT2 = (OUT_5POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
|
||||
OUT_5POINT1POINT4 = (OUT_5POINT1 |
|
||||
OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT |
|
||||
OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT),
|
||||
OUT_6POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
|
||||
OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
|
||||
OUT_BACK_LEFT | OUT_BACK_RIGHT |
|
||||
OUT_BACK_CENTER),
|
||||
/** matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND */
|
||||
OUT_7POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
|
||||
OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
|
||||
OUT_BACK_LEFT | OUT_BACK_RIGHT |
|
||||
OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
|
||||
OUT_7POINT1POINT2 = (OUT_7POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
|
||||
OUT_7POINT1POINT4 = (OUT_7POINT1 |
|
||||
OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT |
|
||||
OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT),
|
||||
// Note that the 2.0 OUT_ALL* have been moved to helper functions
|
||||
|
||||
/* These are bits only, not complete values */
|
||||
|
||||
/** input channels */
|
||||
IN_LEFT = 0x4,
|
||||
IN_RIGHT = 0x8,
|
||||
IN_FRONT = 0x10,
|
||||
IN_BACK = 0x20,
|
||||
IN_LEFT_PROCESSED = 0x40,
|
||||
IN_RIGHT_PROCESSED = 0x80,
|
||||
IN_FRONT_PROCESSED = 0x100,
|
||||
IN_BACK_PROCESSED = 0x200,
|
||||
IN_PRESSURE = 0x400,
|
||||
IN_X_AXIS = 0x800,
|
||||
IN_Y_AXIS = 0x1000,
|
||||
IN_Z_AXIS = 0x2000,
|
||||
IN_BACK_LEFT = 0x10000,
|
||||
IN_BACK_RIGHT = 0x20000,
|
||||
IN_CENTER = 0x40000,
|
||||
IN_LOW_FREQUENCY = 0x100000,
|
||||
IN_TOP_LEFT = 0x200000,
|
||||
IN_TOP_RIGHT = 0x400000,
|
||||
|
||||
IN_VOICE_UPLINK = 0x4000,
|
||||
IN_VOICE_DNLINK = 0x8000,
|
||||
|
||||
IN_MONO = IN_FRONT,
|
||||
IN_STEREO = (IN_LEFT | IN_RIGHT),
|
||||
IN_FRONT_BACK = (IN_FRONT | IN_BACK),
|
||||
IN_6 = (IN_LEFT | IN_RIGHT |
|
||||
IN_FRONT | IN_BACK |
|
||||
IN_LEFT_PROCESSED | IN_RIGHT_PROCESSED),
|
||||
IN_2POINT0POINT2 = (IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT),
|
||||
IN_2POINT1POINT2 = (IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT |
|
||||
IN_LOW_FREQUENCY),
|
||||
IN_3POINT0POINT2 = (IN_LEFT | IN_CENTER | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT),
|
||||
IN_3POINT1POINT2 = (IN_LEFT | IN_CENTER | IN_RIGHT |
|
||||
IN_TOP_LEFT | IN_TOP_RIGHT | IN_LOW_FREQUENCY),
|
||||
IN_5POINT1 = (IN_LEFT | IN_CENTER | IN_RIGHT |
|
||||
IN_BACK_LEFT | IN_BACK_RIGHT | IN_LOW_FREQUENCY),
|
||||
IN_VOICE_UPLINK_MONO = (IN_VOICE_UPLINK | IN_MONO),
|
||||
IN_VOICE_DNLINK_MONO = (IN_VOICE_DNLINK | IN_MONO),
|
||||
IN_VOICE_CALL_MONO = (IN_VOICE_UPLINK_MONO |
|
||||
IN_VOICE_DNLINK_MONO),
|
||||
// Note that the 2.0 IN_ALL* have been moved to helper functions
|
||||
|
||||
COUNT_MAX = 30,
|
||||
INDEX_HDR = REPRESENTATION_INDEX << COUNT_MAX,
|
||||
INDEX_MASK_1 = INDEX_HDR | ((1 << 1) - 1),
|
||||
INDEX_MASK_2 = INDEX_HDR | ((1 << 2) - 1),
|
||||
INDEX_MASK_3 = INDEX_HDR | ((1 << 3) - 1),
|
||||
INDEX_MASK_4 = INDEX_HDR | ((1 << 4) - 1),
|
||||
INDEX_MASK_5 = INDEX_HDR | ((1 << 5) - 1),
|
||||
INDEX_MASK_6 = INDEX_HDR | ((1 << 6) - 1),
|
||||
INDEX_MASK_7 = INDEX_HDR | ((1 << 7) - 1),
|
||||
INDEX_MASK_8 = INDEX_HDR | ((1 << 8) - 1)
|
||||
};
|
||||
|
||||
/**
|
||||
* Major modes for a mobile device. The current mode setting affects audio
|
||||
* routing.
|
||||
*/
|
||||
@export(name="audio_mode_t", value_prefix="AUDIO_MODE_")
|
||||
enum AudioMode : int32_t {
|
||||
NORMAL = 0,
|
||||
RINGTONE = 1,
|
||||
/** Calls handled by the telephony stack (Eg: PSTN). */
|
||||
IN_CALL = 2,
|
||||
/** Calls handled by apps (Eg: Hangout). */
|
||||
IN_COMMUNICATION = 3,
|
||||
};
|
||||
|
||||
@export(name="", value_prefix="AUDIO_DEVICE_")
|
||||
enum AudioDevice : uint32_t {
|
||||
NONE = 0x0,
|
||||
/** reserved bits */
|
||||
BIT_IN = 0x80000000,
|
||||
BIT_DEFAULT = 0x40000000,
|
||||
/** output devices */
|
||||
OUT_EARPIECE = 0x1,
|
||||
OUT_SPEAKER = 0x2,
|
||||
OUT_WIRED_HEADSET = 0x4,
|
||||
OUT_WIRED_HEADPHONE = 0x8,
|
||||
OUT_BLUETOOTH_SCO = 0x10,
|
||||
OUT_BLUETOOTH_SCO_HEADSET = 0x20,
|
||||
OUT_BLUETOOTH_SCO_CARKIT = 0x40,
|
||||
OUT_BLUETOOTH_A2DP = 0x80,
|
||||
OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
|
||||
OUT_BLUETOOTH_A2DP_SPEAKER = 0x200,
|
||||
OUT_AUX_DIGITAL = 0x400,
|
||||
OUT_HDMI = OUT_AUX_DIGITAL,
|
||||
/** uses an analog connection (multiplexed over the USB pins for instance) */
|
||||
OUT_ANLG_DOCK_HEADSET = 0x800,
|
||||
OUT_DGTL_DOCK_HEADSET = 0x1000,
|
||||
/** USB accessory mode: Android device is USB device and dock is USB host */
|
||||
OUT_USB_ACCESSORY = 0x2000,
|
||||
/** USB host mode: Android device is USB host and dock is USB device */
|
||||
OUT_USB_DEVICE = 0x4000,
|
||||
OUT_REMOTE_SUBMIX = 0x8000,
|
||||
/** Telephony voice TX path */
|
||||
OUT_TELEPHONY_TX = 0x10000,
|
||||
/** Analog jack with line impedance detected */
|
||||
OUT_LINE = 0x20000,
|
||||
/** HDMI Audio Return Channel */
|
||||
OUT_HDMI_ARC = 0x40000,
|
||||
/** S/PDIF out */
|
||||
OUT_SPDIF = 0x80000,
|
||||
/** FM transmitter out */
|
||||
OUT_FM = 0x100000,
|
||||
/** Line out for av devices */
|
||||
OUT_AUX_LINE = 0x200000,
|
||||
/** limited-output speaker device for acoustic safety */
|
||||
OUT_SPEAKER_SAFE = 0x400000,
|
||||
OUT_IP = 0x800000,
|
||||
/** audio bus implemented by the audio system (e.g an MOST stereo channel) */
|
||||
OUT_BUS = 0x1000000,
|
||||
OUT_PROXY = 0x2000000,
|
||||
OUT_USB_HEADSET = 0x4000000,
|
||||
OUT_HEARING_AID = 0x8000000,
|
||||
OUT_ECHO_CANCELLER = 0x10000000,
|
||||
OUT_DEFAULT = BIT_DEFAULT,
|
||||
// Note that the 2.0 OUT_ALL* have been moved to helper functions
|
||||
|
||||
/** input devices */
|
||||
IN_COMMUNICATION = BIT_IN | 0x1,
|
||||
IN_AMBIENT = BIT_IN | 0x2,
|
||||
IN_BUILTIN_MIC = BIT_IN | 0x4,
|
||||
IN_BLUETOOTH_SCO_HEADSET = BIT_IN | 0x8,
|
||||
IN_WIRED_HEADSET = BIT_IN | 0x10,
|
||||
IN_AUX_DIGITAL = BIT_IN | 0x20,
|
||||
IN_HDMI = IN_AUX_DIGITAL,
|
||||
/** Telephony voice RX path */
|
||||
IN_VOICE_CALL = BIT_IN | 0x40,
|
||||
IN_TELEPHONY_RX = IN_VOICE_CALL,
|
||||
IN_BACK_MIC = BIT_IN | 0x80,
|
||||
IN_REMOTE_SUBMIX = BIT_IN | 0x100,
|
||||
IN_ANLG_DOCK_HEADSET = BIT_IN | 0x200,
|
||||
IN_DGTL_DOCK_HEADSET = BIT_IN | 0x400,
|
||||
IN_USB_ACCESSORY = BIT_IN | 0x800,
|
||||
IN_USB_DEVICE = BIT_IN | 0x1000,
|
||||
/** FM tuner input */
|
||||
IN_FM_TUNER = BIT_IN | 0x2000,
|
||||
/** TV tuner input */
|
||||
IN_TV_TUNER = BIT_IN | 0x4000,
|
||||
/** Analog jack with line impedance detected */
|
||||
IN_LINE = BIT_IN | 0x8000,
|
||||
/** S/PDIF in */
|
||||
IN_SPDIF = BIT_IN | 0x10000,
|
||||
IN_BLUETOOTH_A2DP = BIT_IN | 0x20000,
|
||||
IN_LOOPBACK = BIT_IN | 0x40000,
|
||||
IN_IP = BIT_IN | 0x80000,
|
||||
/** audio bus implemented by the audio system (e.g an MOST stereo channel) */
|
||||
IN_BUS = BIT_IN | 0x100000,
|
||||
IN_PROXY = BIT_IN | 0x1000000,
|
||||
IN_USB_HEADSET = BIT_IN | 0x2000000,
|
||||
IN_BLUETOOTH_BLE = BIT_IN | 0x4000000,
|
||||
IN_DEFAULT = BIT_IN | BIT_DEFAULT,
|
||||
|
||||
// Note that the 2.0 IN_ALL* have been moved to helper functions
|
||||
};
|
||||
|
||||
/**
|
||||
* The audio output flags serve two purposes:
|
||||
*
|
||||
* - when an AudioTrack is created they indicate a "wish" to be connected to an
|
||||
* output stream with attributes corresponding to the specified flags;
|
||||
*
|
||||
* - when present in an output profile descriptor listed for a particular audio
|
||||
* hardware module, they indicate that an output stream can be opened that
|
||||
* supports the attributes indicated by the flags.
|
||||
*
|
||||
* The audio policy manager will try to match the flags in the request
|
||||
* (when getOuput() is called) to an available output stream.
|
||||
*/
|
||||
@export(name="audio_output_flags_t", value_prefix="AUDIO_OUTPUT_FLAG_")
|
||||
enum AudioOutputFlag : int32_t {
|
||||
NONE = 0x0, // no attributes
|
||||
DIRECT = 0x1, // this output directly connects a track
|
||||
// to one output stream: no software mixer
|
||||
PRIMARY = 0x2, // this output is the primary output of the device. It is
|
||||
// unique and must be present. It is opened by default and
|
||||
// receives routing, audio mode and volume controls related
|
||||
// to voice calls.
|
||||
FAST = 0x4, // output supports "fast tracks", defined elsewhere
|
||||
DEEP_BUFFER = 0x8, // use deep audio buffers
|
||||
COMPRESS_OFFLOAD = 0x10, // offload playback of compressed streams to
|
||||
// hardware codec
|
||||
NON_BLOCKING = 0x20, // use non-blocking write
|
||||
HW_AV_SYNC = 0x40, // output uses a hardware A/V sync
|
||||
TTS = 0x80, // output for streams transmitted through speaker at a
|
||||
// sample rate high enough to accommodate lower-range
|
||||
// ultrasonic p/b
|
||||
RAW = 0x100, // minimize signal processing
|
||||
SYNC = 0x200, // synchronize I/O streams
|
||||
IEC958_NONAUDIO = 0x400, // Audio stream contains compressed audio in SPDIF
|
||||
// data bursts, not PCM.
|
||||
DIRECT_PCM = 0x2000, // Audio stream containing PCM data that needs
|
||||
// to pass through compress path for DSP post proc.
|
||||
MMAP_NOIRQ = 0x4000, // output operates in MMAP no IRQ mode.
|
||||
VOIP_RX = 0x8000, // preferred output for VoIP calls.
|
||||
/** preferred output for call music */
|
||||
INCALL_MUSIC = 0x10000,
|
||||
};
|
||||
|
||||
/**
|
||||
* The audio input flags are analogous to audio output flags.
|
||||
* Currently they are used only when an AudioRecord is created,
|
||||
* to indicate a preference to be connected to an input stream with
|
||||
* attributes corresponding to the specified flags.
|
||||
*/
|
||||
@export(name="audio_input_flags_t", value_prefix="AUDIO_INPUT_FLAG_")
|
||||
enum AudioInputFlag : int32_t {
|
||||
NONE = 0x0, // no attributes
|
||||
FAST = 0x1, // prefer an input that supports "fast tracks"
|
||||
HW_HOTWORD = 0x2, // prefer an input that captures from hw hotword source
|
||||
RAW = 0x4, // minimize signal processing
|
||||
SYNC = 0x8, // synchronize I/O streams
|
||||
MMAP_NOIRQ = 0x10, // input operates in MMAP no IRQ mode.
|
||||
VOIP_TX = 0x20, // preferred input for VoIP calls.
|
||||
HW_AV_SYNC = 0x40, // input connected to an output that uses a hardware A/V sync
|
||||
};
|
||||
|
||||
@export(name="audio_usage_t", value_prefix="AUDIO_USAGE_")
|
||||
enum AudioUsage : int32_t {
|
||||
// These values must kept in sync with
|
||||
// frameworks/base/media/java/android/media/AudioAttributes.java
|
||||
// Note that not all framework values are exposed
|
||||
UNKNOWN = 0,
|
||||
MEDIA = 1,
|
||||
VOICE_COMMUNICATION = 2,
|
||||
VOICE_COMMUNICATION_SIGNALLING = 3,
|
||||
ALARM = 4,
|
||||
NOTIFICATION = 5,
|
||||
NOTIFICATION_TELEPHONY_RINGTONE = 6,
|
||||
ASSISTANCE_ACCESSIBILITY = 11,
|
||||
ASSISTANCE_NAVIGATION_GUIDANCE = 12,
|
||||
ASSISTANCE_SONIFICATION = 13,
|
||||
GAME = 14,
|
||||
VIRTUAL_SOURCE = 15,
|
||||
ASSISTANT = 16,
|
||||
};
|
||||
|
||||
/** Type of audio generated by an application. */
|
||||
@export(name="audio_content_type_t", value_prefix="AUDIO_CONTENT_TYPE_")
|
||||
enum AudioContentType : uint32_t {
|
||||
// Do not change these values without updating their counterparts
|
||||
// in frameworks/base/media/java/android/media/AudioAttributes.java
|
||||
UNKNOWN = 0,
|
||||
SPEECH = 1,
|
||||
MUSIC = 2,
|
||||
MOVIE = 3,
|
||||
SONIFICATION = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional information about the stream passed to hardware decoders.
|
||||
*/
|
||||
struct AudioOffloadInfo {
|
||||
uint32_t sampleRateHz;
|
||||
bitfield<AudioChannelMask> channelMask;
|
||||
AudioFormat format;
|
||||
AudioStreamType streamType;
|
||||
uint32_t bitRatePerSecond;
|
||||
int64_t durationMicroseconds; // -1 if unknown
|
||||
bool hasVideo;
|
||||
bool isStreaming;
|
||||
uint32_t bitWidth;
|
||||
uint32_t bufferSize;
|
||||
AudioUsage usage;
|
||||
};
|
||||
|
||||
/**
|
||||
* Commonly used audio stream configuration parameters.
|
||||
*/
|
||||
struct AudioConfig {
|
||||
uint32_t sampleRateHz;
|
||||
bitfield<AudioChannelMask> channelMask;
|
||||
AudioFormat format;
|
||||
AudioOffloadInfo offloadInfo;
|
||||
uint64_t frameCount;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Volume control
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Type of gain control exposed by an audio port.
|
||||
*/
|
||||
@export(name="", value_prefix="AUDIO_GAIN_MODE_")
|
||||
enum AudioGainMode : uint32_t {
|
||||
JOINT = 0x1, // supports joint channel gain control
|
||||
CHANNELS = 0x2, // supports separate channel gain control
|
||||
RAMP = 0x4 // supports gain ramps
|
||||
};
|
||||
|
||||
/**
|
||||
* An audio_gain struct is a representation of a gain stage.
|
||||
* A gain stage is always attached to an audio port.
|
||||
*/
|
||||
struct AudioGain {
|
||||
bitfield<AudioGainMode> mode;
|
||||
bitfield<AudioChannelMask> channelMask; // channels which gain an be controlled
|
||||
int32_t minValue; // minimum gain value in millibels
|
||||
int32_t maxValue; // maximum gain value in millibels
|
||||
int32_t defaultValue; // default gain value in millibels
|
||||
uint32_t stepValue; // gain step in millibels
|
||||
uint32_t minRampMs; // minimum ramp duration in ms
|
||||
uint32_t maxRampMs; // maximum ramp duration in ms
|
||||
};
|
||||
|
||||
/**
|
||||
* The gain configuration structure is used to get or set the gain values of a
|
||||
* given port.
|
||||
*/
|
||||
struct AudioGainConfig {
|
||||
int32_t index; // index of the corresponding AudioGain in AudioPort.gains
|
||||
AudioGainMode mode;
|
||||
AudioChannelMask channelMask; // channels which gain value follows
|
||||
/**
|
||||
* 4 = sizeof(AudioChannelMask),
|
||||
* 8 is not "FCC_8", so it won't need to be changed for > 8 channels.
|
||||
* Gain values in millibels for each channel ordered from LSb to MSb in
|
||||
* channel mask. The number of values is 1 in joint mode or
|
||||
* popcount(channel_mask).
|
||||
*/
|
||||
int32_t[4 * 8] values;
|
||||
uint32_t rampDurationMs; // ramp duration in ms
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Routing control
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Types defined here are used to describe an audio source or sink at internal
|
||||
* framework interfaces (audio policy, patch panel) or at the audio HAL.
|
||||
* Sink and sources are grouped in a concept of “audio port” representing an
|
||||
* audio end point at the edge of the system managed by the module exposing
|
||||
* the interface.
|
||||
*/
|
||||
|
||||
/** Audio port role: either source or sink */
|
||||
@export(name="audio_port_role_t", value_prefix="AUDIO_PORT_ROLE_")
|
||||
enum AudioPortRole : int32_t {
|
||||
NONE,
|
||||
SOURCE,
|
||||
SINK,
|
||||
};
|
||||
|
||||
/**
|
||||
* Audio port type indicates if it is a session (e.g AudioTrack), a mix (e.g
|
||||
* PlaybackThread output) or a physical device (e.g OUT_SPEAKER)
|
||||
*/
|
||||
@export(name="audio_port_type_t", value_prefix="AUDIO_PORT_TYPE_")
|
||||
enum AudioPortType : int32_t {
|
||||
NONE,
|
||||
DEVICE,
|
||||
MIX,
|
||||
SESSION,
|
||||
};
|
||||
|
||||
/**
|
||||
* Extension for audio port configuration structure when the audio port is a
|
||||
* hardware device.
|
||||
*/
|
||||
struct AudioPortConfigDeviceExt {
|
||||
AudioModuleHandle hwModule; // module the device is attached to
|
||||
AudioDevice type; // device type (e.g OUT_SPEAKER)
|
||||
uint8_t[32] address; // device address. "" if N/A
|
||||
};
|
||||
|
||||
/**
|
||||
* Extension for audio port configuration structure when the audio port is an
|
||||
* audio session.
|
||||
*/
|
||||
struct AudioPortConfigSessionExt {
|
||||
AudioSession session;
|
||||
};
|
||||
|
||||
/**
|
||||
* Flags indicating which fields are to be considered in AudioPortConfig.
|
||||
*/
|
||||
@export(name="", value_prefix="AUDIO_PORT_CONFIG_")
|
||||
enum AudioPortConfigMask : uint32_t {
|
||||
SAMPLE_RATE = 0x1,
|
||||
CHANNEL_MASK = 0x2,
|
||||
FORMAT = 0x4,
|
||||
GAIN = 0x8,
|
||||
};
|
||||
|
||||
/**
|
||||
* Audio port configuration structure used to specify a particular configuration
|
||||
* of an audio port.
|
||||
*/
|
||||
struct AudioPortConfig {
|
||||
AudioPortHandle id;
|
||||
bitfield<AudioPortConfigMask> configMask;
|
||||
uint32_t sampleRateHz;
|
||||
bitfield<AudioChannelMask> channelMask;
|
||||
AudioFormat format;
|
||||
AudioGainConfig gain;
|
||||
AudioPortType type; // type is used as a discriminator for Ext union
|
||||
AudioPortRole role; // role is used as a discriminator for UseCase union
|
||||
union Ext {
|
||||
AudioPortConfigDeviceExt device;
|
||||
struct AudioPortConfigMixExt {
|
||||
AudioModuleHandle hwModule; // module the stream is attached to
|
||||
AudioIoHandle ioHandle; // I/O handle of the input/output stream
|
||||
union UseCase {
|
||||
AudioStreamType stream;
|
||||
AudioSource source;
|
||||
} useCase;
|
||||
} mix;
|
||||
AudioPortConfigSessionExt session;
|
||||
} ext;
|
||||
};
|
||||
|
||||
/**
|
||||
* Extension for audio port structure when the audio port is a hardware device.
|
||||
*/
|
||||
struct AudioPortDeviceExt {
|
||||
AudioModuleHandle hwModule; // module the device is attached to
|
||||
AudioDevice type;
|
||||
/** 32 byte string identifying the port. */
|
||||
uint8_t[32] address;
|
||||
};
|
||||
|
||||
/**
|
||||
* Latency class of the audio mix.
|
||||
*/
|
||||
@export(name="audio_mix_latency_class_t", value_prefix="AUDIO_LATENCY_")
|
||||
enum AudioMixLatencyClass : int32_t {
|
||||
LOW,
|
||||
NORMAL
|
||||
};
|
||||
|
||||
struct AudioPortMixExt {
|
||||
AudioModuleHandle hwModule; // module the stream is attached to
|
||||
AudioIoHandle ioHandle; // I/O handle of the stream
|
||||
AudioMixLatencyClass latencyClass;
|
||||
};
|
||||
|
||||
/**
|
||||
* Extension for audio port structure when the audio port is an audio session.
|
||||
*/
|
||||
struct AudioPortSessionExt {
|
||||
AudioSession session;
|
||||
};
|
||||
|
||||
struct AudioPort {
|
||||
AudioPortHandle id;
|
||||
AudioPortRole role;
|
||||
string name;
|
||||
vec<uint32_t> sampleRates;
|
||||
vec<bitfield<AudioChannelMask>> channelMasks;
|
||||
vec<AudioFormat> formats;
|
||||
vec<AudioGain> gains;
|
||||
AudioPortConfig activeConfig; // current audio port configuration
|
||||
AudioPortType type; // type is used as a discriminator
|
||||
union Ext {
|
||||
AudioPortDeviceExt device;
|
||||
AudioPortMixExt mix;
|
||||
AudioPortSessionExt session;
|
||||
} ext;
|
||||
};
|
||||
|
||||
struct ThreadInfo {
|
||||
int64_t pid;
|
||||
int64_t tid;
|
||||
};
|
||||
1
audio/common/README
Normal file
1
audio/common/README
Normal file
@@ -0,0 +1 @@
|
||||
This folder contains code common to audio core and effect API
|
||||
1
audio/common/all-versions/README
Normal file
1
audio/common/all-versions/README
Normal file
@@ -0,0 +1 @@
|
||||
This folder contains code common to all versions of the audio API
|
||||
43
audio/common/all-versions/default/Android.bp
Normal file
43
audio/common/all-versions/default/Android.bp
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Copyright (C) 2016 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.
|
||||
|
||||
cc_library_shared {
|
||||
name: "android.hardware.audio.common-util",
|
||||
defaults: ["hidl_defaults"],
|
||||
vendor_available: true,
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
srcs: [
|
||||
"EffectMap.cpp",
|
||||
],
|
||||
|
||||
export_include_dirs: ["include"],
|
||||
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libhidlbase",
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"android.hardware.audio.common.util@all-versions",
|
||||
"libaudio_system_headers",
|
||||
"libhardware_headers",
|
||||
],
|
||||
export_header_lib_headers: [
|
||||
"android.hardware.audio.common.util@all-versions",
|
||||
]
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include "EffectMap.h"
|
||||
#include "common/all-versions/default/EffectMap.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef android_hardware_audio_V2_0_EffectMap_H_
|
||||
#define android_hardware_audio_V2_0_EffectMap_H_
|
||||
#ifndef android_hardware_audio_common_EffectMap_H_
|
||||
#define android_hardware_audio_common_EffectMap_H_
|
||||
|
||||
#include <mutex>
|
||||
|
||||
@@ -27,14 +27,14 @@ namespace android {
|
||||
|
||||
// This class needs to be in 'android' ns because Singleton macros require that.
|
||||
class EffectMap : public Singleton<EffectMap> {
|
||||
public:
|
||||
public:
|
||||
static const uint64_t INVALID_ID;
|
||||
|
||||
uint64_t add(effect_handle_t handle);
|
||||
effect_handle_t get(const uint64_t& id);
|
||||
void remove(effect_handle_t handle);
|
||||
|
||||
private:
|
||||
private:
|
||||
static uint64_t makeUniqueId();
|
||||
|
||||
std::mutex mLock;
|
||||
@@ -43,4 +43,4 @@ class EffectMap : public Singleton<EffectMap> {
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // android_hardware_audio_V2_0_EffectMap_H_
|
||||
#endif // android_hardware_audio_common_EffectMap_H_
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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 AUDIO_HAL_VERSION
|
||||
#error "AUDIO_HAL_VERSION must be set before including this file."
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <system/audio.h>
|
||||
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioConfig;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGain;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGainConfig;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioOffloadInfo;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPort;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfig;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::Uuid;
|
||||
using ::android::hardware::hidl_vec;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace common {
|
||||
namespace AUDIO_HAL_VERSION {
|
||||
|
||||
class HidlUtils {
|
||||
public:
|
||||
static void audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config);
|
||||
static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig);
|
||||
static void audioGainConfigFromHal(const struct audio_gain_config& halConfig,
|
||||
AudioGainConfig* config);
|
||||
static void audioGainConfigToHal(const AudioGainConfig& config,
|
||||
struct audio_gain_config* halConfig);
|
||||
static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain);
|
||||
static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain);
|
||||
static AudioUsage audioUsageFromHal(const audio_usage_t halUsage);
|
||||
static audio_usage_t audioUsageToHal(const AudioUsage usage);
|
||||
static void audioOffloadInfoFromHal(const audio_offload_info_t& halOffload,
|
||||
AudioOffloadInfo* offload);
|
||||
static void audioOffloadInfoToHal(const AudioOffloadInfo& offload,
|
||||
audio_offload_info_t* halOffload);
|
||||
static void audioPortConfigFromHal(const struct audio_port_config& halConfig,
|
||||
AudioPortConfig* config);
|
||||
static void audioPortConfigToHal(const AudioPortConfig& config,
|
||||
struct audio_port_config* halConfig);
|
||||
static void audioPortConfigsFromHal(unsigned int numHalConfigs,
|
||||
const struct audio_port_config* halConfigs,
|
||||
hidl_vec<AudioPortConfig>* configs);
|
||||
static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal(
|
||||
const hidl_vec<AudioPortConfig>& configs);
|
||||
static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port);
|
||||
static void audioPortToHal(const AudioPort& port, struct audio_port* halPort);
|
||||
static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid);
|
||||
static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid);
|
||||
};
|
||||
|
||||
} // namespace AUDIO_HAL_VERSION
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -0,0 +1,365 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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 AUDIO_HAL_VERSION
|
||||
#error "AUDIO_HAL_VERSION must be set before including this file."
|
||||
#endif
|
||||
|
||||
#include <common/all-versions/VersionUtils.h>
|
||||
#include <string.h>
|
||||
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGainMode;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMixLatencyClass;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfigMask;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortRole;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortType;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioStreamType;
|
||||
using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioUsage;
|
||||
|
||||
using ::android::hardware::audio::common::utils::mkEnumConverter;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace common {
|
||||
namespace AUDIO_HAL_VERSION {
|
||||
|
||||
void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) {
|
||||
config->sampleRateHz = halConfig.sample_rate;
|
||||
config->channelMask = mkEnumConverter<AudioChannelMask>(halConfig.channel_mask);
|
||||
config->format = AudioFormat(halConfig.format);
|
||||
audioOffloadInfoFromHal(halConfig.offload_info, &config->offloadInfo);
|
||||
config->frameCount = halConfig.frame_count;
|
||||
}
|
||||
|
||||
void HidlUtils::audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig) {
|
||||
memset(halConfig, 0, sizeof(audio_config_t));
|
||||
halConfig->sample_rate = config.sampleRateHz;
|
||||
halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
|
||||
halConfig->format = static_cast<audio_format_t>(config.format);
|
||||
audioOffloadInfoToHal(config.offloadInfo, &halConfig->offload_info);
|
||||
halConfig->frame_count = config.frameCount;
|
||||
}
|
||||
|
||||
void HidlUtils::audioGainConfigFromHal(const struct audio_gain_config& halConfig,
|
||||
AudioGainConfig* config) {
|
||||
config->index = halConfig.index;
|
||||
config->mode = mkEnumConverter<AudioGainMode>(halConfig.mode);
|
||||
config->channelMask = mkEnumConverter<AudioChannelMask>(halConfig.channel_mask);
|
||||
for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) {
|
||||
config->values[i] = halConfig.values[i];
|
||||
}
|
||||
config->rampDurationMs = halConfig.ramp_duration_ms;
|
||||
}
|
||||
|
||||
void HidlUtils::audioGainConfigToHal(const AudioGainConfig& config,
|
||||
struct audio_gain_config* halConfig) {
|
||||
halConfig->index = config.index;
|
||||
halConfig->mode = static_cast<audio_gain_mode_t>(config.mode);
|
||||
halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
|
||||
memset(halConfig->values, 0, sizeof(halConfig->values));
|
||||
for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) {
|
||||
halConfig->values[i] = config.values[i];
|
||||
}
|
||||
halConfig->ramp_duration_ms = config.rampDurationMs;
|
||||
}
|
||||
|
||||
void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) {
|
||||
gain->mode = mkEnumConverter<AudioGainMode>(halGain.mode);
|
||||
gain->channelMask = mkEnumConverter<AudioChannelMask>(halGain.channel_mask);
|
||||
gain->minValue = halGain.min_value;
|
||||
gain->maxValue = halGain.max_value;
|
||||
gain->defaultValue = halGain.default_value;
|
||||
gain->stepValue = halGain.step_value;
|
||||
gain->minRampMs = halGain.min_ramp_ms;
|
||||
gain->maxRampMs = halGain.max_ramp_ms;
|
||||
}
|
||||
|
||||
void HidlUtils::audioGainToHal(const AudioGain& gain, struct audio_gain* halGain) {
|
||||
halGain->mode = static_cast<audio_gain_mode_t>(gain.mode);
|
||||
halGain->channel_mask = static_cast<audio_channel_mask_t>(gain.channelMask);
|
||||
halGain->min_value = gain.minValue;
|
||||
halGain->max_value = gain.maxValue;
|
||||
halGain->default_value = gain.defaultValue;
|
||||
halGain->step_value = gain.stepValue;
|
||||
halGain->min_ramp_ms = gain.minRampMs;
|
||||
halGain->max_ramp_ms = gain.maxRampMs;
|
||||
}
|
||||
|
||||
AudioUsage HidlUtils::audioUsageFromHal(const audio_usage_t halUsage) {
|
||||
switch (halUsage) {
|
||||
case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
|
||||
case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
|
||||
case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
|
||||
case AUDIO_USAGE_NOTIFICATION_EVENT:
|
||||
return AudioUsage::NOTIFICATION;
|
||||
default:
|
||||
return static_cast<AudioUsage>(halUsage);
|
||||
}
|
||||
}
|
||||
|
||||
audio_usage_t HidlUtils::audioUsageToHal(const AudioUsage usage) {
|
||||
return static_cast<audio_usage_t>(usage);
|
||||
}
|
||||
|
||||
void HidlUtils::audioOffloadInfoFromHal(const audio_offload_info_t& halOffload,
|
||||
AudioOffloadInfo* offload) {
|
||||
offload->sampleRateHz = halOffload.sample_rate;
|
||||
offload->channelMask = mkEnumConverter<AudioChannelMask>(halOffload.channel_mask);
|
||||
offload->format = AudioFormat(halOffload.format);
|
||||
offload->streamType = AudioStreamType(halOffload.stream_type);
|
||||
offload->bitRatePerSecond = halOffload.bit_rate;
|
||||
offload->durationMicroseconds = halOffload.duration_us;
|
||||
offload->hasVideo = halOffload.has_video;
|
||||
offload->isStreaming = halOffload.is_streaming;
|
||||
offload->bitWidth = halOffload.bit_width;
|
||||
offload->bufferSize = halOffload.offload_buffer_size;
|
||||
offload->usage = audioUsageFromHal(halOffload.usage);
|
||||
}
|
||||
|
||||
void HidlUtils::audioOffloadInfoToHal(const AudioOffloadInfo& offload,
|
||||
audio_offload_info_t* halOffload) {
|
||||
*halOffload = AUDIO_INFO_INITIALIZER;
|
||||
halOffload->sample_rate = offload.sampleRateHz;
|
||||
halOffload->channel_mask = static_cast<audio_channel_mask_t>(offload.channelMask);
|
||||
halOffload->format = static_cast<audio_format_t>(offload.format);
|
||||
halOffload->stream_type = static_cast<audio_stream_type_t>(offload.streamType);
|
||||
halOffload->bit_rate = offload.bitRatePerSecond;
|
||||
halOffload->duration_us = offload.durationMicroseconds;
|
||||
halOffload->has_video = offload.hasVideo;
|
||||
halOffload->is_streaming = offload.isStreaming;
|
||||
halOffload->bit_width = offload.bitWidth;
|
||||
halOffload->offload_buffer_size = offload.bufferSize;
|
||||
halOffload->usage = audioUsageToHal(offload.usage);
|
||||
}
|
||||
|
||||
void HidlUtils::audioPortConfigFromHal(const struct audio_port_config& halConfig,
|
||||
AudioPortConfig* config) {
|
||||
config->id = halConfig.id;
|
||||
config->role = AudioPortRole(halConfig.role);
|
||||
config->type = AudioPortType(halConfig.type);
|
||||
config->configMask = mkEnumConverter<AudioPortConfigMask>(halConfig.config_mask);
|
||||
config->sampleRateHz = halConfig.sample_rate;
|
||||
config->channelMask = mkEnumConverter<AudioChannelMask>(halConfig.channel_mask);
|
||||
config->format = AudioFormat(halConfig.format);
|
||||
audioGainConfigFromHal(halConfig.gain, &config->gain);
|
||||
switch (halConfig.type) {
|
||||
case AUDIO_PORT_TYPE_NONE:
|
||||
break;
|
||||
case AUDIO_PORT_TYPE_DEVICE: {
|
||||
config->ext.device.hwModule = halConfig.ext.device.hw_module;
|
||||
config->ext.device.type = AudioDevice(halConfig.ext.device.type);
|
||||
memcpy(config->ext.device.address.data(), halConfig.ext.device.address,
|
||||
AUDIO_DEVICE_MAX_ADDRESS_LEN);
|
||||
break;
|
||||
}
|
||||
case AUDIO_PORT_TYPE_MIX: {
|
||||
config->ext.mix.hwModule = halConfig.ext.mix.hw_module;
|
||||
config->ext.mix.ioHandle = halConfig.ext.mix.handle;
|
||||
if (halConfig.role == AUDIO_PORT_ROLE_SOURCE) {
|
||||
config->ext.mix.useCase.source = AudioSource(halConfig.ext.mix.usecase.source);
|
||||
} else if (halConfig.role == AUDIO_PORT_ROLE_SINK) {
|
||||
config->ext.mix.useCase.stream = AudioStreamType(halConfig.ext.mix.usecase.stream);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AUDIO_PORT_TYPE_SESSION: {
|
||||
config->ext.session.session = halConfig.ext.session.session;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HidlUtils::audioPortConfigToHal(const AudioPortConfig& config,
|
||||
struct audio_port_config* halConfig) {
|
||||
memset(halConfig, 0, sizeof(audio_port_config));
|
||||
halConfig->id = config.id;
|
||||
halConfig->role = static_cast<audio_port_role_t>(config.role);
|
||||
halConfig->type = static_cast<audio_port_type_t>(config.type);
|
||||
halConfig->config_mask = static_cast<unsigned int>(config.configMask);
|
||||
halConfig->sample_rate = config.sampleRateHz;
|
||||
halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
|
||||
halConfig->format = static_cast<audio_format_t>(config.format);
|
||||
audioGainConfigToHal(config.gain, &halConfig->gain);
|
||||
switch (config.type) {
|
||||
case AudioPortType::NONE:
|
||||
break;
|
||||
case AudioPortType::DEVICE: {
|
||||
halConfig->ext.device.hw_module = config.ext.device.hwModule;
|
||||
halConfig->ext.device.type = static_cast<audio_devices_t>(config.ext.device.type);
|
||||
memcpy(halConfig->ext.device.address, config.ext.device.address.data(),
|
||||
AUDIO_DEVICE_MAX_ADDRESS_LEN);
|
||||
break;
|
||||
}
|
||||
case AudioPortType::MIX: {
|
||||
halConfig->ext.mix.hw_module = config.ext.mix.hwModule;
|
||||
halConfig->ext.mix.handle = config.ext.mix.ioHandle;
|
||||
if (config.role == AudioPortRole::SOURCE) {
|
||||
halConfig->ext.mix.usecase.source =
|
||||
static_cast<audio_source_t>(config.ext.mix.useCase.source);
|
||||
} else if (config.role == AudioPortRole::SINK) {
|
||||
halConfig->ext.mix.usecase.stream =
|
||||
static_cast<audio_stream_type_t>(config.ext.mix.useCase.stream);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AudioPortType::SESSION: {
|
||||
halConfig->ext.session.session =
|
||||
static_cast<audio_session_t>(config.ext.session.session);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HidlUtils::audioPortConfigsFromHal(unsigned int numHalConfigs,
|
||||
const struct audio_port_config* halConfigs,
|
||||
hidl_vec<AudioPortConfig>* configs) {
|
||||
configs->resize(numHalConfigs);
|
||||
for (unsigned int i = 0; i < numHalConfigs; ++i) {
|
||||
audioPortConfigFromHal(halConfigs[i], &(*configs)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<audio_port_config[]> HidlUtils::audioPortConfigsToHal(
|
||||
const hidl_vec<AudioPortConfig>& configs) {
|
||||
std::unique_ptr<audio_port_config[]> halConfigs(new audio_port_config[configs.size()]);
|
||||
for (size_t i = 0; i < configs.size(); ++i) {
|
||||
audioPortConfigToHal(configs[i], &halConfigs[i]);
|
||||
}
|
||||
return halConfigs;
|
||||
}
|
||||
|
||||
void HidlUtils::audioPortFromHal(const struct audio_port& halPort, AudioPort* port) {
|
||||
port->id = halPort.id;
|
||||
port->role = AudioPortRole(halPort.role);
|
||||
port->type = AudioPortType(halPort.type);
|
||||
port->name.setToExternal(halPort.name, strlen(halPort.name));
|
||||
port->sampleRates.resize(halPort.num_sample_rates);
|
||||
for (size_t i = 0; i < halPort.num_sample_rates; ++i) {
|
||||
port->sampleRates[i] = halPort.sample_rates[i];
|
||||
}
|
||||
port->channelMasks.resize(halPort.num_channel_masks);
|
||||
for (size_t i = 0; i < halPort.num_channel_masks; ++i) {
|
||||
port->channelMasks[i] = mkEnumConverter<AudioChannelMask>(halPort.channel_masks[i]);
|
||||
}
|
||||
port->formats.resize(halPort.num_formats);
|
||||
for (size_t i = 0; i < halPort.num_formats; ++i) {
|
||||
port->formats[i] = AudioFormat(halPort.formats[i]);
|
||||
}
|
||||
port->gains.resize(halPort.num_gains);
|
||||
for (size_t i = 0; i < halPort.num_gains; ++i) {
|
||||
audioGainFromHal(halPort.gains[i], &port->gains[i]);
|
||||
}
|
||||
audioPortConfigFromHal(halPort.active_config, &port->activeConfig);
|
||||
switch (halPort.type) {
|
||||
case AUDIO_PORT_TYPE_NONE:
|
||||
break;
|
||||
case AUDIO_PORT_TYPE_DEVICE: {
|
||||
port->ext.device.hwModule = halPort.ext.device.hw_module;
|
||||
port->ext.device.type = AudioDevice(halPort.ext.device.type);
|
||||
memcpy(port->ext.device.address.data(), halPort.ext.device.address,
|
||||
AUDIO_DEVICE_MAX_ADDRESS_LEN);
|
||||
break;
|
||||
}
|
||||
case AUDIO_PORT_TYPE_MIX: {
|
||||
port->ext.mix.hwModule = halPort.ext.mix.hw_module;
|
||||
port->ext.mix.ioHandle = halPort.ext.mix.handle;
|
||||
port->ext.mix.latencyClass = AudioMixLatencyClass(halPort.ext.mix.latency_class);
|
||||
break;
|
||||
}
|
||||
case AUDIO_PORT_TYPE_SESSION: {
|
||||
port->ext.session.session = halPort.ext.session.session;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HidlUtils::audioPortToHal(const AudioPort& port, struct audio_port* halPort) {
|
||||
memset(halPort, 0, sizeof(audio_port));
|
||||
halPort->id = port.id;
|
||||
halPort->role = static_cast<audio_port_role_t>(port.role);
|
||||
halPort->type = static_cast<audio_port_type_t>(port.type);
|
||||
strncpy(halPort->name, port.name.c_str(), AUDIO_PORT_MAX_NAME_LEN);
|
||||
halPort->name[AUDIO_PORT_MAX_NAME_LEN - 1] = '\0';
|
||||
halPort->num_sample_rates =
|
||||
std::min(port.sampleRates.size(), static_cast<size_t>(AUDIO_PORT_MAX_SAMPLING_RATES));
|
||||
for (size_t i = 0; i < halPort->num_sample_rates; ++i) {
|
||||
halPort->sample_rates[i] = port.sampleRates[i];
|
||||
}
|
||||
halPort->num_channel_masks =
|
||||
std::min(port.channelMasks.size(), static_cast<size_t>(AUDIO_PORT_MAX_CHANNEL_MASKS));
|
||||
for (size_t i = 0; i < halPort->num_channel_masks; ++i) {
|
||||
halPort->channel_masks[i] = static_cast<audio_channel_mask_t>(port.channelMasks[i]);
|
||||
}
|
||||
halPort->num_formats =
|
||||
std::min(port.formats.size(), static_cast<size_t>(AUDIO_PORT_MAX_FORMATS));
|
||||
for (size_t i = 0; i < halPort->num_formats; ++i) {
|
||||
halPort->formats[i] = static_cast<audio_format_t>(port.formats[i]);
|
||||
}
|
||||
halPort->num_gains = std::min(port.gains.size(), static_cast<size_t>(AUDIO_PORT_MAX_GAINS));
|
||||
for (size_t i = 0; i < halPort->num_gains; ++i) {
|
||||
audioGainToHal(port.gains[i], &halPort->gains[i]);
|
||||
}
|
||||
audioPortConfigToHal(port.activeConfig, &halPort->active_config);
|
||||
switch (port.type) {
|
||||
case AudioPortType::NONE:
|
||||
break;
|
||||
case AudioPortType::DEVICE: {
|
||||
halPort->ext.device.hw_module = port.ext.device.hwModule;
|
||||
halPort->ext.device.type = static_cast<audio_devices_t>(port.ext.device.type);
|
||||
memcpy(halPort->ext.device.address, port.ext.device.address.data(),
|
||||
AUDIO_DEVICE_MAX_ADDRESS_LEN);
|
||||
break;
|
||||
}
|
||||
case AudioPortType::MIX: {
|
||||
halPort->ext.mix.hw_module = port.ext.mix.hwModule;
|
||||
halPort->ext.mix.handle = port.ext.mix.ioHandle;
|
||||
halPort->ext.mix.latency_class =
|
||||
static_cast<audio_mix_latency_class_t>(port.ext.mix.latencyClass);
|
||||
break;
|
||||
}
|
||||
case AudioPortType::SESSION: {
|
||||
halPort->ext.session.session = static_cast<audio_session_t>(port.ext.session.session);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HidlUtils::uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid) {
|
||||
uuid->timeLow = halUuid.timeLow;
|
||||
uuid->timeMid = halUuid.timeMid;
|
||||
uuid->versionAndTimeHigh = halUuid.timeHiAndVersion;
|
||||
uuid->variantAndClockSeqHigh = halUuid.clockSeq;
|
||||
memcpy(uuid->node.data(), halUuid.node, uuid->node.size());
|
||||
}
|
||||
|
||||
void HidlUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) {
|
||||
halUuid->timeLow = uuid.timeLow;
|
||||
halUuid->timeMid = uuid.timeMid;
|
||||
halUuid->timeHiAndVersion = uuid.versionAndTimeHigh;
|
||||
halUuid->clockSeq = uuid.variantAndClockSeqHigh;
|
||||
memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
|
||||
}
|
||||
|
||||
} // namespace AUDIO_HAL_VERSION
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -16,45 +16,6 @@
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.audio@2.0-impl
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_PROPRIETARY_MODULE := true
|
||||
LOCAL_SRC_FILES := \
|
||||
Conversions.cpp \
|
||||
Device.cpp \
|
||||
DevicesFactory.cpp \
|
||||
ParametersUtil.cpp \
|
||||
PrimaryDevice.cpp \
|
||||
Stream.cpp \
|
||||
StreamIn.cpp \
|
||||
StreamOut.cpp \
|
||||
|
||||
LOCAL_CFLAGS := -Wall -Werror
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libbase \
|
||||
libcutils \
|
||||
libfmq \
|
||||
libhardware \
|
||||
libhidlbase \
|
||||
libhidltransport \
|
||||
liblog \
|
||||
libutils \
|
||||
android.hardware.audio@2.0 \
|
||||
android.hardware.audio.common@2.0 \
|
||||
android.hardware.audio.common@2.0-util \
|
||||
|
||||
LOCAL_HEADER_LIBRARIES := \
|
||||
libaudioclient_headers \
|
||||
libaudio_system_headers \
|
||||
libhardware_headers \
|
||||
libmedia_headers \
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := libmedia_helper
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
#
|
||||
# Service
|
||||
#
|
||||
@@ -70,19 +31,24 @@ LOCAL_SRC_FILES := \
|
||||
LOCAL_CFLAGS := -Wall -Werror
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libbinder \
|
||||
libhidlbase \
|
||||
libhidltransport \
|
||||
liblog \
|
||||
libutils \
|
||||
libhardware \
|
||||
android.hardware.audio@2.0 \
|
||||
android.hardware.audio@4.0 \
|
||||
android.hardware.audio.common@2.0 \
|
||||
android.hardware.audio.common@4.0 \
|
||||
android.hardware.audio.effect@2.0 \
|
||||
android.hardware.audio.effect@4.0 \
|
||||
android.hardware.bluetooth.a2dp@1.0 \
|
||||
android.hardware.soundtrigger@2.0 \
|
||||
android.hardware.broadcastradio@1.0 \
|
||||
android.hardware.broadcastradio@1.1 \
|
||||
android.hardware.bluetooth.a2dp@1.0
|
||||
android.hardware.soundtrigger@2.1
|
||||
|
||||
# Can not switch to Android.bp until AUDIOSERVER_MULTILIB
|
||||
# is deprecated as build config variable are not supported
|
||||
ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
|
||||
LOCAL_MULTILIB := 32
|
||||
else
|
||||
@@ -1,4 +1,4 @@
|
||||
service audio-hal-2-0 /vendor/bin/hw/android.hardware.audio@2.0-service
|
||||
service vendor.audio-hal-2-0 /vendor/bin/hw/android.hardware.audio@2.0-service
|
||||
class hal
|
||||
user audioserver
|
||||
# media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
|
||||
@@ -9,3 +9,5 @@ service audio-hal-2-0 /vendor/bin/hw/android.hardware.audio@2.0-service
|
||||
# and its .rc file has an "onrestart restart audio-hal" rule, thus
|
||||
# an additional auto-restart from the init process isn't needed.
|
||||
oneshot
|
||||
interface android.hardware.audio@4.0::IDevicesFactory default
|
||||
interface android.hardware.audio@2.0::IDevicesFactory default
|
||||
57
audio/common/all-versions/default/service/service.cpp
Normal file
57
audio/common/all-versions/default/service/service.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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 "audiohalservice"
|
||||
|
||||
#include <android/hardware/audio/2.0/IDevicesFactory.h>
|
||||
#include <android/hardware/audio/4.0/IDevicesFactory.h>
|
||||
#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
|
||||
#include <android/hardware/audio/effect/4.0/IEffectsFactory.h>
|
||||
#include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioOffload.h>
|
||||
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
|
||||
#include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h>
|
||||
#include <binder/ProcessState.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
using namespace android::hardware;
|
||||
using android::OK;
|
||||
|
||||
int main(int /* argc */, char* /* argv */ []) {
|
||||
android::ProcessState::initWithDriver("/dev/vndbinder");
|
||||
// start a threadpool for vndbinder interactions
|
||||
android::ProcessState::self()->startThreadPool();
|
||||
configureRpcThreadpool(16, true /*callerWillJoin*/);
|
||||
|
||||
bool fail = registerPassthroughServiceImplementation<audio::V4_0::IDevicesFactory>() != OK &&
|
||||
registerPassthroughServiceImplementation<audio::V2_0::IDevicesFactory>() != OK;
|
||||
LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2.0 nor 4.0");
|
||||
|
||||
fail = registerPassthroughServiceImplementation<audio::effect::V4_0::IEffectsFactory>() != OK &&
|
||||
registerPassthroughServiceImplementation<audio::effect::V2_0::IEffectsFactory>() != OK,
|
||||
LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2.0 nor 4.0");
|
||||
|
||||
fail = registerPassthroughServiceImplementation<soundtrigger::V2_1::ISoundTriggerHw>() != OK &&
|
||||
registerPassthroughServiceImplementation<soundtrigger::V2_0::ISoundTriggerHw>() != OK,
|
||||
ALOGW_IF(fail, "Could not register soundtrigger API 2.0 nor 2.1");
|
||||
|
||||
fail =
|
||||
registerPassthroughServiceImplementation<bluetooth::a2dp::V1_0::IBluetoothAudioOffload>() !=
|
||||
OK;
|
||||
ALOGW_IF(fail, "Could not register Bluetooth audio offload 1.0");
|
||||
|
||||
joinRpcThreadpool();
|
||||
}
|
||||
2
audio/common/all-versions/test/OWNERS
Normal file
2
audio/common/all-versions/test/OWNERS
Normal file
@@ -0,0 +1,2 @@
|
||||
yim@google.com
|
||||
zhuoyao@google.com
|
||||
@@ -17,7 +17,7 @@
|
||||
#define ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_ASSERTOK_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <initializer_list>
|
||||
|
||||
#include <hidl/Status.h>
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace detail {
|
||||
// This is a detail namespace, thus it is OK to import a class as nobody else is
|
||||
// allowed to use it
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::audio::V2_0::Result;
|
||||
|
||||
template <class T>
|
||||
inline ::testing::AssertionResult assertIsOk(const char* expr, const Return<T>& ret) {
|
||||
@@ -50,6 +49,7 @@ inline ::testing::AssertionResult continueIfIsOk(const char* expr, const Return<
|
||||
}
|
||||
|
||||
// Expect two equal Results
|
||||
template <class Result>
|
||||
inline ::testing::AssertionResult assertResult(const char* e_expr, const char* r_expr,
|
||||
Result expected, Result result) {
|
||||
return ::testing::AssertionResult(expected == result)
|
||||
@@ -58,6 +58,7 @@ inline ::testing::AssertionResult assertResult(const char* e_expr, const char* r
|
||||
}
|
||||
|
||||
// Expect two equal Results one being wrapped in an OK Return
|
||||
template <class Result>
|
||||
inline ::testing::AssertionResult assertResult(const char* e_expr, const char* r_expr,
|
||||
Result expected, const Return<Result>& ret) {
|
||||
return continueIfIsOk(r_expr, ret,
|
||||
@@ -65,8 +66,10 @@ inline ::testing::AssertionResult assertResult(const char* e_expr, const char* r
|
||||
}
|
||||
|
||||
// Expect a Result to be part of a list of Results
|
||||
template <class Result>
|
||||
inline ::testing::AssertionResult assertResult(const char* e_expr, const char* r_expr,
|
||||
const std::vector<Result>& expected, Result result) {
|
||||
const std::initializer_list<Result>& expected,
|
||||
Result result) {
|
||||
if (std::find(expected.begin(), expected.end(), result) != expected.end()) {
|
||||
return ::testing::AssertionSuccess(); // result is in expected
|
||||
}
|
||||
@@ -77,8 +80,9 @@ inline ::testing::AssertionResult assertResult(const char* e_expr, const char* r
|
||||
}
|
||||
|
||||
// Expect a Result wrapped in an OK Return to be part of a list of Results
|
||||
template <class Result>
|
||||
inline ::testing::AssertionResult assertResult(const char* e_expr, const char* r_expr,
|
||||
const std::vector<Result>& expected,
|
||||
const std::initializer_list<Result>& expected,
|
||||
const Return<Result>& ret) {
|
||||
return continueIfIsOk(r_expr, ret,
|
||||
[&] { return assertResult(e_expr, r_expr, expected, Result{ret}); });
|
||||
@@ -88,15 +92,17 @@ inline ::testing::AssertionResult assertOk(const char* expr, const Return<void>&
|
||||
return assertIsOk(expr, ret);
|
||||
}
|
||||
|
||||
template <class Result>
|
||||
inline ::testing::AssertionResult assertOk(const char* expr, Result result) {
|
||||
return ::testing::AssertionResult(result == Result::OK)
|
||||
<< "Expected success: " << expr << "\nActual: " << ::testing::PrintToString(result);
|
||||
}
|
||||
|
||||
template <class Result>
|
||||
inline ::testing::AssertionResult assertOk(const char* expr, const Return<Result>& ret) {
|
||||
return continueIfIsOk(expr, ret, [&] { return assertOk(expr, Result{ret}); });
|
||||
}
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
#define ASSERT_IS_OK(ret) ASSERT_PRED_FORMAT1(detail::assertIsOk, ret)
|
||||
#define EXPECT_IS_OK(ret) EXPECT_PRED_FORMAT1(detail::assertIsOk, ret)
|
||||
@@ -108,11 +114,11 @@ inline ::testing::AssertionResult assertOk(const char* expr, const Return<Result
|
||||
#define ASSERT_RESULT(expected, ret) ASSERT_PRED_FORMAT2(detail::assertResult, expected, ret)
|
||||
#define EXPECT_RESULT(expected, ret) EXPECT_PRED_FORMAT2(detail::assertResult, expected, ret)
|
||||
|
||||
} // utility
|
||||
} // test
|
||||
} // common
|
||||
} // audio
|
||||
} // test
|
||||
} // utility
|
||||
} // namespace utility
|
||||
} // namespace test
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_ASSERTOK_H
|
||||
@@ -60,11 +60,11 @@ void note(const std::string& note) {
|
||||
}
|
||||
} // namespace doc
|
||||
|
||||
} // utility
|
||||
} // test
|
||||
} // common
|
||||
} // audio
|
||||
} // test
|
||||
} // utility
|
||||
} // namespace utility
|
||||
} // namespace test
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_ENVIRONMENT_TEARDOWN
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <functional>
|
||||
#include <list>
|
||||
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace android {
|
||||
@@ -33,13 +34,13 @@ namespace utility {
|
||||
* Avoid destroying static objects after main return.
|
||||
* Post main return destruction leads to incorrect gtest timing measurements as
|
||||
* well as harder debuging if anything goes wrong during destruction. */
|
||||
class Environment : public ::testing::Environment {
|
||||
class Environment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
using TearDownFunc = std::function<void()>;
|
||||
void registerTearDown(TearDownFunc&& tearDown) { tearDowns.push_back(std::move(tearDown)); }
|
||||
|
||||
private:
|
||||
void TearDown() override {
|
||||
void HidlTearDown() override {
|
||||
// Call the tear downs in reverse order of insertion
|
||||
for (auto& tearDown : tearDowns) {
|
||||
tearDown();
|
||||
@@ -48,11 +49,11 @@ class Environment : public ::testing::Environment {
|
||||
std::list<TearDownFunc> tearDowns;
|
||||
};
|
||||
|
||||
} // utility
|
||||
} // test
|
||||
} // common
|
||||
} // audio
|
||||
} // test
|
||||
} // utility
|
||||
} // namespace utility
|
||||
} // namespace test
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_ENVIRONMENT_TEARDOWN_H
|
||||
@@ -14,57 +14,49 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef AUDIO_HAL_VERSION
|
||||
#error "AUDIO_HAL_VERSION must be set before including this file."
|
||||
#endif
|
||||
|
||||
#ifndef ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_PRETTY_PRINT_AUDIO_TYPES_H
|
||||
#define ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_PRETTY_PRINT_AUDIO_TYPES_H
|
||||
|
||||
#include <iosfwd>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <android/hardware/audio/2.0/types.h>
|
||||
#include <android/hardware/audio/common/2.0/types.h>
|
||||
|
||||
/** @file Use HIDL generated toString methods to pretty print gtest errors */
|
||||
|
||||
namespace prettyPrintAudioTypesDetail {
|
||||
|
||||
// Print the value of an enum as hex
|
||||
template <class Enum>
|
||||
inline void printUnderlyingValue(Enum value, ::std::ostream* os) {
|
||||
*os << std::hex << " (0x" << static_cast<std::underlying_type_t<Enum>>(value) << ")";
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
/** @file Use HIDL generated toString methods to pretty print gtest errors
|
||||
* Unfortunately Gtest does not offer a template to specialize, only
|
||||
* overloading PrintTo.
|
||||
* @note that this overload can NOT be template because
|
||||
* the fallback is already template, resulting in ambiguity.
|
||||
* @note that the overload MUST be in the exact namespace
|
||||
* the type is declared in, as per the ADL rules.
|
||||
*/
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace V2_0 {
|
||||
|
||||
inline void PrintTo(const Result& result, ::std::ostream* os) {
|
||||
*os << toString(result);
|
||||
prettyPrintAudioTypesDetail::printUnderlyingValue(result, os);
|
||||
}
|
||||
#define DEFINE_GTEST_PRINT_TO(T) \
|
||||
inline void PrintTo(const T& val, ::std::ostream* os) { *os << toString(val); }
|
||||
|
||||
namespace AUDIO_HAL_VERSION {
|
||||
DEFINE_GTEST_PRINT_TO(IPrimaryDevice::TtyMode)
|
||||
DEFINE_GTEST_PRINT_TO(Result)
|
||||
} // namespace AUDIO_HAL_VERSION
|
||||
|
||||
} // namespace V2_0
|
||||
namespace common {
|
||||
namespace V2_0 {
|
||||
|
||||
inline void PrintTo(const AudioConfig& config, ::std::ostream* os) {
|
||||
*os << toString(config);
|
||||
}
|
||||
|
||||
inline void PrintTo(const AudioDevice& device, ::std::ostream* os) {
|
||||
*os << toString(device);
|
||||
prettyPrintAudioTypesDetail::printUnderlyingValue(device, os);
|
||||
}
|
||||
|
||||
inline void PrintTo(const AudioChannelMask& channelMask, ::std::ostream* os) {
|
||||
*os << toString(channelMask);
|
||||
prettyPrintAudioTypesDetail::printUnderlyingValue(channelMask, os);
|
||||
}
|
||||
|
||||
} // namespace V2_0
|
||||
namespace AUDIO_HAL_VERSION {
|
||||
DEFINE_GTEST_PRINT_TO(AudioConfig)
|
||||
DEFINE_GTEST_PRINT_TO(AudioMode)
|
||||
DEFINE_GTEST_PRINT_TO(AudioDevice)
|
||||
DEFINE_GTEST_PRINT_TO(AudioFormat)
|
||||
DEFINE_GTEST_PRINT_TO(AudioChannelMask)
|
||||
} // namespace AUDIO_HAL_VERSION
|
||||
} // namespace common
|
||||
|
||||
#undef DEFINE_GTEST_PRINT_TO
|
||||
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -45,7 +45,7 @@ class ReturnIn {
|
||||
template <class Head, class... Tail>
|
||||
void set(Head&& head, Tail&&... tail) {
|
||||
std::get<sizeof...(ResultStore) - sizeof...(Tail) - 1>(results) = std::forward<Head>(head);
|
||||
set(tail...);
|
||||
set(std::forward<Tail>(tail)...);
|
||||
}
|
||||
// Trivial case
|
||||
void set() {}
|
||||
@@ -56,7 +56,7 @@ class ReturnIn {
|
||||
} // namespace detail
|
||||
|
||||
// Generate the HIDL synchronous callback with a copy policy
|
||||
// Input: the variables (lvalue reference) where to save the return values
|
||||
// Input: the variables (lvalue references) where to copy the return values
|
||||
// Output: the callback to provide to a HIDL call with a synchronous callback
|
||||
// The output parameters *will be copied* do not use this function if you have
|
||||
// a zero copy policy
|
||||
@@ -65,11 +65,11 @@ detail::ReturnIn<ResultStore...> returnIn(ResultStore&... ts) {
|
||||
return {ts...};
|
||||
}
|
||||
|
||||
} // utility
|
||||
} // test
|
||||
} // common
|
||||
} // audio
|
||||
} // test
|
||||
} // utility
|
||||
} // namespace utility
|
||||
} // namespace test
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_RETURN_IN_H
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_COMMON_TEST_UTILITY_VALIDATE_XML_H
|
||||
#define ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_VALIDATE_XML_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace common {
|
||||
namespace test {
|
||||
namespace utility {
|
||||
|
||||
/** Validate the provided XmlFile with the provided xsdFile.
|
||||
* Intended to use with ASSERT_PRED_FORMAT2 as such:
|
||||
* ASSERT_PRED_FORMAT2(validateXml, pathToXml, pathToXsd);
|
||||
* See ASSERT_VALID_XML for a helper macro.
|
||||
*/
|
||||
::testing::AssertionResult validateXml(const char* xmlFilePathExpr, const char* xsdFilePathExpr,
|
||||
const char* xmlFilePath, const char* xsdFilePath);
|
||||
|
||||
/** Helper gtest ASSERT to test XML validity against an XSD. */
|
||||
#define ASSERT_VALID_XML(xmlFilePath, xsdFilePath) \
|
||||
ASSERT_PRED_FORMAT2(::android::hardware::audio::common::test::utility::validateXml, \
|
||||
xmlFilePath, xsdFilePath)
|
||||
|
||||
/** Helper gtest EXPECT to test XML validity against an XSD. */
|
||||
#define EXPECT_VALID_XML(xmlFilePath, xsdFilePath) \
|
||||
EXPECT_PRED_FORMAT2(::android::hardware::audio::common::test::utility::validateXml, \
|
||||
xmlFilePath, xsdFilePath)
|
||||
|
||||
/** Validate an XML according to an xsd.
|
||||
* The XML file must be in at least one of the provided locations.
|
||||
* If multiple are found, all are validated.
|
||||
*/
|
||||
::testing::AssertionResult validateXmlMultipleLocations(
|
||||
const char* xmlFileNameExpr, const char* xmlFileLocationsExpr, const char* xsdFilePathExpr,
|
||||
const char* xmlFileName, std::vector<const char*> xmlFileLocations, const char* xsdFilePath);
|
||||
|
||||
/** ASSERT that an XML is valid according to an xsd.
|
||||
* The XML file must be in at least one of the provided locations.
|
||||
* If multiple are found, all are validated.
|
||||
*/
|
||||
#define ASSERT_ONE_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath) \
|
||||
ASSERT_PRED_FORMAT3( \
|
||||
::android::hardware::audio::common::test::utility::validateXmlMultipleLocations, \
|
||||
xmlFileName, xmlFileLocations, xsdFilePath)
|
||||
|
||||
/** EXPECT an XML to be valid according to an xsd.
|
||||
* The XML file must be in at least one of the provided locations.
|
||||
* If multiple are found, all are validated.
|
||||
*/
|
||||
#define EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(xmlFileName, xmlFileLocations, xsdFilePath) \
|
||||
EXPECT_PRED_FORMAT3( \
|
||||
::android::hardware::audio::common::test::utility::validateXmlMultipleLocations, \
|
||||
xmlFileName, xmlFileLocations, xsdFilePath)
|
||||
|
||||
} // namespace utility
|
||||
} // namespace test
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_VALIDATE_XML_H
|
||||
@@ -17,6 +17,8 @@
|
||||
#define LOG_TAG "ValidateAudioConfig"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include <numeric>
|
||||
|
||||
#define LIBXML_SCHEMAS_ENABLED
|
||||
#include <libxml/xmlschemastypes.h>
|
||||
#define LIBXML_XINCLUDE_ENABLED
|
||||
@@ -94,9 +96,9 @@ struct Libxml2Global {
|
||||
Libxml2Global libxml2;
|
||||
|
||||
auto context = [&]() {
|
||||
return std::string() + " While validating: " + xmlFilePathExpr +
|
||||
return std::string() + " While validating: " + xmlFilePathExpr +
|
||||
"\n Which is: " + xmlFilePath + "\nAgainst the schema: " + xsdFilePathExpr +
|
||||
"\n Which is: " + xsdFilePath + "Libxml2 errors\n" + libxml2.getErrors();
|
||||
"\n Which is: " + xsdFilePath + "\nLibxml2 errors:\n" + libxml2.getErrors();
|
||||
};
|
||||
|
||||
auto schemaParserCtxt = make_xmlUnique(xmlSchemaNewParserCtxt(xsdFilePath));
|
||||
@@ -117,7 +119,7 @@ struct Libxml2Global {
|
||||
auto schemaCtxt = make_xmlUnique(xmlSchemaNewValidCtxt(schema.get()));
|
||||
int ret = xmlSchemaValidateDoc(schemaCtxt.get(), doc.get());
|
||||
if (ret > 0) {
|
||||
return ::testing::AssertionFailure() << "xml is not valid according to the xsd.\n"
|
||||
return ::testing::AssertionFailure() << "XML is not valid according to the xsd\n"
|
||||
<< context();
|
||||
}
|
||||
if (ret < 0) {
|
||||
@@ -127,9 +129,43 @@ struct Libxml2Global {
|
||||
return ::testing::AssertionSuccess();
|
||||
}
|
||||
|
||||
} // utility
|
||||
} // test
|
||||
} // common
|
||||
} // audio
|
||||
} // test
|
||||
} // utility
|
||||
::testing::AssertionResult validateXmlMultipleLocations(
|
||||
const char* xmlFileNameExpr, const char* xmlFileLocationsExpr, const char* xsdFilePathExpr,
|
||||
const char* xmlFileName, std::vector<const char*> xmlFileLocations, const char* xsdFilePath) {
|
||||
using namespace std::string_literals;
|
||||
|
||||
std::vector<std::string> errors;
|
||||
std::vector<std::string> foundFiles;
|
||||
|
||||
for (const char* location : xmlFileLocations) {
|
||||
std::string xmlFilePath = location + "/"s + xmlFileName;
|
||||
if (access(xmlFilePath.c_str(), F_OK) != 0) {
|
||||
// If the file does not exist ignore this location and fallback on the next one
|
||||
continue;
|
||||
}
|
||||
foundFiles.push_back(" " + xmlFilePath + '\n');
|
||||
auto result = validateXml("xmlFilePath", xsdFilePathExpr, xmlFilePath.c_str(), xsdFilePath);
|
||||
if (!result) {
|
||||
errors.push_back(result.message());
|
||||
}
|
||||
}
|
||||
|
||||
if (foundFiles.empty()) {
|
||||
errors.push_back("No xml file found in provided locations.\n");
|
||||
}
|
||||
|
||||
return ::testing::AssertionResult(errors.empty())
|
||||
<< errors.size() << " error" << (errors.size() == 1 ? " " : "s ")
|
||||
<< std::accumulate(begin(errors), end(errors), "occurred during xml validation:\n"s)
|
||||
<< " While validating all: " << xmlFileNameExpr
|
||||
<< "\n Which is: " << xmlFileName
|
||||
<< "\n In the following folders: " << xmlFileLocationsExpr
|
||||
<< "\n Which is: " << ::testing::PrintToString(xmlFileLocations);
|
||||
}
|
||||
|
||||
} // namespace utility
|
||||
} // namespace test
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
10
audio/common/all-versions/util/Android.bp
Normal file
10
audio/common/all-versions/util/Android.bp
Normal file
@@ -0,0 +1,10 @@
|
||||
cc_library_headers {
|
||||
name: "android.hardware.audio.common.util@all-versions",
|
||||
defaults: ["hidl_defaults"],
|
||||
vendor_available: true,
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
|
||||
export_include_dirs: ["include"],
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 AUDIO_HAL_VERSION
|
||||
#error "AUDIO_HAL_VERSION must be set before including this file."
|
||||
#endif
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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_hardware_audio_common_VersionUtils_H_
|
||||
#define android_hardware_audio_common_VersionUtils_H_
|
||||
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace common {
|
||||
namespace utils {
|
||||
|
||||
/** Similar to static_cast but also casts to hidl_bitfield depending on
|
||||
* return type inference (emulated through user-define conversion).
|
||||
*/
|
||||
template <class Source, class Destination = Source>
|
||||
class EnumConverter {
|
||||
public:
|
||||
static_assert(std::is_enum<Source>::value || std::is_enum<Destination>::value,
|
||||
"Source or destination should be an enum");
|
||||
|
||||
explicit EnumConverter(Source source) : mSource(source) {}
|
||||
|
||||
operator Destination() const { return static_cast<Destination>(mSource); }
|
||||
|
||||
template <class = std::enable_if_t<std::is_enum<Destination>::value>>
|
||||
operator ::android::hardware::hidl_bitfield<Destination>() {
|
||||
return static_cast<std::underlying_type_t<Destination>>(mSource);
|
||||
}
|
||||
|
||||
private:
|
||||
const Source mSource;
|
||||
};
|
||||
template <class Destination, class Source>
|
||||
auto mkEnumConverter(Source source) {
|
||||
return EnumConverter<Source, Destination>{source};
|
||||
}
|
||||
|
||||
/** Allows converting an enum to its bitfield or itself. */
|
||||
template <class Enum>
|
||||
EnumConverter<Enum> mkBitfield(Enum value) {
|
||||
return EnumConverter<Enum>{value};
|
||||
}
|
||||
|
||||
} // namespace utils
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // android_hardware_audio_common_VersionUtils_H_
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_COMMON_TEST_UTILITY_VALIDATE_XML_H
|
||||
#define ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_VALIDATE_XML_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace common {
|
||||
namespace test {
|
||||
namespace utility {
|
||||
|
||||
/** Validate the provided XmlFile with the provided xsdFile.
|
||||
* Intended to use with ASSERT_PRED_FORMAT2 as such:
|
||||
* ASSERT_PRED_FORMAT2(validateXml, pathToXml, pathToXsd);
|
||||
* See ASSERT_VALID_XML for a helper macro.
|
||||
*/
|
||||
::testing::AssertionResult validateXml(const char* xmlFilePathExpr, const char* xsdFilePathExpr,
|
||||
const char* xmlFilePath, const char* xsdPathName);
|
||||
|
||||
/** Helper gtest ASSERT to test xml validity against an xsd. */
|
||||
#define ASSERT_VALID_XML(xmlFilePath, xsdFilePath) \
|
||||
ASSERT_PRED_FORMAT2(::android::hardware::audio::common::test::utility::validateXml, \
|
||||
xmlFilePath, xsdFilePath)
|
||||
|
||||
} // utility
|
||||
} // test
|
||||
} // common
|
||||
} // audio
|
||||
} // test
|
||||
} // utility
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_VALIDATE_XML_H
|
||||
53
audio/core/2.0/default/Android.bp
Normal file
53
audio/core/2.0/default/Android.bp
Normal file
@@ -0,0 +1,53 @@
|
||||
cc_library_shared {
|
||||
name: "android.hardware.audio@2.0-impl",
|
||||
relative_install_path: "hw",
|
||||
proprietary: true,
|
||||
vendor: true,
|
||||
srcs: [
|
||||
"Conversions.cpp",
|
||||
"Device.cpp",
|
||||
"DevicesFactory.cpp",
|
||||
"ParametersUtil.cpp",
|
||||
"PrimaryDevice.cpp",
|
||||
"Stream.cpp",
|
||||
"StreamIn.cpp",
|
||||
"StreamOut.cpp",
|
||||
],
|
||||
|
||||
cflags: [
|
||||
"-DAUDIO_HAL_VERSION_2_0",
|
||||
],
|
||||
|
||||
defaults: ["hidl_defaults"],
|
||||
|
||||
export_include_dirs: ["include"],
|
||||
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libfmq",
|
||||
"libhardware",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"android.hardware.audio@2.0",
|
||||
"android.hardware.audio.common@2.0",
|
||||
"android.hardware.audio.common@2.0-util",
|
||||
"android.hardware.audio.common-util",
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"android.hardware.audio.common.util@all-versions",
|
||||
"android.hardware.audio.core@all-versions-impl",
|
||||
"libaudioclient_headers",
|
||||
"libaudio_system_headers",
|
||||
"libhardware_headers",
|
||||
"libmedia_headers",
|
||||
],
|
||||
|
||||
whole_static_libs: [
|
||||
"libmedia_helper",
|
||||
],
|
||||
|
||||
}
|
||||
21
audio/core/2.0/default/Conversions.cpp
Normal file
21
audio/core/2.0/default/Conversions.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "core/2.0/default/Conversions.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/Conversions.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
28
audio/core/2.0/default/Device.cpp
Normal file
28
audio/core/2.0/default/Device.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "DeviceHAL"
|
||||
|
||||
#include "core/2.0/default/Device.h"
|
||||
#include <HidlUtils.h>
|
||||
#include "core/2.0/default/Conversions.h"
|
||||
#include "core/2.0/default/StreamIn.h"
|
||||
#include "core/2.0/default/StreamOut.h"
|
||||
#include "core/2.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/Device.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
25
audio/core/2.0/default/DevicesFactory.cpp
Normal file
25
audio/core/2.0/default/DevicesFactory.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "DevicesFactoryHAL"
|
||||
|
||||
#include "core/2.0/default/DevicesFactory.h"
|
||||
#include "core/2.0/default/Device.h"
|
||||
#include "core/2.0/default/PrimaryDevice.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/DevicesFactory.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
3
audio/core/2.0/default/OWNERS
Normal file
3
audio/core/2.0/default/OWNERS
Normal file
@@ -0,0 +1,3 @@
|
||||
elaurent@google.com
|
||||
krocard@google.com
|
||||
mnaganov@google.com
|
||||
22
audio/core/2.0/default/ParametersUtil.cpp
Normal file
22
audio/core/2.0/default/ParametersUtil.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "core/2.0/default/ParametersUtil.h"
|
||||
#include "core/2.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/ParametersUtil.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
24
audio/core/2.0/default/PrimaryDevice.cpp
Normal file
24
audio/core/2.0/default/PrimaryDevice.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "PrimaryDeviceHAL"
|
||||
|
||||
#include "core/2.0/default/PrimaryDevice.h"
|
||||
#include "core/2.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/PrimaryDevice.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
26
audio/core/2.0/default/Stream.cpp
Normal file
26
audio/core/2.0/default/Stream.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "StreamHAL"
|
||||
|
||||
#include "core/2.0/default/Stream.h"
|
||||
#include "common/all-versions/default/EffectMap.h"
|
||||
#include "core/2.0/default/Conversions.h"
|
||||
#include "core/2.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/Stream.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
24
audio/core/2.0/default/StreamIn.cpp
Normal file
24
audio/core/2.0/default/StreamIn.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "StreamInHAL"
|
||||
|
||||
#include "core/2.0/default/StreamIn.h"
|
||||
#include "core/2.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/StreamIn.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
24
audio/core/2.0/default/StreamOut.cpp
Normal file
24
audio/core/2.0/default/StreamOut.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "StreamOutHAL"
|
||||
|
||||
#include "core/2.0/default/StreamOut.h"
|
||||
#include "core/2.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/StreamOut.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V2_0_CONVERSIONS_H_
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_CONVERSIONS_H_
|
||||
|
||||
#include <android/hardware/audio/2.0/types.h>
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/Conversions.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_CONVERSIONS_H_
|
||||
28
audio/core/2.0/default/include/core/2.0/default/Device.h
Normal file
28
audio/core/2.0/default/include/core/2.0/default/Device.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V2_0_DEVICE_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H
|
||||
|
||||
#include <android/hardware/audio/2.0/IDevice.h>
|
||||
|
||||
#include "ParametersUtil.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/Device.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V2_0_DEVICESFACTORY_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_DEVICESFACTORY_H
|
||||
|
||||
#include <android/hardware/audio/2.0/IDevicesFactory.h>
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/DevicesFactory.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_DEVICESFACTORY_H
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V2_0_PARAMETERS_UTIL_H_
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_PARAMETERS_UTIL_H_
|
||||
|
||||
#include <android/hardware/audio/2.0/types.h>
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/ParametersUtil.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_PARAMETERS_UTIL_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H
|
||||
|
||||
#include <android/hardware/audio/2.0/IPrimaryDevice.h>
|
||||
|
||||
#include "Device.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/PrimaryDevice.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H
|
||||
28
audio/core/2.0/default/include/core/2.0/default/Stream.h
Normal file
28
audio/core/2.0/default/include/core/2.0/default/Stream.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V2_0_STREAM_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H
|
||||
|
||||
#include <android/hardware/audio/2.0/IStream.h>
|
||||
|
||||
#include "ParametersUtil.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/Stream.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H
|
||||
29
audio/core/2.0/default/include/core/2.0/default/StreamIn.h
Normal file
29
audio/core/2.0/default/include/core/2.0/default/StreamIn.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V2_0_STREAMIN_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_STREAMIN_H
|
||||
|
||||
#include <android/hardware/audio/2.0/IStreamIn.h>
|
||||
|
||||
#include "Device.h"
|
||||
#include "Stream.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/StreamIn.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_STREAMIN_H
|
||||
29
audio/core/2.0/default/include/core/2.0/default/StreamOut.h
Normal file
29
audio/core/2.0/default/include/core/2.0/default/StreamOut.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V2_0_STREAMOUT_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_STREAMOUT_H
|
||||
|
||||
#include <android/hardware/audio/2.0/IStreamOut.h>
|
||||
|
||||
#include "Device.h"
|
||||
#include "Stream.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/StreamOut.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_STREAMOUT_H
|
||||
26
audio/core/2.0/default/include/core/2.0/default/Util.h
Normal file
26
audio/core/2.0/default/include/core/2.0/default/Util.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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_HARDWARE_AUDIO_V2_0_UTIL_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V2_0_UTIL_H
|
||||
|
||||
#include <android/hardware/audio/2.0/types.h>
|
||||
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include <core/all-versions/default/Util.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V2_0_UTIL_H
|
||||
@@ -25,9 +25,8 @@ cc_test {
|
||||
"android.hardware.audio.common.test.utility",
|
||||
"android.hardware.audio@2.0",
|
||||
"android.hardware.audio.common@2.0",
|
||||
"libicuuc",
|
||||
"libicuuc_stubdata",
|
||||
"libxml2",
|
||||
],
|
||||
shared_libs: [
|
||||
"libicuuc",
|
||||
],
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <initializer_list>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -40,9 +41,11 @@
|
||||
#include "utility/AssertOk.h"
|
||||
#include "utility/Documentation.h"
|
||||
#include "utility/EnvironmentTearDown.h"
|
||||
#define AUDIO_HAL_VERSION V2_0
|
||||
#include "utility/PrettyPrintAudioTypes.h"
|
||||
#include "utility/ReturnIn.h"
|
||||
|
||||
using std::initializer_list;
|
||||
using std::string;
|
||||
using std::to_string;
|
||||
using std::vector;
|
||||
@@ -85,8 +88,13 @@ using ::android::hardware::audio::common::V2_0::ThreadInfo;
|
||||
|
||||
using namespace ::android::hardware::audio::common::test::utility;
|
||||
|
||||
class AudioHidlTestEnvironment : public ::Environment {
|
||||
public:
|
||||
virtual void registerTestServices() override { registerTestService<IDevicesFactory>(); }
|
||||
};
|
||||
|
||||
// Instance to register global tearDown
|
||||
static Environment* environment;
|
||||
static AudioHidlTestEnvironment* environment;
|
||||
|
||||
class HidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
protected:
|
||||
@@ -106,8 +114,8 @@ class AudioHidlTest : public HidlTest {
|
||||
|
||||
if (devicesFactory == nullptr) {
|
||||
environment->registerTearDown([] { devicesFactory.clear(); });
|
||||
devicesFactory = ::testing::VtsHalHidlTargetTestBase::getService<
|
||||
IDevicesFactory>();
|
||||
devicesFactory = ::testing::VtsHalHidlTargetTestBase::getService<IDevicesFactory>(
|
||||
environment->getServiceName<IDevicesFactory>("default"));
|
||||
}
|
||||
ASSERT_TRUE(devicesFactory != nullptr);
|
||||
}
|
||||
@@ -126,8 +134,7 @@ TEST_F(AudioHidlTest, OpenDeviceInvalidParameter) {
|
||||
doc::test("test passing an invalid parameter to openDevice");
|
||||
IDevicesFactory::Result result;
|
||||
sp<IDevice> device;
|
||||
ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device(-1),
|
||||
returnIn(result, device)));
|
||||
ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device(-1), returnIn(result, device)));
|
||||
ASSERT_EQ(IDevicesFactory::Result::INVALID_ARGUMENTS, result);
|
||||
ASSERT_TRUE(device == nullptr);
|
||||
}
|
||||
@@ -146,9 +153,8 @@ class AudioPrimaryHidlTest : public AudioHidlTest {
|
||||
if (device == nullptr) {
|
||||
IDevicesFactory::Result result;
|
||||
sp<IDevice> baseDevice;
|
||||
ASSERT_OK(
|
||||
devicesFactory->openDevice(IDevicesFactory::Device::PRIMARY,
|
||||
returnIn(result, baseDevice)));
|
||||
ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device::PRIMARY,
|
||||
returnIn(result, baseDevice)));
|
||||
ASSERT_OK(result);
|
||||
ASSERT_TRUE(baseDevice != nullptr);
|
||||
|
||||
@@ -182,10 +188,8 @@ class AccessorPrimaryHidlTest : public AudioPrimaryHidlTest {
|
||||
protected:
|
||||
/** Test a property getter and setter. */
|
||||
template <class Getter, class Setter>
|
||||
void testAccessors(const string& propertyName,
|
||||
const vector<Property>& valuesToTest, Setter setter,
|
||||
Getter getter,
|
||||
const vector<Property>& invalidValues = {}) {
|
||||
void testAccessors(const string& propertyName, const vector<Property>& valuesToTest,
|
||||
Setter setter, Getter getter, const vector<Property>& invalidValues = {}) {
|
||||
Property initialValue; // Save initial value to restore it at the end
|
||||
// of the test
|
||||
ASSERT_OK((device.get()->*getter)(returnIn(res, initialValue)));
|
||||
@@ -203,21 +207,17 @@ class AccessorPrimaryHidlTest : public AudioPrimaryHidlTest {
|
||||
}
|
||||
|
||||
for (Property invalidValue : invalidValues) {
|
||||
SCOPED_TRACE("Try to set " + propertyName +
|
||||
" with the invalid value " +
|
||||
SCOPED_TRACE("Try to set " + propertyName + " with the invalid value " +
|
||||
testing::PrintToString(invalidValue));
|
||||
EXPECT_RESULT(Result::INVALID_ARGUMENTS,
|
||||
(device.get()->*setter)(invalidValue));
|
||||
EXPECT_RESULT(Result::INVALID_ARGUMENTS, (device.get()->*setter)(invalidValue));
|
||||
}
|
||||
|
||||
ASSERT_OK(
|
||||
(device.get()->*setter)(initialValue)); // restore initial value
|
||||
ASSERT_OK((device.get()->*setter)(initialValue)); // restore initial value
|
||||
}
|
||||
|
||||
/** Test the getter and setter of an optional feature. */
|
||||
template <class Getter, class Setter>
|
||||
void testOptionalAccessors(const string& propertyName,
|
||||
const vector<Property>& valuesToTest,
|
||||
void testOptionalAccessors(const string& propertyName, const vector<Property>& valuesToTest,
|
||||
Setter setter, Getter getter,
|
||||
const vector<Property>& invalidValues = {}) {
|
||||
doc::test("Test the optional " + propertyName + " getters and setter");
|
||||
@@ -232,8 +232,7 @@ class AccessorPrimaryHidlTest : public AudioPrimaryHidlTest {
|
||||
ASSERT_OK(res); // If it is supported it must succeed
|
||||
}
|
||||
// The feature is supported, test it
|
||||
testAccessors(propertyName, valuesToTest, setter, getter,
|
||||
invalidValues);
|
||||
testAccessors(propertyName, valuesToTest, setter, getter, invalidValues);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -241,8 +240,7 @@ using BoolAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<bool>;
|
||||
|
||||
TEST_F(BoolAccessorPrimaryHidlTest, MicMuteTest) {
|
||||
doc::test("Check that the mic can be muted and unmuted");
|
||||
testAccessors("mic mute", {true, false, true}, &IDevice::setMicMute,
|
||||
&IDevice::getMicMute);
|
||||
testAccessors("mic mute", {true, false, true}, &IDevice::setMicMute, &IDevice::getMicMute);
|
||||
// TODO: check that the mic is really muted (all sample are 0)
|
||||
}
|
||||
|
||||
@@ -250,18 +248,17 @@ TEST_F(BoolAccessorPrimaryHidlTest, MasterMuteTest) {
|
||||
doc::test(
|
||||
"If master mute is supported, try to mute and unmute the master "
|
||||
"output");
|
||||
testOptionalAccessors("master mute", {true, false, true},
|
||||
&IDevice::setMasterMute, &IDevice::getMasterMute);
|
||||
testOptionalAccessors("master mute", {true, false, true}, &IDevice::setMasterMute,
|
||||
&IDevice::getMasterMute);
|
||||
// TODO: check that the master volume is really muted
|
||||
}
|
||||
|
||||
using FloatAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<float>;
|
||||
TEST_F(FloatAccessorPrimaryHidlTest, MasterVolumeTest) {
|
||||
doc::test("Test the master volume if supported");
|
||||
testOptionalAccessors("master volume", {0, 0.5, 1},
|
||||
&IDevice::setMasterVolume, &IDevice::getMasterVolume,
|
||||
{-0.1, 1.1, NAN, INFINITY, -INFINITY,
|
||||
1 + std::numeric_limits<float>::epsilon()});
|
||||
testOptionalAccessors(
|
||||
"master volume", {0, 0.5, 1}, &IDevice::setMasterVolume, &IDevice::getMasterVolume,
|
||||
{-0.1, 1.1, NAN, INFINITY, -INFINITY, 1 + std::numeric_limits<float>::epsilon()});
|
||||
// TODO: check that the master volume is really changed
|
||||
}
|
||||
|
||||
@@ -300,17 +297,14 @@ class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest {
|
||||
public:
|
||||
// Cache result ?
|
||||
static const vector<AudioConfig> getRequiredSupportPlaybackAudioConfig() {
|
||||
return combineAudioConfig(
|
||||
{AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
|
||||
{8000, 11025, 16000, 22050, 32000, 44100},
|
||||
{AudioFormat::PCM_16_BIT});
|
||||
return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
|
||||
{8000, 11025, 16000, 22050, 32000, 44100},
|
||||
{AudioFormat::PCM_16_BIT});
|
||||
}
|
||||
|
||||
static const vector<AudioConfig>
|
||||
getRecommendedSupportPlaybackAudioConfig() {
|
||||
return combineAudioConfig(
|
||||
{AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
|
||||
{24000, 48000}, {AudioFormat::PCM_16_BIT});
|
||||
static const vector<AudioConfig> getRecommendedSupportPlaybackAudioConfig() {
|
||||
return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
|
||||
{24000, 48000}, {AudioFormat::PCM_16_BIT});
|
||||
}
|
||||
|
||||
static const vector<AudioConfig> getSupportedPlaybackAudioConfig() {
|
||||
@@ -320,8 +314,7 @@ class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest {
|
||||
}
|
||||
|
||||
static const vector<AudioConfig> getRequiredSupportCaptureAudioConfig() {
|
||||
return combineAudioConfig({AudioChannelMask::IN_MONO},
|
||||
{8000, 11025, 16000, 44100},
|
||||
return combineAudioConfig({AudioChannelMask::IN_MONO}, {8000, 11025, 16000, 44100},
|
||||
{AudioFormat::PCM_16_BIT});
|
||||
}
|
||||
static const vector<AudioConfig> getRecommendedSupportCaptureAudioConfig() {
|
||||
@@ -335,9 +328,9 @@ class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest {
|
||||
}
|
||||
|
||||
private:
|
||||
static const vector<AudioConfig> combineAudioConfig(
|
||||
vector<AudioChannelMask> channelMasks, vector<uint32_t> sampleRates,
|
||||
vector<AudioFormat> formats) {
|
||||
static const vector<AudioConfig> combineAudioConfig(vector<AudioChannelMask> channelMasks,
|
||||
vector<uint32_t> sampleRates,
|
||||
vector<AudioFormat> formats) {
|
||||
vector<AudioConfig> configs;
|
||||
for (auto channelMask : channelMasks) {
|
||||
for (auto sampleRate : sampleRates) {
|
||||
@@ -361,8 +354,7 @@ class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest {
|
||||
* As the only parameter changing are channel mask and sample rate,
|
||||
* only print those ones in the test name.
|
||||
*/
|
||||
static string generateTestName(
|
||||
const testing::TestParamInfo<AudioConfig>& info) {
|
||||
static string generateTestName(const testing::TestParamInfo<AudioConfig>& info) {
|
||||
const AudioConfig& config = info.param;
|
||||
return to_string(info.index) + "__" + to_string(config.sampleRateHz) + "_" +
|
||||
// "MONO" is more clear than "FRONT_LEFT"
|
||||
@@ -380,15 +372,12 @@ static string generateTestName(
|
||||
// android.hardware.microphone
|
||||
// how to get this value ? is it a property ???
|
||||
|
||||
class AudioCaptureConfigPrimaryTest
|
||||
: public AudioConfigPrimaryTest,
|
||||
public ::testing::WithParamInterface<AudioConfig> {
|
||||
class AudioCaptureConfigPrimaryTest : public AudioConfigPrimaryTest,
|
||||
public ::testing::WithParamInterface<AudioConfig> {
|
||||
protected:
|
||||
void inputBufferSizeTest(const AudioConfig& audioConfig,
|
||||
bool supportRequired) {
|
||||
void inputBufferSizeTest(const AudioConfig& audioConfig, bool supportRequired) {
|
||||
uint64_t bufferSize;
|
||||
ASSERT_OK(
|
||||
device->getInputBufferSize(audioConfig, returnIn(res, bufferSize)));
|
||||
ASSERT_OK(device->getInputBufferSize(audioConfig, returnIn(res, bufferSize)));
|
||||
|
||||
switch (res) {
|
||||
case Result::INVALID_ARGUMENTS:
|
||||
@@ -400,8 +389,7 @@ class AudioCaptureConfigPrimaryTest
|
||||
EXPECT_GT(bufferSize, uint64_t(0));
|
||||
break;
|
||||
default:
|
||||
FAIL() << "Invalid return status: "
|
||||
<< ::testing::PrintToString(res);
|
||||
FAIL() << "Invalid return status: " << ::testing::PrintToString(res);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -417,13 +405,11 @@ TEST_P(RequiredInputBufferSizeTest, RequiredInputBufferSizeTest) {
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
RequiredInputBufferSize, RequiredInputBufferSizeTest,
|
||||
::testing::ValuesIn(
|
||||
AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
|
||||
::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
|
||||
&generateTestName);
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
SupportedInputBufferSize, RequiredInputBufferSizeTest,
|
||||
::testing::ValuesIn(
|
||||
AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
|
||||
::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
|
||||
&generateTestName);
|
||||
|
||||
// Test that the recommended capture config are supported or lead to a
|
||||
@@ -437,8 +423,7 @@ TEST_P(OptionalInputBufferSizeTest, OptionalInputBufferSizeTest) {
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
RecommendedCaptureAudioConfigSupport, OptionalInputBufferSizeTest,
|
||||
::testing::ValuesIn(
|
||||
AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
|
||||
::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
|
||||
&generateTestName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -530,11 +515,9 @@ class OpenStreamTest : public AudioConfigPrimaryTest,
|
||||
void testOpen(Open openStream, const AudioConfig& config) {
|
||||
// FIXME: Open a stream without an IOHandle
|
||||
// This is not required to be accepted by hal implementations
|
||||
AudioIoHandle ioHandle =
|
||||
(AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE;
|
||||
AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE;
|
||||
AudioConfig suggestedConfig{};
|
||||
ASSERT_OK(openStream(ioHandle, config,
|
||||
returnIn(res, stream, suggestedConfig)));
|
||||
ASSERT_OK(openStream(ioHandle, config, returnIn(res, stream, suggestedConfig)));
|
||||
|
||||
// TODO: only allow failure for RecommendedPlaybackAudioConfig
|
||||
switch (res) {
|
||||
@@ -547,17 +530,15 @@ class OpenStreamTest : public AudioConfigPrimaryTest,
|
||||
AudioConfig suggestedConfigRetry;
|
||||
// Could not open stream with config, try again with the
|
||||
// suggested one
|
||||
ASSERT_OK(
|
||||
openStream(ioHandle, suggestedConfig,
|
||||
returnIn(res, stream, suggestedConfigRetry)));
|
||||
ASSERT_OK(openStream(ioHandle, suggestedConfig,
|
||||
returnIn(res, stream, suggestedConfigRetry)));
|
||||
// This time it must succeed
|
||||
ASSERT_OK(res);
|
||||
ASSERT_TRUE(stream != nullptr);
|
||||
audioConfig = suggestedConfig;
|
||||
break;
|
||||
default:
|
||||
FAIL() << "Invalid return status: "
|
||||
<< ::testing::PrintToString(res);
|
||||
FAIL() << "Invalid return status: " << ::testing::PrintToString(res);
|
||||
}
|
||||
open = true;
|
||||
}
|
||||
@@ -588,12 +569,10 @@ class OutputStreamTest : public OpenStreamTest<IStreamOut> {
|
||||
ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base
|
||||
address.device = AudioDevice::OUT_DEFAULT;
|
||||
const AudioConfig& config = GetParam();
|
||||
AudioOutputFlag flags =
|
||||
AudioOutputFlag::NONE; // TODO: test all flag combination
|
||||
AudioOutputFlag flags = AudioOutputFlag::NONE; // TODO: test all flag combination
|
||||
testOpen(
|
||||
[&](AudioIoHandle handle, AudioConfig config, auto cb) {
|
||||
return device->openOutputStream(handle, address, config, flags,
|
||||
cb);
|
||||
return device->openOutputStream(handle, address, config, flags, cb);
|
||||
},
|
||||
config);
|
||||
}
|
||||
@@ -606,19 +585,16 @@ TEST_P(OutputStreamTest, OpenOutputStreamTest) {
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
RequiredOutputStreamConfigSupport, OutputStreamTest,
|
||||
::testing::ValuesIn(
|
||||
AudioConfigPrimaryTest::getRequiredSupportPlaybackAudioConfig()),
|
||||
::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportPlaybackAudioConfig()),
|
||||
&generateTestName);
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
SupportedOutputStreamConfig, OutputStreamTest,
|
||||
::testing::ValuesIn(
|
||||
AudioConfigPrimaryTest::getSupportedPlaybackAudioConfig()),
|
||||
::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedPlaybackAudioConfig()),
|
||||
&generateTestName);
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
RecommendedOutputStreamConfigSupport, OutputStreamTest,
|
||||
::testing::ValuesIn(
|
||||
AudioConfigPrimaryTest::getRecommendedSupportPlaybackAudioConfig()),
|
||||
::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportPlaybackAudioConfig()),
|
||||
&generateTestName);
|
||||
|
||||
////////////////////////////// openInputStream //////////////////////////////
|
||||
@@ -628,14 +604,11 @@ class InputStreamTest : public OpenStreamTest<IStreamIn> {
|
||||
ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base
|
||||
address.device = AudioDevice::IN_DEFAULT;
|
||||
const AudioConfig& config = GetParam();
|
||||
AudioInputFlag flags =
|
||||
AudioInputFlag::NONE; // TODO: test all flag combination
|
||||
AudioSource source =
|
||||
AudioSource::DEFAULT; // TODO: test all flag combination
|
||||
AudioInputFlag flags = AudioInputFlag::NONE; // TODO: test all flag combination
|
||||
AudioSource source = AudioSource::DEFAULT; // TODO: test all flag combination
|
||||
testOpen(
|
||||
[&](AudioIoHandle handle, AudioConfig config, auto cb) {
|
||||
return device->openInputStream(handle, address, config, flags,
|
||||
source, cb);
|
||||
return device->openInputStream(handle, address, config, flags, source, cb);
|
||||
},
|
||||
config);
|
||||
}
|
||||
@@ -649,19 +622,16 @@ TEST_P(InputStreamTest, OpenInputStreamTest) {
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
RequiredInputStreamConfigSupport, InputStreamTest,
|
||||
::testing::ValuesIn(
|
||||
AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
|
||||
::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
|
||||
&generateTestName);
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
SupportedInputStreamConfig, InputStreamTest,
|
||||
::testing::ValuesIn(
|
||||
AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
|
||||
::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
|
||||
&generateTestName);
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
RecommendedInputStreamConfigSupport, InputStreamTest,
|
||||
::testing::ValuesIn(
|
||||
AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
|
||||
::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
|
||||
&generateTestName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -691,10 +661,8 @@ static R extract(Return<R> ret) {
|
||||
code; \
|
||||
}
|
||||
|
||||
TEST_IO_STREAM(
|
||||
GetFrameCount,
|
||||
"Check that the stream frame count == the one it was opened with",
|
||||
ASSERT_EQ(audioConfig.frameCount, extract(stream->getFrameCount())))
|
||||
TEST_IO_STREAM(GetFrameCount, "Check that the stream frame count == the one it was opened with",
|
||||
ASSERT_EQ(audioConfig.frameCount, extract(stream->getFrameCount())))
|
||||
|
||||
TEST_IO_STREAM(GetSampleRate, "Check that the stream sample rate == the one it was opened with",
|
||||
ASSERT_EQ(audioConfig.sampleRateHz, extract(stream->getSampleRate())))
|
||||
@@ -702,25 +670,22 @@ TEST_IO_STREAM(GetSampleRate, "Check that the stream sample rate == the one it w
|
||||
TEST_IO_STREAM(GetChannelMask, "Check that the stream channel mask == the one it was opened with",
|
||||
ASSERT_EQ(audioConfig.channelMask, extract(stream->getChannelMask())))
|
||||
|
||||
TEST_IO_STREAM(GetFormat,
|
||||
"Check that the stream format == the one it was opened with",
|
||||
TEST_IO_STREAM(GetFormat, "Check that the stream format == the one it was opened with",
|
||||
ASSERT_EQ(audioConfig.format, extract(stream->getFormat())))
|
||||
|
||||
// TODO: for now only check that the framesize is not incoherent
|
||||
TEST_IO_STREAM(GetFrameSize,
|
||||
"Check that the stream frame size == the one it was opened with",
|
||||
TEST_IO_STREAM(GetFrameSize, "Check that the stream frame size == the one it was opened with",
|
||||
ASSERT_GT(extract(stream->getFrameSize()), 0U))
|
||||
|
||||
TEST_IO_STREAM(GetBufferSize,
|
||||
"Check that the stream buffer size== the one it was opened with",
|
||||
ASSERT_GE(extract(stream->getBufferSize()),
|
||||
extract(stream->getFrameSize())));
|
||||
TEST_IO_STREAM(GetBufferSize, "Check that the stream buffer size== the one it was opened with",
|
||||
ASSERT_GE(extract(stream->getBufferSize()), extract(stream->getFrameSize())));
|
||||
|
||||
template <class Property, class CapabilityGetter, class Getter, class Setter>
|
||||
template <class Property, class CapabilityGetter>
|
||||
static void testCapabilityGetter(const string& name, IStream* stream,
|
||||
Property currentValue,
|
||||
CapabilityGetter capablityGetter,
|
||||
Getter getter, Setter setter) {
|
||||
Return<Property> (IStream::*getter)(),
|
||||
Return<Result> (IStream::*setter)(Property),
|
||||
bool currentMustBeSupported = true) {
|
||||
hidl_vec<Property> capabilities;
|
||||
ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities)));
|
||||
if (capabilities.size() == 0) {
|
||||
@@ -731,42 +696,46 @@ static void testCapabilityGetter(const string& name, IStream* stream,
|
||||
doc::partialTest(name + " is not supported");
|
||||
return;
|
||||
};
|
||||
// TODO: This code has never been tested on a hal that supports
|
||||
// getSupportedSampleRates
|
||||
EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
|
||||
capabilities.end())
|
||||
<< "current " << name << " is not in the list of the supported ones "
|
||||
<< toString(capabilities);
|
||||
|
||||
if (currentMustBeSupported) {
|
||||
Property currentValue = extract((stream->*getter)());
|
||||
EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
|
||||
capabilities.end())
|
||||
<< "current " << name << " is not in the list of the supported ones "
|
||||
<< toString(capabilities);
|
||||
}
|
||||
|
||||
// Check that all declared supported values are indeed supported
|
||||
for (auto capability : capabilities) {
|
||||
ASSERT_OK((stream->*setter)(capability));
|
||||
auto ret = (stream->*setter)(capability);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
if (ret == Result::NOT_SUPPORTED) {
|
||||
doc::partialTest("Setter is not supported");
|
||||
return;
|
||||
}
|
||||
ASSERT_OK(ret);
|
||||
ASSERT_EQ(capability, extract((stream->*getter)()));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_IO_STREAM(SupportedSampleRate,
|
||||
"Check that the stream sample rate is declared as supported",
|
||||
TEST_IO_STREAM(SupportedSampleRate, "Check that the stream sample rate is declared as supported",
|
||||
testCapabilityGetter("getSupportedSampleRate", stream.get(),
|
||||
extract(stream->getSampleRate()),
|
||||
&IStream::getSupportedSampleRates,
|
||||
&IStream::getSampleRate,
|
||||
&IStream::setSampleRate))
|
||||
&IStream::getSupportedSampleRates, &IStream::getSampleRate,
|
||||
&IStream::setSampleRate,
|
||||
// getSupportedSampleRate returns the native sampling rates,
|
||||
// (the sampling rates that can be played without resampling)
|
||||
// but other sampling rates can be supported by the HAL.
|
||||
false))
|
||||
|
||||
TEST_IO_STREAM(SupportedChannelMask,
|
||||
"Check that the stream channel mask is declared as supported",
|
||||
TEST_IO_STREAM(SupportedChannelMask, "Check that the stream channel mask is declared as supported",
|
||||
testCapabilityGetter("getSupportedChannelMask", stream.get(),
|
||||
extract(stream->getChannelMask()),
|
||||
&IStream::getSupportedChannelMasks,
|
||||
&IStream::getChannelMask,
|
||||
&IStream::getSupportedChannelMasks, &IStream::getChannelMask,
|
||||
&IStream::setChannelMask))
|
||||
|
||||
TEST_IO_STREAM(SupportedFormat,
|
||||
"Check that the stream format is declared as supported",
|
||||
TEST_IO_STREAM(SupportedFormat, "Check that the stream format is declared as supported",
|
||||
testCapabilityGetter("getSupportedFormat", stream.get(),
|
||||
extract(stream->getFormat()),
|
||||
&IStream::getSupportedFormats,
|
||||
&IStream::getFormat, &IStream::setFormat))
|
||||
&IStream::getSupportedFormats, &IStream::getFormat,
|
||||
&IStream::setFormat))
|
||||
|
||||
static void testGetDevice(IStream* stream, AudioDevice expectedDevice) {
|
||||
// Unfortunately the interface does not allow the implementation to return
|
||||
@@ -780,27 +749,22 @@ static void testGetDevice(IStream* stream, AudioDevice expectedDevice) {
|
||||
<< "\n Actual: " << ::testing::PrintToString(device);
|
||||
}
|
||||
|
||||
TEST_IO_STREAM(GetDevice,
|
||||
"Check that the stream device == the one it was opened with",
|
||||
areAudioPatchesSupported()
|
||||
? doc::partialTest("Audio patches are supported")
|
||||
: testGetDevice(stream.get(), address.device))
|
||||
TEST_IO_STREAM(GetDevice, "Check that the stream device == the one it was opened with",
|
||||
areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
|
||||
: testGetDevice(stream.get(), address.device))
|
||||
|
||||
static void testSetDevice(IStream* stream, const DeviceAddress& address) {
|
||||
DeviceAddress otherAddress = address;
|
||||
otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0
|
||||
? AudioDevice::OUT_SPEAKER
|
||||
: AudioDevice::IN_BUILTIN_MIC;
|
||||
otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER
|
||||
: AudioDevice::IN_BUILTIN_MIC;
|
||||
EXPECT_OK(stream->setDevice(otherAddress));
|
||||
|
||||
ASSERT_OK(stream->setDevice(address)); // Go back to the original value
|
||||
}
|
||||
|
||||
TEST_IO_STREAM(
|
||||
SetDevice,
|
||||
"Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
|
||||
areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
|
||||
: testSetDevice(stream.get(), address))
|
||||
TEST_IO_STREAM(SetDevice, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
|
||||
areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
|
||||
: testSetDevice(stream.get(), address))
|
||||
|
||||
static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig) {
|
||||
uint32_t sampleRateHz;
|
||||
@@ -823,8 +787,7 @@ TEST_IO_STREAM(GetAudioProperties,
|
||||
static void testConnectedState(IStream* stream) {
|
||||
DeviceAddress address = {};
|
||||
using AD = AudioDevice;
|
||||
for (auto device :
|
||||
{AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) {
|
||||
for (auto device : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) {
|
||||
address.device = device;
|
||||
|
||||
ASSERT_OK(stream->setConnectedState(address, true));
|
||||
@@ -836,17 +799,15 @@ TEST_IO_STREAM(SetConnectedState,
|
||||
"deconnection",
|
||||
testConnectedState(stream.get()))
|
||||
|
||||
static auto invalidArgsOrNotSupportedOrOK = {Result::INVALID_ARGUMENTS,
|
||||
Result::NOT_SUPPORTED, Result::OK};
|
||||
static auto invalidArgsOrNotSupportedOrOK = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED,
|
||||
Result::OK};
|
||||
TEST_IO_STREAM(SetHwAvSync, "Try to set hardware sync to an invalid value",
|
||||
ASSERT_RESULT(invalidArgsOrNotSupportedOrOK,
|
||||
stream->setHwAvSync(666)))
|
||||
ASSERT_RESULT(invalidArgsOrNotSupportedOrOK, stream->setHwAvSync(666)))
|
||||
|
||||
TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail",
|
||||
ASSERT_IS_OK(device->getHwAvSync()));
|
||||
TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", ASSERT_IS_OK(device->getHwAvSync()));
|
||||
|
||||
static void checkGetNoParameter(IStream* stream, hidl_vec<hidl_string> keys,
|
||||
vector<Result> expectedResults) {
|
||||
initializer_list<Result> expectedResults) {
|
||||
hidl_vec<ParameterValue> parameters;
|
||||
Result res;
|
||||
ASSERT_OK(stream->getParameters(keys, returnIn(res, parameters)));
|
||||
@@ -865,30 +826,23 @@ static void checkGetNoParameter(IStream* stream, hidl_vec<hidl_string> keys,
|
||||
TEST_IO_STREAM(getEmptySetParameter, "Retrieve the values of an empty set",
|
||||
checkGetNoParameter(stream.get(), {} /* keys */, {Result::OK}))
|
||||
|
||||
TEST_IO_STREAM(getNonExistingParameter,
|
||||
"Retrieve the values of an non existing parameter",
|
||||
checkGetNoParameter(stream.get(),
|
||||
{"Non existing key"} /* keys */,
|
||||
TEST_IO_STREAM(getNonExistingParameter, "Retrieve the values of an non existing parameter",
|
||||
checkGetNoParameter(stream.get(), {"Non existing key"} /* keys */,
|
||||
{Result::NOT_SUPPORTED}))
|
||||
|
||||
TEST_IO_STREAM(setEmptySetParameter,
|
||||
"Set the values of an empty set of parameters",
|
||||
TEST_IO_STREAM(setEmptySetParameter, "Set the values of an empty set of parameters",
|
||||
ASSERT_RESULT(Result::OK, stream->setParameters({})))
|
||||
|
||||
TEST_IO_STREAM(
|
||||
setNonExistingParameter, "Set the values of an non existing parameter",
|
||||
// Unfortunately, the set_parameter legacy interface did not return any
|
||||
// error code when a key is not supported.
|
||||
// To allow implementation to just wrapped the legacy one, consider OK as a
|
||||
// valid result for setting a non existing parameter.
|
||||
ASSERT_RESULT(invalidArgsOrNotSupportedOrOK,
|
||||
stream->setParameters({{"non existing key", "0"}})))
|
||||
TEST_IO_STREAM(setNonExistingParameter, "Set the values of an non existing parameter",
|
||||
// Unfortunately, the set_parameter legacy interface did not return any
|
||||
// error code when a key is not supported.
|
||||
// To allow implementation to just wrapped the legacy one, consider OK as a
|
||||
// valid result for setting a non existing parameter.
|
||||
ASSERT_RESULT(invalidArgsOrNotSupportedOrOK,
|
||||
stream->setParameters({{"non existing key", "0"}})))
|
||||
|
||||
TEST_IO_STREAM(DebugDump,
|
||||
"Check that a stream can dump its state without error",
|
||||
testDebugDump([this](const auto& handle) {
|
||||
return stream->debugDump(handle);
|
||||
}))
|
||||
TEST_IO_STREAM(DebugDump, "Check that a stream can dump its state without error",
|
||||
testDebugDump([this](const auto& handle) { return stream->debugDump(handle); }))
|
||||
|
||||
TEST_IO_STREAM(DebugDumpInvalidArguments,
|
||||
"Check that the stream dump doesn't crash on invalid arguments",
|
||||
@@ -900,10 +854,8 @@ TEST_IO_STREAM(DebugDumpInvalidArguments,
|
||||
|
||||
TEST_IO_STREAM(AddNonExistingEffect, "Adding a non existing effect should fail",
|
||||
ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->addEffect(666)))
|
||||
TEST_IO_STREAM(RemoveNonExistingEffect,
|
||||
"Removing a non existing effect should fail",
|
||||
ASSERT_RESULT(Result::INVALID_ARGUMENTS,
|
||||
stream->removeEffect(666)))
|
||||
TEST_IO_STREAM(RemoveNonExistingEffect, "Removing a non existing effect should fail",
|
||||
ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->removeEffect(666)))
|
||||
|
||||
// TODO: positive tests
|
||||
|
||||
@@ -914,29 +866,22 @@ TEST_IO_STREAM(RemoveNonExistingEffect,
|
||||
TEST_IO_STREAM(standby, "Make sure the stream can be put in stanby",
|
||||
ASSERT_OK(stream->standby())) // can not fail
|
||||
|
||||
static vector<Result> invalidStateOrNotSupported = {Result::INVALID_STATE,
|
||||
Result::NOT_SUPPORTED};
|
||||
static constexpr auto invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUPPORTED};
|
||||
|
||||
TEST_IO_STREAM(startNoMmap,
|
||||
"Starting a mmaped stream before mapping it should fail",
|
||||
TEST_IO_STREAM(startNoMmap, "Starting a mmaped stream before mapping it should fail",
|
||||
ASSERT_RESULT(invalidStateOrNotSupported, stream->start()))
|
||||
|
||||
TEST_IO_STREAM(stopNoMmap,
|
||||
"Stopping a mmaped stream before mapping it should fail",
|
||||
TEST_IO_STREAM(stopNoMmap, "Stopping a mmaped stream before mapping it should fail",
|
||||
ASSERT_RESULT(invalidStateOrNotSupported, stream->stop()))
|
||||
|
||||
TEST_IO_STREAM(getMmapPositionNoMmap,
|
||||
"Get a stream Mmap position before mapping it should fail",
|
||||
TEST_IO_STREAM(getMmapPositionNoMmap, "Get a stream Mmap position before mapping it should fail",
|
||||
ASSERT_RESULT(invalidStateOrNotSupported, stream->stop()))
|
||||
|
||||
TEST_IO_STREAM(close, "Make sure a stream can be closed",
|
||||
ASSERT_OK(closeStream()))
|
||||
TEST_IO_STREAM(closeTwice, "Make sure a stream can not be closed twice",
|
||||
ASSERT_OK(closeStream());
|
||||
TEST_IO_STREAM(close, "Make sure a stream can be closed", ASSERT_OK(closeStream()))
|
||||
TEST_IO_STREAM(closeTwice, "Make sure a stream can not be closed twice", ASSERT_OK(closeStream());
|
||||
ASSERT_RESULT(Result::INVALID_STATE, closeStream()))
|
||||
|
||||
static auto invalidArgsOrNotSupported = {Result::INVALID_ARGUMENTS,
|
||||
Result::NOT_SUPPORTED};
|
||||
static auto invalidArgsOrNotSupported = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED};
|
||||
static void testCreateTooBigMmapBuffer(IStream* stream) {
|
||||
MmapBufferInfo info;
|
||||
Result res;
|
||||
@@ -958,18 +903,16 @@ static void testGetMmapPositionOfNonMmapedStream(IStream* stream) {
|
||||
ASSERT_RESULT(invalidArgsOrNotSupported, res);
|
||||
}
|
||||
|
||||
TEST_IO_STREAM(
|
||||
GetMmapPositionOfNonMmapedStream,
|
||||
"Retrieving the mmap position of a non mmaped stream should fail",
|
||||
testGetMmapPositionOfNonMmapedStream(stream.get()))
|
||||
TEST_IO_STREAM(GetMmapPositionOfNonMmapedStream,
|
||||
"Retrieving the mmap position of a non mmaped stream should fail",
|
||||
testGetMmapPositionOfNonMmapedStream(stream.get()))
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////// StreamIn ///////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST_P(InputStreamTest, GetAudioSource) {
|
||||
doc::test(
|
||||
"Retrieving the audio source of an input stream should always succeed");
|
||||
doc::test("Retrieving the audio source of an input stream should always succeed");
|
||||
AudioSource source;
|
||||
ASSERT_OK(stream->getAudioSource(returnIn(res, source)));
|
||||
if (res == Result::NOT_SUPPORTED) {
|
||||
@@ -981,11 +924,9 @@ TEST_P(InputStreamTest, GetAudioSource) {
|
||||
}
|
||||
|
||||
static void testUnitaryGain(std::function<Return<Result>(float)> setGain) {
|
||||
for (float value :
|
||||
(float[]){-INFINITY, -1.0, 1.0 + std::numeric_limits<float>::epsilon(),
|
||||
2.0, INFINITY, NAN}) {
|
||||
EXPECT_RESULT(Result::INVALID_ARGUMENTS, setGain(value)) << "value="
|
||||
<< value;
|
||||
for (float value : (float[]){-INFINITY, -1.0, 1.0 + std::numeric_limits<float>::epsilon(), 2.0,
|
||||
INFINITY, NAN}) {
|
||||
EXPECT_RESULT(Result::INVALID_ARGUMENTS, setGain(value)) << "value=" << value;
|
||||
}
|
||||
// Do not consider -0.0 as an invalid value as it is == with 0.0
|
||||
for (float value : {-0.0, 0.0, 0.01, 0.5, 0.09, 1.0 /* Restore volume*/}) {
|
||||
@@ -993,8 +934,8 @@ static void testUnitaryGain(std::function<Return<Result>(float)> setGain) {
|
||||
}
|
||||
}
|
||||
|
||||
static void testOptionalUnitaryGain(
|
||||
std::function<Return<Result>(float)> setGain, string debugName) {
|
||||
static void testOptionalUnitaryGain(std::function<Return<Result>(float)> setGain,
|
||||
string debugName) {
|
||||
auto result = setGain(1);
|
||||
ASSERT_IS_OK(result);
|
||||
if (result == Result::NOT_SUPPORTED) {
|
||||
@@ -1006,32 +947,26 @@ static void testOptionalUnitaryGain(
|
||||
|
||||
TEST_P(InputStreamTest, SetGain) {
|
||||
doc::test("The gain of an input stream should only be set between [0,1]");
|
||||
testOptionalUnitaryGain(
|
||||
[this](float volume) { return stream->setGain(volume); },
|
||||
"InputStream::setGain");
|
||||
testOptionalUnitaryGain([this](float volume) { return stream->setGain(volume); },
|
||||
"InputStream::setGain");
|
||||
}
|
||||
|
||||
static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize,
|
||||
uint32_t framesCount) {
|
||||
static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize, uint32_t framesCount) {
|
||||
Result res;
|
||||
// Ignore output parameters as the call should fail
|
||||
ASSERT_OK(stream->prepareForReading(
|
||||
frameSize, framesCount,
|
||||
[&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
|
||||
ASSERT_OK(stream->prepareForReading(frameSize, framesCount,
|
||||
[&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
|
||||
EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
|
||||
}
|
||||
|
||||
TEST_P(InputStreamTest, PrepareForReadingWithZeroBuffer) {
|
||||
doc::test(
|
||||
"Preparing a stream for reading with a 0 sized buffer should fail");
|
||||
doc::test("Preparing a stream for reading with a 0 sized buffer should fail");
|
||||
testPrepareForReading(stream.get(), 0, 0);
|
||||
}
|
||||
|
||||
TEST_P(InputStreamTest, PrepareForReadingWithHugeBuffer) {
|
||||
doc::test(
|
||||
"Preparing a stream for reading with a 2^32 sized buffer should fail");
|
||||
testPrepareForReading(stream.get(), 1,
|
||||
std::numeric_limits<uint32_t>::max());
|
||||
doc::test("Preparing a stream for reading with a 2^32 sized buffer should fail");
|
||||
testPrepareForReading(stream.get(), 1, std::numeric_limits<uint32_t>::max());
|
||||
}
|
||||
|
||||
TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
|
||||
@@ -1043,8 +978,7 @@ TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
|
||||
}
|
||||
|
||||
TEST_P(InputStreamTest, GetInputFramesLost) {
|
||||
doc::test(
|
||||
"The number of frames lost on a never started stream should be 0");
|
||||
doc::test("The number of frames lost on a never started stream should be 0");
|
||||
auto ret = stream->getInputFramesLost();
|
||||
ASSERT_IS_OK(ret);
|
||||
uint32_t framesLost{ret};
|
||||
@@ -1074,32 +1008,26 @@ TEST_P(OutputStreamTest, getLatency) {
|
||||
|
||||
TEST_P(OutputStreamTest, setVolume) {
|
||||
doc::test("Try to set the output volume");
|
||||
testOptionalUnitaryGain(
|
||||
[this](float volume) { return stream->setVolume(volume, volume); },
|
||||
"setVolume");
|
||||
testOptionalUnitaryGain([this](float volume) { return stream->setVolume(volume, volume); },
|
||||
"setVolume");
|
||||
}
|
||||
|
||||
static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize,
|
||||
uint32_t framesCount) {
|
||||
static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize, uint32_t framesCount) {
|
||||
Result res;
|
||||
// Ignore output parameters as the call should fail
|
||||
ASSERT_OK(stream->prepareForWriting(
|
||||
frameSize, framesCount,
|
||||
[&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
|
||||
ASSERT_OK(stream->prepareForWriting(frameSize, framesCount,
|
||||
[&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
|
||||
EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
|
||||
}
|
||||
|
||||
TEST_P(OutputStreamTest, PrepareForWriteWithZeroBuffer) {
|
||||
doc::test(
|
||||
"Preparing a stream for writing with a 0 sized buffer should fail");
|
||||
doc::test("Preparing a stream for writing with a 0 sized buffer should fail");
|
||||
testPrepareForWriting(stream.get(), 0, 0);
|
||||
}
|
||||
|
||||
TEST_P(OutputStreamTest, PrepareForWriteWithHugeBuffer) {
|
||||
doc::test(
|
||||
"Preparing a stream for writing with a 2^32 sized buffer should fail");
|
||||
testPrepareForWriting(stream.get(), 1,
|
||||
std::numeric_limits<uint32_t>::max());
|
||||
doc::test("Preparing a stream for writing with a 2^32 sized buffer should fail");
|
||||
testPrepareForWriting(stream.get(), 1, std::numeric_limits<uint32_t>::max());
|
||||
}
|
||||
|
||||
TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) {
|
||||
@@ -1125,8 +1053,7 @@ struct Capability {
|
||||
};
|
||||
|
||||
TEST_P(OutputStreamTest, SupportsPauseAndResumeAndDrain) {
|
||||
doc::test(
|
||||
"Implementation must expose pause, resume and drain capabilities");
|
||||
doc::test("Implementation must expose pause, resume and drain capabilities");
|
||||
Capability(stream.get());
|
||||
}
|
||||
|
||||
@@ -1280,13 +1207,10 @@ TEST_P(OutputStreamTest, GetPresentationPositionStop) {
|
||||
struct timespec currentTS;
|
||||
ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, ¤tTS)) << errno;
|
||||
|
||||
auto toMicroSec = [](uint64_t sec, auto nsec) {
|
||||
return sec * 1e+6 + nsec / 1e+3;
|
||||
};
|
||||
auto toMicroSec = [](uint64_t sec, auto nsec) { return sec * 1e+6 + nsec / 1e+3; };
|
||||
auto currentTime = toMicroSec(currentTS.tv_sec, currentTS.tv_nsec);
|
||||
auto mesureTime = toMicroSec(mesureTS.tvSec, mesureTS.tvNSec);
|
||||
ASSERT_PRED2([](auto c, auto m) { return c - m < 1e+6; }, currentTime,
|
||||
mesureTime);
|
||||
ASSERT_PRED2([](auto c, auto m) { return c - m < 1e+6; }, currentTime, mesureTime);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1303,15 +1227,13 @@ TEST_F(AudioPrimaryHidlTest, setMode) {
|
||||
"Make sure setMode always succeeds if mode is valid "
|
||||
"and fails otherwise");
|
||||
// Test Invalid values
|
||||
for (AudioMode mode :
|
||||
{AudioMode::INVALID, AudioMode::CURRENT, AudioMode::CNT}) {
|
||||
for (AudioMode mode : {AudioMode::INVALID, AudioMode::CURRENT, AudioMode::CNT}) {
|
||||
SCOPED_TRACE("mode=" + toString(mode));
|
||||
ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(mode));
|
||||
}
|
||||
// Test valid values
|
||||
for (AudioMode mode :
|
||||
{AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
|
||||
AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) {
|
||||
for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
|
||||
AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) {
|
||||
SCOPED_TRACE("mode=" + toString(mode));
|
||||
ASSERT_OK(device->setMode(mode));
|
||||
}
|
||||
@@ -1334,15 +1256,13 @@ TEST_F(BoolAccessorPrimaryHidlTest, setGetBtScoWidebandEnabled) {
|
||||
using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>;
|
||||
TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) {
|
||||
doc::test("Query and set the TTY mode state");
|
||||
testOptionalAccessors(
|
||||
"TTY mode", {TtyMode::OFF, TtyMode::HCO, TtyMode::VCO, TtyMode::FULL},
|
||||
&IPrimaryDevice::setTtyMode, &IPrimaryDevice::getTtyMode);
|
||||
testOptionalAccessors("TTY mode", {TtyMode::OFF, TtyMode::HCO, TtyMode::VCO, TtyMode::FULL},
|
||||
&IPrimaryDevice::setTtyMode, &IPrimaryDevice::getTtyMode);
|
||||
}
|
||||
|
||||
TEST_F(BoolAccessorPrimaryHidlTest, setGetHac) {
|
||||
doc::test("Query and set the HAC state");
|
||||
testOptionalAccessors("HAC", {true, false, true},
|
||||
&IPrimaryDevice::setHacEnabled,
|
||||
testOptionalAccessors("HAC", {true, false, true}, &IPrimaryDevice::setHacEnabled,
|
||||
&IPrimaryDevice::getHacEnabled);
|
||||
}
|
||||
|
||||
@@ -1351,9 +1271,10 @@ TEST_F(BoolAccessorPrimaryHidlTest, setGetHac) {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
environment = new Environment;
|
||||
environment = new AudioHidlTestEnvironment;
|
||||
::testing::AddGlobalTestEnvironment(environment);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
environment->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
return status;
|
||||
}
|
||||
@@ -14,21 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
|
||||
#include "utility/ValidateXml.h"
|
||||
|
||||
TEST(CheckConfig, audioPolicyConfigurationValidation) {
|
||||
const char* configName = "audio_policy_configuration.xml";
|
||||
const char* possibleConfigLocations[] = {"/odm/etc", "/vendor/etc", "/system/etc"};
|
||||
const char* configSchemaPath = "/data/local/tmp/audio_policy_configuration.xsd";
|
||||
RecordProperty("description",
|
||||
"Verify that the audio policy configuration file "
|
||||
"is valid according to the schema");
|
||||
|
||||
for (std::string folder : possibleConfigLocations) {
|
||||
const auto configPath = folder + '/' + configName;
|
||||
if (access(configPath.c_str(), R_OK) == 0) {
|
||||
ASSERT_VALID_XML(configPath.c_str(), configSchemaPath);
|
||||
return; // The framework does not read past the first config file found
|
||||
}
|
||||
}
|
||||
std::vector<const char*> locations = {"/odm/etc", "/vendor/etc", "/system/etc"};
|
||||
EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS("audio_policy_configuration.xml", locations,
|
||||
"/data/local/tmp/audio_policy_configuration.xsd");
|
||||
}
|
||||
53
audio/core/4.0/default/Android.bp
Normal file
53
audio/core/4.0/default/Android.bp
Normal file
@@ -0,0 +1,53 @@
|
||||
cc_library_shared {
|
||||
name: "android.hardware.audio@4.0-impl",
|
||||
relative_install_path: "hw",
|
||||
proprietary: true,
|
||||
vendor: true,
|
||||
srcs: [
|
||||
"Conversions.cpp",
|
||||
"Device.cpp",
|
||||
"DevicesFactory.cpp",
|
||||
"ParametersUtil.cpp",
|
||||
"PrimaryDevice.cpp",
|
||||
"Stream.cpp",
|
||||
"StreamIn.cpp",
|
||||
"StreamOut.cpp",
|
||||
],
|
||||
|
||||
cflags: [
|
||||
"-DAUDIO_HAL_VERSION_4_0",
|
||||
],
|
||||
|
||||
defaults: ["hidl_defaults"],
|
||||
|
||||
export_include_dirs: ["include"],
|
||||
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libfmq",
|
||||
"libhardware",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"android.hardware.audio@4.0",
|
||||
"android.hardware.audio.common@4.0",
|
||||
"android.hardware.audio.common@4.0-util",
|
||||
"android.hardware.audio.common-util",
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"android.hardware.audio.common.util@all-versions",
|
||||
"android.hardware.audio.core@all-versions-impl",
|
||||
"libaudioclient_headers",
|
||||
"libaudio_system_headers",
|
||||
"libhardware_headers",
|
||||
"libmedia_headers",
|
||||
],
|
||||
|
||||
whole_static_libs: [
|
||||
"libmedia_helper",
|
||||
],
|
||||
|
||||
}
|
||||
21
audio/core/4.0/default/Conversions.cpp
Normal file
21
audio/core/4.0/default/Conversions.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "core/4.0/default/Conversions.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/Conversions.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
28
audio/core/4.0/default/Device.cpp
Normal file
28
audio/core/4.0/default/Device.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "DeviceHAL"
|
||||
|
||||
#include "core/4.0/default/Device.h"
|
||||
#include <HidlUtils.h>
|
||||
#include "core/4.0/default/Conversions.h"
|
||||
#include "core/4.0/default/StreamIn.h"
|
||||
#include "core/4.0/default/StreamOut.h"
|
||||
#include "core/4.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/Device.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
25
audio/core/4.0/default/DevicesFactory.cpp
Normal file
25
audio/core/4.0/default/DevicesFactory.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "DevicesFactoryHAL"
|
||||
|
||||
#include "core/4.0/default/DevicesFactory.h"
|
||||
#include "core/4.0/default/Device.h"
|
||||
#include "core/4.0/default/PrimaryDevice.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/DevicesFactory.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
3
audio/core/4.0/default/OWNERS
Normal file
3
audio/core/4.0/default/OWNERS
Normal file
@@ -0,0 +1,3 @@
|
||||
elaurent@google.com
|
||||
krocard@google.com
|
||||
mnaganov@google.com
|
||||
22
audio/core/4.0/default/ParametersUtil.cpp
Normal file
22
audio/core/4.0/default/ParametersUtil.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "core/4.0/default/ParametersUtil.h"
|
||||
#include "core/4.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/ParametersUtil.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
24
audio/core/4.0/default/PrimaryDevice.cpp
Normal file
24
audio/core/4.0/default/PrimaryDevice.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "PrimaryDeviceHAL"
|
||||
|
||||
#include "core/4.0/default/PrimaryDevice.h"
|
||||
#include "core/4.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/PrimaryDevice.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
26
audio/core/4.0/default/Stream.cpp
Normal file
26
audio/core/4.0/default/Stream.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "StreamHAL"
|
||||
|
||||
#include "core/4.0/default/Stream.h"
|
||||
#include "common/all-versions/default/EffectMap.h"
|
||||
#include "core/4.0/default/Conversions.h"
|
||||
#include "core/4.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/Stream.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
24
audio/core/4.0/default/StreamIn.cpp
Normal file
24
audio/core/4.0/default/StreamIn.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "StreamInHAL"
|
||||
|
||||
#include "core/4.0/default/StreamIn.h"
|
||||
#include "core/4.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/StreamIn.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
24
audio/core/4.0/default/StreamOut.cpp
Normal file
24
audio/core/4.0/default/StreamOut.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 "StreamOutHAL"
|
||||
|
||||
#include "core/4.0/default/StreamOut.h"
|
||||
#include "core/4.0/default/Util.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/StreamOut.impl.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_
|
||||
#define ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_
|
||||
|
||||
#include <android/hardware/audio/4.0/types.h>
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/Conversions.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_
|
||||
28
audio/core/4.0/default/include/core/4.0/default/Device.h
Normal file
28
audio/core/4.0/default/include/core/4.0/default/Device.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V4_0_DEVICE_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H
|
||||
|
||||
#include <android/hardware/audio/4.0/IDevice.h>
|
||||
|
||||
#include "ParametersUtil.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/Device.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H
|
||||
|
||||
#include <android/hardware/audio/4.0/IDevicesFactory.h>
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/DevicesFactory.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_
|
||||
#define ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_
|
||||
|
||||
#include <android/hardware/audio/4.0/types.h>
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/ParametersUtil.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H
|
||||
|
||||
#include <android/hardware/audio/4.0/IPrimaryDevice.h>
|
||||
|
||||
#include "Device.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/PrimaryDevice.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H
|
||||
28
audio/core/4.0/default/include/core/4.0/default/Stream.h
Normal file
28
audio/core/4.0/default/include/core/4.0/default/Stream.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V4_0_STREAM_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H
|
||||
|
||||
#include <android/hardware/audio/4.0/IStream.h>
|
||||
|
||||
#include "ParametersUtil.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/Stream.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H
|
||||
29
audio/core/4.0/default/include/core/4.0/default/StreamIn.h
Normal file
29
audio/core/4.0/default/include/core/4.0/default/StreamIn.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V4_0_STREAMIN_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H
|
||||
|
||||
#include <android/hardware/audio/4.0/IStreamIn.h>
|
||||
|
||||
#include "Device.h"
|
||||
#include "Stream.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/StreamIn.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H
|
||||
29
audio/core/4.0/default/include/core/4.0/default/StreamOut.h
Normal file
29
audio/core/4.0/default/include/core/4.0/default/StreamOut.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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_HARDWARE_AUDIO_V4_0_STREAMOUT_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H
|
||||
|
||||
#include <android/hardware/audio/4.0/IStreamOut.h>
|
||||
|
||||
#include "Device.h"
|
||||
#include "Stream.h"
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/StreamOut.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H
|
||||
26
audio/core/4.0/default/include/core/4.0/default/Util.h
Normal file
26
audio/core/4.0/default/include/core/4.0/default/Util.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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_HARDWARE_AUDIO_V4_0_UTIL_H
|
||||
#define ANDROID_HARDWARE_AUDIO_V4_0_UTIL_H
|
||||
|
||||
#include <android/hardware/audio/4.0/types.h>
|
||||
|
||||
#define AUDIO_HAL_VERSION V4_0
|
||||
#include <core/all-versions/default/Util.h>
|
||||
#undef AUDIO_HAL_VERSION
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_V4_0_UTIL_H
|
||||
35
audio/core/4.0/vts/functional/Android.bp
Normal file
35
audio/core/4.0/vts/functional/Android.bp
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Copyright (C) 2017 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.
|
||||
//
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalAudioV4_0TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: [
|
||||
"AudioPrimaryHidlHalTest.cpp",
|
||||
"ValidateAudioConfiguration.cpp"
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.audio.common.test.utility",
|
||||
"android.hardware.audio@4.0",
|
||||
"android.hardware.audio.common@4.0",
|
||||
"libicuuc",
|
||||
"libicuuc_stubdata",
|
||||
"libxml2",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.audio.common.util@all-versions",
|
||||
],
|
||||
}
|
||||
1467
audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
Normal file
1467
audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user