Example #1
0
void
iec61883_dv_xmit_stop (iec61883_dv_t dv)
{
	assert (dv != NULL);
	if (dv->synch)
		raw1394_iso_xmit_sync (dv->handle);
	raw1394_iso_shutdown (dv->handle);
}
Example #2
0
static int _raw1394_iso_xmit_queue_packets(raw1394handle_t handle)
{
	struct raw1394_iso_status *stat = &handle->iso_status;
	struct raw1394_iso_packets packets;
	int retval = -1;
	int stop_sync = 0;

	if(handle->iso_mode != ISO_XMIT) {
		errno = EINVAL;
		goto out;
	}

	/* we could potentially send up to stat->n_packets packets */
	packets.n_packets = 0;
	packets.infos = malloc(stat->n_packets * sizeof(struct raw1394_iso_packet_info));
	if(packets.infos == NULL)
		goto out;

	while(stat->n_packets > 0) {
		enum raw1394_iso_disposition disp;
		unsigned int len;
		
		struct raw1394_iso_packet_info *info = &packets.infos[packets.n_packets];

		info->offset = handle->iso_buf_stride * handle->next_packet;
		
		/* call handler */
		disp = handle->iso_xmit_handler(handle,
						handle->iso_buffer + info->offset,
						&len,
						&info->tag, &info->sy,
						stat->xmit_cycle,
						_raw1394_iso_dropped(handle));
		info->len = len;
		
		/* advance packet cursors and cycle counter */
		stat->n_packets--;
		handle->next_packet = (handle->next_packet + 1) % stat->config.buf_packets;
		if(stat->xmit_cycle != -1)
			stat->xmit_cycle = (stat->xmit_cycle + 1) % 8000;
		packets.n_packets++;

		if(disp == RAW1394_ISO_DEFER) {
			/* queue an event so that we don't hang in the next read() */
			if(ioctl(handle->fd, RAW1394_IOC_ISO_QUEUE_ACTIVITY, 0))
				goto out_produce;
			break;
		} else if(disp == RAW1394_ISO_STOP) {
			stop_sync = 1;
			break;
		} else if(disp == RAW1394_ISO_STOP_NOSYNC) {
			raw1394_iso_stop(handle);
			break;
		} else if(disp == RAW1394_ISO_ERROR) {
			goto out_produce;
		}
	}

	/* success */
	retval = 0;

out_produce:
	if(packets.n_packets > 0) {
		if(ioctl(handle->fd, RAW1394_IOC_ISO_XMIT_PACKETS, &packets))
			retval = -1;
	}
	free(packets.infos);
out:
	if(stop_sync) {
		if(raw1394_iso_xmit_sync(handle))
			return -1;
		raw1394_iso_stop(handle);
	}
	
	return retval;
}