Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mmal_queue.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef MMAL_QUEUE_H
  26. #define MMAL_QUEUE_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /** \defgroup MmalQueue Queues of buffer headers
  31. * This provides a thread-safe implementation of a queue of buffer headers
  32. * (\ref MMAL_BUFFER_HEADER_T). The queue works in a first-in, first-out basis
  33. * so the buffer headers will be dequeued in the order they have been queued. */
  34. /* @{ */
  35. #include "mmal_buffer.h"
  36. typedef struct MMAL_QUEUE_T MMAL_QUEUE_T;
  37. /** Create a queue of MMAL_BUFFER_HEADER_T
  38. *
  39. * @return Pointer to the newly created queue or NULL on failure.
  40. */
  41. MMAL_QUEUE_T *mmal_queue_create(void);
  42. /** Put a MMAL_BUFFER_HEADER_T into a queue
  43. *
  44. * @param queue Pointer to a queue
  45. * @param buffer Pointer to the MMAL_BUFFER_HEADER_T to add to the queue
  46. */
  47. void mmal_queue_put(MMAL_QUEUE_T *queue, MMAL_BUFFER_HEADER_T *buffer);
  48. /** Put a MMAL_BUFFER_HEADER_T back at the start of a queue.
  49. * This is used when a buffer header was removed from the queue but not
  50. * fully processed and needs to be put back where it was originally taken.
  51. *
  52. * @param queue Pointer to a queue
  53. * @param buffer Pointer to the MMAL_BUFFER_HEADER_T to add to the queue
  54. */
  55. void mmal_queue_put_back(MMAL_QUEUE_T *queue, MMAL_BUFFER_HEADER_T *buffer);
  56. /** Get a MMAL_BUFFER_HEADER_T from a queue
  57. *
  58. * @param queue Pointer to a queue
  59. *
  60. * @return pointer to the next MMAL_BUFFER_HEADER_T or NULL if the queue is empty.
  61. */
  62. MMAL_BUFFER_HEADER_T *mmal_queue_get(MMAL_QUEUE_T *queue);
  63. /** Wait for a MMAL_BUFFER_HEADER_T from a queue.
  64. * This is the same as a get except that this will block until a buffer header is
  65. * available.
  66. *
  67. * @param queue Pointer to a queue
  68. *
  69. * @return pointer to the next MMAL_BUFFER_HEADER_T.
  70. */
  71. MMAL_BUFFER_HEADER_T *mmal_queue_wait(MMAL_QUEUE_T *queue);
  72. /** Wait for a MMAL_BUFFER_HEADER_T from a queue, up to a given timeout.
  73. * This is the same as a wait, except that it will abort in case of timeout.
  74. *
  75. * @param queue Pointer to a queue
  76. * @param timeout Number of milliseconds to wait before
  77. * returning if the semaphore can't be acquired.
  78. *
  79. * @return pointer to the next MMAL_BUFFER_HEADER_T.
  80. */
  81. MMAL_BUFFER_HEADER_T *mmal_queue_timedwait(MMAL_QUEUE_T *queue, VCOS_UNSIGNED timeout);
  82. /** Get the number of MMAL_BUFFER_HEADER_T currently in a queue.
  83. *
  84. * @param queue Pointer to a queue
  85. *
  86. * @return length (in elements) of the queue.
  87. */
  88. unsigned int mmal_queue_length(MMAL_QUEUE_T *queue);
  89. /** Destroy a queue of MMAL_BUFFER_HEADER_T.
  90. *
  91. * @param queue Pointer to a queue
  92. */
  93. void mmal_queue_destroy(MMAL_QUEUE_T *queue);
  94. /* @} */
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif /* MMAL_QUEUE_H */