ijksdl_timer.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*****************************************************************************
  2. * ijksdl_thread.h
  3. *****************************************************************************
  4. *
  5. * Copyright (c) 2013 Bilibili
  6. * copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
  7. *
  8. * This file is part of ijkPlayer.
  9. *
  10. * ijkPlayer is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * ijkPlayer is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with ijkPlayer; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #ifndef IJKSDL__IJKSDL_TIMER_H
  25. #define IJKSDL__IJKSDL_TIMER_H
  26. #include "ijksdl_stdinc.h"
  27. void SDL_Delay(Uint32 ms);
  28. Uint64 SDL_GetTickHR(void);
  29. typedef struct SDL_Profiler
  30. {
  31. int64_t total_elapsed;
  32. int total_counter;
  33. int64_t sample_elapsed;
  34. int sample_counter;
  35. float sample_per_seconds;
  36. int64_t average_elapsed;
  37. int64_t begin_time;
  38. int max_sample;
  39. } SDL_Profiler;
  40. void SDL_ProfilerReset(SDL_Profiler* profiler, int max_sample);
  41. void SDL_ProfilerBegin(SDL_Profiler* profiler);
  42. int64_t SDL_ProfilerEnd(SDL_Profiler* profiler);
  43. typedef struct SDL_SpeedSampler
  44. {
  45. Uint64 samples[10];
  46. int capacity;
  47. int count;
  48. int first_index;
  49. int next_index;
  50. Uint64 last_log_time;
  51. } SDL_SpeedSampler;
  52. void SDL_SpeedSamplerReset(SDL_SpeedSampler *sampler);
  53. // return samples per seconds
  54. float SDL_SpeedSamplerAdd(SDL_SpeedSampler *sampler, int enable_log, const char *log_tag);
  55. typedef struct SDL_SpeedSampler2
  56. {
  57. int64_t sample_range;
  58. int64_t last_profile_tick;
  59. int64_t last_profile_duration;
  60. int64_t last_profile_quantity;
  61. int64_t last_profile_speed;
  62. } SDL_SpeedSampler2;
  63. void SDL_SpeedSampler2Reset(SDL_SpeedSampler2 *sampler, int sample_range);
  64. int64_t SDL_SpeedSampler2Add(SDL_SpeedSampler2 *sampler, int quantity);
  65. int64_t SDL_SpeedSampler2GetSpeed(SDL_SpeedSampler2 *sampler);
  66. #endif