IPB

Welcome Guest ( Log In | Register )

Winamp 2 Kernel Streaming Output Plugin, Wanna try out my KS output plugin for WA
Chun-Yu
post Nov 29 2002, 01:52
Post #1





Group: Developer
Posts: 359
Joined: 29-October 02
Member No.: 3652



I just wrote a simple Kernel Streaming output plugin for WA2 - check it out at http://www.cs.indiana.edu/~cshei/out_ks.dll. It's very experimental right now - it just uses the first output device it finds, and it's currently hard-coded to use 10 output buffers (so it might skip if you have all those WinXP visual effects enabled). Source code is at http://www.cs.indiana.edu/~cshei/out_ks.zip (a VC++ .NET project - sorry VC++ 6 users). I just wrote it this afternoon, because Microsoft released a Kernel Streaming demo today smile.gif. I'll be adding tons of stuff soon, including SSRC resampling (for those who are blessed with fixed sampling rate DACs wink.gif ) and selection of output device and # of buffers.

Annuka: using Kernel Streaming should prevent ALL other programs from using the sound device, which should solve the "Silence Flash" problem.

Edit: By the way, if you do give it a try, give me some comments/suggestions

This post has been edited by Chun-Yu: Nov 29 2002, 01:54
Go to the top of the page
+Quote Post
13 Pages V   1 2 3 > »   
Start new topic
Replies (1 - 24)
cynix
post Nov 29 2002, 02:36
Post #2





Group: Members
Posts: 24
Joined: 19-March 02
Member No.: 1564



will kernel streaming allow me to play mp3s while i'm in ntice?
Go to the top of the page
+Quote Post
Peter
post Nov 29 2002, 02:38
Post #3


foobar2000 developer


Group: Admin
Posts: 3276
Joined: 30-September 01
Member No.: 84



out_ks.dll apparently needs msvc7 dlls, which i dont have on my win2k. i don't have msvc7 either, i use only msvc6.


CODE
dumpbin /imports out_ks.dll
Microsoft COFF Binary File Dumper Version 6.00.8447
Copyright Microsoft Corp 1992-1998. All rights reserved.


Dump of file out_ks.dll

File Type: DLL

Section contains the following imports:

KERNEL32.DLL
1000F064 Import Address Table
0 Import Name Table
0 time date stamp
0 Index of first forwarder reference

0 LoadLibraryA
0 GetProcAddress

MSVCR70.dll
1000F070 Import Address Table
0 Import Name Table
0 time date stamp
0 Index of first forwarder reference

0 free

SETUPAPI.dll
1000F078 Import Address Table
0 Import Name Table
0 time date stamp
0 Index of first forwarder reference

0 SetupDiGetClassDevsA

USER32.dll
1000F080 Import Address Table
0 Import Name Table
0 time date stamp
0 Index of first forwarder reference

0 MessageBoxA

Summary

A000 UPX0
3000 UPX1
1000 UPX2


This post has been edited by Peter: May 16 2009, 23:46
Reason for edit: Sanitized, removed my own useless post + reply.
Go to the top of the page
+Quote Post
Gabriel
post Nov 29 2002, 09:03
Post #4


LAME developer


Group: Developer
Posts: 2950
Joined: 1-October 01
From: Nanterre, France
Member No.: 138



Sorry, but what does "kernel streaming" means?
Go to the top of the page
+Quote Post
cynix
post Nov 29 2002, 11:14
Post #5





Group: Members
Posts: 24
Joined: 19-March 02
Member No.: 1564



QUOTE (Gabriel @ Nov 29 2002 - 07:03 PM)
Sorry, but what does "kernel streaming" means?

http://www.microsoft.com/hwdev/tech/stream/csa1.asp
Go to the top of the page
+Quote Post
WaldoMonster
post Nov 29 2002, 14:49
Post #6





Group: Members
Posts: 234
Joined: 18-September 02
From: the Netherlands
Member No.: 3392



What are the advantages over a directsound output?


--------------------
netjukebox - the flexible media share
http://www.netjukebox.nl
Go to the top of the page
+Quote Post
Peter
post Nov 29 2002, 15:03
Post #7


