void send_buff_to_encoder(MMAL_PORT_T *port, MMAL_QUEUE_T *queue, MMAL_BUFFER_HEADER_T *buffer) { if (mmal_port_send_buffer(port, buffer) != MMAL_SUCCESS) { mmal_queue_put_back(queue, buffer); } }
/* Send a payload buffer to a connected port/client */ static MMAL_STATUS_T mmal_port_clock_forward_payload(MMAL_PORT_T *port, const MMAL_CLOCK_PAYLOAD_T *payload) { MMAL_STATUS_T status; MMAL_BUFFER_HEADER_T *buffer; buffer = mmal_queue_get(port->priv->module->queue); if (!buffer) { LOG_ERROR("no free buffers available"); return MMAL_ENOSPC; } status = mmal_buffer_header_mem_lock(buffer); if (status != MMAL_SUCCESS) { LOG_ERROR("failed to lock buffer %s", mmal_status_to_string(status)); mmal_queue_put_back(port->priv->module->queue, buffer); goto end; } buffer->length = sizeof(MMAL_CLOCK_PAYLOAD_T); memcpy(buffer->data, payload, buffer->length); mmal_buffer_header_mem_unlock(buffer); mmal_port_buffer_header_callback(port, buffer); end: return status; }
void consume_queue_on_connection(MMAL_PORT_T *port, MMAL_QUEUE_T *queue) { MMAL_BUFFER_HEADER_T *buffer; while ((buffer = mmal_queue_get(queue)) != NULL) { if (mmal_port_send_buffer(port, buffer) != MMAL_SUCCESS) { mmal_queue_put_back(queue, buffer); break; } } }
/** Send a buffer header to a port */ static MMAL_STATUS_T splitter_send_output(MMAL_BUFFER_HEADER_T *buffer, MMAL_PORT_T *out_port) { MMAL_BUFFER_HEADER_T *out; MMAL_STATUS_T status; /* Get a buffer header from output port */ out = mmal_queue_get(out_port->priv->module->queue); if (!out) return MMAL_EAGAIN; /* Copy our input buffer header */ status = mmal_buffer_header_replicate(out, buffer); if (status != MMAL_SUCCESS) goto error; /* Send buffer back */ mmal_port_buffer_header_callback(out_port, out); return MMAL_SUCCESS; error: mmal_queue_put_back(out_port->priv->module->queue, out); return status; }
/** Start playback on an instance of mmalplay. * Note: this is test code. Do not use it in your app. It *will* change or even be removed without notice. */ MMAL_STATUS_T mmalplay_play(MMALPLAY_T *ctx) { MMAL_STATUS_T status = MMAL_SUCCESS; unsigned int i; LOG_TRACE("%p, %s", ctx, ctx->uri); ctx->time_playback = vcos_getmicrosecs(); /* Start the clocks */ if (ctx->video_clock) mmal_port_parameter_set_boolean(ctx->video_clock, MMAL_PARAMETER_CLOCK_ACTIVE, MMAL_TRUE); if (ctx->audio_clock) mmal_port_parameter_set_boolean(ctx->audio_clock, MMAL_PARAMETER_CLOCK_ACTIVE, MMAL_TRUE); while(1) { MMAL_BUFFER_HEADER_T *buffer; vcos_semaphore_wait(&ctx->event); if (ctx->stop || ctx->status != MMAL_SUCCESS) { status = ctx->status; break; } /* Loop through all the connections */ for (i = 0; i < ctx->connection_num; i++) { MMAL_CONNECTION_T *connection = ctx->connection[i]; if (connection->flags & MMAL_CONNECTION_FLAG_TUNNELLING) continue; /* Nothing else to do in tunnelling mode */ /* Send any queued buffer to the next component */ buffer = mmal_queue_get(connection->queue); while (buffer) { if (buffer->cmd) { status = mmalplay_event_handle(connection, connection->out, buffer); if (status != MMAL_SUCCESS) goto error; buffer = mmal_queue_get(connection->queue); continue; } /* Code specific to handling of the video output port */ if (connection->out == ctx->video_out_port) { if (buffer->length) ctx->decoded_frames++; if (ctx->options.stepping) getchar(); } status = mmal_port_send_buffer(connection->in, buffer); if (status != MMAL_SUCCESS) { LOG_ERROR("mmal_port_send_buffer failed (%i)", status); mmal_queue_put_back(connection->queue, buffer); goto error; } buffer = mmal_queue_get(connection->queue); } /* Send empty buffers to the output port of the connection */ buffer = connection->pool ? mmal_queue_get(connection->pool->queue) : NULL; while (buffer) { status = mmal_port_send_buffer(connection->out, buffer); if (status != MMAL_SUCCESS) { LOG_ERROR("mmal_port_send_buffer failed (%i)", status); mmal_queue_put_back(connection->pool->queue, buffer); goto error; } buffer = mmal_queue_get(connection->pool->queue); } } } error: ctx->time_playback = vcos_getmicrosecs() - ctx->time_playback; /* For still images we want to pause a bit once they are displayed */ if (ctx->is_still_image && status == MMAL_SUCCESS) vcos_sleep(MMALPLAY_STILL_IMAGE_PAUSE); return status; }