• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/TimeSpec.h>
19 
20 #include <memory>
21 
22 #include "public/audio_proxy.h"
23 
24 namespace audio_proxy {
25 
26 using aidl::device::google::atv::audio_proxy::AudioDrain;
27 using aidl::device::google::atv::audio_proxy::TimeSpec;
28 
29 // C++ friendly wrapper of audio_proxy_stream_out. It handles type conversion
30 // between C type and aidl type.
31 class AudioProxyStreamOut final {
32  public:
33   AudioProxyStreamOut(audio_proxy_stream_out_t* stream,
34                       audio_proxy_device_t* device);
35   ~AudioProxyStreamOut();
36 
37   ssize_t write(const void* buffer, size_t bytes);
38   void getPresentationPosition(int64_t* frames, TimeSpec* timestamp) const;
39 
40   void standby();
41   void pause();
42   void resume();
43   void drain(AudioDrain type);
44   void flush();
45 
46   void setVolume(float left, float right);
47 
48  private:
49   audio_proxy_stream_out_t* const mStream;
50   audio_proxy_device_t* const mDevice;
51 };
52 
53 }  // namespace audio_proxy
54