foobar2000 developer


Group: Admin
Posts: 3276
Joined: 30-September 01
Member No.: 84



from my short IRC survey, you should give it a try if your favourite colors are blue and white.
Go to the top of the page
+Quote Post
Chun-Yu
post Nov 29 2002, 15:19
Post #8





Group: Developer
Posts: 359
Joined: 29-October 02
Member No.: 3652



Ok - point taken, Peter. Although I don't think msvcr70.dll is part of the .NET framework, it probably comes with it. I've changed it to be statically linked (same URL).
QUOTE (WaldoMonster @ Nov 29 2002 - 05:49 AM)
What are the advantages over a directsound output?

Well, the main reason I wrote it is because Kernel Streaming prevents all other programs from playing sound, so my music won't be interrupted by some other sound (yes, I could just disable the Windows sounds, but I don't mind hearing them at other times). Kernel Streaming bypasses the Windows KMixer and sends data directly to the audio driver, so I suppose another benefit would be that KMixer doesn't get to mess with your audio data (which can give you a warm, fuzzy feeling smile.gif ). Generally, the main reason to use kernel streaming is to achieve extremely low latency output, because KMixer adds about 30 ms latency. Low latency output isn't useful/possible with Winamp because the input plugins send data in like 13-26 ms bursts. Low latency output is really useful for audio editing programs.
Go to the top of the page
+Quote Post
Peter
post Nov 29 2002, 15:53
Post #9


foobar2000 developer


Group: Admin
Posts: 3276
Joined: 30-September 01
Member No.: 84



"low-latency output" is totally useless for music playback because it kills any underrun protection.
BTW, just tested your plugin, works on my win2k / terratec sixpack. i'm too lazy to look at the source but you should make sure that the thread which *started* playback doesn't die until playback is legally terminated, otherwise it makes bad sounds on stop (i had similar "problem" in out_ds a while ago, its a bug in win2k/xp WDM).
Go to the top of the page
+Quote Post
Jasper
post Nov 29 2002, 16:18
Post #10





Group: Members
Posts: 189
Joined: 9-July 02
Member No.: 2536



Actually low-latency output doesn't have to (entirely) "kill" any underrun protection, since the audio files can usually be read faster than they are played, which means the program can still build up a buffer. Of course the small buffers that are sent to the soundcard will mean a little more skipping if you keep the processor real busy, but under normal use you shouldn't notice that a lot (I haven't had a single skip for months, and I'm using ASIO to output the sound, which has a very low latency).
Go to the top of the page
+Quote Post
Peter
post Nov 29 2002, 16:25
Post #11


foobar2000 developer


Group: Admin
Posts: 3276
Joined: 30-September 01
Member No.: 84



depends what else you are using the computer playing music for.
Go to the top of the page
+Quote Post
Chun-Yu
post Nov 29 2002, 16:36
Post #12





Group: Developer
Posts: 359
Joined: 29-October 02
Member No.: 3652



QUOTE (zZzZzZz @ Nov 29 2002 - 06:53 AM)
"low-latency output" is totally useless for music playback because it kills any underrun protection.

Yep - that pretty much what I just said in my previous post.

QUOTE (zZzZzZz @ Nov 29 2002 - 06:53 AM)
i'm too lazy to look at the source but you should make sure that the thread which *started* playback doesn't die until playback is legally terminated, otherwise it makes bad sounds on stop (i had similar "problem" in out_ds a while ago, its a bug in win2k/xp WDM).

Actually, I'm not starting any threads of my own - the IO is done asynchronously. So what happens is that each buffer has an event associated with it, and IsPlaying() checks to see if any buffers aren't done playing yet. So in theory, the input plugin should handle this, since that thread is *supposed* to check IsPlaying() and not quit until the output plugin is done playing.
Go to the top of the page
+Quote Post
Peter
post Nov 29 2002, 16:45
Post #13


foobar2000 developer


Group: Admin
Posts: 3276
Joined: 30-September 01
Member No.: 84



