ijksdl_mutex.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*****************************************************************************
  2. * ijksdl_mutex.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_MUTEX_H
  25. #define IJKSDL__IJKSDL_MUTEX_H
  26. #include <stdint.h>
  27. #include <pthread.h>
  28. #define SDL_MUTEX_TIMEDOUT 1
  29. #define SDL_MUTEX_MAXWAIT (~(uint32_t)0)
  30. typedef struct SDL_mutex {
  31. pthread_mutex_t id;
  32. } SDL_mutex;
  33. SDL_mutex *SDL_CreateMutex(void);
  34. void SDL_DestroyMutex(SDL_mutex *mutex);
  35. void SDL_DestroyMutexP(SDL_mutex **mutex);
  36. int SDL_LockMutex(SDL_mutex *mutex);
  37. int SDL_UnlockMutex(SDL_mutex *mutex);
  38. typedef struct SDL_cond {
  39. pthread_cond_t id;
  40. } SDL_cond;
  41. SDL_cond *SDL_CreateCond(void);
  42. void SDL_DestroyCond(SDL_cond *cond);
  43. void SDL_DestroyCondP(SDL_cond **mutex);
  44. int SDL_CondSignal(SDL_cond *cond);
  45. int SDL_CondBroadcast(SDL_cond *cond);
  46. int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, uint32_t ms);
  47. int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex);
  48. #endif