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: Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)? (Read 10265 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

I've been using foobar2000 for a little while now with a Xonar HDAV1.3 Deluxe in Windows Vista 64 bits. My version of foobar is 1.1.11, and I've tried the latest stable version of the WASAPI plugin as well as both 3.0 betas (1 and 2). It's also worth noting that the sound card is connected to an A/V receiver (Sony DA3600ES) through HDMI.

All three versions of the plugin work the same in terms of perceived behavior. There is, however, something that has kept me wondering: multi-channel output via "S/PDIF".

Before using foobar, I was using mplayer-hc with ReClock. I setup ReClock to use WASAPI through the digital output (S/PDIF). The funny thing is that such setup works rather fine (the only problem is that the center/bass and front/back surround speakers are swapped each, and since it is a pass-through, the Xonar HDAV Center options do nothing). 4.0, 5.1, 24 bits, 48 kHz, 96 kHz, ... all of them work. The A/V receiver receives the proper signal each time. I even asked about it in the ReClock forums, and what was considered surprising was that using S/PDIF for such formats (anything above 2.0) worked for me. It must be noted also that although it's called S/PDIF, it really goes out through HDMI, not coax or optical.

With foobar, however, only 2.0 works when S/PDIF is selected. If I try to play a 4.0 or 5.1 track through S/PDIF, it complains with the error:

Quote
Unrecoverable playback error: Unsupported stream format: 96000 Hz / 24-bit / 6 channels


My question is: do you know what is so magical about ReClock that such a track works properly with it, but foobar doesn't like it? If it's of any use I can paste here the Pin In and Out information when using mplayer-hc with ReClock.

Thanks also for this lovely work.


Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #2
SPDIF interface cannot handle more data than 2 channel uncompressed or 6 channel compressed lossy via DolbyDigital or DTS. You can pass-trough a DTS or Dolby Digital signal to your receiver and the receiver will decode the embedded surround.
HDMI can "pack" up to 4 SPDIF streams (that is max 8 channels uncompressed). Anyway, the decoding (uncompressing) of those 2-8 channels needs to be done in PC via a plug-in adequate to the original surround files.

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #3
I'm aware of the 2 channels limitation of S/PDIF. Notice that in my message I wrote it as "S/PDIF", since it is more of a placeholder. The soundcard can be configured to output either through HDMI or analog. When set to analog and using S/PDIF, the output goes out through coax. When set to HDMI, both speakers and S/PDIF go out through HDMI. There is no such thing as an HDMI output that can be selected in the list of devices.

Although, in theory, S/PDIF should always be limited to 2 channels, ReClock manages to send up to 8 channels with rates up to 192 kHz using WASAPI with S/PDIF selected as output, which my A/V receiver understands and displays as such. Note that the output is not encoded in any way (like on-the-fly DD or DTS), and it even bypasses the graph and speaker swap settings in the soundcard's configuration app. Basically, ReClock manages to do bitstreaming just like ArcSoft TMT does for blu-ray movies.

Coming back to the question: what could be the trick that ReClock manages to do with WASAPI and "S/PDIF" such that multi-channel output works that foobar's WASAPI plugin cannot?

You can see in the following link the settings for ReClock and the soundcard (screenshots): http://www.dropbox.com/gallery/46379500/1/Shared?h=3842b8

Here's the Pin In: http://pastebin.com/R4RJqL2a
And here's the Pin Out: http://pastebin.com/FgP64wmv

The file being played is a 24 bit, 96 kHz, 6 channels FLAC. When played, the A/V receiver shows that there are 6 channels of input and the following text: LINEAR PCM [ 96 kHz].

Any ideas?

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #4
Minor update: I decided to try to initialize WASAPI using the information from the Out Pin with a small program, but IAudioClient::IsFormatSupported() returns AUDCLNT_E_UNSUPPORTED_FORMAT. That really makes me wonder what kind of evil trickery the guys from ReClock use, so a format is finally accepted.

I'll see if I can, somehow, debug it to find out what manages to get it working. Too bad there is no source code publicly available to go through instead. I wonder if those guys would mind sharing that bit...

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #5
Although, in theory, S/PDIF should always be limited to 2 channels, ReClock manages to send up to 8 channels with rates up to 192 kHz using WASAPI with S/PDIF selected as output, which my A/V receiver understands and displays as such. Note that the output is not encoded in any way (like on-the-fly DD or DTS), and it even bypasses the graph and speaker swap settings in the soundcard's configuration app. Basically, ReClock manages to do bitstreaming just like ArcSoft TMT does for blu-ray movies.

Your receiver "understands" what? What is displaying? Maybe you send encoded DTS/DD from your movie files...
My receiver shows "PCM Multi" only when I send a DVD-A encoded signal. Otherwise I have DSD multi or DolbyDigital multi or DTS multi...

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #6
ReClock implies that the decoded PCM audio signal is being resampled to another rate to match the refresh rate of the monitor.

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #7
Your receiver "understands" what?


My receiver understands up to 8 channels of up to 192 kHz via HDMI. That is also my default setting with the soundcard.

What is displaying?


It displays for a 5.1 FLAC at 96 kHz: LINEAR PCM [ 96 kHz]. Additionally, the boxes L, C, R, SL, SR and SW on the display are on, indicating 6 channels of input, and the small indicator "LPCM" remains on.

Maybe you send encoded DTS/DD from your movie files...


Nope. If it was any form of DTS or DD, the display would show DTS or DOLBY DIGITAL, and the small indicator ("DTS" or "DD") would remain on. That is not the case.

ReClock implies that the decoded PCM audio signal is being resampled to another rate to match the refresh rate of the monitor.


If you check the screenshot of my ReClock settings, resampling is disabled. Also, there is no video track when playing the FLAC, so no real need for any adjustment. On top of that, the display of the A/V receiver displays the same input frequency, be it 44.1, 48, 96 or 192 kHz.

To sum it up: ReClock, using WASAPI with S/PDIF selected as output device, can do proper pass-through. foobar's WASAPI plugin (including 3.0 Beta 1 and Beta2), just as my test application, cannot.

The idea is to know how it's done, so it can, hopefully, be integrated into foobar's WASAPI plugin.

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #8
I have found it!

I was planning to check something in particular: force initialization even when the format is not supported. I decided to run a search on StackOverflow first, and I found a rather interesting question there that, among other things, says that even though a particular format can be considered unsupported when asking for it, trying to set it will actually work. I modified my test program to do so, and it works! Just for reference, here's the link: http://stackoverflow.com/questions/7665865...-isformatsuppor

Calling IAudioClient::IsFormatSupported() for a WAVEFORMAT with 6 channels, 96 kHz sampling and 24 bits per sample fails with the error "the format is not supported" (I suppose that's as far as foobar's WASAPI plugin goes, then it bails out). Later on I call IAudioClient::Initialize() with the same exact WAVEFORMAT, and it accepts it (returns S_OK) and can actually play a dummy signal. The A/V receiver indeed shows that it has received a LINEAR PCM 96 kHz with 6 channels.

Here's the source code for the test program: http://pastebin.com/Q7DupQdm

It's an adaptation of an MSDN example which provides an audio source that generates a tone of 400 Hz for about 2 seconds for each channel. At line 132 it asks if the format is supported for the selected device (S/PDIF in my case). That's where it says it is not supported. At line 151, however, it will ignore it and return successfully with the exact same WAVEFORMAT. At line 291 it is used to initialize the IAudioClient, and it accepts it happily.

My lovely request is, therefore, not to bail out if IsFormatSupported() says it is not. There's still a chance Initialize() will actually accept it. Only if Initialize() fails, then it's safe to say the format is not really supported. Hopefully, it will not be very hard to implement the changes.

The source code can be compiled with Visual C++ 2010 Express, if anyone feels like trying it. The executable is just 21.0 KiB, but I have no place to store it.

All that would be left then, for me at least, is having a channel swapper into place. Center and Subwoofer channels are always swapped when passing through, and the soundcard options are, of course, useless (it's a pass-through after all). When it's a 7.1 track, not only Center and Subwoofer are swapped, but also Side and Back surround. There should be a plugin for it, I guess. That's another issue anyway.

 

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #9
My receiver understands up to 8 channels of up to 192 kHz via HDMI. That is also my default setting with the soundcard.

You realize that HDMI is not the same as SPDIF? As I already typed, HDMI connection can "carry" 4 SPDIF streams (8 channels). One SPDIF cannot carry more than 2 uncompressed channels.
So you can carry 8 channels only via HDMI. Maybe previous WASAPI was sending the signal to HDMI instead of SPDIF on your card/drivers...

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #10
You realize that HDMI is not the same as SPDIF? As I already typed, HDMI connection can "carry" 4 SPDIF streams (8 channels). One SPDIF cannot carry more than 2 uncompressed channels.
So you can carry 8 channels only via HDMI. Maybe previous WASAPI was sending the signal to HDMI instead of SPDIF on your card/drivers...


Again: the S/PDIF device of my sound card is more of a fake playback device name. No matter which output I set (analog or HDMI) in the control center, the same two devices are always listed: Speakers and S/PDIF.

When analog is selected, Speakers goes out of the analog outputs of the soundcard and S/PDIF out of the coax connector. When HDMI is selected, both Speakers and S/PDIF go out of the HDMI cable. Windows always shows the same two playback devices, no matter the output setting.

I just tried switching to analog outputs (so the so called S/PDIF playback device goes out through coax instead of HDMI), and playing a 5.1 channels, 24 bit, 96 kHz FLAC using ReClock. Funnily enough, the sound card accepts it, although it stutters horribly and only 2 channels are identified by the A/V receiver. That makes more sense because that is a real S/PDIF interface.

Paraphrasing it in multiple items:

* My sound card provides two playback devices: Speakers and S/PDIF.
* My sound card does not provide a playback device called HDMI.
* Output via HDMI or analog+coax is selected in the soundcard's configuration application, and it is independent from the playback device selected in Windows.
* I know S/PDIF is not the same as HDMI, and I'm aware of S/PDIF's limitations.
* Although the playback device is called S/PDIF, when HDMI is selected as output, it works as an HDMI output (even if its name is still S/PDIF).

In any case, my previous post shows (with source code included), that even if a specific playback device says an audio format is not supported, at the end it may actually be.

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #11
Sounds like your sound card drivers are broken. 

It sounds like the drivers are enforcing the two channel limitation when you select S/PDIF. What happens if you chose speakers instead of S/PDIF when the output is set to HDMI?

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #12
Sounds like your sound card drivers are broken. 

It sounds like the drivers are enforcing the two channel limitation when you select S/PDIF. What happens if you chose speakers instead of S/PDIF when the output is set to HDMI?


If I choose Speakers instead of S/PDIF when the output is set to HDMI, then the soundcard applies resampling, channel swapping, equalization, sound effects, up/down mixing, on-the-fly DD/DTS, ... Whatever is set in the configuration application is applied to anything that uses Speakers as playback device. The signal goes out, of course, through HDMI. Using S/PDIF as playback device, as expected, does a pass-through, also through HDMI.

Thing is that the driver (if it's really it) is rejecting anything with more than 2 channels if you just ask if it's supported, but it happily accepts anything with more than 2 channels if you tell it to use it. As a matter of fact, it's really up to you with WASAPI to ask if the format is supported or not before trying to use it. You can just go ahead and try to use it right away. If it's indeed not supported, it will tell you so, and then you will know it for sure. By checking the post in StackOverflow you can see I'm not the only person who has seen such behavior when using WASAPI.

It's indeed quite a peculiar sound card, but it's also quite a lovely one in terms of features.

If the WASAPI plugin was open source, I would have patched it myself already.

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #13
It's much simpler than you think. The HDAV drivers are not being bypassed by exclusive mode, they can't. Test it yourself with your setup that "works". With ReClock and whatnot. Play your file, and then go into the HDAV control panel and change the sampling rate. It should change too in your receiver. What I'm not clear about is that on your screenshot you have 7.1 output from the HDMI output (yes, it's HDMI, not SPDIF), yet your receiver is showing 5.1. Is this in the same case, or were they separate cases? Asus was taking some flak for this from people who wanted to bypass the resampler in Arcsoft's TMT and realized it couldn't, so they were working on a solution that would detect the sampling rate and automatically change the rate in the control panel. I don't think it works for other players though, but I could be wrong about that. Also, I don't think they planned to implement auto channel switching in the same way, though that's the more useful feature of the two.

Also, the way the HDMI works in this and the Auzen card is shifty to say the least. There are 3 devices, not the 2 who show up in the Windows Sound panel. The analog ("speakers"), the normal SPDIF ("digital output") and the HDMI which is hidden from Windows, so no other player than TMT can use it directly. That's why there's no bitstreaming of "HD" codecs with other players (there is a workaround but with some TMT proprietary files and tinkering). The way it works is that the driver routes anything that's going into the "Speakers" or "Digital Output" (SPDIF) devices into the HDMI device, so you get both outputs out of HDMI, but you're not bypassing the Asus mixer.

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #14
Play your file, and then go into the HDAV control panel and change the sampling rate. It should change too in your receiver.


It doesn't change. Once the fake S/PDIF playback device is used for pass-through, equalization, speaker configuration, channel swapping, sampling rate and every other setting is ignored. It's a real pass-through. I just tested it. I'm playing a 5.1 track at 48 kHz, and that's what I get in the receiver, even though my configuration is 7.1 at 192 kHz (it only applies to Speakers). Changing the sampling rate does nothing to it.

What I'm not clear about is that on your screenshot you have 7.1 output from the HDMI output (yes, it's HDMI, not SPDIF), yet your receiver is showing 5.1. Is this in the same case, or were they separate cases?


If I use Speakers as output, I get 7.1 at 192 kHz (the current settings). If I use S/PDIF as output, I get whatever is sent through it in terms of number of channels and sampling rate.

The way it works is that the driver routes anything that's going into the "Speakers" or "Digital Output" (SPDIF) devices into the HDMI device, so you get both outputs out of HDMI, but you're not bypassing the Asus mixer.


If I am not bypassing it, then it's just not caring about applying any setting to it. Channel swapping was the most important setting for me, and it just won't work once the audio is sent through S/PDIF (and it makes sense for it not to work). It works perfectly fine with Speakers.

Maybe you can test the WASAPI program I made and see if it can send the 5.1 signal using S/PDIF (it will most likely be playback device 1, as I did not dig deeper in order to get the human readable names from them) if you have the equipment (soundcard with HDMI output and so on). It works for me with the Xonar.

For convenience, I have uploaded the binary at https://sites.google.com/site/ceniza666/foobar2000 (WASAPI.zip).

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #15
Well you might wanna go ask at the Asus forums for some updated information on how it works, what I know of it is old news apparently, but I know they were working on auto sampling rate switching, and they probably did auto channel switching as well. Probably it's working now, but you're still not using SPDIF clearly, since you're connected to HDMI. Did you enable or disable the "set matching speaker configuration" for this last test? Can you post all the other ReClock screens including the playback one (from the icon when it's playing)?

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #16
Well you might wanna go ask at the Asus forums for some updated information on how it works, what I know of it is old news apparently, but I know they were working on auto sampling rate switching, and they probably did auto channel switching as well. Probably it's working now, but you're still not using SPDIF clearly, since you're connected to HDMI.


