FastCapture.h 2.2 KB

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