blob: c3817c0f32b93a3157e31c8d008943d8ccffeec0 [file] [log] [blame]
Glenn Kastenf91df1b2014-03-13 14:59:31 -07001/*
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 Kasten04333cd2015-02-17 16:23:03 -080023#include "FastCaptureDumpState.h"
Glenn Kastenf91df1b2014-03-13 14:59:31 -070024
25namespace android {
26
27typedef StateQueue<FastCaptureState> FastCaptureStateQueue;
28
Glenn Kastenf91df1b2014-03-13 14:59:31 -070029class FastCapture : public FastThread {
30
31public:
32 FastCapture();
33 virtual ~FastCapture();
34
35 FastCaptureStateQueue* sq();
36
37private:
38 FastCaptureStateQueue mSQ;
39
40 // callouts
41 virtual const FastThreadState *poll();
Glenn Kasten3ab8d662017-04-03 14:35:09 -070042 virtual void setNBLogWriter(NBLog::Writer *logWriter);
Glenn Kastenf91df1b2014-03-13 14:59:31 -070043 virtual void onIdle();
44 virtual void onExit();
45 virtual bool isSubClassCommand(FastThreadState::Command command);
46 virtual void onStateChange();
47 virtual void onWork();
48
Glenn Kastene4a7ce22015-03-03 11:23:17 -080049 static const FastCaptureState sInitial;
50
51 FastCaptureState mPreIdle; // copy of state before we went into idle
Glenn Kastenf91df1b2014-03-13 14:59:31 -070052 // FIXME by renaming, could pull up many of these to FastThread
Glenn Kastene4a7ce22015-03-03 11:23:17 -080053 NBAIO_Source* mInputSource;
54 int mInputSourceGen;
55 NBAIO_Sink* mPipeSink;
56 int mPipeSinkGen;
Glenn Kasten51157772015-03-03 11:48:45 -080057 void* mReadBuffer;
Glenn Kastene4a7ce22015-03-03 11:23:17 -080058 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 Kastenf91df1b2014-03-13 14:59:31 -070064
65}; // class FastCapture
66
67} // namespace android
68
69#endif // ANDROID_AUDIO_FAST_CAPTURE_H