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"
23 #include "FastCaptureDumpState.h"
24 
25 namespace android {
26 
27 typedef StateQueue<FastCaptureState> FastCaptureStateQueue;
28 
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();
42     virtual void setNBLogWriter(NBLog::Writer *logWriter);
43     virtual void onIdle();
44     virtual void onExit();
45     virtual bool isSubClassCommand(FastThreadState::Command command);
46     virtual void onStateChange();
47     virtual void onWork();
48 
49     static const FastCaptureState sInitial;
50 
51     FastCaptureState    mPreIdle;   // copy of state before we went into idle
52     // FIXME by renaming, could pull up many of these to FastThread
53     NBAIO_Source*       mInputSource;
54     int                 mInputSourceGen;
55     NBAIO_Sink*         mPipeSink;
56     int                 mPipeSinkGen;
57     void*               mReadBuffer;
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
64 
65 };  // class FastCapture
66 
67 }   // namespace android
68 
69 #endif  // ANDROID_AUDIO_FAST_CAPTURE_H
70