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 | 04333cd | 2015-02-17 16:23:03 -0800 | [diff] [blame] | 23 | #include "FastCaptureDumpState.h" |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | typedef StateQueue<FastCaptureState> FastCaptureStateQueue; |
| 28 | |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 29 | class FastCapture : public FastThread { |
| 30 | |
| 31 | public: |
| 32 | FastCapture(); |
| 33 | virtual ~FastCapture(); |
| 34 | |
| 35 | FastCaptureStateQueue* sq(); |
| 36 | |
| 37 | private: |
| 38 | FastCaptureStateQueue mSQ; |
| 39 | |
| 40 | // callouts |
| 41 | virtual const FastThreadState *poll(); |
Glenn Kasten | 3ab8d66 | 2017-04-03 14:35:09 -0700 | [diff] [blame] | 42 | virtual void setNBLogWriter(NBLog::Writer *logWriter); |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 43 | virtual void onIdle(); |
| 44 | virtual void onExit(); |
| 45 | virtual bool isSubClassCommand(FastThreadState::Command command); |
| 46 | virtual void onStateChange(); |
| 47 | virtual void onWork(); |
| 48 | |
Glenn Kasten | e4a7ce2 | 2015-03-03 11:23:17 -0800 | [diff] [blame] | 49 | static const FastCaptureState sInitial; |
| 50 | |
| 51 | FastCaptureState mPreIdle; // copy of state before we went into idle |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 52 | // FIXME by renaming, could pull up many of these to FastThread |
Glenn Kasten | e4a7ce2 | 2015-03-03 11:23:17 -0800 | [diff] [blame] | 53 | NBAIO_Source* mInputSource; |
| 54 | int mInputSourceGen; |
| 55 | NBAIO_Sink* mPipeSink; |
| 56 | int mPipeSinkGen; |
Glenn Kasten | 5115777 | 2015-03-03 11:48:45 -0800 | [diff] [blame] | 57 | void* mReadBuffer; |
Glenn Kasten | e4a7ce2 | 2015-03-03 11:23:17 -0800 | [diff] [blame] | 58 | ssize_t mReadBufferState; // number of initialized frames in readBuffer, |
| 59 | // or -1 to clear |
| 60 | NBAIO_Format mFormat; |
| 61 | unsigned mSampleRate; |
| 62 | FastCaptureDumpState mDummyFastCaptureDumpState; |
| 63 | uint32_t mTotalNativeFramesRead; // copied to dumpState->mFramesRead |
Glenn Kasten | f91df1b | 2014-03-13 14:59:31 -0700 | [diff] [blame] | 64 | |
| 65 | }; // class FastCapture |
| 66 | |
| 67 | } // namespace android |
| 68 | |
| 69 | #endif // ANDROID_AUDIO_FAST_CAPTURE_H |