You are not logged in.

#1 2017-07-06 07:45:04

zuwarm
Member
Registered: 2017-06-20
Posts: 7

ALSA very high CPU usage and distortion

My sound card is a Realtek 889, which has:

- 8 analog outputs (7.1 surround)
- 6 analog inputs (3 stereo, front, line, rear)
- digital out (SPDIF)

I'm running all of this simultaneously with Alsa providing 4 stereo out (analog) + 1 digital and 3 stereo captures.

This is my Alsa config:

pcm_slave.playback {
    pcm "hw:0,0,0"
    channels 8
}

# inputs

pcm.stereo_in1 {
    type plug
    slave.pcm "hw:0,0,0"
    hint.show on
}

pcm.stereo_in2 {
    type plug
    slave.pcm "hw:0,2,0"
    hint.show on
}

pcm.stereo_in3 {
    type plug
    slave.pcm "hw:0,2,1"
    hint.show on
}


# helper outputs

pcm.shared_stereo_out1 {
    type dshare
    ipc_key 10001
    ipc_perm 0666
    slave playback
    bindings.0 0
    bindings.1 1
}

pcm.shared_stereo_out2 {
    type dshare
    ipc_key 10001
    ipc_perm 0666
    slave playback
    bindings.0 2
    bindings.1 3
}

pcm.shared_stereo_out3 {
    type dshare
    ipc_key 10001
    ipc_perm 0666
    slave playback
    bindings.0 4
    bindings.1 5
}

pcm.shared_stereo_out4 {
    type dshare
    ipc_key 10001
    ipc_perm 0666
    slave playback
    bindings.0 6
    bindings.1 7
}


# outputs

pcm.stereo_out1 {
    type plug
    slave.pcm "shared_stereo_out1"
    ttable.0.0 1
    ttable.1.1 1
    hint.show on
}

pcm.stereo_out2 {
    type plug
    slave.pcm "shared_stereo_out2"
    ttable.0.0 1
    ttable.1.1 1
    hint.show on
}

pcm.stereo_out3 {
    type plug
    slave.pcm "shared_stereo_out3"
    ttable.0.0 1
    ttable.1.1 1
    hint.show on
}

pcm.stereo_out4 {
    type plug
    slave.pcm "shared_stereo_out4"
    ttable.0.0 1
    ttable.1.1 1
    hint.show on
}

pcm.stereo_out1_digital {
    type plug
    slave.pcm "hw:0,1,0"
    hint.show on
}

This does actually work with an old Suse 11. With current Kernel and Alsa (with Arch) I get a lot distortion on all channels. My CPU usage also is about 80%. I tried a lot with rate and format convertions because I thought Alsa internal resampling and such eats my cpu, but this doesn't seem to be the case.
When I use only one pcm at a time it is ok!

Any help appreciated.

Offline

#2 2017-07-10 08:03:56

zuwarm
Member
Registered: 2017-06-20
Posts: 7

Re: ALSA very high CPU usage and distortion

As a workaround I tried to use Pulseaudio to do the complicated portion (splitting pcms).

from ~/.config/pulse/default.pa

set-card-profile alsa_card.pci-0000_00_1b.0  output:analog-surround-71

load-module module-remap-sink sink_name=out1 remix=no master=alsa_output.pci-0000_00_1b.0.analog-surround-71 channels=2 master_channel_map=front-left,front-right channel_map=left,right
load-module module-remap-sink sink_name=out2 remix=no master=alsa_output.pci-0000_00_1b.0.analog-surround-71 channels=2 master_channel_map=side-left,side-right channel_map=left,right
load-module module-remap-sink sink_name=out3 remix=no master=alsa_output.pci-0000_00_1b.0.analog-surround-71 channels=2 master_channel_map=rear-left,rear-right channel_map=left,right
load-module module-remap-sink sink_name=out4 remix=no master=alsa_output.pci-0000_00_1b.0.analog-surround-71 channels=2 master_channel_map=center,lfe channel_map=left,right

and asound.conf

pcm.stereo_out1 {
    type pulse
    device "out1"
    hint.show on
}

pcm.stereo_out2 {
    type pulse
    device "out2"
    hint.show on
}

pcm.stereo_out3 {
    type pulse
    device "out3"
    hint.show on
}

pcm.stereo_out4 {
    type pulse
    device "out4"
    hint.show on
}


# from here like before:

pcm.stereo_out1_digital {
    type plug
    slave.pcm "hw:0,1,0"
    hint.show on
}


pcm.stereo_in1 {
    type plug
    slave.pcm "hw:0,0,0"
    hint.show on
}

pcm.stereo_in2 {
    type plug
    slave.pcm "hw:0,2,0"
    hint.show on
}

pcm.stereo_in3 {
    type plug
    slave.pcm "hw:0,2,1"
    hint.show on
}

This only uses Pulseaudio for analog output, input is still the same. Is it possible Pulseaudio can not use all input ports at the same time? e.g.

set-source-port alsa_input.pci-0000_00_1b.0.analog-stereo analog-input-front-mic
# or
set-source-port alsa_input.pci-0000_00_1b.0.analog-stereo analog-input-rear-mic
# or
set-source-port alsa_input.pci-0000_00_1b.0.analog-stereo analog-input-linein

Anyway, with this setup I still get very high CPU usage. This time from Pulseaudio (and application)...

Offline

#3 2017-08-11 09:11:27

zuwarm
Member
Registered: 2017-06-20
Posts: 7

Re: ALSA very high CPU usage and distortion

To close this topic:
We ended up writing our own channel splitting and not use Alsa. asound.conf is very basic now:

pcm.capture1 {
    type plug
    slave.pcm "hw:0,0,0"
    hint.show on
}
pcm.capture2 {
    type plug
    slave.pcm "hw:0,2,0"
    hint.show on
}
pcm.capture3 {
    type plug
    slave.pcm "hw:0,2,1"
    hint.show on
}
pcm.playback {
    type plug
    slave.pcm "hw:0,0,0"
    hint.show on
}
pcm.playback_digital {
    type plug
    slave.pcm "hw:0,1,0"
    hint.show on
}

pcm.plackback is 8 Channels (7.1 surround), our software takes care of all of them.

Last edited by zuwarm (2017-08-11 12:44:48)

Offline

Board footer

Powered by FluxBB