I think the auto sampling rate switching and auto channel switching is not implemented. It looks like if I got it just because it's doing pass-through.

Did you enable or disable the "set matching speaker configuration" for this last test? Can you post all the other ReClock screens including the playback one (from the icon when it's playing)?


I've played with that option already, and I haven't noticed any changes whether it's on or off. In any case, I have uploaded the screenshots you wanted.

I tinkered, in a friendly way, with WASAPI and foobar, to force the return value of IsFormatSupported to be S_OK when the WASAPI plugin called it. The result: foobar can pass multi-channel audio through WASAPI using S/PDIF as playback device, just like in ReClock 

The problem is that, as far as I understand from the license, I cannot patch the DLL, even less provide a patched version of it. The other problem is that the friendly tinkering is impractical. I've been thinking about it, and there's a possibility I have yet to try. If that works, then all that would be needed is a simple plugin that when loaded forces IsFormatSupported to always return S_OK. I'll try that one ASAP, but I'm a little bit low on time at the moment.

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #17
Again: the S/PDIF device of my sound card is more of a fake playback device name.

In order to speak the same language we need to use the same words. I don't care what your driver says, if you are using the HDMI cable to connect the receiver, then is a HDMI connection. If you use the SPDIF cable (coaxial or optical) then is a SPDIF connection.
Don't ask things that are not possible (uncompressed 5.1 via SPDIF connection), just because your driver is screwed. Look at the cables, it's not rocket science. Saves a lot of wasted time in pointless arguments...
Proper  HDMI labeling:

Also, I see that Xonar has an audio panal labeled clearly HDMI for 4 PCM channels, not SPDIF:

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #18
Maybe they actually opened the HDMI device to show up as "SPDIF passthrough" in Windows, or they tweaked the properties of the SPDIF device. What shows up in the properties panel of that playback cevice in Sound Panel in Control Panel? Like how many channels supported and what shows when you click on "configure"? Screenshots if you could, please. Can you also take a screenshot of the full list of playback devices? What SoNic67 says above is right though, you're still using HDMI.

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #19
What shows up in the properties panel of that playback cevice in Sound Panel in Control Panel? Like how many channels supported and what shows when you click on "configure"? Screenshots if you could, please. Can you also take a screenshot of the full list of playback devices? What SoNic67 says above is right though, you're still using HDMI.


I have added the extra screenshots. However, "Configure" is disabled for the S/PDIF playback device. I added screenshots of "Properties", though.

It is also worth noting that Beta 3 of the WASAPI plugin works for me, and there's even another user who reports the new Beta also allows him to play formats the previous versions did not in a Xonar.

Peter hasn't explicitly said that he applied the proposed change (ignore IsFormatSuported), but it works nonetheless. In that sense, this issue is solved.

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #20
Yeah, it clearly says that it only supports what SPDIF is supposed to support, no multichannel. What I think is happening is that either by an oversight of the Asus driver or maybe even by design, fb2k and ReClock can now access the HDMI kind of directly via the SPDIF passthrough. I don't know how this could happen, but I have no other explanation. Do you know if you can bitstream TrueHD or DTS-HD with ffdshow or LAV filters, with ReClock if you also use "SPDIF pass through"?

Why can’t fb2k play more than 2 channels via digital out (SPDIF/HDMI)?

Reply #21
Do you know if you can bitstream TrueHD or DTS-HD with ffdshow or LAV filters, with ReClock if you also use "SPDIF pass through"?


I tried with ffdshow, LAV and multiple ReClock settings, but I could not get bitstreaming to work for TrueHD or DTS-HD. What's even more strange is that it will not work in TMT 5 either if it's just a file. However, if I play any blu-ray that uses TrueHD (both 5.1 and 7.1) or DTS-MA (5.1) in TMT, then it will bitstream just fine. What works is letting TMT send uncompressed LPCM through ReClock, which will switch to the proper number of channels and sampling rate (no wonder there, though).

It could also be an issue in the version of TMT I'm using. I remember upgrading at some point and getting broken multi-channel output, reason why I decided to go back to the previous version. In any case, once ReClock is added to the chain, bitstreaming no longer works.