Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Winamp 2 Kernel Streaming Output Plugin (Read 436722 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Winamp 2 Kernel Streaming Output Plugin

Reply #300
Steve,

Thanks so much. By the time I saw your reply, I already had debugger tripping on division by 0 line, but of course was nowhere close to solving the problem.

I've already tried some different compiler settings, and also MS vs. Intel (VS.NET 2008). Will keep you posted.


P.S.: Post edited to comply with TOS #8.

Winamp 2 Kernel Streaming Output Plugin

Reply #301
Steve,

Thanks so much. By the time I saw your reply, I already had debugger tripping on division by 0 line, but of course was nowhere close to solving the problem.

I've already tried some different compiler settings, and also MS vs. Intel (VS.NET 2008). Will keep you posted.


P.S.: Post edited to comply with TOS #8.


Glad that sorted it out for you. It'd be interesting to know if a change of compiler makes much of a difference performance wise. There are only really a couple of areas in the plugin that would significantly benefit from a better compiler (or for that matter being rewritten to use MMX/SSE etc) and these are basically just copying sample data from Winamp to the plugins input buffer and subsequently from there to the Kernel Streaming interfaces input buffer applying reformatting and packing where appropriate. The volume control if enabled and not set to 100% may also show up on a profiler although I can't see any of it having a major impact on a modern(ish) PC. Anyway, have fun and if you have any questions about what's going on inside the plugin, let me know and I'll help where possible.

Cheers,
Steve

Winamp 2 Kernel Streaming Output Plugin

Reply #302
Steve,

I fixed small problem with "Number of Output Buffers" setting not being read from config file, just adding the following missing line to Config::Read :

   ReadInt("output_buffer_cnt",   &output_buffer_cnt   );


The thing is - I'm not really C/C++ developer, and while the small stuff like above is something I can fix, it's way beyond my capabilities to rewrite the code to use SIMDs, that you mention. I'm pretty sure there would be benefits, and if you could during some free time have a look at what's involved - it would be great.

Again, thank you - I really appreciate your work.

Winamp 2 Kernel Streaming Output Plugin

Reply #303
No worries and thanks for tracing that number of buffers bug. I never got round to looking into that since it was pointed out to me a couple of years ago, so I think it's unlikely I'll be doing a SIMD rewrite any time soon myself. I'll try and get round to posting a new version incorporating your fix at some point in the near future.

Cheers,
Steve

Winamp 2 Kernel Streaming Output Plugin

Reply #304
Steve,

There's one small annoyance I would like to try fixing. Any time playback is started, there's one single "pop" - it sounds like buffer is not empty, and sample(s) that's left there are being played for a fraction of second. If that's so, then buffer needs to be forcibly "flushed" when playback is stopped in Winamp. I guess it could be either input or output buffer.

What do you think about that possibility? Where in the code would you suggest to look if that's the case, and how would you suggest to empty the buffer?

Winamp 2 Kernel Streaming Output Plugin

Reply #305
Steve,

There's one small annoyance I would like to try fixing. Any time playback is started, there's one single "pop" - it sounds like buffer is not empty, and sample(s) that's left there are being played for a fraction of second. If that's so, then buffer needs to be forcibly "flushed" when playback is stopped in Winamp. I guess it could be either input or output buffer.

What do you think about that possibility? Where in the code would you suggest to look if that's the case, and how would you suggest to empty the buffer?


Hi. I don't actually think that's the KS plugin itself as it's not something I get with my setup (and it would drive me up the wall if I did). Chances are it's actually a driver issue relating to how the hardware buffers are fed on your sound card from the KS interface.

Off the top of my head, the input buffer is a single large looping buffer. I keep track of where winamp has written up to and where the KS side of the plugin has read out from (this is done to ensure the input doesn't overwrite the output by refusing data from Winamp until there is enough space to accomodate it), so there's little scope for problems at that end otherwise it would be failing all the time.

There are multiple output buffers, these are allocated and retained for the lifetime of the plugin (unless the settings change). The status of the output buffers are tracked by the plugin. Individually, they can be in one of two states, free - meaning they're empty and not being used by the KS interface or busy - meaning the KS interface is currently making use of them. If an output buffer is free, it is filled in its entirety by copying the next available block of memory from the input buffer to the output buffer and then handing it off to the KS interface. If there isn't enough data in the input buffer to fill the output buffer, the plugin will hang onto the buffer until there is, only dispatching it when full. The exception to this when the user presses stop, in which case the partially filled buffer is handed off to the KS interface, however, the amount of data it contains is set in a header during the handoff, so any unused portion of the buffer should be ignored by the KS interface - I think this is where you may be experiencing a problem, depending on how the driver is coded. In the event of a stop signal, you could try padding out the remainder of the buffer with zeros and see if that solves your problem. Have a look in kscore.cpp for the line;

if (full || mode == MODE_STOPPING) {      // packet was filled, needs to be sent

this particular case is handled inside the following scope, so that would be a good place to flush the remainder of the buffer to see if that helps.

Steve

Winamp 2 Kernel Streaming Output Plugin

Reply #306
Steve,

I confirmed that it's interaction of KS plugin with the particular driver (ASUS Xonar), exactly as you said. Winamp can be closed, then opened again - the "pop" still will be there when starting playback. Definitely something can be done, since ASIO plugin, for instance, doesn't behave the same way.

I think it's a good idea to try padding the buffer with 0's, with the intention for the driver to get "silence" to play for a fraction of second. But I'm not sure how to do that. In the code below, I will split (mode == MODE_STOPPING) case, but how to do actual padding?

         if (full || mode == MODE_STOPPING) {      // packet was filled, needs to be sent
            packets[cur_packet].Header.FrameExtent = packets[cur_packet].Header.DataUsed;
            written_data += packets[cur_packet].Header.DataUsed;
            ResetEvent(packets[cur_packet].Signal.hEvent);
            hr = pin->WriteData(&packets[cur_packet].Header, &packets[cur_packet].Signal);

Winamp 2 Kernel Streaming Output Plugin

Reply #307
Quote
Definitely something can be done, since ASIO plugin, for instance, doesn't behave the same way.


Not necessarily, the ASIO plugin talks to the driver via a different interface within the driver. The fact that the ASIO plugin does not exhibit the same problem merely suggests that this path into the driver is probably more robust than the drivers KS implementation, particularly when you consider that the KS plugin does not exhibit this problem when used with many other types of sound card.

Taking another look, I don't think zeroing out the remainder of the packet buffer will help as it stands, because buffer space beyond what is used never gets sent, however if you really want to try it, you may find filling the remainder of the packet with zeros and sending the whole packet instead of just the bit that's been used may help. You'd probably want to add something along the following lines to KSCore::PlayerThread() (new code in red, original code in black);

if (full || mode == MODE_STOPPING) {      // packet was filled, needs to be sent
[blockquote]if ((mode == MODE_STOPPING) && ((int)packets[cur_packet].Header.DataUsed < packet_size)) {
[blockquote]memset(packets[cur_packet].Header.Data, 0, packet_size - packets[cur_packet].Header.DataUsed);
packets[cur_packet].Header.DataUsed = packet_size;
[/blockquote]}


packets[cur_packet].Header.FrameExtent = packets[cur_packet].Header.DataUsed;

[/blockquote]

This will cause it to pad out each final packet to the full size specified in the settings dialog, even if the packet contains only a couple of bytes of useful data. I haven't actually tested this code, other than to check that it builds, but give it a go and see if it helps.

Steve

Winamp 2 Kernel Streaming Output Plugin

Reply #308
Steve,

I finally had a chance to try the code - it didn't work initially, in the sense that padding the buffer didn't seem to change anything. I decided to dig in a little, and it turns out that whole code section in KSCore::PlayerThread is skipped, if gapless mode is enabled (as is the case for me). The reason is this piece of code in KSCore::EndInternal(int force):

   if (config->gapless_enabled && !force)
      return;

This causes this line, that is down below in the same method, to never execute if gapless mode is enabled:

   mode = MODE_STOPPING;   // tell player thread that we are stopping


Is there a reason why it's done like this? Would it be safe to just remove this "if" statement, so it continues the same as if gapless isn't enabled? If not - what would be best solution?

Winamp 2 Kernel Streaming Output Plugin

Reply #309
Quote
Is there a reason why it's done like this? Would it be safe to just remove this "if" statement, so it continues the same as if gapless isn't enabled? If not - what would be best solution?


No, I wouldn't remove the "if" statement.

Unfortunately there is no distinction in the signals the plugin receives from Winamp between a "stop because the current track has ended" or a "stop because the user pressed stop", this poses a problem for gapless mode. In gapless mode, the plugin has to leave the KS output open between tracks, because, if you close it, even momentarily, the sound card output will be disrupted (causing a pop or a click) which clearly isn't desirable when playing tracks which run continuously into each other.

KSCore::EndInternal() is the function that gets called whenever a stop signal is received from Winamp, this happens at the end of every track and whenever the user presses stop or the application is closed. So that there is no disruption between tracks, most of this function gets ignored when gapless mode is active. The plugin keeps track of the requested state but is only allowed to close the KS output under certain circumstances;

  • When Winamp calls the plugins destructor
  • When the output format changes
  • When Winamp has signalled to stop, the KS interface is requesting more samples and the input buffer from Winamp is empty


If you search through kscore.cpp for End(TRUE) you should find the locations where these three cases are handled (each accompanied by a comment describing why it's being called). I imagine what could be happening is that the plugin is closing the KS interface while there are still samples in buffers that have already been handed off to the KS interface. I guess in this case, your sound cards KS driver isn't cleaning these up properly, so when you, say, manually stop the player and then start a new track, it dumps the remaining buffer contents to the sound card causing the problem you're experiencing.

Just to verify I've got the correct handle on your problem, can you confirm that;

  • From a cold boot, the first track played in Winamp doesn't exhibit this problem
  • Adjacent tracks in the playlist of the same format (i.e. sample rate, word length and number of channels) don't exhibit this problem between them
  • The problem only occurs if you manually stop (not pause) the player while a track is still playing and then manually start a track playing - may also occur if you quit Winamp mid track and restart it or if the format changes - the important point being that audible sound was being output when the plugin was stopped


Cheers,
Steve

Winamp 2 Kernel Streaming Output Plugin

Reply #310
  • From a cold boot, the first track played in Winamp doesn't exhibit this problem
  • Adjacent tracks in the playlist of the same format (i.e. sample rate, word length and number of channels) don't exhibit this problem between them
  • The problem only occurs if you manually stop (not pause) the player while a track is still playing and then manually start a track playing - may also occur if you quit Winamp mid track and restart it or if the format changes - the important point being that audible sound was being output when the plugin was stopped


The answer is "YES" to all 3:

- no problem with first track from cold boot;
- no problem between adjacent tracks;
- the same problem when stop/start playback or quit Winamp/start Winamp/start playback mid-track; no problem when paused/restarted.

Winamp 2 Kernel Streaming Output Plugin

Reply #311
Sorry for interrupting your dialogue, but since i was not able to find any e-mail, blog, forum, etc. on the Kernel Streaming for Winamp's webpage i'm disturbing you here


Winamp 5.541 + Kernel Audio 3.63 + SB Audigy 2SE (24bit) + Latest official drivers.

When i play a normal (16bit) mp3 file, Kernel streaming always says: Sample size: 24 bits. When i play 16bit FLAC file - it says Sample size: 16 bits. When i play 24 bit 96khz file - it's displayed correctly.
Is it normal for FLAC and mp3 files to be streamed differently?


I have a small utility attached to Creative's sound driver. I can select PCM sample rate(44.1,48,96) and "Enable Bit-perfect Playback" and some Dolby Digital options.

Does Kernel Streaming go around these options or it obeys them too?


Thanks!

Winamp 2 Kernel Streaming Output Plugin

Reply #312
Quote
When i play a normal (16bit) mp3 file


MP3 file doesn't have such thing as bit depth.

Winamp 2 Kernel Streaming Output Plugin

Reply #313
Sorry for interrupting your dialogue, but since i was not able to find any e-mail, blog, forum, etc. on the Kernel Streaming for Winamp's webpage i'm disturbing you here


Winamp 5.541 + Kernel Audio 3.63 + SB Audigy 2SE (24bit) + Latest official drivers.

When i play a normal (16bit) mp3 file, Kernel streaming always says: Sample size: 24 bits. When i play 16bit FLAC file - it says Sample size: 16 bits. When i play 24 bit 96khz file - it's displayed correctly.
Is it normal for FLAC and mp3 files to be streamed differently?


I have a small utility attached to Creative's sound driver. I can select PCM sample rate(44.1,48,96) and "Enable Bit-perfect Playback" and some Dolby Digital options.

Does Kernel Streaming go around these options or it obeys them too?


Thanks!


Hi,

the sample size and sample rate displayed in the KS status dialog (assuming this is what you are referring to) describe the format of the output stream from the plugin into the KS interface of the sound cards driver. The KS plugin doesn't generally attempt to reformat what is fed to it in any way and it's totally unaware of the source format (MP3, PCM, FLAC etc) as the data has already been decoded into raw PCM by the time it gets to the KS plugin, so I would suspect that it is actually being fed 24 bit samples from Winamp for some reason if that's what it's putting out to the card. Are you using a non standard MP3 decoder or are you using any DSP/Effect plugins that may cause resampling?

As for your sound cards driver utility, it's entirely down to the implementation of the driver whether KS will bypass this or not. The KS plugin merely talks to the sound card driver via an alternative interface to the usual one, so the behaviour of card specific features is totally in the hands of the driver designer. I suppose the question to ask is, can you hear any difference when you adjust these features while using KS?

Cheers,
Steve

Winamp 2 Kernel Streaming Output Plugin

Reply #314
The only winamp feature i can see enabled in winamp is in "Playback" - "Allow 24 bit". But if i disable it, 24/96 FLACs are played through Kernel Streaming as 16 bit /96Khz. So i guess everything is OK with Kernel Streaming, Winamp is the reason.


As to the sound difference.. There is difference only when i enable "Allow 24 bit" in Winamp. I was not able to catch any difference with or without bitperfect and 44.1/96khz selector, when Kernel Streaming is enabled (but there is difference without it). Basically, sound is less annoying and more open.. .but very hard to explain and very very small difference.

Thanks for the quick reply

Winamp 2 Kernel Streaming Output Plugin

Reply #315
Hi Everyone,

I hope this is the right place to post general questions about Chun Yu & Steve's Winamp Kernel Streaming plugin - my profuse apologies if not, and I'll gladly heed advice about the correct place to post this.

I'm having a frustrating problem with the plugin (v363, Winamp v5.57) on a PC with two sets of sound hardware - here's the scenario:

I want to use Winamp and the KS plugin for high-quality playback (44.1k end-to-end, not resampled up to 48k and back again) via my shiny new M-Audio Audiophile 2496 card (the line-out ports of which are fed in to a hi-fi amp), and the PC's motherboard sound hardware (Realtek AC97 chipset) for Windows system sounds and general stuff.

However, when I select the AP2496 analogue output in the KS config screen and then start playing a track, Winamp hangs with the track timer frozen at "0:00". The only way out is to forcibly close Winamp from the Windows Taskbar.

Everything works really nicely when the KS plugin's pointed at the Realtek chipset. The AP2496 works fine via the Nullsoft DirectSound plugin. For the record I'm using Win XP Home SP3, with all updates applied. I've also seen similar symptoms on a different PC (a laptop with a Conexant sound chipset) when it's hooked up to an external USB sound-card.

Any idea what's going on? Has anyone else seen symptoms like this? Is the only option to disable / uninstall the motherboard sound drivers? Or is there something simple that I've missed?

Despite these problems, big thanks to Chun Yu and Steve for a really great plugin!

Thanks in advance!

Cheers,
englishtim

Winamp 2 Kernel Streaming Output Plugin

Reply #316
hi steve, just in case you still check in on this thread i thought i'd provide this feedback...
i recently started using an external dac (dacmagic) and via usb your kernel streaming plugin for winamp worked really well (using win7 x64).
due to the dac's limitation of 16 bit over usb i have now switched to coaxial spdif output from the motherboards onboard realtek chip (motherboard is gigabyte 965P DS3 using a Realtek ALC883 8 Channel Audio Codec) and as a result the plugin no longer works. Latest realtek drivers are being used.
when winamp is started the error message (as previously reported by another user)
'CKsEnumFilters::EnumFilters failed'
is displayed in a dialogue box, even before kernel streaming been set as the output method. after closing the box and setting kernel streaming as the output, no devices are shown as being available.

Log is shown below

Kernel Streaming Plugin v3.63 (x86) Diagnostic log

input buffer configured to 65536 bytes
output buffer configured to 8192 bytes per packet
Constructed KSCore (Input Size:65536) (Output Size 8192) (Output Cnt 8)
End()
End(force=0)
EndInternal() - mode=0 force=0
End()
End(force=0)
EndInternal() - mode=0 force=0
End()
End(force=0)
EndInternal() - mode=0 force=0
End(force=1)
EndInternal() - mode=0 force=1
Attempting to close player thread
Gapless mode buffer underrun - Player Thread is stopping KS player
End(force=1)
EndInternal() - mode=0 force=1
Player Thread - closing
Player thread has closed
Destructed KSCore

the asio plugins still work with spdif but it would be nice to have the option of kernel streaming as it works without the need to install additional software (other than the plug in itself) and so is a notch more streamlined. anyhows, good luck with any ongoing developments and heres hoping for version 4.0 before too long!

regards,
corumuk

Winamp 2 Kernel Streaming Output Plugin

Reply #317
after closing the box and setting kernel streaming as the output, no devices are shown as being available.


I don't know if you ever solved the filters-error problem, but "no devices are shown" is a problem that I see with ks363 (on 64 bit WinXP). The problem is strictly cosmetic, however: in my case, there are two audio devices (mobo's RealTek HD and a USB speaker-pair from Logitec, which gets all the system sounds). These items are present but not visible in the Kernel Streaming Settings dialog. It took me a while to determine this was the problem; as I recall, I just happened to click on the second location in the listbox and it showed as selected. It's really pretty annoying—so annoying, in fact, that when I first encountered the problem, I moved on to the asio_out(dll) plugin and ASIO4ALL.

But recently, I encountered a weird bug with that plugin under MediaMonkey (MM was hanging if I paused the track); once I'd discovered the cause of the hang, I tried KS again. And guess what: KS handles gapless transition much better than the asio plugin; since switching, I have yet to hear any artifact at track transitions.

Steve Monk, if you ever update to fix this problem (if you haven't abandoned the whole thing now that WASAPI is standard), may I suggest you also fix the tab-order in the dialog? But other than the slight weakness in the UI, this plugin is really high quality.

Winamp 2 Kernel Streaming Output Plugin

Reply #318
Hi all, I'm not sure why, but I haven't seen any notifications from this thread for ages, so I haven't been aware of the last few posts. Anyway, in reverse order;

I don't know if you ever solved the filters-error problem, but "no devices are shown" is a problem that I see with ks363 (on 64 bit WinXP). The problem is strictly cosmetic


That's interesting, as it implies the friendly name look up for the devices are failing on your configuration. Unfortunately I don't have that particular configuration to test against, so I can't really investigate what's going wrong. I was running the plugin at work on 64 bit XP about three years ago and I vaguely recall seeing the same sort of problem. I've been running it on a 64 Bit Win 7 machine for the last year or so and that displayed the device names correctly so I can only presume it's a quirk of 64 bit XP. Either that or it's a driver specific issue.

corumuk:
Quote
CKsEnumFilters::EnumFilters failed


When you see this error it means the plugin has failed during initialisation (i.e. when first launched and way before you get to the point of playing anything). The error indicates that the plugin has failed to find any compatible devices, most likely because your driver doesn't support Kernel Streaming.

Interestingly I've currently got the opposite problem on my home machine (32 bit XP), I want to run my Dac Magic over USB but with the stock drivers Kernel Streaming locks up, although the Win 7 stock drivers are absolutely fine with it.

englishtim:

I've seen this before, it's definitely a driver problem. The most recent AP2496 drivers lock up when fed from the plugin (just like the stock XP CMedia ones for the DacMagic do). The simplest fix is to download and install an earlier set. I'm not sure which specific version you want, but it's one or two back from the latest release, that should sort it out.