No audio with passthrough (works in VLC and mplayer)
#1
Question 
Hi everyone,

I've been struggling the whole day with this problem and I just can't figure it out. I also talked to some guys on the IRC channel but no progress was made.

The problem is that I can't play movies with AC3/DTS audio, because when XBMC has to use the selected passthrough device it fails with the standard "Failed to initialize audio device" error. This is what shows up in the log:

Quote:01:32:31 T:2761333616 M:3895308288 DEBUG: SetActiveDevice - SetActiveDevice from 0 to 2
01:32:31 T:2761333616 M:3895308288 DEBUG: RemoveActiveDevice - Removing device 0
01:32:31 T:2761333616 M:3895308288 DEBUG: Initialize - using alsa device iec958:AES0=0x6,AES1=0x82,AES2=0x0,AES3=0x2
01:32:31 T:2761333616 M:3895181312 ERROR: Initialize - hw_params_get_buffer_size, alsa error: -22 - Invalid argument
01:32:31 T:2761333616 M:3895181312 DEBUG: SetActiveDevice - SetActiveDevice from 2 to 1
01:32:31 T:2761333616 M:3895181312 DEBUG: RemoveActiveDevice - Removing device 2
01:32:31 T:2761333616 M:3895181312 DEBUG: CGUIAudioManager::Initialize
01:32:31 T:2761333616 M:3892387840 ERROR: Creating a Null Audio Renderer, Check your audio settings as this should not happen
01:32:31 T:2761333616 M:3892260864 DEBUG: RemoveActiveDevice - Removing device 1
01:32:31 T:2761333616 M:3892133888 DEBUG: CGUIAudioManager:Big GrineInitialize

Googling for that particular error gives no results...

My setup is as follows:
XBMC version: newest GIT build
Soundcard: M-Audio Audiophile 2492, connected to reciever with coaxial cable

Everything works out of the box with VLC, I get 6 channel audio to my reciever just fine. Same with mplayer when I try playing an AC3 file with this command:

Code:
mplayer -ao alsa:device=iec958 -ac hwac3 test.ac3

I've tried tons of different .asoundrc's I've found by googling, but none of them has worked. Worth noting is that I can play movies with MP3 audio when the output device is set to "Default (ALSA)" (although I have to change some settings in Envy24Control to hear anything).

Here is some (possibly related) outputs:

aplay -l
Quote:**** List of PLAYBACK Hardware Devices ****
card 0: M2496 [M Audio Audiophile 24/96], device 0: ICE1712 multi [ICE1712 multi]
Subdevices: 1/1
Subdevice #0: subdevice #0

aplay -L
Quote:null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=M2496
M Audio Audiophile 24/96, ICE1712 multi
Default Audio Device
front:CARD=M2496,DEV=0
M Audio Audiophile 24/96, ICE1712 multi
Front speakers
surround40:CARD=M2496,DEV=0
M Audio Audiophile 24/96, ICE1712 multi
4.0 Surround output to Front and Rear speakers
surround41:CARD=M2496,DEV=0
M Audio Audiophile 24/96, ICE1712 multi
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=M2496,DEV=0
M Audio Audiophile 24/96, ICE1712 multi
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=M2496,DEV=0
M Audio Audiophile 24/96, ICE1712 multi
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
iec958:CARD=M2496,DEV=0
M Audio Audiophile 24/96, ICE1712 multi
IEC958 (S/PDIF) Digital Audio Output

Output from a successful playback with mplayer (command quoted above)
Quote:mplayer: /usr/local/lib/libaa.so.1: no version information available (required by mplayer)
mplayer: /usr/local/lib/libaa.so.1: no version information available (required by /usr/lib/libggi.so.2)
MPlayer SVN-r31918 © 2000-2010 MPlayer Team
Can't open joystick device /dev/input/js0: No such file or directory
Can't init input joystick
mplayer: could not open config files /home/sam/.lircrc and /etc/lirc/lircrc
mplayer: No such file or directory
Failed to read LIRC config file ~/.lircrc.

Playing /media/Archive/farsan.ac3.
libavformat file format detected.
[ac3 @ 0xa5a9aa0] max_analyze_duration reached
[ac3 @ 0xa5a9aa0] Estimating duration from bitrate, this may be inaccurate
[lavf] stream 0: audio (ac3), -aid 0
==========================================================================
Forced audio codec: hwac3
Opening audio decoder: [hwac3] AC3/DTS pass-through S/PDIF
hwac3: switched to AC3, 448000 bps, 48000 Hz

AUDIO: 48000 Hz, 2 ch, ac3be, 448.0 kbit/29.17% (ratio: 56000->192000)
Selected audio codec: [hwac3] afm: hwac3 (AC3 through S/PDIF)
==========================================================================
AO: [alsa] 48000Hz 2ch ac3be (2 bytes per sample)
Video: no video
Starting playback...
A: 1.0 (00.9) of 5637.1 ( 1:33:57.0) 0.1%


MPlayer interrupted by signal 2 in module: play_audio
A: 1.0 (00.9) of 5637.1 ( 1:33:57.0) 0.1%

Exiting... (Quit)

Please, if anyone has even the slightest idea about what could be wrong, please reply! My only other option after this would be to go buy a 5 meter Toslink cable and use the integrated audio, but that would be such a waste.
Reply
#2
I have no idea ...but
I start xbmc with this easy little script

pulseaudio -k
xbmc
pulseaudio --start

