• 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 // clang-format off
18 #include PATH(android/hardware/audio/FILE_VERSION/IStreamOut.h)
19 // clang-format on
20 #include <hidl/Status.h>
21 
22 namespace audio_proxy {
23 namespace service {
24 
25 using ::android::sp;
26 using ::android::hardware::hidl_bitfield;
27 using ::android::hardware::hidl_string;
28 using ::android::hardware::hidl_vec;
29 using ::android::hardware::Return;
30 using ::android::hardware::Void;
31 using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
32 using ::android::hardware::audio::common::CPP_VERSION::AudioConfig;
33 using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
34 using ::android::hardware::audio::common::CPP_VERSION::DeviceAddress;
35 using ::android::hardware::audio::common::CPP_VERSION::SourceMetadata;
36 using ::android::hardware::audio::CPP_VERSION::AudioDrain;
37 using ::android::hardware::audio::CPP_VERSION::IStreamOut;
38 using ::android::hardware::audio::CPP_VERSION::IStreamOutCallback;
39 using ::android::hardware::audio::CPP_VERSION::ParameterValue;
40 using ::android::hardware::audio::CPP_VERSION::Result;
41 
42 class DummyOutputStream : public IStreamOut {
43 public:
44   DummyOutputStream(const AudioConfig &config);
45 
46 private:
47   Return<uint64_t> getBufferSize() override;
48   Return<uint64_t> getFrameCount() override;
49 
50   Return<void>
51   getSupportedSampleRates(AudioFormat,
52                           getSupportedSampleRates_cb _hidl_cb) override;
53   Return<uint32_t> getSampleRate() override;
54 
55   Return<void>
56   getSupportedChannelMasks(AudioFormat,
57                            getSupportedChannelMasks_cb _hidl_cb) override;
58   Return<hidl_bitfield<AudioChannelMask>> getChannelMask() override;
59 
60   Return<void> getSupportedFormats(getSupportedFormats_cb _hidl_cb) override;
61   Return<AudioFormat> getFormat() override;
62 
63   Return<uint32_t> getLatency() override;
64 
65   Return<Result> standby() override;
66   Return<Result> pause() override;
67   Return<Result> resume() override;
68   Return<Result> drain(AudioDrain) override;
69 
70   Return<void> prepareForWriting(uint32_t frameSize, uint32_t framesCount,
71                                  prepareForWriting_cb _hidl_cb) override;
72 
73   Return<Result>
74   setParameters(const hidl_vec<ParameterValue> &context,
75                 const hidl_vec<ParameterValue> &parameters) override;
76   Return<void> getParameters(const hidl_vec<ParameterValue> &context,
77                              const hidl_vec<hidl_string> &keys,
78                              getParameters_cb _hidl_cb) override;
79 
80   Return<uint64_t> getFrameSize() override;
81   Return<Result> setSampleRate(uint32_t) override;
82   Return<Result> setChannelMask(hidl_bitfield<AudioChannelMask>) override;
83   Return<Result> setFormat(AudioFormat) override;
84   Return<void> getAudioProperties(getAudioProperties_cb _hidl_cb) override;
85   Return<Result> addEffect(uint64_t) override;
86   Return<Result> removeEffect(uint64_t) override;
87   Return<void> getDevices(getDevices_cb _hidl_cb) override;
88   Return<Result> setDevices(const hidl_vec<DeviceAddress> &) override;
89   Return<Result> setHwAvSync(uint32_t hwAvSync) override;
90   Return<Result> start() override;
91   Return<Result> stop() override;
92   Return<void> createMmapBuffer(int32_t minSizeFrames,
93                                 createMmapBuffer_cb _hidl_cb) override;
94   Return<void> getMmapPosition(getMmapPosition_cb _hidl_cb) override;
95   Return<Result> close() override;
96   Return<Result> setVolume(float left, float right) override;
97   Return<void> updateSourceMetadata(const SourceMetadata &) override;
98   Return<void> getRenderPosition(getRenderPosition_cb _hidl_cb) override;
99   Return<void>
100   getNextWriteTimestamp(getNextWriteTimestamp_cb _hidl_cb) override;
101   Return<Result> setCallback(const sp<IStreamOutCallback> &) override;
102   Return<Result> clearCallback() override;
103   Return<void>
104   supportsPauseAndResume(supportsPauseAndResume_cb _hidl_cb) override;
105   Return<bool> supportsDrain() override;
106   Return<Result> flush() override;
107   Return<void>
108   getPresentationPosition(getPresentationPosition_cb _hidl_cb) override;
109   Return<Result> selectPresentation(int32_t, int32_t) override;
110 
111 private:
112   const hidl_bitfield<AudioChannelMask> mChannelMask;
113   const AudioFormat mFormat;
114   const uint32_t mSampleRate;
115 };
116 
117 } // namespace service
118 } // namespace audio_proxy
119