[LINUX] Problems switching from Analog to Digital over SPDIF?
#16
remb0 Wrote:can somebody help me>?

remco@xbmc:~$ aplay -l
**** Lijst van PLAYBACK hardware-apparaten ****
kaart 0: NVidia [HDA NVidia], apparaat 0: ALC662 rev1 Analog [ALC662 rev1 Analog]
Sub-apparaten: 1/1
Sub-apparaat #0: subdevice #0
kaart 0: NVidia [HDA NVidia], apparaat 1: ALC662 rev1 Digital [ALC662 rev1 Digital]
Sub-apparaten: 0/1
Sub-apparaat #0: subdevice #0
kaart 0: NVidia [HDA NVidia], apparaat 3: NVIDIA HDMI [NVIDIA HDMI]
Sub-apparaten: 1/1
Sub-apparaat #0: subdevice #0

but in xbmc i have no dts and dd.
i have chosen iec958 as output, digital and passtrough
i use an optical cable to my receiver

Iḿ a linux noob and spend all night Sad I hope I can explain my problem.

As a start, try to use plughw:0,3 on custom audio device and passthrough device to get sound via HDMI.
Reply
#17
F3d0r Wrote:As a start, try to use plughw:0,3 on custom audio device and passthrough device to get sound via HDMI.

shouldn't he use plughw:0,2 for optical?

If you want a step to step guide, read the solution on the wiki
Reply
#18
I know this may be pushing it a bit, but is there any way to get the nav sounds back? Tongue
Reply
#19
Ubuntu 9.10, Kernel 2.6.31-15.
XBMC 9.11 Beta1.
ALSA v1.0.20.
PulseAudio 1:0.9.19-0ubuntu4.
Nvidia MCP7A Audio.

I've managed to get multichannel pass-through audio, stereo output, and even menu sounds working (although with a few bugs here and there.) Here is how I did it, hopefully it will help someone else:

I'm outputting audio through the optical connection to my receiver.

XBMC > System > System > Audio Output:
Code:
Audio output: Digital
-Dolby Digital (AC3) capable receiver.....(X)
-DTS Capable Receiver........................(X)
Audio output device: Custom
Custom audio device: "plughw:0,1"  (without quotes)
Pass-through output device: Custom
Custom pass-through device: "plughw:0,1"  (without quotes)
Downmix multichannel audio to stereo.............(_)

Those settings did not work ("Failed to initialize audio device" messages) until I launched XBMC with the following script. This script kills PulseAudio just before starting XBMC:

Code:
#!/bin/bash

# Test to see if XBMC is running first
if ps -ef|grep -v grep|grep -i xbmc.bin
then
# Do nothing
echo "XBMC already Running!"
else
# Startup XBMC
ps aux|grep -v grep|grep -i pulseaudio|awk '{print $2}'| xargs kill -9
xbmc
fi
exit

This kills PulseAudio just long enough for XBMC to start and for the XBMC audio settings to take effect. Now the buggy part begins: PulseAudio will auto-restart a few seconds after XBMC launches, so there will be a few seconds before menu sounds return.