yeah yeah. your plugin isn't creating threads, but playback is started from input plugin's thread; if user presses stop, this thread dies before you are closed. you need multithread hacks to workaround this. welcome in winamp v2.x input/output plugin hell.
Go to the top of the page
+Quote Post
Chun-Yu
post Nov 29 2002, 17:03
Post #14





Group: Developer
Posts: 359
Joined: 29-October 02
Member No.: 3652



Ah! - now I see what you mean! My plugin doesn't make werid noises when you hit stop, though. Hmm. I don't know - maybe the bug only happens when using DirectSound/MME? The data is sent to the audio driver using asynchronous DeviceIoControl()s in my plugin, so I don't think the calling thread matters, as long as the buffer isn't deleted before the audio driver finishes with it.
Go to the top of the page
+Quote Post
Peter
post Nov 29 2002, 17:11
Post #15


foobar2000 developer


Group: Admin
Posts: 3276
Joined: 30-September 01
Member No.: 84



i believe that exact effect depends on your drivers, i researched it back then in early out_ds2 days. the thing is, when the thread which *started* playback (eg. queued first waveOut block or called IDirectSoundBuffer::Start()) dies, playback dies too (usually with a weird sound, like on my card). this problem is relatively unimportant for basic functionality, but it will blow up when you try to add "gapless mode".
Go to the top of the page
+Quote Post
Chun-Yu
post Nov 29 2002, 18:14
Post #16





Group: Developer
Posts: 359
Joined: 29-October 02
Member No.: 3652



I'll look into it (probably just try it on a bunch of different soundcards) - thanks for the warning, Peter! Gapless output isn't a very high priority for me right now, but it'll probably be added in the future, so I should find out about this...
Go to the top of the page
+Quote Post
Case
post Nov 30 2002, 14:12
Post #17





Group: Developer (Donating)
Posts: 2214
Joined: 19-October 01
From: Finland
Member No.: 322



QUOTE (Chun-Yu @ Nov 29 2002 - 02:52 AM)
using Kernel Streaming should prevent ALL other programs from using the sound device, which should solve the "Silence Flash" problem.

I tested this on SB Live!, SB Audigy and Turtle Beach Santa Cruz and other programs were able to play sound without any problems when out_ks was in use.

There's also very nice bug, it bluescreens my computer immediately if I don't disable my TV-tuner drivers. It would be nice if it checked that it actually found sound card.
Go to the top of the page
+Quote Post
Chun-Yu
post Dec 1 2002, 18:32
Post #18





Group: Developer
Posts: 359
Joined: 29-October 02
Member No.: 3652



QUOTE (Case @ Nov 30 2002 - 05:12 AM)
QUOTE (Chun-Yu @ Nov 29 2002 - 02:52 AM)
using Kernel Streaming should prevent ALL other programs from using the sound device, which should solve the "Silence Flash" problem.

I tested this on SB Live!, SB Audigy and Turtle Beach Santa Cruz and other programs were able to play sound without any problems when out_ks was in use.

I suppose it depends on your audio driver. I tested it on a Yamaha WaveForce 192 and it does allow other programs to play sound, but on a Creative AudioPCI no other programs can play sound. Anyway, according to Microsoft's documentation, Kernel Streaming should take over the audio device:
QUOTE
Note

Using the DirectKS approach results in exclusive access to the audio device, which can break many aspects of the user experience, including disabling warning alert sounds and loss of interoperability with other audio applications.


QUOTE
There's also very nice bug, it bluescreens my computer immediately if I don't disable my TV-tuner drivers. It would be nice if it checked that it actually found sound card.

Yep - I need to add device selection stuff.
Go to the top of the page
+Quote Post
jrj
post Dec 2 2002, 07:21
Post #19





Group: Members
Posts: 8
Joined: 17-November 01
Member No.: 477



On my system, currently using only a Realtek AC97 spdif out, the sample rate is being converted from 44.1 to 48 kHz as per normal kmixer experience. Shouldn't Kernel Streaming enable direct 44.1 digital output?
Go to the top of the page
+Quote Post
Chun-Yu
post Dec 2 2002, 14:24
Post #20





