PulseAudio on OpenWRT with MPD and other Stuff: Difference between revisions

mNo edit summary
mNo edit summary
Line 88: Line 88:




=== ALSA Related Commands ===
===ALSA Related Commands===
alsamixer: shows a text GUI of controls
alsamixer: shows a text GUI of controls


aplay -l : shows list of sound devices
aplay -l<span> </span>: shows list of sound devices


aplay -L : Shows a list of the various output ports
aplay -L<span> </span>: Shows a list of the various output ports


arecord -l : Shows a list of input / source devices (note, if PulseAudio is running and / or using a device it will show the device as 0, IE, 'unavailable')
arecord -l<span> </span>: Shows a list of input / source devices (note, if PulseAudio is running and / or using a device it will show the device as 0, IE, 'unavailable')


arecord -L : Shows a 'limited' list of the input / source devices
arecord -L<span> </span>: Shows a 'limited' list of the input / source devices


amixer scontrols : Shows a 'brief' list of devices
amixer scontrols<span> </span>: Shows a 'brief' list of devices


amixer scontents : Shows a detailed list of devices
amixer scontents<span> </span>: Shows a detailed list of devices


Example below;<syntaxhighlight lang="text">
Example below;<syntaxhighlight lang="text">
Line 162: Line 162:
The 'Speaker' is actually a 7.1 Surround Sound USB Audio Device with several physical AUX / 1/8" / 3.5mm Output Jacks
The 'Speaker' is actually a 7.1 Surround Sound USB Audio Device with several physical AUX / 1/8" / 3.5mm Output Jacks


The 'PCM' is a "CAPTURE" Device that does absolutely nothing on this device
The 'PCM' is a equates to a "Master Volume" control
The 'PCM Capture Source' is the currently selected input / source (mic, line, or SPDIF)
The 'PCM Capture Source' is the currently selected input / source (mic, line, or SPDIF)
The 'Line' is represented physically by an AUX / 1/8" / 3.5mm Input Jack ("traditionally" blue)
The 'Line' is represented physically by an AUX / 1/8" / 3.5mm Input Jack ("traditionally" blue)
Line 168: Line 168:
The 'IEC958' is represented physically by the SPDIF Jack for a Fiber Optic Cable
The 'IEC958' is represented physically by the SPDIF Jack for a Fiber Optic Cable
...and for this device, the SPDIF output isn't represented to software and apparently is just 'wired' up like a "monitor", where it gets constant full output and cannot be controlled in software (oh, well)
...and for this device, the SPDIF output isn't represented to software and apparently is just 'wired' up like a "monitor", where it gets constant full output and cannot be controlled in software (oh, well)
...another oddity of the above specific device, that one wouldn't readily see from the configuration, but becomes apparent in use is that the Line and Mic levels do nothing, but the Capture Source levels do allow for adjustment of levels (oh, well, each sound device will have it's own oddities)
</syntaxhighlight>
</syntaxhighlight>


=== Some WTF? Holes One Can Fall Into ===


==== module-detect ====
In /etc/pulse/system.pa load-module module-detect (Works great, but can also cause some unexpected issues)


<br />
Try adding this to the system.pa file: load-module module-alsa-sink device=hw:0,0
 
...and: Error opening PCM device hw:0: Resource busy, Failed to load module "module-alsa-source" (argument: "device_id=0"): initialization failed.
 
Why?  Because module-detect found it first!
 
Experiments showed that even loading module-detect after module-alsa-sink still produces an error.  So either module-detect always runs first OR module-detect doesn't check and see if an ALSA device is already loaded.
 
