subs->syncinterval = 1; 
subs->syncinterval = 3; 
static int set_format(snd_usb_substream_t *subs, struct audioformat *fmt){	struct usb_device *dev = subs->dev;	struct usb_host_interface *alts;	struct usb_interface_descriptor *altsd;	struct usb_interface *iface;	unsigned int ep, attr;	int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK;	int err;	iface = usb_ifnum_to_if(dev, fmt->iface);	snd_assert(iface, return -EINVAL);	alts = &iface->altsetting[fmt->altset_idx];	altsd = get_iface_desc(alts);	snd_assert(altsd->bAlternateSetting == fmt->altsetting, return -EINVAL);	if (fmt == subs->cur_audiofmt)		return 0;	/* close the old interface */	if (subs->interface >= 0 && subs->interface != fmt->iface) {		usb_set_interface(subs->dev, subs->interface, 0);		subs->interface = -1;		subs->format = 0;	}	/* set interface */	if (subs->interface != fmt->iface || subs->format != fmt->altset_idx) {		if (usb_set_interface(dev, fmt->iface, fmt->altsetting) < 0) {			snd_printk(KERN_ERR "%d:%d:%d: usb_set_interface failed\n",				   dev->devnum, fmt->iface, fmt->altsetting);			return -EIO;		}		snd_printdd(KERN_INFO "setting usb interface %d:%d\n", fmt->iface, fmt->altsetting);		subs->interface = fmt->iface;		subs->format = fmt->altset_idx;	}	/* create a data pipe */	ep = fmt->endpoint & USB_ENDPOINT_NUMBER_MASK;	if (is_playback)		subs->datapipe = usb_sndisocpipe(dev, ep);	else		subs->datapipe = usb_rcvisocpipe(dev, ep);	subs->syncpipe = subs->syncinterval = 0;	subs->maxpacksize = fmt->maxpacksize;	subs->fill_max = 0;	/* we need a sync pipe in async OUT or adaptive IN mode */	/* check the number of EP, since some devices have broken	 * descriptors which fool us.  if it has only one EP,	 * assume it as adaptive-out or sync-in.	 */	attr = fmt->ep_attr & EP_ATTR_MASK;	if (((is_playback && attr == EP_ATTR_ASYNC) ||	     (! is_playback && attr == EP_ATTR_ADAPTIVE)) &&	    altsd->bNumEndpoints >= 2) {		/* check sync-pipe endpoint */		/* ... and check descriptor size before accessing bSynchAddress		   because there is a version of the SB Audigy 2 NX firmware lacking		   the audio fields in the endpoint descriptors */		if ((get_endpoint(alts, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != 0x01 ||		    (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE &&		     get_endpoint(alts, 1)->bSynchAddress != 0)) {			snd_printk(KERN_ERR "%d:%d:%d : invalid synch pipe\n",				   dev->devnum, fmt->iface, fmt->altsetting);			return -EINVAL;		}		ep = get_endpoint(alts, 1)->bEndpointAddress;		if (get_endpoint(alts, 0)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE &&		    (( is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress | USB_DIR_IN)) ||		     (!is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress & ~USB_DIR_IN)))) {			snd_printk(KERN_ERR "%d:%d:%d : invalid synch pipe\n",				   dev->devnum, fmt->iface, fmt->altsetting);			return -EINVAL;		}		ep &= USB_ENDPOINT_NUMBER_MASK;		if (is_playback)			subs->syncpipe = usb_rcvisocpipe(dev, ep);		else			subs->syncpipe = usb_sndisocpipe(dev, ep);		if (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE &&		    get_endpoint(alts, 1)->bRefresh >= 1 &&		    get_endpoint(alts, 1)->bRefresh <= 9)			subs->syncinterval = get_endpoint(alts, 1)->bRefresh;		else			subs->syncinterval = 1;	}	/* always fill max packet size */	if (fmt->attributes & EP_CS_ATTR_FILL_MAX)		subs->fill_max = 1;	if ((err = init_usb_pitch(dev, subs->interface, alts, fmt)) < 0)		return err;	subs->cur_audiofmt = fmt;#if 0	printk("setting done: format = %d, rate = %d, channels = %d\n",	       fmt->format, fmt->rate, fmt->channels);	printk("  datapipe = 0x%0x, syncpipe = 0x%0x\n",	       subs->datapipe, subs->syncpipe);#endif	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/604cf499256af85703bd4858da56e777ec71714d/usbaudio.c/clean/sound/usb/usbaudio.c