Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 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 | #ifndef ANDROID_AUDIO_FAST_CAPTURE_H |
| 18 | #define ANDROID_AUDIO_FAST_CAPTURE_H |
| 19 | |
| 20 | #include "FastThread.h" |
| 21 | #include "StateQueue.h" |
| 22 | #include "FastCaptureState.h" |
Glenn Kasten | 045ee7e | 2015-02-17 16:22:04 -0800 | [diff] [blame^] | 23 | #include "FastThreadDumpState.h" |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | typedef StateQueue<FastCaptureState> FastCaptureStateQueue; |
| 28 | |
| 29 | struct FastCaptureDumpState : FastThreadDumpState { |
| 30 | FastCaptureDumpState(); |
| 31 | /*virtual*/ ~FastCaptureDumpState(); |
| 32 | |
| 33 | // FIXME by renaming, could pull up many of these to FastThreadDumpState |
| 34 | uint32_t mReadSequence; // incremented before and after each read() |
| 35 | uint32_t mFramesRead; // total number of frames read successfully |
| 36 | uint32_t mReadErrors; // total number of read() errors |
| 37 | uint32_t mSampleRate; |
| 38 | size_t mFrameCount; |
| 39 | }; |
| 40 | |
| 41 | class FastCapture : public FastThread { |
| 42 | |
| 43 | public: |
| 44 | FastCapture(); |
| 45 | virtual ~FastCapture(); |
| 46 | |
| 47 | FastCaptureStateQueue* sq(); |
| 48 | |
| 49 | private: |
| 50 | FastCaptureStateQueue mSQ; |
| 51 | |
| 52 | // callouts |
| 53 | virtual const FastThreadState *poll(); |
| 54 | virtual void setLog(NBLog::Writer *logWriter); |
| 55 | virtual void onIdle(); |
| 56 | virtual void onExit(); |
| 57 | virtual bool isSubClassCommand(FastThreadState::Command command); |
| 58 | virtual void onStateChange(); |
| 59 | virtual void onWork(); |
| 60 | |
| 61 | static const FastCaptureState initial; |
| 62 | FastCaptureState preIdle; // copy of state before we went into idle |
| 63 | // FIXME by renaming, could pull up many of these to FastThread |
| 64 | NBAIO_Source *inputSource; |
| 65 | int inputSourceGen; |
| 66 | NBAIO_Sink *pipeSink; |
| 67 | int pipeSinkGen; |
| 68 | short *readBuffer; |
| 69 | ssize_t readBufferState; // number of initialized frames in readBuffer, or -1 to clear |
| 70 | NBAIO_Format format; |
| 71 | unsigned sampleRate; |
| 72 | FastCaptureDumpState dummyDumpState; |
| 73 | uint32_t totalNativeFramesRead; // copied to dumpState->mFramesRead |
| 74 | |
| 75 | }; // class FastCapture |
| 76 | |
| 77 | } // namespace android |
| 78 | |
| 79 | #endif // ANDROID_AUDIO_FAST_CAPTURE_H |