FastThreadState.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_THREAD_STATE_H
  17. #define ANDROID_AUDIO_FAST_THREAD_STATE_H
  18. #include "Configuration.h"
  19. #include <stdint.h>
  20. #include <media/nblog/NBLog.h>
  21. namespace android {
  22. struct FastThreadDumpState;
  23. // Represents a single state of a FastThread
  24. struct FastThreadState {
  25. FastThreadState();
  26. /*virtual*/ ~FastThreadState();
  27. typedef uint32_t Command;
  28. static const Command
  29. INITIAL = 0, // used only for the initial state
  30. HOT_IDLE = 1, // do nothing
  31. COLD_IDLE = 2, // wait for the futex
  32. IDLE = 3, // either HOT_IDLE or COLD_IDLE
  33. EXIT = 4; // exit from thread
  34. // additional values defined per subclass
  35. Command mCommand; // current command
  36. int32_t* mColdFutexAddr; // for COLD_IDLE only, pointer to the associated futex
  37. unsigned mColdGen; // increment when COLD_IDLE is requested so it's only performed once
  38. // This might be a one-time configuration rather than per-state
  39. FastThreadDumpState* mDumpState; // if non-NULL, then update dump state periodically
  40. NBLog::Writer* mNBLogWriter; // non-blocking logger
  41. // returns NULL if command belongs to a subclass
  42. static const char *commandToString(Command command);
  43. }; // struct FastThreadState
  44. } // android
  45. #endif // ANDROID_AUDIO_FAST_THREAD_STATE_H