that if ure install runs with pulseaudio as default.
Reply
#3
I don't use Pulseaudio so that can't be a problem. I tried it though and got everything to work just fine except the passthrough part (as Pulseaudio apparently doesn't support multi-channel passthrough)
Reply
#4
Well, you haven't told us what settings you've used/tried in the audio settings of XBMC; nor a full debug log (which would say that at least)
So, have you tried:
Device: default
Passthrough: iec958
Reply
#5
I've tried with basically every combination there is, but currently I have it set like this:

Audio output: Optical/Coax
Speaker conf: 5.1
DD/DTS capable: both checked
Audio output device: "Defaults (ALSA)" <- This works
Passthrough output device: "iec958 (ALSA)"

Here's a full debug log with the above settings when trying to play a movie with AC3 audio: http://pastebin.com/FMczXenT

I also noticed that speaker-test fails to play audio through iec958 when XBMC was running so I disabled navigation sounds and speaker-test worked again, although XBMC still can't seem to open the passthrough device.

Edit: I've also tried with a custom device. I've tried "iec958", "plug:iec958" (that works with speaker-test btw), "hw:0,7" (that's my S/PDIF device), but I keep getting the same error or "No such file or directory".
Reply
#6
I fell into this little trap a while ago ... With the speaker config.
I had to set this to 2.0 instead of 5.1; Audio Device: Defaults; Passthrough: iec958

Then I had to create: /etc/asound.conf

pcm.!default {
type plug
slave {
pcm "iec958"
}
}
Reply
#7
Gryph Wrote:I fell into this little trap a while ago ... With the speaker config.
I had to set this to 2.0 instead of 5.1; Audio Device: Defaults; Passthrough: iec958

Then I had to create: /etc/asound.conf

pcm.!default {
type plug
slave {
pcm "iec958"
}
}

I tried that but I'm still getting the same error.
Reply
#8
I seem to have solved it, albeit the very hard way!

I uncommented these lines from xbmc/cores/AudioRenderers/ALSADirectSound.cpp:

Code:
nErr = snd_pcm_hw_params_get_buffer_size(hw_params, &m_uiBufferSize);
CHECK_ALSA_RETURN(LOGERROR,"hw_params_get_buffer_size",nErr);

Now I can use iec958 as device for both passthrough and default. Still trying to get navigation sounds working, but that's a minor issue.

Edit: Can't play music either (it just sits there on 00:00), don't know if this is related to my change

The question is, is this a bug in XBMC, and if it is, what part should I file it against?
Reply
#9
Thank you! Big Grin I've been messing around with this off and on for some time. Your change worked like a charm.

I commented out the lines negge highlighted in the "code" section above, although, one of my lines was slightly different (presumably a different build/version). Then I built the package again using the changes. I'm using the mAudio M2496 card too. Everything in your first post fit my situation exactly, BTW.

On a side note, Music and Videos play fine....
Reply
#10
Artebonz Wrote:Thank you! Big Grin I've been messing around with this off and on for some time. Your change worked like a charm.

I commented out the lines negge highlighted in the "code" section above, although, one of my lines was slightly different (presumably a different build/version). Then I built the package again using the changes. I'm using the mAudio M2496 card too. Everything in your first post fit my situation exactly, BTW.

On a side note, Music and Videos play fine....

Good to hear I'm not alone with this problem. Is passthrough audio working perfectly fine for you or does it stutter from time to time on certain AC3/DTS sources? I ended up using my internal audio card cause I couldn't get the stuttering away.
Reply
#11
I've not used it enough after the fix to know, but, I'll post back and say one way or the other it's the least I can do.....

Matt
Reply
#12
I just watched a 2.5 hour long movie w/a 5.1 ac3 soundtrack and had no issues at all. Also, listened to some music tonight w/no problems for about an hour. So, there must be something else going on for you....

Is your onboard audio card digital w/passthrough too? Any clues when you run xbmc from a terminal?

Anyway, thanks again for posting a fix.
Reply
#13
Quote:I just watched a 2.5 hour long movie w/a 5.1 ac3 soundtrack and had no issues at all. Also, listened to some music tonight w/no problems for about an hour. So, there must be something else going on for you...

In my experience it didn't happen on all movies. It's really weird I tell you. I posted a bug report here, although if it works perfectly for you the problem might lie somewhere else. Could you be kind enough to test the clip I linked to in the bug report (http://werket.tlk.fi/~negge/xbmc_stutter.avi)? I get massive stuttering on that one.

Quote:Is your onboard audio card digital w/passthrough too? Any clues when you run xbmc from a terminal?

Yeah, currently I use the internal soundcard for passthrough over an optical cable (other card uses a coaxial of course), no issues at all. I've scanned xbmc.log for anything suspicious when using the M-Audio card but I couldn't find anything.
Reply
#14
Quote: Could you be kind enough to test the clip I linked to in the bug report (http://werket.tlk.fi/~negge/xbmc_stutter.avi)? I get massive stuttering on that one.

The xbmc_stutter.avi clip played fine for me without any issues....

You're symptoms seem to point to the card itself. Some issue w/ALSA perhaps?

My other thought would be whether you're using internal or external libraries in your build for ac3 / dts or maybe even ffmpeg. I would say that's a possibility, but, that doesn't explain why one card works and the other doesn't...

If I can test anything else out just ask....
Reply
#15
thank you negge, commenting out the lines solved my issue too.
I have ubuntu minimal 10.04, xbmc 10.0, Asus P5C41C-M mb, Asus ENGT220 video and M-Audio Audiophile 2496 and I had the same error about getting the buffer size.
What I am wondering now is if commenting out this line code does not create another issue because when I look in the xbmc.log it displays buffer size 0. However, the card works ok for music and also movies.
Reply

Logout Mark Read Team Forum Stats Members Help
No audio with passthrough (works in VLC and mplayer)0