All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nearest conv_rates matching
@ 2006-03-17 23:57 S. Effendi
  2006-03-18  0:04 ` Lee Revell
  0 siblings, 1 reply; 2+ messages in thread
From: S. Effendi @ 2006-03-17 23:57 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 1018 bytes --]

Hi all,

attached you can find a simple patch to match
"uncommon" rate in some USB speaker to the fixed
conv_rates in usbaudio.c.

I had problem using ALSA with "Typhoon Desktop Mini
USB Speakers" (0e6a:0310 Megawin Technology Co., Ltd).

mpg123 told me "No supported rate found!".

# cat /proc/asound/card1/stream0
USB Audio Device at usb-0000:00:1d.0-2.4, full speed :
USB Audio
  Interface 2
    Altset 1
    Format: S16_LE
    Channels: 2
    Endpoint: 2 OUT (ADAPTIVE)
    Rates: 46875

With this patch now I get:

USB Audio Device at usb-0000:00:1d.0-2.4, full speed :
USB Audio
  Interface 2
    Altset 1
    Format: S16_LE
    Channels: 2
    Endpoint: 2 OUT (ADAPTIVE)
    Rates: 44100

and mpg123 works JustFine(TM) :)

Hope you find it useful.


Best regards,
S. Effendi


	

	
		
_______________________________________________________________________________ 
Apakah Anda Yahoo!?
Kunjungi halaman depan Yahoo! Indonesia yang baru! 
http://beta.id.yahoo.com/

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 3723235254-alsa_usbaudio_conv_rates.patch --]
[-- Type: text/x-patch; name="alsa_usbaudio_conv_rates.patch", Size: 1289 bytes --]

--- linux-2.6.15.6/sound/usb/usbaudio.c	2006-03-05 20:07:54.000000000 +0100
+++ linux-2.6.15.6-patched/sound/usb/usbaudio.c	2006-03-18 00:27:13.000000000 +0100
@@ -2394,17 +2394,35 @@
 		fp->nr_rates = nr_rates;
 		fp->rate_min = fp->rate_max = combine_triple(&fmt[8]);
 		for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) {
+			unsigned int last_rate;
+			unsigned int rate_supported;
 			unsigned int rate = fp->rate_table[r] = combine_triple(&fmt[idx]);
 			if (rate < fp->rate_min)
 				fp->rate_min = rate;
 			else if (rate > fp->rate_max)
 				fp->rate_max = rate;
+			rate_supported = 0;
+			last_rate = 0;
 			for (c = 0; c < (int)ARRAY_SIZE(conv_rates); c++) {
 				if (rate == conv_rates[c]) {
-					fp->rates |= (1 << c);
+					/* conv_rate matched */
+					rate_supported = (1 << c);
+					break;
+				} else if (rate > conv_rates[c]) {
+					/* nearest conv_rate matched */
+					rate_supported = (1 << c);
+					last_rate = conv_rates[c];
+				} else {
 					break;
 				}
 			}
+			fp->rates |= rate_supported;
+			if(last_rate > 0) {
+				if(fp->rate_min > last_rate)
+					fp->rate_min = last_rate; /* fix to nearest conv_rate matched */
+				/* nearest supported conv_rate */
+				fp->rate_table[r] = last_rate; 
+			}
 		}
 	} else {
 		/* continuous rates */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] nearest conv_rates matching
  2006-03-17 23:57 [PATCH] nearest conv_rates matching S. Effendi
@ 2006-03-18  0:04 ` Lee Revell
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Revell @ 2006-03-18  0:04 UTC (permalink / raw)
  To: S. Effendi; +Cc: alsa-devel

On Sat, 2006-03-18 at 06:57 +0700, S. Effendi wrote:
> Hi all,
> 
> attached you can find a simple patch to match
> "uncommon" rate in some USB speaker to the fixed
> conv_rates in usbaudio.c.

So it just plays the file off-speed?  Or is the device reporting a wrong
sample rate?

Lee



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-18  0:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-17 23:57 [PATCH] nearest conv_rates matching S. Effendi
2006-03-18  0:04 ` Lee Revell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.