NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/52585 (AUDIO_GETENC does not return actual encodings)



The following reply was made to PR kern/52585; it has been noted by GNATS.

From: Nathanial Sloss <nat%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost,
 isaki%pastel-flower.jp@localhost
Cc: 
Subject: Re: kern/52585 (AUDIO_GETENC does not return actual encodings)
Date: Mon, 4 Jun 2018 11:02:05 +1000

 --Boundary-00=_O+IFbeKSHQ/FBKh
 Content-Type: Text/Plain;
   charset="iso-8859-15"
 Content-Transfer-Encoding: 7bit
 
 Hi,
 
 Please try the attached patch and let me know if it works for you and that it 
 addresses the PR.
 
 
 Best regards,
 
 Nat
 
 --Boundary-00=_O+IFbeKSHQ/FBKh
 Content-Type: text/x-patch;
   charset="ISO-8859-1";
   name="auconv-encodings.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="auconv-encodings.diff"
 
 Index: auconv.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/auconv.c,v
 retrieving revision 1.35
 diff -u -p -r1.35 auconv.c
 --- auconv.c	16 Dec 2017 16:09:36 -0000	1.35
 +++ auconv.c	3 Jun 2018 23:52:16 -0000
 @@ -2340,8 +2340,9 @@ auconv_create_encodings(const struct aud
  {
  	struct audio_encoding_set *buf;
  	int capacity;
 -	int i;
 +	int i, j;
  	int err;
 +	static int enc_precision[] = { 8, 16, 32 };
  
  #define	ADD_ENCODING(enc, prec, flags)	do { \
  	err = auconv_add_encoding(enc, prec, flags, &buf, &capacity); \
 @@ -2358,120 +2359,29 @@ auconv_create_encodings(const struct aud
  	for (i = 0; i < nformats; i++) {
  		if (!AUFMT_IS_VALID(&formats[i]))
  			continue;
 -		switch (formats[i].encoding) {
 -		case AUDIO_ENCODING_SLINEAR_LE:
 -			ADD_ENCODING(formats[i].encoding,
 -				     formats[i].precision, 0);
 -			ADD_ENCODING(AUDIO_ENCODING_SLINEAR_BE,
 -				     formats[i].precision,
 -				     AUDIO_ENCODINGFLAG_EMULATED);
 -			ADD_ENCODING(AUDIO_ENCODING_ULINEAR_LE,
 -				     formats[i].precision,
 -				     AUDIO_ENCODINGFLAG_EMULATED);
 -			ADD_ENCODING(AUDIO_ENCODING_ULINEAR_BE,
 -				     formats[i].precision,
 -				     AUDIO_ENCODINGFLAG_EMULATED);
 -#if NMULAW > 0
 -			if (formats[i].precision == 8
 -			    || formats[i].precision == 16) {
 -				ADD_ENCODING(AUDIO_ENCODING_ULAW, 8,
 -					     AUDIO_ENCODINGFLAG_EMULATED);
 -				ADD_ENCODING(AUDIO_ENCODING_ALAW, 8,
 -					     AUDIO_ENCODINGFLAG_EMULATED);
 -			}
 -#endif
 -			break;
 -		case AUDIO_ENCODING_SLINEAR_BE:
 -			ADD_ENCODING(formats[i].encoding,
 -				     formats[i].precision, 0);
 -			ADD_ENCODING(AUDIO_ENCODING_SLINEAR_LE,
 -				     formats[i].precision,
 -				     AUDIO_ENCODINGFLAG_EMULATED);
 -			ADD_ENCODING(AUDIO_ENCODING_ULINEAR_LE,
 -				     formats[i].precision,
 -				     AUDIO_ENCODINGFLAG_EMULATED);
 -			ADD_ENCODING(AUDIO_ENCODING_ULINEAR_BE,
 -				     formats[i].precision,
 -				     AUDIO_ENCODINGFLAG_EMULATED);
 -#if NMULAW > 0
 -			if (formats[i].precision == 8
 -			    || formats[i].precision == 16) {
 -				ADD_ENCODING(AUDIO_ENCODING_ULAW, 8,
 -					     AUDIO_ENCODINGFLAG_EMULATED);
 -				ADD_ENCODING(AUDIO_ENCODING_ALAW, 8,
 -					     AUDIO_ENCODINGFLAG_EMULATED);
 -			}
 -#endif
 -			break;
 -		case AUDIO_ENCODING_ULINEAR_LE:
 -			ADD_ENCODING(formats[i].encoding,
 -				     formats[i].precision, 0);
 +
 +		for (j = 0; j < __arraycount(enc_precision); j++) {
  			ADD_ENCODING(AUDIO_ENCODING_SLINEAR_BE,
 -				     formats[i].precision,
 +				     enc_precision[j],
  				     AUDIO_ENCODINGFLAG_EMULATED);
  			ADD_ENCODING(AUDIO_ENCODING_SLINEAR_LE,
 -				     formats[i].precision,
 +				     enc_precision[j],
  				     AUDIO_ENCODINGFLAG_EMULATED);
  			ADD_ENCODING(AUDIO_ENCODING_ULINEAR_BE,
 -				     formats[i].precision,
 -				     AUDIO_ENCODINGFLAG_EMULATED);
 -#if NMULAW > 0
 -			if (formats[i].precision == 8
 -			    || formats[i].precision == 16) {
 -				ADD_ENCODING(AUDIO_ENCODING_ULAW, 8,
 -					     AUDIO_ENCODINGFLAG_EMULATED);
 -				ADD_ENCODING(AUDIO_ENCODING_ALAW, 8,
 -					     AUDIO_ENCODINGFLAG_EMULATED);
 -			}
 -#endif
 -			break;
 -		case AUDIO_ENCODING_ULINEAR_BE:
 -			ADD_ENCODING(formats[i].encoding,
 -				     formats[i].precision, 0);
 -			ADD_ENCODING(AUDIO_ENCODING_SLINEAR_BE,
 -				     formats[i].precision,
 +				     enc_precision[j],
  				     AUDIO_ENCODINGFLAG_EMULATED);
  			ADD_ENCODING(AUDIO_ENCODING_ULINEAR_LE,
 -				     formats[i].precision,
 -				     AUDIO_ENCODINGFLAG_EMULATED);
 -			ADD_ENCODING(AUDIO_ENCODING_SLINEAR_LE,
 -				     formats[i].precision,
 +				     enc_precision[j],
  				     AUDIO_ENCODINGFLAG_EMULATED);
 +		}
  #if NMULAW > 0
 -			if (formats[i].precision == 8
 -			    || formats[i].precision == 16) {
 -				ADD_ENCODING(AUDIO_ENCODING_ULAW, 8,
 -					     AUDIO_ENCODINGFLAG_EMULATED);
 -				ADD_ENCODING(AUDIO_ENCODING_ALAW, 8,
 -					     AUDIO_ENCODINGFLAG_EMULATED);
 -			}
 +		ADD_ENCODING(AUDIO_ENCODING_ULAW, 8,
 +			     AUDIO_ENCODINGFLAG_EMULATED);
 +		ADD_ENCODING(AUDIO_ENCODING_ALAW, 8,
 +			     AUDIO_ENCODINGFLAG_EMULATED);
  #endif
 -			break;
 -
 -		case AUDIO_ENCODING_ULAW:
 -		case AUDIO_ENCODING_ALAW:
 -		case AUDIO_ENCODING_ADPCM:
 -		case AUDIO_ENCODING_MPEG_L1_STREAM:
 -		case AUDIO_ENCODING_MPEG_L1_PACKETS:
 -		case AUDIO_ENCODING_MPEG_L1_SYSTEM:
 -		case AUDIO_ENCODING_MPEG_L2_STREAM:
 -		case AUDIO_ENCODING_MPEG_L2_PACKETS:
 -		case AUDIO_ENCODING_MPEG_L2_SYSTEM:
 -		case AUDIO_ENCODING_AC3:
 -			ADD_ENCODING(formats[i].encoding,
 -				     formats[i].precision, 0);
 -			break;
 -
 -		case AUDIO_ENCODING_SLINEAR:
 -		case AUDIO_ENCODING_ULINEAR:
 -		case AUDIO_ENCODING_LINEAR:
 -		case AUDIO_ENCODING_LINEAR8:
 -		default:
 -			printf("%s: invalid encoding value "
 -			       "for audio_format: %d\n",
 -			       __func__, formats[i].encoding);
 -			break;
 -		}
 +		ADD_ENCODING(formats[i].encoding,
 +			     formats[i].precision, 0);
  	}
  	*encodings = buf;
  	return 0;
 
 --Boundary-00=_O+IFbeKSHQ/FBKh--
 


Home | Main Index | Thread Index | Old Index