Пример #1
0
int raw1394_iso_xmit_sync(raw1394handle_t handle)
{
	if (!handle) {
		errno = EINVAL;
		return -1;
	}
	if (handle->is_fw)
		return fw_iso_xmit_sync(handle);
	else
		return ieee1394_iso_xmit_sync(handle->mode.ieee1394);
}
Пример #2
0
static int _iso_xmit_queue_packets(raw1394handle_t handle)
{
	ieee1394handle_t ihandle = handle->mode.ieee1394;
	struct raw1394_iso_status *stat = &ihandle->iso_status;
	struct raw1394_iso_packets packets;
	int retval = -1;
	int stop_sync = 0;

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

	/* ensure stat->n_packets is sane */
	if (stat->n_packets > stat->config.buf_packets)
		stat->n_packets = stat->config.buf_packets;

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

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

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

		if(disp == RAW1394_ISO_DEFER) {
			/* queue an event so that we don't hang in the next read() */
			if(ioctl(ihandle->fd, RAW1394_IOC_ISO_QUEUE_ACTIVITY, 0))
				goto out_produce;
			break;
		} else if(disp == RAW1394_ISO_AGAIN) {
			/* the last packet was not ready, decrement counter */
			packets.n_packets--;
			
			/* queue an event so that we don't hang in the next read() */
			if(ioctl(ihandle->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) {
			ieee1394_iso_stop(ihandle);
			break;
		} else if(disp == RAW1394_ISO_ERROR) {
			goto out_produce;
		}
	}

	/* success */
	retval = 0;

out_produce:
	if(packets.n_packets > 0) {
		if(ioctl(ihandle->fd, RAW1394_IOC_ISO_XMIT_PACKETS, &packets))
			retval = -1;
	}
out:
	if(stop_sync) {
		if(ieee1394_iso_xmit_sync(ihandle))
			return -1;
		ieee1394_iso_stop(ihandle);
	}
	
	return retval;
}