978ccd40f9
On platform release T, the legacy `audio.a2dp.default` HAL no longer exists, and cannot be trivially restored for generic system-side A2DP audio support. Rather than trying to cling on to its existence (which does not even work anymore even if one did so), it is time to come up with a new solution. This commit introduces a system-side implementation of the generic bluetooth audio HAL. The HAL itself is modelled after the default bluetooth audio HAL, while substantial components of the default audio HAL are also included as it has to also implement the audio HAL interfaces. The audio HAL implementation is delegated to `audio.sysbta.default`, forked from `audio.bluetooth.default` from the Bluetooth apex package. It then communicates with the bluetooth audio HAL interfaces, which need to live in the same process (in this case, the process of the sysbta HAL). This is why we cannot just load `audio.sysbta.default` into the default audio HAL or the audioserver process directly, but rather have to include our own simplistic audio HAL implementation. For now, the audio HAL implementation only includes one for the 6.0 version, but technically, an interface for *every* audio HAL version needs to exist. This, along with other messiness in the sysbta implementation, will be addressed in a future commit. Note that to actually make use of the sysbta audio hal, patches in frameworks/av and packages/modules/Bluetooth are required to introduce support for the property `persist.bluetooth.system_audio_hal.enabled`.
155 lines
6.7 KiB
C++
155 lines
6.7 KiB
C++
/*
|
|
* 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_PRIMARYDEVICE_H
|
|
#define ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H
|
|
|
|
#include PATH(android/hardware/audio/FILE_VERSION/IPrimaryDevice.h)
|
|
|
|
#include "Device.h"
|
|
|
|
#include <hidl/Status.h>
|
|
|
|
#include <hidl/MQDescriptor.h>
|
|
|
|
namespace android {
|
|
namespace hardware {
|
|
namespace audio {
|
|
namespace CPP_VERSION {
|
|
namespace implementation {
|
|
|
|
using ::android::sp;
|
|
using ::android::hardware::hidl_string;
|
|
using ::android::hardware::hidl_vec;
|
|
using ::android::hardware::Return;
|
|
using ::android::hardware::Void;
|
|
using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION;
|
|
using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION;
|
|
using namespace ::android::hardware::audio::CPP_VERSION;
|
|
|
|
struct PrimaryDevice : public IPrimaryDevice {
|
|
explicit PrimaryDevice(audio_hw_device_t* device);
|
|
|
|
// Methods from ::android::hardware::audio::CPP_VERSION::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,
|
|
#if MAJOR_VERSION <= 6
|
|
AudioOutputFlags flags,
|
|
#else
|
|
const AudioOutputFlags& flags,
|
|
#endif
|
|
#if MAJOR_VERSION >= 4
|
|
const SourceMetadata& sourceMetadata,
|
|
#endif
|
|
openOutputStream_cb _hidl_cb) override;
|
|
Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
|
|
const AudioConfig& config,
|
|
#if MAJOR_VERSION <= 6
|
|
AudioInputFlags flags,
|
|
#else
|
|
const AudioInputFlags& flags,
|
|
#endif
|
|
#if MAJOR_VERSION == 2
|
|
AudioSource source,
|
|
#elif MAJOR_VERSION >= 4
|
|
const SinkMetadata& sinkMetadata,
|
|
#endif
|
|
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<Result> setScreenState(bool turnedOn) override;
|
|
|
|
#if MAJOR_VERSION == 2
|
|
Return<AudioHwSync> getHwAvSync() 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;
|
|
#elif MAJOR_VERSION >= 4
|
|
Return<void> getHwAvSync(getHwAvSync_cb _hidl_cb) override;
|
|
Return<void> getParameters(const hidl_vec<ParameterValue>& context,
|
|
const hidl_vec<hidl_string>& keys,
|
|
getParameters_cb _hidl_cb) override;
|
|
Return<Result> setParameters(const hidl_vec<ParameterValue>& context,
|
|
const hidl_vec<ParameterValue>& parameters) override;
|
|
Return<void> getMicrophones(getMicrophones_cb _hidl_cb) override;
|
|
Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override;
|
|
#endif
|
|
#if MAJOR_VERSION >= 6
|
|
Return<Result> close() override;
|
|
Return<Result> addDeviceEffect(AudioPortHandle device, uint64_t effectId) override;
|
|
Return<Result> removeDeviceEffect(AudioPortHandle device, uint64_t effectId) override;
|
|
Return<void> updateAudioPatch(int32_t previousPatch, const hidl_vec<AudioPortConfig>& sources,
|
|
const hidl_vec<AudioPortConfig>& sinks,
|
|
updateAudioPatch_cb _hidl_cb) override;
|
|
#endif
|
|
|
|
Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
|
|
|
|
// Methods from ::android::hardware::audio::CPP_VERSION::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;
|
|
|
|
#if MAJOR_VERSION >= 4
|
|
Return<Result> setBtScoHeadsetDebugName(const hidl_string& name) override;
|
|
Return<void> getBtHfpEnabled(getBtHfpEnabled_cb _hidl_cb) override;
|
|
Return<Result> setBtHfpEnabled(bool enabled) override;
|
|
Return<Result> setBtHfpSampleRate(uint32_t sampleRateHz) override;
|
|
Return<Result> setBtHfpVolume(float volume) override;
|
|
Return<Result> updateRotation(IPrimaryDevice::Rotation rotation) override;
|
|
#endif
|
|
#if MAJOR_VERSION == 7 && MINOR_VERSION == 1
|
|
Return<sp<::android::hardware::audio::V7_1::IDevice>> getDevice() override { return mDevice; }
|
|
#endif
|
|
private:
|
|
sp<Device> mDevice;
|
|
|
|
virtual ~PrimaryDevice();
|
|
};
|
|
|
|
} // namespace implementation
|
|
} // namespace CPP_VERSION
|
|
} // namespace audio
|
|
} // namespace hardware
|
|
} // namespace android
|
|
|
|
#endif // ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H
|