/** Get a MMAL_BUFFER_HEADER_T from a QUEUE. */ MMAL_BUFFER_HEADER_T *mmal_queue_get(MMAL_QUEUE_T *queue) { vcos_assert(queue); if(!queue) return 0; if(vcos_semaphore_trywait(&queue->semaphore) != VCOS_SUCCESS) return NULL; return mmal_queue_get_core(queue); }
/** * <DFN>vc_hdcp2_service_wait_for_reply</DFN> blocks until a response comes back * from Videocore. * * @param client_handle is the vchi client handle * * @param sema is the signalling semaphore indicating a reply * * @param response is the reponse buffer * * @param max_length is the maximum length of the buffer * * @param actual_length will be set to the actual length of the buffer (or zero if error) * * @return zero if successful, vchi error code otherwise */ int32_t vc_hdcp2_service_wait_for_reply(VCHI_SERVICE_HANDLE_T client_handle, VCOS_SEMAPHORE_T *sema, void *response, uint32_t max_length, uint32_t *actual_length) { int32_t success = 0; VCOS_STATUS_T status; uint32_t length_read = 0; vcos_assert(sema); vcos_assert(response && max_length); do { //TODO : we need to deal with messages coming through on more than one connections properly //At the moment it will always try to read the first connection if there is something there //Check if there is something in the queue, if so return immediately //otherwise wait for the semaphore and read again success = vchi_msg_dequeue( client_handle, response, max_length, &length_read, VCHI_FLAGS_NONE ); } while( length_read == 0 || (status = vcos_semaphore_trywait(sema)) != VCOS_SUCCESS); if(vcos_verify(*actual_length)) { *actual_length = (success == 0)? length_read : 0; } return success; }