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 <memory>
19 #include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h)
20 #include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h)
21 #include "ireader.h"
22 
23 namespace android {
24 namespace hardware {
25 namespace audio {
26 namespace CPP_VERSION {
27 namespace implementation {
28 
29 using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION;
30 using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION;
31 
32 struct DevicePortSink {
~DevicePortSinkDevicePortSink33     virtual ~DevicePortSink() {}
34     virtual Result getPresentationPosition(uint64_t &frames, TimeSpec &ts) = 0;
35     virtual size_t write(float volume, size_t bytesToWrite, IReader &) = 0;
36 
37     static std::unique_ptr<DevicePortSink> create(size_t readerBufferSizeHint,
38                                                   const DeviceAddress &,
39                                                   const AudioConfig &,
40                                                   const hidl_vec<AudioInOutFlag> &,
41                                                   uint64_t initialFrames);
42 
43     static int getLatencyMs(const DeviceAddress &, const AudioConfig &);
44     static bool validateDeviceAddress(const DeviceAddress &);
45 };
46 
47 }  // namespace implementation
48 }  // namespace CPP_VERSION
49 }  // namespace audio
50 }  // namespace hardware
51 }  // namespace android
52