The second bug occurs when launching a stereo (2.0) audio stream. The *first* time any 2.0 audio stream is launched, it will give the familiar "Failed to initialize audio device" error. Simply stop whatever you were trying to play, give it a second, and restart it. All 2.0 audio will work from then on. (IDK why this happens, but it does, and it's stupid. Damn you PulseAudio.)

For reference, here are my aplay -l and aplay -L outputs:

Code:
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 0: ALC1200 Analog [ALC1200 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 1: ALC1200 Digital [ALC1200 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Code:
aplay -L
front:CARD=NVidia,DEV=0
    HDA NVidia, ALC1200 Analog
    Front speakers
surround40:CARD=NVidia,DEV=0
    HDA NVidia, ALC1200 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=NVidia,DEV=0
    HDA NVidia, ALC1200 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=NVidia,DEV=0
    HDA NVidia, ALC1200 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=NVidia,DEV=0
    HDA NVidia, ALC1200 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=NVidia,DEV=0
    HDA NVidia, ALC1200 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=NVidia,DEV=0
    HDA NVidia, ALC1200 Digital
    IEC958 (S/PDIF) Digital Audio Output
hdmi:CARD=NVidia,DEV=0
    HDA NVidia, NVIDIA HDMI
    HDMI Audio Output
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    Playback/recording through the PulseAudio sound server

Your "plughw:X,X" values will change depending on sound-card, and desired audio output device.

Hope this helps someone!
Reply
#20
Thanks so much for that. I don't get the system sounds but that doesn't bother me.

After setting up XBMC for this, I discovered that I could also use 'pasuspender xbmc' to accomplish the same thing - mainly though, I was lacking the correct xbmc settings.

Thanks again

Jonathan
Reply
#21
Smile 
F3d0r Wrote:With the help of the alsa dmix plugin I also managed to get crossfade working.

I just put the following in ~/.asoundrc
Code:
pcm.dmixer {
    type dmix
    ipc_key 1024
    slave {
        pcm "hw:0,1"
        period_time 0
        period_size 1024
        buffer_size 8192
        #periods 128
        #rate 44100
        rate 48000
     }
     bindings {
        0 0
        1 1
     }
}

After this I specified plug:dmixer as audio output device.

Result: Anlaog Audio + Crossfading + Passthrough via a single SPDIF device Smile

Thanks for this shit man, I now have Analog + Crossfade + Passthrough + Menu sounds, all via optical cable Big Grin
Reply
#22
F3d0r, do you know if it's possible to combine one and another?

I want to use both hdmi and SPDIF at the same time using the asoundrc conf you suggested. Any ideas?
Reply
#23
erhnam Wrote:F3d0r, do you know if it's possible to combine one and another?

I want to use both hdmi and SPDIF at the same time using the asoundrc conf you suggested. Any ideas?

You want simultaneous audio output of the same audio stream on spdif and hdmi?
I am sure this is possible but I not ALSA expert enough to quote the corresponding config script (.asoundrc) out of my head.

Have a look at the ALSA plugin documentation, maybe the copy plugin or some of the other plugins may help you to achieve this:
http://www.alsa-project.org/alsa-doc/als...ugins.html
Reply
#24
Interesting question erhnam, i'm trying to get the same (hdmi + optical + headphones) at same time, but no luck. All i can get is optical out (no hdmi sound) i've upgraded to alsa 1.0.22 but same results... Sad
Reply
#25
This will get spdif + hdmi audio working with dmix thus allowing crossfading in xbmc!! :-)

Works like a charm on Asrock ION 330HT system and is probably a starting point for non-ion systems.

save to /etc/asound.conf or .asoundrc

Code:
pcm.!default {
    type plug
    slave {
        pcm "both"
    }
}
pcm.both {
    type route
    slave {
        pcm multi
        channels 4
    }
    ttable.0.0 1.0
    ttable.1.1 1.0
    ttable.0.2 1.0
    ttable.1.3 1.0
}
pcm.multi {
    type multi
    slaves.a {
        pcm "dmixtv"
        channels 2
    }
    slaves.b {
        pcm "dmixrec"
        channels 2
    }
    bindings.0.slave a
    bindings.0.channel 0
    bindings.1.slave a
    bindings.1.channel 1
    bindings.2.slave b
    bindings.2.channel 0
    bindings.3.slave b
    bindings.3.channel 1
}
pcm.dmixtv {
    type dmix
    ipc_key 1024
    slave {
        pcm "tv"
        period_time 0
        period_size 1024
        buffer_size 8192
        rate 48000
     }
     bindings {
        0 0
        1 1
     }
}
pcm.dmixrec {
    type dmix
    ipc_key 1024
    slave {
        pcm "receiver"
        period_time 0
        period_size 1024
        buffer_size 8192
        rate 48000
     }
     bindings {
        0 0
        1 1
     }
}
pcm.tv {
    type hw
    card 0
    device 3
    channels 2
}
pcm.receiver {
    type hw
    card 0
    device 1
    channels 2
}

Hope this helped.
Reply
#26
josbeir Wrote:This will get spdif + hdmi audio working with dmix thus allowing crossfading in xbmc!! :-)

Works like a charm on Asrock ION 330HT system and is probably a starting point for non-ion systems.

save to /etc/asound.conf or .asoundrc

Hope this helped.

The good thing is that my hick-ups and pop-ups are gone when switching from one song to another (using spdif). The bad thing is that I that no my hdmi crackles. I also have issues when swithing from one song to another that I have to press play one more time. Also the screen is quite smaller when I finish watching a movie using hdmi. When I look at my xbmc.log and find these errors:

Code:
15:23:40 T:3079460752 M:1383768064   ERROR: PulseAudio: Waited for the Context but it failed
15:23:40 T:3079460752 M:1383768064   ERROR: PulseAudio: Failed to create context
15:23:40 T:3079460752 M:1383514112   ERROR: PulseAudio: Waited for the Context but it failed
15:23:40 T:3079460752 M:1383514112   ERROR: PulseAudio: Failed to create context
15:23:46 T:3079460752 M:1384239104   ERROR: PulseAudio: Waited for the Context but it failed
15:23:46 T:3079460752 M:1384239104   ERROR: PulseAudio: Failed to create context
15:23:46 T:3079460752 M:1384239104   ERROR: PulseAudio: Waited for the Context but it failed
15:23:46 T:3079460752 M:1384239104   ERROR: PulseAudio: Failed to create context
15:23:58 T:3079460752 M:1384189952   ERROR: PulseAudio: Waited for the Context but it failed
15:23:58 T:3079460752 M:1384189952   ERROR: PulseAudio: Failed to create context
15:23:58 T:3079460752 M:1384054784   ERROR: PulseAudio: Waited for the Context but it failed
15:23:58 T:3079460752 M:1384054784   ERROR: PulseAudio: Failed to create context
15:24:32 T:3079460752 M:1367171072   ERROR: PulseAudio: Waited for the Context but it failed
15:24:32 T:3079460752 M:1367171072   ERROR: PulseAudio: Failed to create context
15:37:19 T:3078018960 M:1373483008 WARNING: CALSADirectSound::CALSADirectSound - device is not able to pause playback, will flush instead

This config seems to work much better! At least it doesn't give me hdmi problems.

Code:
pcm.!default {
    type plug
    slave {
        pcm "both"
    }
}
pcm.both {
    type route
    slave {
        pcm multi
        channels 4
    }
    ttable.0.0 1.0
    ttable.1.1 1.0
    ttable.0.2 1.0
    ttable.1.3 1.0
}
pcm.multi {
    type multi
    slaves.a {
        pcm "tv"
        channels 2
    }
    slaves.b {
        pcm "dmixrec"
        channels 2
    }
    bindings.0.slave a
    bindings.0.channel 0
    bindings.1.slave a
    bindings.1.channel 1
    bindings.2.slave b
    bindings.2.channel 0
    bindings.3.slave b
    bindings.3.channel 1
}
pcm.dmixrec {
    type dmix
    ipc_key 1024
    slave {
        pcm "receiver"
        period_time 0
        period_size 1024
        buffer_size 8192
        rate 48000
     }
     bindings {
        0 0
        1 1
     }
}
pcm.tv {
    type hw
    card 0
    device 3
    channels 2
}
pcm.receiver {
    type hw
    card 0
    device 1
    channels 2
}
Reply
#27
It seems that you are using pulseaudio erhnam. Uninstall it and it should work fine...
Reply
#28
erhnam Wrote:The good thing is that my hick-ups and pop-ups are gone when switching from one song to another (using spdif). The bad thing is that I that no my hdmi crackles. I also have issues when swithing from one song to another that I have to press play one more time. Also the screen is quite smaller when I finish watching a movie using hdmi. When I look at my xbmc.log and find these errors:

Code:
15:23:40 T:3079460752 M:1383768064   ERROR: PulseAudio: Waited for the Context but it failed
15:23:40 T:3079460752 M:1383768064   ERROR: PulseAudio: Failed to create context
15:23:40 T:3079460752 M:1383514112   ERROR: PulseAudio: Waited for the Context but it failed
15:23:40 T:3079460752 M:1383514112   ERROR: PulseAudio: Failed to create context
15:23:46 T:3079460752 M:1384239104   ERROR: PulseAudio: Waited for the Context but it failed
15:23:46 T:3079460752 M:1384239104   ERROR: PulseAudio: Failed to create context
15:23:46 T:3079460752 M:1384239104   ERROR: PulseAudio: Waited for the Context but it failed
15:23:46 T:3079460752 M:1384239104   ERROR: PulseAudio: Failed to create context
15:23:58 T:3079460752 M:1384189952   ERROR: PulseAudio: Waited for the Context but it failed
15:23:58 T:3079460752 M:1384189952   ERROR: PulseAudio: Failed to create context
15:23:58 T:3079460752 M:1384054784   ERROR: PulseAudio: Waited for the Context but it failed
15:23:58 T:3079460752 M:1384054784   ERROR: PulseAudio: Failed to create context
15:24:32 T:3079460752 M:1367171072   ERROR: PulseAudio: Waited for the Context but it failed
15:24:32 T:3079460752 M:1367171072   ERROR: PulseAudio: Failed to create context
15:37:19 T:3078018960 M:1373483008 WARNING: CALSADirectSound::CALSADirectSound - device is not able to pause playback, will flush instead

This config seems to work much better! At least it doesn't give me hdmi problems.

Code:
pcm.!default {
    type plug
    slave {
        pcm "both"
    }
}
pcm.both {
    type route
    slave {
        pcm multi
        channels 4
    }
    ttable.0.0 1.0
    ttable.1.1 1.0
    ttable.0.2 1.0
    ttable.1.3 1.0
}
pcm.multi {
    type multi
    slaves.a {
        pcm "tv"
        channels 2
    }
    slaves.b {
        pcm "dmixrec"
        channels 2
    }
    bindings.0.slave a
    bindings.0.channel 0
    bindings.1.slave a
    bindings.1.channel 1
    bindings.2.slave b
    bindings.2.channel 0
    bindings.3.slave b
    bindings.3.channel 1
}
pcm.dmixrec {
    type dmix
    ipc_key 1024
    slave {
        pcm "receiver"
        period_time 0
        period_size 1024
        buffer_size 8192
        rate 48000
     }
     bindings {
        0 0
        1 1
     }
}
pcm.tv {
    type hw
    card 0
    device 3
    channels 2
}
pcm.receiver {
    type hw
    card 0
    device 1
    channels 2
}

The script is just a copy paste of some findings on the net and these forums but works good on my setup (asrock ion 330ht + yamaha receiver @ spdif + panasonic 50" (P50s10) @ hdmi; no hiss and crossfading works (on both tv and receiver)

Just some thinking out loud but have you tried lowering the 'rate' parameter of your dmix tv device. its probably because your tv can't handle the 48000 rate. try adjusting this to something lower: 44100

Regards.
Reply
#29
Dumb question time:
Won't this config drop you down to 2.0 sound instead of 5.1 (or above) ?
Reply
#30
No, ac3/dts audio still gets passed trough, alsa knows only two formats: pcm and 'not supported'

'pcm' will be captured by the dmixer and 'not supported' will be redirected to the receiver.
Reply

Logout Mark Read Team Forum Stats Members Help
[LINUX] Problems switching from Analog to Digital over SPDIF?1