⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 audio.c

📁 freebsd v4.4内核源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	zero_cmd(cmd);	cmd[0]=ABORT;			/*Abort playing audio*/	i=docmd(cmd,ldrive,cdrive,controller,port);	/*Issue command*/#ifdef DEBUGIOCTL	printf("matcd%d: Abort results %d \n",ldrive,i);#endif /*DEBUGIOCTL*/	cd->status=CD_AS_PLAY_COMPLETED;/*<14>the drive if it is paused*/	return(i);}/*-----------------------------------------------------------------------------	matcd_level - Read or set the audio levels<12>	New for Edit 12-----------------------------------------------------------------------------*/static int matcd_level(int ldrive, int cdrive, int controller,		       struct ioc_vol * level, int action){	struct	matcd_data *cd;	int	i,z,port;	unsigned char c;	unsigned char cmd[MAXCMDSIZ];	unsigned char data[5];	cd=&matcd_data[ldrive];	port=cd->iobase;	zero_cmd(cmd);	if (action==CDIOCSETVOL) {	/*We are setting new volume settings*//*	Here we set the volume levels.  Note that the same command	also sets the patching (routing) of audio, so we have to rely	on previously-stored settings to fill in these fields.*/		cmd[0]=MODESELECT;	/*Write drive settings*/		cmd[1]=AUDIOPARM;	/*Audio/routing settings*//*	Although the drive allows a left and right channel volume to be	specified separately, the drive refuses the settings if the	values are different.*/		c=level->vol[0] | level->vol[1];	/*Or them together*/		cmd[4]=cd->volume[0]=c;	/*Channel 0 (Left) volume*/		cmd[6]=cd->volume[1]=c;	/*Channel 1 (Right) volume*/		cmd[3]=cd->patch[0];	/*Channel 0 (Left)  patching*/		cmd[5]=cd->patch[1];	/*Channel 1 (Right)  patching*/		i=docmd(cmd,ldrive,cdrive,controller,port);/*Issue cmd*/#ifdef DEBUGIOCTL		printf("matcd%d: Volume set %d\n",ldrive,i);#endif /*DEBUGIOCTL*/		return(i);	} else {			/*Read existing settings*//*	This code reads the settings for the drive back - note that	volume and patching are both returned so we have to keep	both internally.*/		cmd[0]=MODESENSE;	/*Read drive settings*/		cmd[1]=AUDIOPARM;	/*Audio/routing settings*/		lockbus(controller, ldrive);	/*<16>Request bus*/		matcd_slowcmd(port,ldrive,cdrive,cmd);		i=waitforit(10*TICKRES,DTEN,port,"matlvl");	/*<25>*/		matcd_pread(port, 5, data);	/*Read data returned*/		z=get_stat(port,ldrive);/*Read status byte*/		unlockbus(controller, ldrive);	/*<16>Release bus*/#ifdef DEBUGIOCTL		printf("matcd%d: Data got was %x %x %x %x %x   ",ldrive,		       data[0],data[1],data[2], data[3],data[4]);		printf("status byte %x\n",z);#endif	/*DEBUGIOCTL*/		cd->volume[0]=level->vol[0]=	/*Channel 0 (Left) volume*/			      data[2];		cd->volume[1]=level->vol[1]=	/*Channel 1 (Right) volume*/			      data[4];		level->vol[2]=level->vol[3]=0;	/*Channel 2 & 3 not avail*/		cd->patch[0]=data[1];	/*Channel 0 (Left) patching*/		cd->patch[1]=data[3];	/*Channel 1 (Right) patching*/		return(0);	}}/*-----------------------------------------------------------------------------	matcd_routing - Set the audio routing (patching)<12>	New for Edit 12-----------------------------------------------------------------------------*/static int matcd_route(int ldrive, int cdrive, int controller,		       int command){	struct	matcd_data *cd;	int	i,port;	unsigned char l,r;	unsigned char cmd[MAXCMDSIZ];	cd=&matcd_data[ldrive];	port=cd->iobase;	zero_cmd(cmd);	switch (command) {	case	CDIOCSETMUTE:		l=r=0;		break;	case	CDIOCSETLEFT:		l=r=OUTLEFT;		break;	case	CDIOCSETRIGHT:		l=r=OUTRIGHT;		break;	default:	case	CDIOCSETSTEREO:		l=OUTLEFT;		r=OUTRIGHT;		break;	}/*	Here we set the volume levels.  Note that the same command	also sets the patching (routing) of audio, so we have to rely	on previously-stored settings to fill in these fields.*/	cmd[0]=MODESELECT;		/*Write drive settings*/	cmd[1]=AUDIOPARM;		/*Audio/routing settings*//*	Although the drive allows a left and right channel volume to be	specified separately, the drive refuses the settings if the	values are different.*/	cmd[4]=cd->volume[0];		/*Channel 0 (Left) volume*/	cmd[6]=cd->volume[1];		/*Channel 1 (Right) volume*/	cmd[3]=cd->patch[0]=l;		/*Channel 0 (Left)  patching*/	cmd[5]=cd->patch[1]=r;		/*Channel 1 (Right)  patching*/	i=docmd(cmd,ldrive,cdrive,controller,port);/*Issue cmd*/#ifdef DEBUGIOCTL	printf("matcd%d: Routing set %d\n",ldrive,i);#endif /*DEBUGIOCTL*/	return(i);}/*-----------------------------------------------------------------------------	matcd_patch - Set the audio routing (patching)<12>	New for Edit 12-----------------------------------------------------------------------------*/static int matcd_patch(int ldrive, int cdrive, int controller,		       struct ioc_patch * routing){	struct	matcd_data *cd;	int	i,port;	unsigned char cmd[MAXCMDSIZ];	cd=&matcd_data[ldrive];	port=cd->iobase;	zero_cmd(cmd);/*	Here we set the volume levels.  Note that the same command	also sets the patching (routing) of audio, so we have to rely	on previously-stored settings to fill in these fields.*/	cmd[0]=MODESELECT;		/*Write drive settings*/	cmd[1]=AUDIOPARM;		/*Audio/routing settings*//*	Although the drive allows a left and right channel volume to be	specified separately, the drive refuses the settings if the	values are different.*/	cmd[4]=cd->volume[0];		/*Channel 0 (Left) volume*/	cmd[6]=cd->volume[1];		/*Channel 1 (Right) volume*/	cmd[3]=cd->patch[0]=		/*Channel 0 (Left)  patching*/	       (routing->patch[0] & 0x03);	cmd[5]=cd->patch[1]=		/*Channel 1 (Right)  patching*/	       (routing->patch[1] & 0x03);	i=docmd(cmd,ldrive,cdrive,controller,port);/*Issue cmd*/#ifdef DEBUGIOCTL	printf("matcd%d: Routing set %d\n",ldrive,i);#endif /*DEBUGIOCTL*/	return(i);}/*-----------------------------------------------------------------------------	matcd_pitch - Change audio playback rate		      Apart from making things sound funny, the only		      other application might be Karaoke.  Ugh.<12>	New for Edit 12-----------------------------------------------------------------------------*/static int matcd_pitch(int ldrive, int cdrive, int controller,		       struct ioc_pitch * speed){	struct	matcd_data *cd;	short	i;	int	z,port;	unsigned char cmd[MAXCMDSIZ];	cd=&matcd_data[ldrive];	port=cd->iobase;	zero_cmd(cmd);/*	This function sets the audio playback rate.  In SCSI devices this is	referred to as the logical block addresses per second parameter.	Uh huh.  Sounds like they didn't want anyone to find it.	Anyway, a study found that no one else has implemented this ioctl	but the capability does exist in the SCSI standard so I am following	the SCSI scheme even though it really doesn't fit this drive well.	I define the parameter to this ioctl as -32767 to -1 being	"play slower", 0x0000 flat and 1 to 32767 being "play faster"	within the scale allowed by the device.  The value is scaled to fit	the allowed by the device and any excess is treated as being	the positive or negative limit.  No ioctl input value is considered	invalid.	This device has a +/- 13% playback pitch specified by a range	-130 to +130.  The drive does a hard enforcement on this.	SCSI defines a 16 bit LBAS count, and a "multiplier" that	is either x1 or x(1/256).  The Matsushita drive only provides	10 bits total for indicating pitch so the LSbits are discarded.*/	cmd[0]=MODESELECT;		/*Write drive settings*/	cmd[1]=SPEEDPARM;		/*Audio speed settings*/	i=speed->speed>>7;		/*Scale down to our usable range*/	if (i!=0) {			/*Real pitch value*/		if (i < -130) i=-130;	/*Force into range we support*/		else if (i > 130) i=130;		cmd[3]=((i>>8)&0x03) | 0x04;	/*Get upper bits*/		cmd[4]=(i & 0xff);	/*Set lower bits*/	}	z=docmd(cmd,ldrive,cdrive,controller,port);/*Issue cmd*/#ifdef DEBUGIOCTL	printf("matcd%d: Pitch set %d\n",ldrive,i);#endif /*DEBUGIOCTL*/	return(z);}/*End of audio.c*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -