1 /* 2 * Copyright (C) 2014 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 "FastThread.h" 20 #include "StateQueue.h" 21 #include "FastCaptureState.h" 22 #include "FastCaptureDumpState.h" 23 24 namespace android { 25 26 using FastCaptureStateQueue = StateQueue<FastCaptureState>; 27 28 class FastCapture : public FastThread { 29 30 public: 31 FastCapture(); 32 33 FastCaptureStateQueue* sq(); 34 35 private: 36 FastCaptureStateQueue mSQ; 37 38 // callouts 39 const FastThreadState *poll() override; 40 void setNBLogWriter(NBLog::Writer *logWriter) override; 41 void onIdle() override; 42 void onExit() override; 43 bool isSubClassCommand(FastThreadState::Command command) override; 44 void onStateChange() override; 45 void onWork() override; 46 47 static const FastCaptureState sInitial; 48 49 FastCaptureState mPreIdle; // copy of state before we went into idle 50 // FIXME by renaming, could pull up many of these to FastThread 51 NBAIO_Source* mInputSource = nullptr; 52 int mInputSourceGen = 0; 53 NBAIO_Sink* mPipeSink = nullptr; 54 int mPipeSinkGen = 0; 55 void* mReadBuffer = nullptr; 56 ssize_t mReadBufferState = -1; // number of initialized frames in readBuffer, 57 // or -1 to clear 58 NBAIO_Format mFormat = Format_Invalid; 59 unsigned mSampleRate = 0; 60 FastCaptureDumpState mDummyFastCaptureDumpState; 61 uint32_t mTotalNativeFramesRead = 0; // copied to dumpState->mFramesRead 62 63 }; // class FastCapture 64 65 } // namespace android 66