1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 #include <android/hardware/audio/6.0/IStream.h>
19 
20 namespace android {
21 namespace hardware {
22 namespace audio {
23 namespace V6_0 {
24 namespace implementation {
25 
26 using ::android::sp;
27 using ::android::hardware::hidl_bitfield;
28 using ::android::hardware::hidl_string;
29 using ::android::hardware::hidl_vec;
30 using ::android::hardware::Return;
31 using namespace ::android::hardware::audio::common::V6_0;
32 using namespace ::android::hardware::audio::V6_0;
33 
34 struct StreamCommon {
35     StreamCommon(int32_t ioHandle,
36                  const DeviceAddress& device,
37                  const AudioConfig& config,
38                  hidl_bitfield<AudioInputFlag> flags);
39 
40     uint64_t getFrameSize() const;
41     uint64_t getFrameCount() const;
42     uint64_t getBufferSize() const;
43     uint32_t getSampleRate() const;
44     void getSupportedSampleRates(AudioFormat format,
45                                  IStream::getSupportedSampleRates_cb _hidl_cb) const;
46     Result setSampleRate(uint32_t sampleRateHz) const;
47     hidl_bitfield<AudioChannelMask> getChannelMask() const;
48     void getSupportedChannelMasks(AudioFormat format,
49                                   IStream::getSupportedChannelMasks_cb _hidl_cb) const;
50     Result setChannelMask(hidl_bitfield<AudioChannelMask> mask) const;
51     AudioFormat getFormat() const;
52     void getSupportedFormats(IStream::getSupportedFormats_cb _hidl_cb) const;
53     Result setFormat(AudioFormat format) const;
54     void getAudioProperties(IStream::getAudioProperties_cb _hidl_cb) const;
55     void getDevices(IStream::getDevices_cb _hidl_cb) const;
56     Result setDevices(const hidl_vec<DeviceAddress>& devices) const;
57 
58     const int32_t m_ioHandle;
59     const DeviceAddress m_device;
60     const AudioConfig m_config;
61     const hidl_bitfield<AudioOutputFlag> m_flags;
62 };
63 
64 }  // namespace implementation
65 }  // namespace V6_0
66 }  // namespace audio
67 }  // namespace hardware
68 }  // namespace android
69