if (subs->hwptr == runtime->buffer_size) subs->hwptr = 0; 
static int prepare_playback_urb(snd_usb_substream_t *subs,				snd_pcm_runtime_t *runtime,				struct urb *urb){	int i, stride, offs;	unsigned int counts;	unsigned long flags;	snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context;	stride = runtime->frame_bits >> 3;	offs = 0;	urb->dev = ctx->subs->dev; /* we need to set this at each time */	urb->number_of_packets = 0;	spin_lock_irqsave(&subs->lock, flags);	for (i = 0; i < ctx->packets; i++) {		/* calculate the size of a packet */		if (subs->fill_max)			counts = subs->maxframesize; /* fixed */		else {			subs->phase = (subs->phase & 0xffff) + subs->freqm;			counts = subs->phase >> 16;			if (counts > subs->maxframesize)				counts = subs->maxframesize;		}		/* set up descriptor */		urb->iso_frame_desc[i].offset = offs * stride;		urb->iso_frame_desc[i].length = counts * stride;		offs += counts;		urb->number_of_packets++;		subs->transfer_sched += counts;		if (subs->transfer_sched >= runtime->period_size) {			subs->transfer_sched -= runtime->period_size;			if (subs->fmt_type == USB_FORMAT_TYPE_II) {				if (subs->transfer_sched > 0) {					/* FIXME: fill-max mode is not supported yet */					offs -= subs->transfer_sched;					counts -= subs->transfer_sched;					urb->iso_frame_desc[i].length = counts * stride;					subs->transfer_sched = 0;				}				i++;				if (i < ctx->packets) {					/* add a transfer delimiter */					urb->iso_frame_desc[i].offset = offs * stride;					urb->iso_frame_desc[i].length = 0;					urb->number_of_packets++;				}			}			break; 		}	}	if (subs->hwptr + offs > runtime->buffer_size) {		/* err, the transferred area goes over buffer boundary.		 * copy the data to the temp buffer.		 */		int len;		len = runtime->buffer_size - subs->hwptr;		urb->transfer_buffer = subs->tmpbuf;		memcpy(subs->tmpbuf, runtime->dma_area + subs->hwptr * stride, len * stride);		memcpy(subs->tmpbuf + len * stride, runtime->dma_area, (offs - len) * stride);		subs->hwptr += offs;		subs->hwptr -= runtime->buffer_size;	} else {		/* set the buffer pointer */		urb->transfer_buffer = runtime->dma_area + subs->hwptr * stride;		subs->hwptr += offs;	}	spin_unlock_irqrestore(&subs->lock, flags);	urb->transfer_buffer_length = offs * stride;	ctx->transfer = offs;	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/29b16931f936fdbcd78995e66d0f5626f3afbda8/usbaudio.c/clean/sound/usb/usbaudio.c