Tiny Core Linux

dCore Import Debian Packages to Mountable SCE extensions => General dCore Talk => Topic started by: Jason W on March 28, 2019, 07:14:46 PM

Title: Pulseaudio with multiple sound cards
Post by: Jason W on March 28, 2019, 07:14:46 PM
I looked in the info in the dCore wiki and the forums for this and pardon me if I didn't see it. My onboard audio has died, so I got a USB audio device. My onboard device as well as my Nvidia card is also recognized as sound devices.  Whether it is a USB audio device or a second or third sound card, the below may help when pulseaudio is installed and a second sound card is being used and settings are wished to be maintained across reboots.   This worked for me, may be better ways of doing it.  Make sure the following packages are installed and loaded on boot:

alsa-modules-$kernel-version
alsa-utils
pulseaudio

Determine your desired default sound card by viewing the output of the below command:
cat /proc/asound/cards

Mine is card #2:

 0 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0xf8800000 irq 30
 1 [NVidia         ]: HDA-Intel - HDA NVidia
                      HDA NVidia at 0xf3000000 irq 17
 2 [Device         ]: USB-Audio - USB Audio Device
                      C-Media Electronics Inc. USB Audio Device at usb-0000:00:1a.2-1, full speed

Use the card # of your desired card, then enter the below in /etc/asound.conf and back up the file if yours is card #2:

defaults.pcm.card 2
defaults.ctl.card 2

Then issue the command to find the desired pulseaudio card:
pactl list short sinks

Look for card by full name, my USB device is found below after this tutorial is followed:

0       alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device.analog-stereo       module-alsa-card.c      s16le 2ch 48000Hz       SUSPENDED
1       alsa_output.pci-0000_00_1b.0.analog-stereo      module-alsa-card.c     s16le 2ch 48000Hz        SUSPENDED

Then enter in ~.X.d/pulseaudio the below and back up the file with the correct entry, mine is the USB device:
Code: [Select]
#!/bin/sh

sleep 10
start-pulseaudio-x11
pacmd set-default-sink alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device.analog-stereo
pacmd set-default-source alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device.analog-stereo



This will make that sound device the default, otherwise using the graphical pulseaudio
tools will forget the settings on reboot.  Firefox seems to need pulseaudio running to work lately. 

Entering the normal values below at the end of /etc/pulse/default.pa does not work the same on dCore.

set-default-sink alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device.analog-stereo
set-default-source alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device.analog-stereo

I am surely open to suggestions or corrections on this.
Title: Re: Pulseaudio with multiple sound cards
Post by: Jason W on June 09, 2019, 07:24:00 PM
The above mentioned  ~.X.d/pulseaudio script does not work with dCore-buster64.  What does work is the below ~.X.d/pulseaudio file which has been tested with the standard firefox package and the firefox-latest which is obtained by the dCore-firefox-installer utility in dCore-buster64, dCore-stretch64, dCore-bionic64, and dCore-jessie. 

~.X.d/pulseaudio
Code: [Select]
#!/bin/sh

sleep 5
pulseaudio &
sleep 5
pacmd set-default-sink alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device.analog-stereo
pacmd set-default-source alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device.analog-stereo
 

This is of course assuming the pacmd commands are for those entries.