1 /* 2 * Copyright (C) 2024 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 19 #include "core-impl/Stream.h" 20 21 namespace aidl::android::hardware::audio::core { 22 23 class DriverStubImpl : virtual public DriverInterface { 24 public: 25 explicit DriverStubImpl(const StreamContext& context); 26 27 ::android::status_t init() override; 28 ::android::status_t drain(StreamDescriptor::DrainMode) override; 29 ::android::status_t flush() override; 30 ::android::status_t pause() override; 31 ::android::status_t standby() override; 32 ::android::status_t start() override; 33 ::android::status_t transfer(void* buffer, size_t frameCount, size_t* actualFrameCount, 34 int32_t* latencyMs) override; 35 void shutdown() override; 36 37 private: 38 const size_t mBufferSizeFrames; 39 const size_t mFrameSizeBytes; 40 const int mSampleRate; 41 const bool mIsAsynchronous; 42 const bool mIsInput; 43 bool mIsInitialized = false; // Used for validating the state machine logic. 44 bool mIsStandby = true; // Used for validating the state machine logic. 45 int64_t mStartTimeNs = 0; 46 long mFramesSinceStart = 0; 47 }; 48 49 } // namespace aidl::android::hardware::audio::core 50