1 // Copyright (C) 2020 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #include <aidl/device/google/atv/audio_proxy/AudioDrain.h> 18 #include <aidl/device/google/atv/audio_proxy/MmapBufferInfo.h> 19 #include <aidl/device/google/atv/audio_proxy/PresentationPosition.h> 20 #include <aidl/device/google/atv/audio_proxy/TimeSpec.h> 21 22 #include <memory> 23 24 #include "public/audio_proxy.h" 25 26 namespace audio_proxy { 27 28 using aidl::device::google::atv::audio_proxy::AudioDrain; 29 using aidl::device::google::atv::audio_proxy::MmapBufferInfo; 30 using aidl::device::google::atv::audio_proxy::PresentationPosition; 31 using aidl::device::google::atv::audio_proxy::TimeSpec; 32 33 // C++ friendly wrapper of audio_proxy_stream_out. It handles type conversion 34 // between C type and aidl type. 35 class AudioProxyStreamOut final { 36 public: 37 AudioProxyStreamOut(audio_proxy_stream_out_t* stream, 38 audio_proxy_device_t* device); 39 ~AudioProxyStreamOut(); 40 41 ssize_t write(const void* buffer, size_t bytes); 42 void getPresentationPosition(int64_t* frames, TimeSpec* timestamp) const; 43 44 void standby(); 45 void pause(); 46 void resume(); 47 void drain(AudioDrain type); 48 void flush(); 49 50 void setVolume(float left, float right); 51 52 int64_t getBufferSizeBytes(); 53 int32_t getLatencyMs(); 54 55 void start(); 56 void stop(); 57 MmapBufferInfo createMmapBuffer(int32_t minBufferSizeFrames); 58 PresentationPosition getMmapPosition(); 59 60 private: 61 audio_proxy_stream_out_t* const mStream; 62 audio_proxy_device_t* const mDevice; 63 }; 64 65 } // namespace audio_proxy 66