static void arv_stream_finalize (GObject *object) { ArvStream *stream = ARV_STREAM (object); ArvBuffer *buffer; arv_debug_stream ("[Stream::finalize] Flush %d buffer[s] in input queue", g_async_queue_length (stream->priv->input_queue)); arv_debug_stream ("[Stream::finalize] Flush %d buffer[s] in output queue", g_async_queue_length (stream->priv->output_queue)); do { buffer = g_async_queue_try_pop (stream->priv->output_queue); if (buffer != NULL) g_object_unref (buffer); } while (buffer != NULL); do { buffer = g_async_queue_try_pop (stream->priv->input_queue); if (buffer != NULL) g_object_unref (buffer); } while (buffer != NULL); g_async_queue_unref (stream->priv->input_queue); g_async_queue_unref (stream->priv->output_queue); parent_class->finalize (object); }
ArvStream * arv_uv_stream_new (ArvUvDevice *uv_device, ArvStreamCallback callback, void *user_data) { ArvDevice *device; ArvUvStream *uv_stream; ArvUvStreamThreadData *thread_data; ArvStream *stream; guint64 offset; guint64 sirm_offset; guint64 si_req_payload_size; guint32 si_req_leader_size; guint32 si_req_trailer_size; guint32 si_payload_size; guint32 si_payload_count; guint32 si_transfer1_size; guint32 si_transfer2_size; guint32 si_control; g_return_val_if_fail (ARV_IS_UV_DEVICE (uv_device), NULL); device = ARV_DEVICE (uv_device); arv_device_read_memory (device, ARV_ABRM_SBRM_ADDRESS, sizeof (guint64), &offset, NULL); arv_device_read_memory (device, offset + ARV_SBRM_SIRM_ADDRESS, sizeof (guint64), &sirm_offset, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_REQ_PAYLOAD_SIZE, sizeof (si_req_payload_size), &si_req_payload_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_REQ_LEADER_SIZE, sizeof (si_req_leader_size), &si_req_leader_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_REQ_TRAILER_SIZE, sizeof (si_req_trailer_size), &si_req_trailer_size, NULL); arv_debug_stream ("SI_REQ_PAYLOAD_SIZE = 0x%016lx", si_req_payload_size); arv_debug_stream ("SI_REQ_LEADER_SIZE = 0x%08x", si_req_leader_size); arv_debug_stream ("SI_REQ_TRAILER_SIZE = 0x%08x", si_req_trailer_size); si_payload_size = MAXIMUM_TRANSFER_SIZE; si_payload_count= si_req_payload_size / si_payload_size; si_transfer1_size = si_req_payload_size % si_payload_size; si_transfer2_size = 0; arv_device_write_memory (device, sirm_offset + ARV_SI_MAX_LEADER_SIZE, sizeof (si_req_leader_size), &si_req_leader_size, NULL); arv_device_write_memory (device, sirm_offset + ARV_SI_MAX_TRAILER_SIZE, sizeof (si_req_trailer_size), &si_req_trailer_size, NULL); arv_device_write_memory (device, sirm_offset + ARV_SI_PAYLOAD_SIZE, sizeof (si_payload_size), &si_payload_size, NULL); arv_device_write_memory (device, sirm_offset + ARV_SI_PAYLOAD_COUNT, sizeof (si_payload_count), &si_payload_count, NULL); arv_device_write_memory (device, sirm_offset + ARV_SI_TRANSFER1_SIZE, sizeof (si_transfer1_size), &si_transfer1_size, NULL); arv_device_write_memory (device, sirm_offset + ARV_SI_TRANSFER2_SIZE, sizeof (si_transfer2_size), &si_transfer2_size, NULL); arv_debug_stream ("SI_PAYLOAD_SIZE = 0x%08x", si_payload_size); arv_debug_stream ("SI_PAYLOAD_COUNT = 0x%08x", si_payload_count); arv_debug_stream ("SI_TRANSFER1_SIZE = 0x%08x", si_transfer1_size); arv_debug_stream ("SI_TRANSFER2_SIZE = 0x%08x", si_transfer2_size); arv_debug_stream ("SI_MAX_LEADER_SIZE = 0x%08x", si_req_leader_size); arv_debug_stream ("SI_MAX_TRAILER_SIZE = 0x%08x", si_req_trailer_size); si_control = 0x1; arv_device_write_memory (device, sirm_offset + ARV_SI_CONTROL, sizeof (si_control), &si_control, NULL); uv_stream = g_object_new (ARV_TYPE_UV_STREAM, NULL); stream = ARV_STREAM (uv_stream); thread_data = g_new (ArvUvStreamThreadData, 1); thread_data->uv_device = g_object_ref (uv_device); thread_data->stream = stream; thread_data->callback = callback; thread_data->user_data = user_data; thread_data->cancel = FALSE; thread_data->leader_size = si_req_leader_size; thread_data->payload_size = si_payload_size; thread_data->trailer_size = si_req_trailer_size; thread_data->n_completed_buffers = 0; thread_data->n_failures = 0; thread_data->n_underruns = 0; uv_stream->priv->thread_data = thread_data; uv_stream->priv->thread = arv_g_thread_new ("arv_uv_stream", arv_uv_stream_thread, uv_stream->priv->thread_data); return ARV_STREAM (uv_stream); }
static void arv_gv_stream_finalize (GObject *object) { ArvGvStream *gv_stream = ARV_GV_STREAM (object); if (gv_stream->thread != NULL) { ArvGvStreamThreadData *thread_data; char *statistic_string; thread_data = gv_stream->thread_data; thread_data->cancel = TRUE; g_thread_join (gv_stream->thread); g_object_unref (thread_data->device_address); statistic_string = arv_statistic_to_string (thread_data->statistic); arv_debug_stream (statistic_string); g_free (statistic_string); arv_statistic_free (thread_data->statistic); arv_debug_stream ("[GvStream::finalize] n_completed_buffers = %u", thread_data->n_completed_buffers); arv_debug_stream ("[GvStream::finalize] n_failures = %u", thread_data->n_failures); arv_debug_stream ("[GvStream::finalize] n_timeouts = %u", thread_data->n_timeouts); arv_debug_stream ("[GvStream::finalize] n_aborteds = %u", thread_data->n_aborteds); arv_debug_stream ("[GvStream::finalize] n_underruns = %u", thread_data->n_underruns); arv_debug_stream ("[GvStream::finalize] n_missing_frames = %u", thread_data->n_missing_frames); arv_debug_stream ("[GvStream::finalize] n_size_mismatch_errors = %u", thread_data->n_size_mismatch_errors); arv_debug_stream ("[GvStream::finalize] n_received_packets = %u", thread_data->n_received_packets); arv_debug_stream ("[GvStream::finalize] n_missing_packets = %u", thread_data->n_missing_packets); arv_debug_stream ("[GvStream::finalize] n_error_packets = %u", thread_data->n_error_packets); arv_debug_stream ("[GvStream::finalize] n_ignored_packets = %u", thread_data->n_ignored_packets); arv_debug_stream ("[GvStream::finalize] n_resend_requests = %u", thread_data->n_resend_requests); arv_debug_stream ("[GvStream::finalize] n_resent_packets = %u", thread_data->n_resent_packets); arv_debug_stream ("[GvStream::finalize] n_duplicated_packets = %u", thread_data->n_duplicated_packets); g_free (thread_data); gv_stream->thread_data = NULL; gv_stream->thread = NULL; } g_object_unref (gv_stream->incoming_address); g_object_unref (gv_stream->socket); parent_class->finalize (object); }