=== Useful Commands for Testing (from a live file, hence the # Comment Tags) ===
<nowiki>###</nowiki> Useful Commands for testing stuff;
 
<nowiki>###</nowiki> /usr/bin/mpd --no-daemon /etc/mpd.conf --verbose
 
<nowiki>###</nowiki> /usr/bin/pulseaudio --system --disallow-exit --disable-shm --exit-idle-time=-1 --realtime=false --verbose
 
<nowiki>###</nowiki> bluetoothctl connect FC:58:FA:2E:BA:7C
 
<nowiki>###</nowiki> bluetoothctl connect F4:4E:FC:EA:3B:33 for the Bluetooth Transceiver Device in Rx Mode
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> bluetoothctl devices Connected (the C in Connected has to be capitalized)
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> btmgmt is another command.
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> btmgmt --index 0 connectable on
 
<nowiki>###</nowiki> btmgmt bondable on
 
<nowiki>###</nowiki> btmgmt discov yes
 
<nowiki>###</nowiki> btmgmt find on OR just plain find
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> ...after playing with btmgmt, is is very busted on OpenWRT
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> pactl set-sink-volume bluez_sink.FC_58_FA_2E_BA_7C.a2dp_sink 10%
 
<nowiki>###</nowiki> alsamixer
 
<nowiki>###</nowiki> ls /usr/lib/pulse-*/modules/
 
<nowiki>###</nowiki> pactl list modules short
 
<nowiki>###</nowiki> pactl list short sinks
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> pactl info
 
<nowiki>###</nowiki> pactl list sources short
 
<nowiki>###</nowiki> pactl load-module module-loopback source=WhatEverNameOfSink
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> pactl load-module module-loopback source=3 sink=0
 
<nowiki>###</nowiki> pactl set-sink-volume 0 100%
 
<nowiki>###</nowiki> pactl set-source-volume 3 100%
 
<nowiki>###</nowiki> pactl list modules
 
<nowiki>###</nowiki> pactl list sink-inputs
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> pacmd is a command too
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> /usr/bin/pulseaudio --system --disallow-exit --disable-shm --exit-idle-time=-1 --verbose
 
<nowiki>###</nowiki> /usr/bin/pulseaudio --system --disallow-exit --disable-shm --exit-idle-time=-1 --verbose --log-level=debug --log-target=stderr
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> Device F4:4E:FC:EA:3B:33 BT17
 
<nowiki>###</nowiki> Device FC:58:FA:2E:BA:7C Gemini GHSI-W650BT
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> aplay WhatEverSongAsLongAsItIs.WAV <-- PulseAudio service must be stopped! (same for sox)
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> hcitool dev
 
<nowiki>###</nowiki> hciconfig -a
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> ...inside of bluetoothctl
 
<nowiki>######</nowiki> list (to show bluetooth controllers)
 
<nowiki>######</nowiki> devices
 
<nowiki>######</nowiki>
 
<nowiki>######</nowiki> select... one of the following;
 
<nowiki>######</nowiki> 5C:F3:70:9C:2B:20 ( ASUS 4.0 )
 
<nowiki>######</nowiki> 8A:88:4B:80:F5:CB ( RealTek 5.3 )
 
<nowiki>######</nowiki>
 
<nowiki>######</nowiki>
 
<nowiki>######</nowiki>
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 lsplaylist
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 playlist
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 add
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 del
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 clear
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 load
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 save
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 status
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 current (current song playing)
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 queued (next song up)
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47
 
<nowiki>###</nowiki> mpc -h password@10.100.100.47 update ("Update" the fact there are new songs in the physical directory.  After adding song to physical directory, can't play or add to playlist without UPDATE)
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> opkg install bluez-daemon bluez-libs bluez-tools bluez-utils bluez-utils-btmon bluez-utils-extra kmod-input-uinput
 
<nowiki>###</nowiki> opkg install pulseaudio-daemon-avahi pulseaudio-profiles pulseaudio-tools
 
<nowiki>###</nowiki> opkg install mpd-avahi-service mpd-full mpc libmpdclient
 
<nowiki>###</nowiki> opkg install alsa-lib alsa-ucm-conf alsa-utils gst1-mod-alsa
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> opkg install rtl8761bu-firmware kmod-bluetooth kmod-usb-core kmod-usb2 kmod-usb3 kmod-usb-ohci kmod-usb-uhci kmod-usb-hid  kmod-hid kmod-cfg80211
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> opkg install shadow-groupadd shadow-useradd shadow-usermod
 
<nowiki>###</nowiki> usermod
 
<nowiki>###</nowiki> ...OR: nano /etc/group: audio:x:29:root,mpd
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> opkg install coreutils-stat procps-ng-pgrep (for the bt-reconnect service)
 
<nowiki>###</nowiki>
 
<nowiki>###</nowiki> Files to modify (from previously configured devices): /etc/init.d/pulseaudio, /etc/pulse/system.pa, /etc/mpd.conf, asound.conf (maybe)
 
<nowiki>###</nowiki> ^^^ Remember to adjust the source sinks and bluetooth sinks for devices
 
<nowiki>###</nowiki> Configuration Services and Scripts (by me): /etc/init.d/bt-reconnect, /etc/bluetooth.sh, /etc/pulse/pulseaudio.sh