kernels/linux-2.4.0/drivers/sound/dmasound/dmasound_q40.c
/* a bit too complicated to optimise right now ..*/
a bit too complicated to optimise right now
a bit too complicated to optimise right now
static ssize_t q40_ctx_law(const u_char *userPtr, size_t userCount,
			    u_char frame[], ssize_t *frameUsed,
			    ssize_t frameLeft)
{
	unsigned char *table = (unsigned char *)
		(dmasound.soft.format == AFMT_MU_LAW ? dmasound_ulaw2dma8: dmasound_alaw2dma8);
	unsigned int data = expand_data;
	u_char *p = (u_char *) &frame[*frameUsed];
	int bal = expand_bal;
	int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
	int utotal, ftotal;
	ftotal = frameLeft;
	utotal = userCount;
	while (frameLeft) {
		u_char c;
		if (bal < 0) {
			if (userCount == 0)
				break;
			if (get_user(c, userPtr++))
				return -EFAULT;
			data = table[c];
			data += 0x80;
			userCount--;
			bal += hSpeed;
		}
		*p++ = data;
		frameLeft--;
		bal -= sSpeed;
	}
	expand_bal = bal;
	expand_data = data;
	*frameUsed += (ftotal - frameLeft);
	utotal -= userCount;
	return utotal;
}
static ssize_t q40_ctx_law ( const u_char * userPtr , size_t userCount , u_char frame [ ] , ssize_t * frameUsed , ssize_t frameLeft ) { unsigned char * table = ( unsigned char * ) ( dmasound . soft . format == AFMT_MU_LAW ? dmasound_ulaw2dma8 : dmasound_alaw2dma8 ) ; unsigned int data = expand_data ; u_char * p = ( u_char * ) & frame [ * frameUsed ] ; int bal = expand_bal ; int hSpeed = dmasound . hard . speed , sSpeed = dmasound . soft . speed ; int utotal , ftotal ; ftotal = frameLeft ; utotal = userCount ; while ( frameLeft ) { u_char c ; if ( bal < 0 ) { if ( userCount == 0 ) break ; if ( get_user ( c , userPtr ++ ) ) return - EFAULT ; data = table [ c ] ; data += 0x80 ; userCount -- ; bal += hSpeed ; } * p ++ = data ; frameLeft -- ; bal -= sSpeed ; } expand_bal = bal ; expand_data = data ; * frameUsed += ( ftotal - frameLeft ) ; utotal -= userCount ; return utotal ; }
a bit too complicated to optimise right now ..
a bit too complicated to optimise right now ..