Group: Developer
Posts: 359
Joined: 29-October 02
Member No.: 3652



QUOTE (jrj @ Dec 1 2002 - 10:21 PM)
On my system, currently using only a Realtek AC97 spdif out, the sample rate is being converted from 44.1 to 48 kHz as per normal kmixer experience. Shouldn't Kernel Streaming enable direct 44.1 digital output?

No, if your audio driver only outputs at 48 kHz (probably because your DAC only supports a fixed rate of 48 kHz). I'm guessing that since the DAC is fixed at 48 kHz, so is the digital out (like the SB Live!?). In this case, the sampling rate conversion isn't done by KMixer, but by the audio driver, which cannot be bypassed. All I can suggest is...getting a new soundcard? wink.gif
Go to the top of the page
+Quote Post
jrj
post Dec 4 2002, 08:33
Post #21





Group: Members
Posts: 8
Joined: 17-November 01
Member No.: 477



After a little further experimentation, it looks like your explanation is on the mark. As best I can tell, in my system, out_ks bypasses windows as desired (the winamp volume control doesn't work) and sends the bits to the Intel ICH4 chipset, which resamples to 48 kHz, then sends the bits to the Realtek AC97 Codec. That can be set to output either 48 kHz or 44.1, but since 44.1 involves another resample (down from 48) it sounds terrible. So I'm stuck resampling to 48 somewhere along the line, since the ICH4 seems to require it.

Too bad. I don't have another slot for a soundcard.
Go to the top of the page
+Quote Post
c^2
post Dec 14 2002, 05:08
Post #22





Group: Members
Posts: 1
Joined: 14-December 02
Member No.: 4075



Any update on your progress, Chun-yu? I'm really interested in this, as it would allow those of us without ASIO capable cards to bypass kmixer without using SSRC. (SSRC uses up to 40% of my Athlon 650)

The current build works fine for me, but breaks into static when there is heavy activity on the PCI bus. Would it be possible to put in an option to increase the buffers? As I just use it for listening, I wouldn't mind the increased latency at all. Or is there a bigger problem with increased buffers that I don't understand?

Edit: I've found that if I boost Winamp's priority to high in task manager the static is no longer a problem. I guess it was heavy CPU usage by another program that was causing the static.

This post has been edited by c^2: Dec 14 2002, 05:13
Go to the top of the page
+Quote Post
thomaspf
post Dec 29 2002, 20:12
Post #23





Group: Members
Posts: 63
Joined: 29-December 02
From: USA
Member No.: 4308



Chun-Yu,

great effort! A kernel streaming output has the potential of bypassing kmixer for more sound cards that allow pass through of PCM data but do not have an ASIO driver available.

In addition to resampling kmixer has the undesirable side effect of modifying all stream even if the input and output format are 16/44.1Khz. SSRC does not help with that either. If you upsample kmixer will mangle the upsampled stream before handing it to the sound card. The effects of this are quite audible and affect any PCM data played through waveout or direct sound on sound cards with a native WDM audio driver. Another benefit of kernel streaming is very low overhead.

Many sound cards do have multiple devices on it and your current plugin follows the SDK sample in just taking the head of the enumerated list. One urgent feature request would be to provide for a selector for which device to use. By looking at the sample code I could not find a way to expose the actual device name but just giving the option to pick from a numbered list will do. Once you have that we could test this plugin for bit transparency via a digital output.

Cheers

Thomas
Go to the top of the page
+Quote Post
KikeG
post Apr 23 2003, 07:50
Post #24


WinABX developer


Group: Developer
Posts: 1578
Joined: 1-October 01
Member No.: 137



Ehm... any update on the plugin, Chun-Yu? rolleyes.gif
Go to the top of the page
+Quote Post
Chun-Yu
post Apr 23 2003, 14:21
Post #25





Group: Developer
Posts: 359
Joined: 29-October 02
Member No.: 3652



Not yet - been real busy. Should have much more time in about 2 1/2 weeks - when classes at IU end smile.gif.
Go to the top of the page
+Quote Post

13 Pages V   1 2 3 > » 
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 30th August 2014 - 20:50