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: DriverStubImpl(const StreamContext & context)25 explicit DriverStubImpl(const StreamContext& context) 26 : DriverStubImpl(context, 500 /*asyncSleepTimeUs*/) {} 27 DriverStubImpl(const StreamContext& context, int asyncSleepTimeUs); 28 29 ::android::status_t init(DriverCallbackInterface* callback) override; 30 ::android::status_t drain(StreamDescriptor::DrainMode) override; 31 ::android::status_t flush() override; 32 ::android::status_t pause() override; 33 ::android::status_t standby() override; 34 ::android::status_t start() override; 35 ::android::status_t transfer(void* buffer, size_t frameCount, size_t* actualFrameCount, 36 int32_t* latencyMs) override; 37 void shutdown() override; 38 39 protected: 40 const size_t mBufferSizeFrames; 41 const size_t mFrameSizeBytes; 42 const int mSampleRate; 43 const bool mIsAsynchronous; 44 const bool mIsInput; 45 const int32_t mMixPortHandle; 46 const int mAsyncSleepTimeUs; 47 bool mIsInitialized = false; // Used for validating the state machine logic. 48 bool mIsStandby = true; // Used for validating the state machine logic. 49 int64_t mStartTimeNs = 0; 50 long mFramesSinceStart = 0; 51 }; 52 53 } // namespace aidl::android::hardware::audio::core 54