Re: Using module-ladspa-sink - what LADSPA plugin exactly do I need to install?

2024-06-03 Thread Sean Greenslade
On Mon, Jun 03, 2024 at 06:17:59PM +0300, Doron Behar wrote:
> I found this program I'd like to use:
> 
> https://github.com/pulseaudio-equalizer-ladspa/equalizer
> 
> I managed to compile and run it, but I don't hear it makes a difference
> in the sound. Do I need to enable the `module-ladspa-sink` module? Link:
> 
> https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#module-ladspa-sink
> 
> What makes it difficult for me to figure this out myself, is the
> [LADSPA](http://www.ladspa.org/) link, which seems to general, because
> this group develop many projects, or which I'm not sure which I should
> compile as a pulseaudio plugin (some of which are available in my
> distribution.
> 
> Thanks for any help in advance.

What distro of Linux are you running?

Eyeballing the Arch package for this equalizer, it looks like it needs
the swh-plugins package for the actual LADSPA plugin itself. It might be
named differently on your distro.

You shouldn't need to manually load any modules in pulse; this equalizer
script seems to do all the module loading automagically.

--Sean



Re: I see no way to report a bug on "How to report a bug" wiki page

2024-03-11 Thread Sean Greenslade
On Mon, Mar 11, 2024 at 10:28:47AM +0100, Martin Guy wrote:
> Hi!
> 
>   A pulseaudio bug has surfaced today - the server running out of file
> descriptors when playing short music tracks continuously for over a week -
> but on the "How to report a bug" wiki page
> 
> https://www.freedesktop.org/wiki/Software/PulseAudio/BugReports
> 
> I see nothing saying how to report a bug, and the gitlab project does not
> seem to have an "Issues" section.

If you click the "community" link on the top bar, one of the first links
on that page is the Gitlab issue tracker:

https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues

--Sean



Re: Mic volume Keeps changing randomly

2024-03-05 Thread Sean Greenslade
On Sat, Feb 24, 2024 at 08:58:34PM -0800, Igal Sapir wrote:
> Hello,
> 
> I am running Ubuntu 22.04.4 and every time I get into a meeting everyone
> asks me to adjust my mic volume.
> 
> How can I set it so that it does not change by itself?
> 
> I have 3 microphones (obviously only using one at a time):
> 
> 1) Internal on Dell laptop
> 2) 3.5mm Jack headset
> 3) Bluetooth headset

Hi, Igal. Sorry for the slow response.

Pulseaudio does not adjust volumes by itself. The behavior you're
decribing is usually a result of one or more videoconferencing apps with
a "helpful" adjust-my-mic-volume setting. I personally find those
features to cause more problems than they solve, so I disable them. Look
through the audio setting of your videoconferencing applications (e.g.
Zoom, Skype, Teams, Slack).

Unfortunately, Pulse does not have a way of locking out other
applications from touching your volumes. That would be a neat feature to
have...

--Sean



Re: [pulseaudio-discuss] Switching output ports across sound cards will cause the Headphone to be silent.

2023-11-20 Thread Sean Greenslade
On Mon, Nov 20, 2023 at 03:03:41PM +0800, 赵成义 wrote:
> > OK, so your custom client application is deliberately changing the
> > default sink? Note that just changing the default sink will not move
> > existing sink input streams. You will need to do that yourself, for
> > example with the pa_context_move_sink_input_by_index function.
> 
> 
> 
> Hi Sean,
> 
> 
> In fact, the sink-input has been moved correctly. If the speaker port is 
> closed, this problem will not occur.
> 
> 
> 
> I think this is a kernel problem. At that time, the speaker was always on and 
> switching between sound cards 
> 
> was performed when the headphone was plugged and unplugged.
> 
> 
> 
> logs:
> ---
> 
> 11月 20 13:40:10.689190 uos60-PC pulseaudio[8944]: I: [pulseaudio] core.c: 
> configured_default_sink: alsa_output.pci-_00_1f.3.analog-stereo -> 
> alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00.analog-stereo
> 11月 20 13:40:10.689190 uos60-PC pulseaudio[8944]: I: [pulseaudio] core.c: 
> default_sink: alsa_output.pci-_00_1f.3.analog-stereo -> 
> alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00.analog-stereo
> 11月 20 13:40:10.689623 uos60-PC pulseaudio[8944]: D: [pulseaudio] 
> module-suspend-on-idle.c: Sink alsa_output.pci-_00_1f.3.analog-stereo 
> becomes idle, timeout in 2 seconds.
> 11月 20 13:40:10.689623 uos60-PC pulseaudio[8944]: D: [pulseaudio] 
> sink-input.c: Starting to move sink input 0 from 
> 'alsa_output.pci-_00_1f.3.analog-stereo'

I'm unable to reproduce the behavior you are describing. I tried on
several machines with both internal soundcards and a USB sound card
attached, and I was able to move sink inputs between the two cards
immediately after plugging in headphones with no issues.

As a next step, you should try to determine where in the stack the issue
is. Your logs don't have any smoking guns in them, so I would get your
system into the problematic state while your audio source is running,
then check everything starting at the source of the audio:
- Audio player is actually playing media (e.g. not paused)
- Pulse APIs are consuming audio samples (e.g. not stalled)
- Pulse reports that the sink input is not corked, not muted, and set at
  a reasonable volume level
- Pulse reports that the sink input is routed to the correct sink
- Pulse reports that the sink is running, not muted, set to a reasonable
  volume, and has the correct active port
- Alsamixer shows the device master channel as unmuted and at
  approximately the same volume that pulse reports
- Alsamixer shows the intended port's channel at 100% volume and not
  muted

--Sean



Re: [pulseaudio-discuss] Switching output ports across sound cards will cause the Headphone to be silent.

2023-11-19 Thread Sean Greenslade
On Mon, Nov 20, 2023 at 01:58:34PM +0800, 赵成义 wrote:
> Hi Sean,
> 
> 
> Thanks for your reply.
> 
> Yes, at first, unplugging theheadphones should switch to the speaker channel 
> of 
> 
> the same ALSA card,  but then the client sends 
> "command_set_default_sink_or_source" 
> 
> to switth to USB Speaker, so the following switching sequence occurs.
> headphone -> speaker-> usb speaker (or Bluetooth earphone)
> 
> Part of the log is as follows:
> --
> 11月 20 13:40:10.686234 uos60-PC pulseaudio[8944]: I: [pulseaudio] sink.c: 
> Changed port of sink 1 "alsa_output.pci-_00_1f.3.analog-stereo" to 
> analog-output-speaker
> 11月 20 13:40:10.686234 uos60-PC pulseaudio[8944]: I: [pulseaudio] core.c: 
> default_sink: 
> alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00.analog-stereo
>  -> alsa_output.pci-_00_1f.3.analog-stereo
> 
> ...
> 
> 11月 20 13:40:10.689190 uos60-PC pulseaudio[8944]: I: [pulseaudio] core.c: 
> configured_default_sink: alsa_output.pci-_00_1f.3.analog-stereo -> 
> alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00.analog-stereo
> 11月 20 13:40:10.689190 uos60-PC pulseaudio[8944]: I: [pulseaudio] core.c: 
> default_sink: alsa_output.pci-_00_1f.3.analog-stereo -> 
> alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00.analog-stereo

OK, so your custom client application is deliberately changing the
default sink? Note that just changing the default sink will not move
existing sink input streams. You will need to do that yourself, for
example with the pa_context_move_sink_input_by_index function.

--Sean



Re: [pulseaudio-discuss] Switching output ports across sound cards will cause the Headphone to be silent.

2023-11-19 Thread Sean Greenslade
On Fri, Nov 17, 2023 at 04:59:44PM +0800, 赵成义 wrote:
> Hi Guys,
> 
> 
> In the following scenario, switching output ports across sound cards will 
> cause the Headphone to be silent.
> (Tips: USB speakers or Bluetooth earphones use independent sound cards, and 
> the device uses an onboard sound card.)
> 
> 
> 1. headphone is unplugged, automatically change port: headphone -> 
> speaker-> usb speaker (or Bluetooth earphone)
> 2. headphone is plugged, automatically change port: usb speaker(or Bluetooth 
> earphone) -> headphone
> 
> 
> Step 1. When the headphone is unplugged, the port is automatically switched 
> from the headphone to the speaker. 
> The following configuration items in the analog-output-speaker.conf file will 
> be applied, and then the port is 
> switched to the USB speaker.
> Close Headphone volume
> [Element Headphone]
> switch=off
> volume=off
> 
> 
> Step 2, when the headphone is plugged in, the port is automatically switched 
> from the USB speaker to the headphone, 
> and the following configuration items in the analog-output-headphone.conf 
> file will be applied.
> [Element Headphone]
> required-any = any
> switch = mute
> volume=merge
> override-map.1 = all
> override-map.2 = all-left,all-right
> 
> 
> As you can see through alsamixer, the volume of the Headphone has been 
> restored, but the Headphone is silent.
> 
> 
> 
> Could you please help slove this issue, thanks!

Hi, Chengyi.

Your question is somewhat unclear. The behavior you're describing is not
how pulseaudio operates by default, but the config file snippets you
provide are not modified from the defaults. By default, unplugging the
headphones should switch to the speaker channel of the same ALSA card.
Have you made any modifications to the various pulseaudo alsa-mixer
paths conf files? If so, please show what you have changed.

--Sean



Re: [pulseaudio-discuss] Problem with HSP/HFP profiles with bluetooth devices

2023-09-10 Thread Sean Greenslade
On Fri, Sep 08, 2023 at 05:02:54PM +0200, Antoine Nauzet wrote:
> Le ven. 8 sept. 2023 à 07:55, Sean Greenslade  a
> > I would start with using your distro's pulse package and checking both
> > the system logs and the pulseaudio logs. I would expect there to be some
> > chatter when a bluetooth device event like that happens.
> >
> > --Sean
> >
> >
> I'm back to distro's pulse package. When the headset_audio_gateway
> capability is switch to not available, the pulse audio logs this:
> 
> ( 543.481|   8.707) D: [pulseaudio] bluez5-util.c: Device
> /org/bluez/hci0/dev_78_29_C9_4F_C2_4E removed

This line only happens when pulse receives an "InterfacesRemoved"
message from Bluez. Whatever is going wrong in your system, it's
happening in the bluetooth stack itself. Pulse has no control over it.
I think you'll need to ask for help from the Bluez project.

> ( 543.482|   0.000) D: [pulseaudio] backend-ofono.c: HF card removed:
> /card_2
> ( 543.482|   0.000) D: [pulseaudio] bluez5-util.c: Transport /card_2 state:
> idle -> disconnected
> ( 543.482|   0.000) D: [pulseaudio] card.c: Setting card
> bluez_card.4C_DD_31_43_8E_FF profile headset_audio_gateway to availability
> status no
> ( 543.482|   0.000) D: [pulseaudio] device-port.c: Setting port
> phone-output to status no
> ( 543.482|   0.000) D: [pulseaudio] core-subscribe.c: Dropped redundant
> event due to change event.
> 
> Is "card_2" the card "2" display when typing pactl list cards?

No, /card_2 is a reference to the transport path from the bluetooth
stack. Nothing to do with the card numberings in pulse.

--Sean



Re: [pulseaudio-discuss] iec958 (S/PDIF) + USB = 100% CPU usage

2023-09-10 Thread Sean Greenslade
On Fri, Sep 08, 2023 at 11:00:35AM -0600, Ismael Farfán wrote:
> Hi Sean
> 
> I noticed it only happens when using 5.1 audio and something is playing.
> It triggers 100% usage from 1 core, not the whole CPU
> So this causes the issue : Digital Surround 5.1 (IEC958/AC3)
> But the stereo ones doesn't: Digital Stereo (Duplex) (IEC958)

Ah, well, I don't have any 5.1 channel hardware, so I can't test this.
Sorry.

> I'll try updating my kernel from backports and see if I can squeeze more
> logs.
> 
> I haven't found how to get only pulse audio logs from journalctl
> journalctl --user _SYSTEMD_UNIT=pulseaudio.service

That should be the correct command. I'm not sure why that isn't
returning the logs. If all else fails, you could try killing the
systemd pulse service and running the pulseaudio server manually in a
terminal to capture the logs.

> I'll come back when I get more info about this issue, may actually try with
> arch :v
> 
> systemctl status --user pulseaudio
> sep 08 08:17:39  pulseaudio[1822]: Failed to open module
> module-zeroconf-publish.so: module-zeroconf-publish.so: cannot open shared
> object file: No such file or directory
> sep 08 08:17:39  pulseaudio[1822]: Failed to open module
> "module-zeroconf-publish".
> sep 08 08:17:39  pulseaudio[1822]: module-rescue-stream is obsolete and
> should no longer be loaded. Please remove it from your configuration.
> sep 08 08:17:39  pulseaudio[1822]: Failed to open module
> module-zeroconf-publish.so: module-zeroconf-publish.so: cannot open shared
> object file: No such file or directory
> sep 08 08:17:39  pulseaudio[1822]: Failed to open module
> "module-zeroconf-publish".
> sep 08 08:17:39  pulseaudio[1822]: Module "module-rescue-streams" should be
> loaded once at most. Refusing to load.
> sep 08 08:17:39  systemd[1806]: Started pulseaudio.service - Sound Service.
> sep 08 08:17:39  pulseaudio[1822]: Could not find
> org.bluez.BatteryProviderManager1.RegisterBatteryProvider(), is bluetoothd
> started with experimental features enabled (-E flag)?
> sep 08 10:28:35  pulseaudio[1822]: Got POLLNVAL from ALSA
> sep 08 10:28:35  pulseaudio[1822]: Error opening PCM device
> plug:SLAVE='a52:3': No such file or directory

No smoking gun in these logs that I can see. You could try to turn up
the log verbosity, though I don't really know if that will shed any
additional light on the issue.

--Sean



Re: [pulseaudio-discuss] Problem with HSP/HFP profiles with bluetooth devices

2023-09-07 Thread Sean Greenslade
On Wed, Sep 06, 2023 at 02:46:05PM +0200, Antoine Nauzet wrote:
> Hello,
> 
> I'm working on a Raspberry Pi 4, with an USB Bluetooth dongle, trying to
> connect is to an android device as a hand free device.
> 
> My configuration is the following:
> 
>- kernel version 6.1.21
>- bluez version 5.55
>- Pulseaudio version 14.2
>- ofono version 1.31
> 
> I manage to make the connection, and the bluetooth device is detected by
> Pulseaudio. The HSP/HFP profile is available. But when making a call, after
> a certain time, the HSP/HFP profile change to unavailable. The device is
> still connected, I can play sound from the android device to the raspberry.
> But the sound from the call is not working anymore.
> 
> What could explain the lost of the profil? Is there something to do to keep
> it up?
> 
> I tried with the last version of pulseaudio, compiling it from the sources
> get from the git repository. The version is now 16.99.1-8-g13ef0.
> Now, when connecting the device, both HSP and HFP are not available! I
> could not get them to be up.
> 
> Is there anything I have to do to make it work? When installing pulseaudio
> with apt-get, I was installing pulseaudio and pulseaudio-module-bluetooth.
> Is there something to include it when installing from the sources?
> 
> What should I check to start figured out what is going on?
> 
> Thank you for your help
> Antoine

I would start with using your distro's pulse package and checking both
the system logs and the pulseaudio logs. I would expect there to be some
chatter when a bluetooth device event like that happens.

--Sean



Re: [pulseaudio-discuss] Disable system wide mode

2023-09-07 Thread Sean Greenslade
On Tue, Sep 05, 2023 at 10:58:10AM -0400, dhtguru wrote:
> Hello,
> 
> Somehow I accidentally enabled PA system wide mode.  I think it was by
> 
> using 'pulseaudio -vvv'.
> My home assistant log is advising that it may be causing issues with my BT.
> 
> How do I disable system wide mode?
> 
> Thanks in advance.

Pulseaudio doesn't enable system-wide mode by itself. You (or some other
utility) would have to edit your global /etc/pulse/daemon.conf file and
change the "system-instance" setting to yes.

If all you did was manually run "pulseaudio -vvv", that should not have
changed any settings. Simply kill any running pulseaudio servers (e.g.
with a "sudo killall pulseaudio") and let the auto-spawn service
re-launch pulse. Or just reboot the computer.

--Sean



Re: [pulseaudio-discuss] iec958 (S/PDIF) + USB = 100% CPU usage

2023-09-07 Thread Sean Greenslade
On Tue, Aug 29, 2023 at 10:25:03AM -0600, Ismael Farfán wrote:
> Hello pulse
> 
> I'm not sure if it's a bug or not but, I did google around for about an
> hour.
> 
> I noticed that whenever I have a device configured with the S/PDIF profile
> (iec958), PulseAudio uses 100% cpu (2 threads 50% each)
> 
> I have a cheap USB device with optical audio support
> Bus 003 Device 011: ID 0d8c:0012 C-Media Electronics, Inc. USB Audio Device
> Bus 003 Device 010: ID 0d8c:0102 C-Media Electronics, Inc. CM106 Like Sound
> Device
> 
> Here's how top looks when anything is grabbing the output, even if it's a
> paused video. As soon as I close the tab it disappears from top.
> PID   PRI  NI  VIRT   RES   SHR S  CPU%▽MEM%   TIME+  Command
> 1820   9 -11 2218M 46576 28064 S  51.5  0.1  3h41:07 /usr/bin/pulseaudio
> --daemonize=no --log-target=journal
> 55780  -6   0 2218M 46576 28064 S  50.9  0.1  6:23.43 /usr/bin/pulseaudio
> --daemonize=no --log-target=journal
> 
> I changed the profile of my USB headphones to use iec958 and I could see
> pulseaudio again using 100% cpu even though I only hear noise because the
> headphones don't support it.
> 
> So my guess is that it's got something to do with the iec958 encoding.
> 
> Any ideas?
> 
> I'm on Debian stable bookworm with KDE Plasma

Hi, Ismael.

I'm sorry to report that I was unable to reproduce your issue. I managed
to find two different USB audio devices in my collection that enumerate
with an iec958 interface, one with an actual optical S/PDIF port (a Fiio
E10) and one without (a Scarlet Solo). Neither device triggered any sort
of abnormal CPU usage when switched to iec958 compared to the analog
outputs.

That said, I am running Arch instead of Debian, so I likely have a
different kernel (and therefore ALSA drivers) and pulse version than
you. I'm not too familiar with the particulars of Debian, but perhaps
you could enable backports and see if there's a newer version of pulse
you could test?

Otherwise, my suggestion for further troubleshooting would be to check
the pulseaudio logs, increasing the verbosity if need be.

--Sean



Re: [pulseaudio-discuss] pa_simple_new function - Failed to load cookie file from cookie: Not a directory

2023-08-22 Thread Sean Greenslade
On Fri, Aug 18, 2023 at 09:05:12AM +0200, Björn Försterling wrote:
> Hi Sean,
> 
> thank you very much for the reply.
> 
> I figured out my mistake.
> I actually modified the HOME environment variable in my program
> by using the pointer that was returned by the getenv() function.
> (which is not a pointer to a copy of the string but to the actual env var...)
> 
> I wonder why pulseaudio is using these authentication cookies when trying to
> connect to a local pulseaudio server though.

As the pulse docs [0] put it:

>> cookie: A random value which may be used to identify this instance of
>> PulseAudio. Not cryptographically secure in any way.

It's mainly a sanity check to make sure that you're talking to the pulse
server that you're expecting to, on the off chance that multiple servers
are running on the same system.

--Sean

[0]: 
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/CoreAPI/


Re: [pulseaudio-discuss] pa_simple_new function - Failed to load cookie file from cookie: Not a directory

2023-08-17 Thread Sean Greenslade
On Wed, Aug 16, 2023 at 05:08:25PM +0200, Björn Försterling wrote:
> Hello everyone,
> 
> I am using the pulse audio simple API in a C program and I am getting the
> following error message when using the "pa_simple_new" function:
> 
> 28simple = pa_simple_new(NULL, "Audio Playback", PA_STREAM_PLAYBACK,
> NULL, "playback", &ss, NULL, NULL, &pa_error);
> (gdb) 
> [New Thread 0x734416c0 (LWP 3517)]
> Failed to load cookie file from cookie: Not a directory
> 
> The audio file that I am playing in the later part of the program is still 
> being
> played correctly.
> But how do I suppress (or solve) this error message?
> 
> I tried setting the environment variable PULSE_COOKIE like this:
> export PULSE_COOKIE="~/.config/pulse/cookie"
> But it did not help. (this "cookie" file exists)
> 
> The return value of the pa_simple_new function is not NULL:
> (gdb) p simple
> $1 = (pa_simple *) 0x92d0
> 
> And the pa_error integer that I am trying to get an error code with stays at 
> 0.
> 
> Can someone please help me to debug this issue?

The fact that you're getting this exact error message:

> Failed to load cookie file from cookie: Not a directory

implies that your environment variable is not getting picked up by your
application. If you're launching your program from a shell, perhaps try
directly setting the env var in the calling line, like so:

$ PULSE_COOKIE=~/.config/pulse/cookie ./my-pulse-using-executable

--Sean



Re: [pulseaudio-discuss] Inserting headphone "locks" audio

2023-08-07 Thread Sean Greenslade
On Sun, Aug 06, 2023 at 07:55:22AM -0700, John Oliver wrote:
> On Sat, Aug 5, 2023 at 11:23 PM Sean Greenslade 
> wrote:
> > I suspect what you will need to do is to make sure that the internal
> > card (likely the top one in pavucontrol) profile is set to your correct
> > HDMI port, and then select that card as the default in the Output
> > Devices tab. Some applications may not respect the default, but you can
> > move them over to the internal card by using the drop-down in the
> > playback tab.
>
> How would I do that?  Sorry, I know next to nothing about this stuff.
 
In pavucontrol, the relevant tabs are "Playback" and "Output Devices".

The Playback tab shows all applications that are currently outputting
sound. When you have multiple sound cards available, each application
line will also have a drop-down box to select which sound card to send
the application's sound to. This drop-down will change the output
on-the-fly.

On the Output Devices tab, you will have a line for every sound card
currently attached to your system. At the far right of each line, there
is a group of three buttons. One is the card mute, one is the Left-Right
volume unlock, and the last one is the "Set as Default" button. Only
one card in your system can be selected as the default. You generally
only need to select your desired default once, then Pulse should
remember that selection going forward. That said, not all applications
respect the default. Some pulse-aware applications have their own
internal settings for which card they select, and most applications will
return to the card they last used if you had manually moved it to a
different card in the Playback tab.

Hopefully this helps. Let me know if anything is still unclear.

--Sean



Re: [pulseaudio-discuss] Inserting headphone "locks" audio

2023-08-05 Thread Sean Greenslade
On Sat, Aug 05, 2023 at 10:55:36AM -0700, John Oliver wrote:
> > I would guess that the dock shows up as a separate audio device from the
> > internal sound card on the laptop, hence the two options listed in
> > pavucontrol. But to confirm, can you post the output you get from the
> > following command:
> >
> > $ pactl list cards
> >
> > That should give some more detail on what the two audio devices are.
>
> Card #0
> Name: alsa_card.pci-_00_1f.3-platform-skl_hda_dsp_generic
> Driver: module-alsa-card.c
> Owner Module: 22
> Properties:
> alsa.card = "0"
> alsa.card_name = "sof-hda-dsp"
> alsa.long_card_name = "LENOVO-21CB000HUS-ThinkPadX1CarbonGen10"

OK, so card #0 is indeed your internal card, and card #6 is the dock.
These are the two cards you see in pavucontrol.

> Card #6
> Name:
> alsa_card.usb-DisplayLink_ThinkPad_Hybrid_USB-C_with_USB-A_Dock_10085535-02
> Driver: module-alsa-card.c
> Owner Module: 32
> Properties:
> alsa.card = "1"
> alsa.card_name = "ThinkPad Hybrid USB-C with USB-"
> alsa.long_card_name = "DisplayLink ThinkPad Hybrid USB-C with USB- at
> usb-:00:0d.0-3.2, super spee"
> alsa.driver_name = "snd_usb_audio"
> device.bus_path = "pci-:00:0d.0-usb-0:3.2:1.2"
> sysfs.path =
> "/devices/pci:00/:00:0d.0/usb2/2-3/2-3.2/2-3.2:1.2/sound/card1"
> udev.id =
> "usb-DisplayLink_ThinkPad_Hybrid_USB-C_with_USB-A_Dock_10085535-02"
> device.bus = "usb"
> device.vendor.id = "17e9"
> device.vendor.name = "DisplayLink"
> device.product.id = "6015"
> device.product.name = "ThinkPad Hybrid USB-C with USB-A Dock"
> device.serial = "DisplayLink_ThinkPad_Hybrid_USB-C_with_USB-A_Dock_10085535"
> device.string = "1"
> device.description = "ThinkPad Hybrid USB-C with USB-A Dock"
> module-udev-detect.discovered = "1"
> device.icon_name = "audio-card-usb"
> Profiles:

This section is what corresponds to the entries in the dropdowns in the
configuration tab of pavucontrol.

> input:analog-stereo: Analog Stereo Input (sinks: 0, sources: 1, priority:
> 65, available: no)
> input:iec958-stereo: Digital Stereo (IEC958) Input (sinks: 0, sources: 1,
> priority: 32823, available: yes)
> output:analog-stereo: Analog Stereo Output (sinks: 1, sources: 0, priority:
> 39268, available: yes)
> output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (sinks: 1,
> sources: 1, priority: 6565, available: yes)
> output:analog-stereo+input:iec958-stereo: Analog Stereo Output + Digital
> Stereo (IEC958) Input (sinks: 1, sources: 1, priority: 39323, available:
> yes)
> output:analog-surround-21: Analog Surround 2.1 Output (sinks: 1, sources:
> 0, priority: 34068, available: yes)
> output:analog-surround-21+input:analog-stereo: Analog Surround 2.1 Output +
> Analog Stereo Input (sinks: 1, sources: 1, priority: 1365, available: yes)
> output:analog-surround-21+input:iec958-stereo: Analog Surround 2.1 Output +
> Digital Stereo (IEC958) Input (sinks: 1, sources: 1, priority: 34123,
> available: yes)
> output:analog-surround-41: Analog Surround 4.1 Output (sinks: 1, sources:
> 0, priority: 34068, available: yes)
> output:analog-surround-41+input:analog-stereo: Analog Surround 4.1 Output +
> Analog Stereo Input (sinks: 1, sources: 1, priority: 1365, available: yes)
> output:analog-surround-41+input:iec958-stereo: Analog Surround 4.1 Output +
> Digital Stereo (IEC958) Input (sinks: 1, sources: 1, priority: 34123,
> available: yes)
> output:analog-surround-50: Analog Surround 5.0 Output (sinks: 1, sources:
> 0, priority: 33968, available: yes)
> output:analog-surround-50+input:analog-stereo: Analog Surround 5.0 Output +
> Analog Stereo Input (sinks: 1, sources: 1, priority: 1265, available: yes)
> output:analog-surround-50+input:iec958-stereo: Analog Surround 5.0 Output +
> Digital Stereo (IEC958) Input (sinks: 1, sources: 1, priority: 34023,
> available: yes)
> output:analog-surround-51: Analog Surround 5.1 Output (sinks: 1, sources:
> 0, priority: 34068, available: yes)
> output:analog-surround-51+input:analog-stereo: Analog Surround 5.1 Output +
> Analog Stereo Input (sinks: 1, sources: 1, priority: 1365, available: yes)
> output:analog-surround-51+input:iec958-stereo: Analog Surround 5.1 Output +
> Digital Stereo (IEC958) Input (sinks: 1, sources: 1, priority: 34123,
> available: yes)
> output:iec958-stereo: Digital Stereo (IEC958) Output (sinks: 1, sources: 0,
> priority: 38268, available: yes)
> output:iec958-stereo+input:analog-stereo: Digital Stereo (IEC958) Output +
> Analog Stereo Input (sinks: 1, sources: 1, priority: 5565, available: yes)
> output:iec958-stereo+input:iec958-stereo: Digital Stereo Duplex (IEC958)
> (sinks: 1, sources: 1, priority: 38323, available: yes)
> off: Off (sinks: 0, sources: 0, priority: 0, available: yes)

What I notice here is that none of these profiles mention HDMI / Display
Port. So my suspicion is that audio for the HDMI ports is still provided
by the built-in audio card, whereas the analog port (headphone jack) on
the dock is provided by the dock's USB audio card.

I sus

Re: [pulseaudio-discuss] Inserting headphone "locks" audio

2023-08-04 Thread Sean Greenslade
On Fri, Aug 04, 2023 at 07:18:30AM -0700, John Oliver wrote:
> I have two drop-downs, both titled "Built-in Audio"  The top is "Digital
> Stereo (HDMI) Output" and the other is "Analog Stereo Duplex"
> 
> I'm not clear on what I would change.  The top one has a bunch of other
> options, all of which are unplugged and unavailable.  The other has three
> more options... "Analog Stereo Input", "Analog Stereo Output", and "Off"

I would guess that the dock shows up as a separate audio device from the
internal sound card on the laptop, hence the two options listed in
pavucontrol. But to confirm, can you post the output you get from the
following command:

$ pactl list cards

That should give some more detail on what the two audio devices are.

--Sean



Re: [pulseaudio-discuss] Inserting headphone "locks" audio

2023-08-04 Thread Sean Greenslade
On Thu, Aug 03, 2023 at 08:09:53AM -0700, John Oliver wrote:
> I have a ThinkPad X1 running Ubuntu 22.04 and a "ThinkPad Hybrid USB-C with
> USB-A Dock"  If I insert a headphone jack to the docking station, I can
> only hear sound coming from the headphones... I cannot switch to HDMI.  At
> my last job I had another ThinkPad running RHEL 8 and a docking station,
> and I was able to leave my headphones plugged in and switch to HDMI.  How
> can I fix?  The docking station is tucked away, and it's a bit of a chore
> to plug the headphones in and out.

Some audio interfaces have the HDMI and the analog ports exposed as
different profiles of the same card. If you run pavucontrol and go into
the Configuration tab, check what is listed in the Profile drop-down for
your audio card. The profile that corresponds to using only the analog
ports is usually called "Analog Stereo Duplex". The HDMI options (if
present) will have various names depending on the number of ports and
which channel configurations your card supports.

Changing the selection in that dropdown should live re-route any playing
audio to the selected port. Try selecting some of the HDMI options and
see if that gets the audio routed the way you want.

--Sean



Re: [pulseaudio-discuss] Crackling Audio in Pulseaudio RTP Stream

2023-02-18 Thread Sean Greenslade
On Sat, Feb 18, 2023 at 08:44:21PM +0100, NicoHood wrote:
> Hey Guys,
> I am using pulseaudio for years now, but since Version 14, maybe 15 there is
> a crackling in the rtp stream. I've setup RTP just with paprefs, enable the
> sender and local receiver on a separate audio device.
> 
> I know that I am reporting this really late and the bug is there for some
> years now. I hoped this gets eventually fixed, but it did not. I am using
> the latest archlinux pulseaudio.
> 
> Are you guys aware of the issue, does it also happen to you? It is just a
> tiny crackling, but you can hear in on good audio boxes. It sound a bit like
> the vinyl sound, just not so often. You can hear it on the sender via
> loopback and on all other receivers as well.

Can you describe your setup in more detail? It's unclear if you're using
pulseaudio as the RTP sender, RTP receiver, or both.

Occasional audible crackling is usually due to buffer underruns. Are
your RTP streams going over a wireless network? If so, have you tried
increasing the jitter buffer size on the receiver?

--Sean



Re: [pulseaudio-discuss] How to be sure about the quality of the audio?

2023-02-05 Thread Sean Greenslade
On Fri, Feb 03, 2023 at 08:25:53PM -0300, MilS Lion wrote:
> HI.
> Im having this issue:
> I subscribed to Qobuz (an Hi-res audio quality).
> 
> I was using ALSA directly and with alsa, i just put this:
> sudo cat /proc/asound/IQaudIODAC/pcm0p/sub0/hw_params
> 
> if it is a 16bit 44000Khz audio i get:
> access: MMAP_INTERLEAVED
> format: S16_LE
> subformat: STD
> channels: 2
> rate: 44000 (44000/1)
> period_size: 2160
> buffer_size: 8640
> 
> if it is a 24bit, 192Khz i get the adequate values.
> 
> But with PulseAudio how to be sure about the quality of the audio?
> if i put the same parameter (sudo cat
> /proc/asound/IQaudIODAC/pcm0p/sub0/hw_params ) i always just get the sample
> rate and format that i config in the daemon.conf... it is not relevant if
> the audio is actually 16bit or 24 and the Khz are 44000 or 192000 or
> whatever.
> 
> So... there is a command to know exactly the quality that is really playing?

Yes, there is. To see what the ALSA card is actually being sent, you can
use the command "pactl list sinks". For example:

> $ pactl list sinks
> ...
> Sink #2
>   State: IDLE
>   Name: alsa_output.usb-Focusrite_Scarlett_Solo_USB-00.analog-stereo
>   Description: Scarlett Solo USB Analog Stereo
>   Driver: module-alsa-card.c
>   Sample Specification: s32le 2ch 44100Hz
^^^ This shows the current bit depth 
and sample rate.
>   Channel Map: front-left,front-right
> ...

If you want to see what your media player is supplying to pulseaudio,
and what resampler (if any) is in use, the command "pactl list sink-inputs"
will show this:

> $ pactl list sink-inputs
> Sink Input #356
>   Driver: protocol-native.c
>   Owner Module: 9
>   Client: 347
>   Sink: 2
>   Sample Specification: float32le 2ch 48000Hz
^^^ This shows the player's bit 
depth and sample rate.
>   Channel Map: front-left,front-right
>   Format: pcm, format.sample_format = "\"float32le\""  format.rate = 
> "48000"  format.channels = "2"  format.channel_map = 
> "\"front-left,front-right\""
>   Corked: no
>   Mute: no
>   Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% 
> / 0.00 dB
>   balance 0.00
>   Buffer Latency: 84341 usec
>   Sink Latency: 48686 usec
>   Resample method: speex-float-1
^^ This shows the resampler in use.
>   Properties:
>   media.icon_name = "SMPlayer"

There are a couple of settings you can adjust in daemon.conf if you are
concerned about resampling. First is the "avoid-resampling" setting.
Turning this on will tell pulse to attempt to reconfigure an ALSA device
to use the same sample rate and bit depth as the playback source if
there is only one source active (and the card supports the target sample
rate, bit depth, and sample format, and supports live reconfiguration).

Second is the choice of resampler. This is configured by the
"resample-method" setting. See the man pages for more info about the
possible choices and their trade-offs:

https://man.archlinux.org/man/pulse-daemon.conf.5#resample_method=

--Sean



Re: [pulseaudio-discuss] using the line-out of my plugable usb audio adapter

2023-01-27 Thread Sean Greenslade
On Fri, Jan 27, 2023 at 03:57:25PM -0500, Paul Elliott wrote:
>>
>> Can you post the output of this command while the card is plugged in?
> 
> OK, here it is:

I trimmed it down to just the card in question:

> Card #3
> Name: alsa_card.usb-C-Media_Electronics_Inc._USB_Audio_Device-00
> Driver: module-alsa-card.c
> Owner Module: 27
> Properties:
> alsa.card = "1"
> alsa.card_name = "USB Audio Device"
> alsa.long_card_name = "C-Media Electronics Inc. USB Audio Device at
> usb-:00:1a.0-2, full speed"
> alsa.driver_name = "snd_usb_audio"
> device.bus_path = "pci-:00:1a.0-usb-0:2:1.0"
> sysfs.path = "/devices/pci:00/:00:1a.0/usb2/2-2/2-2:1.0/sound/card1"
> udev.id = "usb-C-Media_Electronics_Inc._USB_Audio_Device-00"
> device.bus = "usb"
> device.vendor.id = "0d8c"
> device.vendor.name = "C-Media Electronics, Inc."
> device.product.id = "0014"
> device.product.name = "Audio Adapter (Unitek Y-247A)"
> device.serial = "C-Media_Electronics_Inc._USB_Audio_Device"
> device.string = "1"
> device.description = "Audio Adapter (Unitek Y-247A)"
> module-udev-detect.discovered = "1"
> device.icon_name = "audio-card-usb"

Here we see the available profiles of the card:

> Profiles:
> input:mono-fallback: Mono Input (sinks: 0, sources: 1, priority: 1,
> available: yes)
> input:multichannel-input: Multichannel Input (sinks: 0, sources: 1,
> priority: 1, available: yes)
> output:analog-stereo: Analog Stereo Output (sinks: 1, sources: 0, priority:
> 6500, available: yes)
> output:analog-stereo+input:mono-fallback: Analog Stereo Output + Mono Input
> (sinks: 1, sources: 1, priority: 6501, available: yes)
> output:analog-stereo+input:multichannel-input: Analog Stereo Output +
> Multichannel Input (sinks: 1, sources: 1, priority: 6501, available: yes)
> output:iec958-stereo: Digital Stereo (IEC958) Output (sinks: 1, sources: 0,
> priority: 5500, available: yes)
> output:iec958-stereo+input:mono-fallback: Digital Stereo (IEC958) Output +
> Mono Input (sinks: 1, sources: 1, priority: 5501, available: yes)
> output:iec958-stereo+input:multichannel-input: Digital Stereo (IEC958)
> Output + Multichannel Input (sinks: 1, sources: 1, priority: 5501,
> available: yes)
> output:iec958-ac3-surround-51: Digital Surround 5.1 (IEC958/AC3) Output
> (sinks: 1, sources: 0, priority: 300, available: yes)
> output:iec958-ac3-surround-51+input:mono-fallback: Digital Surround 5.1
> (IEC958/AC3) Output + Mono Input (sinks: 1, sources: 1, priority: 301,
> available: yes)
> output:iec958-ac3-surround-51+input:multichannel-input: Digital Surround
> 5.1 (IEC958/AC3) Output + Multichannel Input (sinks: 1, sources: 1,
> priority: 301, available: yes)
> off: Off (sinks: 0, sources: 0, priority: 0, available: yes)

And the current active profile is one that only handles the output:

> Active Profile: output:analog-stereo

Try this command to set it to the combo stereo output plus multichannel
input (though this card probably only has mono input):

$ pactl set-card-profile 
alsa_card.usb-C-Media_Electronics_Inc._USB_Audio_Device-00 
output:analog-stereo+input:multichannel-input


--Sean



Re: [pulseaudio-discuss] using the line-out of my plugable usb audio adapter

2023-01-27 Thread Sean Greenslade
On January 27, 2023 10:47:45 AM PST, Paul Elliott 
 wrote:
>My Plugable usb audio adapter  has two
>jacks,
>a pink one and a greenone. One is for (pink) microphone and microphone
>speaker the other is supposed to be (green) lineout.
>
>I want to plug into line out because I want to use the pink one for
>microphone.
>
>Currently sound comes out of the pink one and silence out of the green
>one.
>
>I can not solve this problem by setting a different default sink,
>because
>the device shows only one port called analog-output-speaker.
>
>How to I get pulse audio to create a port for the green jack, so I can
>set
>it into the default?

Can you post the output of this command while the card is plugged in?

$ pactl list cards


--Sean




Re: [pulseaudio-discuss] pulse audio receive multicast

2022-12-31 Thread Sean Greenslade
On Thu, Dec 29, 2022 at 01:01:02PM -0500, Jerry Geis wrote:
> I am trying to get a computer to receive multicast with pulse audio on
> 20.04 LTS.
> 
> on the receive computer I did this
> pacmd load-module module-null-sink sink_name=rtpsink
> pacmd load-module module-rtp-recv sink=rtpsink sap_address=239.168.3.10
> port=11000
> 
> From another computer I sent multicast audio with asterisk. Other devices
> received the multicast - but the receive computer did not. With asterisk I
> sent on port 239.168.3.10:11000
> 
> Is there something else I have to do to receive multicast and play it?

The rtp-recv module does not support passing port as an argument. See
the docs for the only supported arguments:

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#module-rtp-recv

The SAP port is hard-coded as 9875.

--Sean



Re: [pulseaudio-discuss] pacmd ignores PULSE_SERVER env var

2022-11-09 Thread Sean Greenslade
On Sun, Nov 06, 2022 at 07:02:03PM +, Tudor Zaharia wrote:
> Hello,
> 
> Following this documentation page https://wiki.archlinux.org/title/PulseAudio 
> I am setting the PULSE_SERVER env var to point to a pulseaudio server that 
> runs inside a docker container.
> 
> Unfortunately the "pacmd" command seems to ignore this env var and query 
> instead the local machine. Am I doing something wrong? Is this the expected 
> behavior?
> pactl command works as expected though.
> 
> $ pacmd --ver
> pacmd 13.99.1
> Compiled with libpulse 13.99.0
> Linked with libpulse 13.99.0

As a brief (but hopefully helpful) answer, I can confirm that pacmd
indeed ignores PULSE_SERVER. pactl, on the other hand, respects
PULSE_SEVER. Are you able to use pactl instead?

--Sean



Re: [pulseaudio-discuss] lo-latency-test not working

2022-07-25 Thread Sean Greenslade
On Tue, Jul 19, 2022 at 08:35:48PM +0800, Velicheti Sita wrote:
> Hi All,
> 
> 
> We are trying to run lo-latency-test on pulseaudio 15 version on raspberrypi4
> WebOS OS.
> 
> 
> It's giving beep sound and not giving any latency values.

Can you describe more specifically what you are trying to accomplish?
What latency are you trying to measure? And why?

--Sean



Re: [pulseaudio-discuss] How do different sound cards dynamically use different configurations?

2022-07-19 Thread Sean Greenslade
On Mon, Jul 18, 2022 at 02:42:07PM +0800, zhaochen...@uniontech.com wrote:
> On 2022/7/17 上午3:18, Sean Greenslade wrote:
> > On Fri, Jul 15, 2022 at 06:04:49PM +0800, zhaochen...@uniontech.com wrote:
> > > Hi guys,
> > > 
> > > On a special PC, it is required to start the pulseaudio daemon
> > > with some special parameters in the file /etc/pulse/daemon.conf,
> > > as follows:
> > > 
> > > ---
> > > default-sample-rate = 48000
> > > default-fragments = 2
> > > default-fragment-size-msec = 20
> > > ---
> > > 
> > > When plugging in a USB headset with a separate sound card to this special
> > > PC,
> > > I found that there was a noise in the playback audio. After investigation,
> > > the sound card of the USB headset needs to use the following default
> > > parameters.
> > > 
> > > ---
> > > default-sample-rate = 44100
> > > default-fragments = 4
> > > default-fragment-size-msec = 25
> > > ---
> 
> After my further investigation, I found that noise is only generated
> when changing the sink-input volume (pa_context_set_sink_input_volume),
> but not when changing the sink volume (pa_context_set_sink_volume_by_index).

Can you describe this noise more specifically? Does it go away with
larger fragment size / counts? Have you enabled or disabled tsched? Have
you run with Pulse debug logging enabled and looked for any hints there
(e.g. underruns)?

--Sean



Re: [pulseaudio-discuss] How do different sound cards dynamically use different configurations?

2022-07-16 Thread Sean Greenslade
On Fri, Jul 15, 2022 at 06:04:49PM +0800, zhaochen...@uniontech.com wrote:
> Hi guys,
> 
> On a special PC, it is required to start the pulseaudio daemon
> with some special parameters in the file /etc/pulse/daemon.conf,
> as follows:
> 
> ---
> default-sample-rate = 48000
> default-fragments = 2
> default-fragment-size-msec = 20
> ---
> 
> When plugging in a USB headset with a separate sound card to this special
> PC,
> I found that there was a noise in the playback audio. After investigation,
> the sound card of the USB headset needs to use the following default
> parameters.
> 
> ---
> default-sample-rate = 44100
> default-fragments = 4
> default-fragment-size-msec = 25
> ---
> 
> So, how to enable the parameters required by the sound card
> of the USB headset when using it.

Assuming you are using pulseaudio 15.0 or newer, there is a feature to
apply module-alsa-card parameters by udev rule. See:

https://freedesktop.org/wiki/Software/PulseAudio/Notes/15.0/#index8h3

Just craft an appropriate udev rule that matches your USB headset and
include the PULSE_MODARGS variable with rate / fragments / fragment_size
set appropriately. Note that fragment_size is in bytes, see the docs for
more info:

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#module-alsa-card

--Sean



Re: [pulseaudio-discuss] Playback via alsa sink in pulseaudio 15 fails with assert failed

2022-07-16 Thread Sean Greenslade
>On Fri, Jul 15, 2022 at 05:39:22PM +0800, Velicheti Sita wrote:
>> On Fri, Jul 15, 2022 at 02:30:05PM +0800, Velicheti Sita wrote:
>>
>> > We are running pulseaudio 15 and during playback through paplay, 
>> > pulseaudio is
>> > exiting with assertion failed.
>> >
>> >
>> > Error is like below:
>> >
>> > D: [alsa-sink-Swmixer7 playback Pulse audio pcm6-6] alsa-sink.c:
>> > snd_pcm_writei: Resource temporarily unavailable
>> >
>> > E: [alsa-sink-Swmixer7 playback Pulse audio pcm6-6] alsa-sink.c: Assertion 
>> > 'err
>> > != -11' failed at ../git/src/modules/alsa/alsa-sink.c:512, function 
>> > try_recover
>> > (). Aborting.
>> >
>> > Aborted
>> >
>> >
>> > This error exists even after adjusting the fragment size and fragments.
>> >
>> >
>> >  It's working normally in pulseaudio version 9.
>> >
>> >
>> > FYI after commenting the assert in alsa-sink.c line no 512, playback and 
>> > all
>> > other functionality works fine.
>> >
>> >
>> > module-alsa-sink is loaded in system.pa as below:
>> >
>> > load-module module-alsa-sink device=hw:0,6 mmap=0 sink_name=pcm_output
>> > fragment_size=4096 tsched=0 fragments=2
>> 
>> Can you describe more about what your platform / OS / hardware is? There
>> was another post on this list recently comparing pulse version 9 to 15
>> from someone with an email at the same domain. I'm guessing that more
>> than just the pulse version has changed in your comparison.
>> 
>> I had a look at the assertion that's firing, and none of the code
>> in that area has changed between pulse version 9 and 15. What seems
>> to be happening in the code is that ALSA reports that sufficient buffer
>> space is available, then returns EAGAIN when pulse tries to write into
>> that buffer. This shouldn't happen, hence the assertion.
>> 
>> Can you try running pulse with the log level set to debug and report the
>> output? There's a condition in the code where a buffer size is guessed
>> at instead of trusting the returned value from ALSA, and there should be
>> a corresponding log message for this.

> Please find attached logs for reference.

Just as I suspected, this is present in your logs:

> E: [alsa-sink-Swmixer8 playback Pulse audio pcm7-7] alsa-sink.c: ALSA woke us 
> up to write new data to the device, but there was actually nothing to write.
> E: [alsa-sink-Swmixer8 playback Pulse audio pcm7-7] alsa-sink.c: Most likely 
> this is a bug in the ALSA driver 'mlp_alsa'. Please report this issue to the 
> ALSA developers.
> E: [alsa-sink-Swmixer8 playback Pulse audio pcm7-7] alsa-sink.c: We were 
> woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 
> or another value < min_avail.

This is probably a bug in the ALSA driver for your particular sound
device. As the above message suggests, you should probably take this
issue to an ALSA mailing list.

--Sean



Re: [pulseaudio-discuss] Playback via alsa sink in pulseaudio 15 fails with assert failed

2022-07-15 Thread Sean Greenslade
On Fri, Jul 15, 2022 at 02:30:05PM +0800, Velicheti Sita wrote:
> Hi,
> 
> 
> We are running pulseaudio 15 and during playback through paplay, pulseaudio is
> exiting with assertion failed.
> 
> 
> Error is like below:
> 
> D: [alsa-sink-Swmixer7 playback Pulse audio pcm6-6] alsa-sink.c:
> snd_pcm_writei: Resource temporarily unavailable
> 
> E: [alsa-sink-Swmixer7 playback Pulse audio pcm6-6] alsa-sink.c: Assertion 
> 'err
> != -11' failed at ../git/src/modules/alsa/alsa-sink.c:512, function 
> try_recover
> (). Aborting.
> 
> Aborted
> 
> 
> This error exists even after adjusting the fragment size and fragments.
> 
> 
>  It's working normally in pulseaudio version 9.
> 
> 
> FYI after commenting the assert in alsa-sink.c line no 512, playback and all
> other functionality works fine.
> 
> 
> module-alsa-sink is loaded in system.pa as below:
> 
> load-module module-alsa-sink device=hw:0,6 mmap=0 sink_name=pcm_output
> fragment_size=4096 tsched=0 fragments=2

Can you describe more about what your platform / OS / hardware is? There
was another post on this list recently comparing pulse version 9 to 15
from someone with an email at the same domain. I'm guessing that more
than just the pulse version has changed in your comparison.

I had a look at the assertion that's firing, and none of the code
in that area has changed between pulse version 9 and 15. What seems
to be happening in the code is that ALSA reports that sufficient buffer
space is available, then returns EAGAIN when pulse tries to write into
that buffer. This shouldn't happen, hence the assertion.

Can you try running pulse with the log level set to debug and report the
output? There's a condition in the code where a buffer size is guessed
at instead of trusting the returned value from ALSA, and there should be
a corresponding log message for this.

--Sean



Re: [pulseaudio-discuss] How to map 2 channels from a 32-channel USB device to L/R?

2022-07-13 Thread Sean Greenslade
On Wed, Jul 13, 2022 at 05:39:25PM -0400, Richard Cooke wrote:
> Holy cow I may have fixed it!
> 
> Rather, figured out the problem.
> 
> Further to that post I read about Skype rejecting the QU digital signal 
> without boosting. I could see the peak VU in Audacity is much lower than I 
> see on the mixer screen.
> 
> So in OBS I applied a 24db gain to the ch1 and CH2.  I also have OBS set to 
> play to my virtual null-sink. And monitor the sink. In Zoom I select the null 
> sink’s monitor as the mic and BOOM I have sound!
> 
> Oh wow!  I have to vacate the venue now. I will try this setup again.
> 
> If it works twice…..

I had a look at the manual for the mixer you're using, and it has the
ability to change what is routed to each of the 32 USB channels. That's
probably a much simpler way of getting the signals that you want to
always be in channels 1 and 2. No pulse / ALSA / JACK tweaking
necessary.

I would suggest changing channels 1 and 2 to be LR mix pre-fader. If your
incoming signals are mixed at an appropriate level, that should get you
what you need. If they're still too low, you might want to use a group
or matrix in post-fader mode to create a boosted copy of the main mix.

You could even apply a compressor to the matrix/group with a fairly
heavy ratio and makeup gain but a slow release. That would help tamp
down the dynamic range for the stream if your performances have
widely-varying loudness.

--Sean



Re: [pulseaudio-discuss] How to map 2 channels from a 32-channel USB device to L/R?

2022-07-11 Thread Sean Greenslade
On Sun, Jul 10, 2022 at 09:41:16PM -0400, Richard Cooke wrote:
> On 2022-07-10 4:14 PM, Sean Greenslade wrote:
> > You should (in theory) be able to use module-remap-sink or
> > module-remap-source to create a virtual 2-channel sink/source using
> > specific channels from the 32 channel one. See:
> > 
> > https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#module-remap-sink
> > 
> > It may require some experimentation to figure out what names pulse is
> > assigning to each channel, since the first 8 channels are given
> > standardized 7.1-channel names. Take a look here for the string names
> > that module-remap-* is looking for in channel_map:
> > 
> > https://github.com/pulseaudio/pulseaudio/blob/7f4d7fcf5f6407913e50604c6195d0d5356195b1/src/pulse/channelmap.c#L39
>
> Thanks Sean!  I was working on it again today, I posted the latest update to
> another website:
> 
> https://linuxmusicians.com/viewtopic.php?f=27&t=24713&sid=e80ee72d0f2e1b23402e32e62ca0bf6f
> 
> In summary, I can see only two MIDI devices in the signal patch window.  I
> do not see the 32-channels of audio data that I know is there - because
> Audacity can access it.
> 
> So I assume I am missing something in my config to expose those channels.
> 
> I'll read through your links too, in  case the missing piece is in there.
> 
> Part of my frustration is I can only see the QU when its powered up.  The
> streaming PC is on all the time, but we cannot leave the QU powered up
> because of the main power amps.  Bad things could easily happen if I play
> around with signals while the whole system is live!  Or while left
> unattended.

I re-added the mailing list, although this is perhapes straying away
from a pulse-specific discussion.

You mention "Catlia" in your forum post, which I assume is a typo. There
are two similar programs in the KXStudio lineup, "Catia" and "Carla".
I'm assuming you're using catia, which is a patchbay for the JACK audio
server. JACK is similar to Pulseaudio in that it is a sound routing
engine and not a direct soundcard driver. In Linux, the soundcard driver
is ALSA. Both JACK and Pulse make use of ALSA to interact with the
hardware sound devices. Generally speaking you would only use one sound
server. Although there are ways to run both simultaneously and to route
audio between the two, that's definitely an advanced setup.

Note that Catia cannot control Pulseaudio at all, and while Carla
technically has the ability to use Pulse as its backend, it doesn't
expose the Pulse sources / sinks in a useful way to provide the type of
routing you're looking to do.

>From your screenshot, it appears that JACK has not taken control of the
ALSA device for your 32-channel mixer, or it's not configured correctly
to detect and expose the full channel count. You should probably find a
JACK mailing list if you want to go down that route, although I believe
Pulse is fully capable of accomplishing the task you laid out in your
original email.

One side note: MIDI is not the same as audio. If you're only concerned
about routing audio signals around, you can completely ignore MIDI.

To give some more concrete suggestions, can you do a fresh reboot of the
streaming PC, turn on and connect the mixer, then run the following
command and post its output:

$ pactl list sources

--Sean



Re: [pulseaudio-discuss] How to map 2 channels from a 32-channel USB device to L/R?

2022-07-10 Thread Sean Greenslade
On Tue, Jul 05, 2022 at 03:26:46PM -0400, Richard Cooke wrote:
> This has been driving me crazy for a few weeks!  I do volunteer work around
> Town, and a local church got its hands on a really nice Allen-Heath QU-24
> sound board.  It has a USB-B jack. I recently set up a Video camera with
> control computer for streaming services and events. The new sound board was
> to vastly improve the audio quality.
> 
> When I connect it to the church's "streaming" computer, running Ubuntu 20.04
> it is recognized as both a SOURCE and SINK device. In Audacity, I can select
> any of the 32-channels and see they are working.  We have our streaming mix
> (9) on CH17 and CH18, repeated on CH1 and CH2 for testing.  Again, Audacity
> has no problem selecting any of them.
> 
> They stream using Zoom, Zoom lists the QU-24 but when selected no audio.  We
> use OBS Studio 27.2.4 for the video (virtual camera), it also lists the
> QU-24 but no audio.
> 
> I figured out half of my solution by creating a virtual sink monitor that
> Zoom can use as a microphone:
> 
> # include the default.pa pulseaudio config file
> .include /etc/pulse/default.pa
> 
> # null sink
> .ifexists module-null-sink.so
> load-module module-null-sink sink_name=Source
> .endif
> 
> # virtual source
> .ifexists module-virtual-source.so
> load-module module-virtual-source source_name=VirtualMic
> master=Source.monitor
> .endif
> 
> 
> Which I learned from this post:
> 
> https://www.youtube.com/watch?v=Goeucg7A9qE
> 
> https://github.com/NapoleonWils0n/cerberus/blob/master/pulseaudio/virtual-mic.org
> 
> 
> Which I tested with an analog mic into OBS that came out the Zoom meeting.
> 
> 
> So, if OBS is not going to pickup the QU audio for me, is there a PACTL
> command I can use to path CH1/CH2 to my virtual sink?  Or, even better,
> CH17/CH18?
> 
> 
> Thank you in advance!

You should (in theory) be able to use module-remap-sink or
module-remap-source to create a virtual 2-channel sink/source using
specific channels from the 32 channel one. See:

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#module-remap-sink

It may require some experimentation to figure out what names pulse is
assigning to each channel, since the first 8 channels are given
standardized 7.1-channel names. Take a look here for the string names
that module-remap-* is looking for in channel_map:

https://github.com/pulseaudio/pulseaudio/blob/7f4d7fcf5f6407913e50604c6195d0d5356195b1/src/pulse/channelmap.c#L39

--Sean



Re: [pulseaudio-discuss] Regarding latency of pulseaudio

2022-07-07 Thread Sean Greenslade
Hello, Thomas.

> What is the latency and configured latency that is being displayed in
> pulseaudio via pactl list sinks?

Configured latency is the target latency that PulseAudio is attempting
to achieve, while the plain latency value is the actual value that pulse
believes it is achieving at the current moment. This can vary due to
timer / scheduling jitter, hardware clock drift, interrupt delays, etc.
 
> It is observed that these parameters value is less in pulseaudio version 9 and
> more in pulseaudio version 15 for module-alsa-sink,
> 
> checked while playing same stream using paplay.
> 
> 
> Example:  version 9 -  Latency: 22429 usec, configured 23219 usec
> 
>   version 15 - Latency: 79711 usec, configured 92879 usec

I took a quick glance through the changelogs for versons 10 through 15,
but I didn't see anything indicating a change in latency behavior.
Perhaps your config changed, or maybe your distro changed a default. For
example, tsched being enabled or disabled could have an effect on the
target latency.

> It's observed that values are too high in pulseaudio 15 version.

Are you experiencing an actual issue here? Pulse tries to keep larger
buffers in order to prevent underflows and reduce the amount of CPU time
used to process audio data. Pulse makes use of buffer rewinding to
prevent buffer latency from causing noticable delays in things like
volume control changes.

If you really need lower latency, pulseaudio provides some config
options to use smaller buffers. There are also other options to prevent
buffer expansion in the case of underruns, in case you would prefer to
have audio crackles rather than higher latency.

> is this the actual latency introduced by the module-alsa-sink? or overall
> pulseaudio ?

Some portion of the latency is dictated by the configuration parameters
of the alsa interface (e.g. the fragment size) and some is dictated by
the chosen pulseaudio buffer size. Other elements along the line (e.g.
resamplers) can introduce additional latency.

> Is there a way to measure the latency introduced by pulseaudio in a file
> playback?

Pulseaudio reports the latency values through its application interface.
This allows applications like mplayer to know the latency of the audio
pipeline and adjust the video playback to sync with the audio.

To view the current latency numbers of an application, use
"pactl list sink-inputs". This gives you both the unavoidable sink
latency, as well as the buffer latency due to the buffer size chosen by
the playback application. See the following for an example with mplayer,
where the sink provides ~26 ms of latency, while the mplayer buffers an
additional ~500 ms of audio. This makes sense for local file playback,
since decoding can look far ahead and do larger batches at a time.

> $ pactl list sink-inputs
> Sink Input #44
>   Driver: protocol-native.c
>   
>   Buffer Latency: 449892 usec
>   Sink Latency: 26475 usec
>   Resample method: speex-float-1
>   Properties:
>   media.name = "ALSA Playback"
>   application.name = "ALSA plug-in [mplayer]"
>   ...

--Sean



Re: [pulseaudio-discuss] problem with module-role-ducking, ducked stream occasionally unmutes / switches / breaks through

2022-06-11 Thread Sean Greenslade
On Wed, Jun 08, 2022 at 10:35:14AM +0200, Chris Beat wrote:
> Hi,
> 
> I am running Kodi on an old netbook to listen to http streamed radio from the 
> internet. I also use
> shairport-sync to cast audio from Apple devices to the same netbook. I use 
> module-role-ducking to
> mute the internet radio when a stream from shairport-sync comes in, this is 
> my logic:
> 
> load-module module-role-ducking volume=0 trigger_roles=ShairportRole,stream 
> ducking_roles=KodiRole
> PULSE_PROP='media.role=ShairportRole' /usr/bin/shairport-sync -uv
> PULSE_PROP='media.role=KodiRole' /usr/bin/kodi
> 
> This all works fine and as expected EXCEPT that occasionally (maybe once a 
> minute) the ducked stream
> from Kodi "breaks through" (I do not know a better word) - meaning that I can 
> hear a short
> (subsecond) "fragment" of the Kodi stream INSTEAD of the shairport-sync 
> stream.
> 
> I am not sure how this can be solved most effectively; maybe it is even 
> better to debug this on the
> shairport-sync side of things? Maybe there are better ways to mute a stream 
> than ducking?

Hi, Chris.

I don't personally have any experience with Airplay or shairport-sync,
but I took a quick glance at the shairport code and I have a potential
theory. Shairport seems to cork the pulseaudio stream if it experiences
an underflow. The module-role-ducking code interprets a corked or muted
stream as inactive, which could be the cause of the momentary unducking.

A once-a-minute interval makes me think it could be a wifi scan causing
packet loss or latency. If the audio buffers are small, that could be
enough to cause an underflow. I've read about similar issues happening
with video conferencing calls done over wifi.

If you're feeling up for some debugging, it looks like there's a debug
message you could uncomment in the shairport code that would confirm if
it is indeed an underflow-induced corking event:

https://github.com/mikebrady/shairport-sync/blob/master/audio_pa.c#L370

--Sean



Re: [pulseaudio-discuss] pactl percentage bug fix

2022-06-04 Thread Sean Greenslade
On Sun, Jun 05, 2022 at 01:51:55AM +0100, Patrick May wrote:
> On 04/06/2022 08:48, Sean Greenslade wrote:
>
> > While debugging, I did notice another issue that I was uncertain of how
> > to solve. The detection of absolute values vs. relative values is based
> > on the presence of a plus or minus at the start of the value. This is
> > fine for everything except decibels, since absolute decibel values will
> > often be negative numbers. The way the code sits now, it's impossible to
> > pass an absolute negative decibel value. Probably not a huge deal, but
> > it seemed worth pointing out.
>
> I tested it with
> 
> pactl -- set-sink-volume 0 0db
> 
> and it sets the volume to 100%. So the ability to specify absolute decibel
> values is only useful if you like blasting stuff at greater than or equal to
> 100% volume

As I said, it's a bug. When I said it's probably not a huge deal, I
meant in the sense that I doubt many people have ever tried to use the
decibel versions of this command, seeing as this bug makes the absolute
decibel inputs nearly useless.

My reason for bringing it up was to try and solicit opinions on how best
to fix it. The current method of assuming a "-" always means relative is
not good, but I can't think of a clean way to fix it. Less clean options
that jump to mind:
- Add a new command, e.g. "set-sink-decibels-absolute -3dB"
- Add a new suffix variant, e.g. "set-sink-volume -3dBAbs"
  (note that "dBA" is not acceptable, since that has a specific meaning
  with regards to sound measurement)
- Have a prefix for absolute numbers, e.g. "set-sink-volume =-3dB"

What do other people think?

--Sean



Re: [pulseaudio-discuss] pactl percentage bug fix

2022-06-04 Thread Sean Greenslade
On Fri, Jun 03, 2022 at 06:19:20PM +0100, Patrick May wrote:
> Here is the problem:
> 
> https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/utils/pactl.c
> 
> In src/utils/pactl.c:
> 
> Between line 2530 and line 2535, in function parse_volume:
> 
> These two 'if' statements will BOTH execute if the input string contains
> both a '.' and ends with a '%'.
> 
> This results in vol_flags having VOL_PERCENT and VOL_LINEAR or'd in and set,
> which is equivalent in effect to '*vol_flags |= VOL_DECIBEL'
> (because VOL_PERCENT is 1 and VOL_LINEAR is 2, and VOL_DECIBEL is 3. Refer
> to line 76)
> So from then on the function is erroneously acting as if the input string
> was a decibel value, instead of a percentage.
> 
> Suggested fix:
> Change line 2532 from this
> if (pa_endswith(vs, "%")) {
> To this:
> else if (pa_endswith(vs, "%")) {
> 
> I apologise for my rudeness earlier but this was not the first time
> pulseaudio bugs have BLASTED EXTREMELY LOUD NOISE AT 100% THROUGH MY
> HEADPHONES and I was very upset.
> 
> I don't have a git account or any of the stuff necessary to actually submit
> a patch so I would appreciate if someone or pulseaudio dev would take note
> of this and make the necessary change

I dug into this issue and found a couple of different bugs in this code.
I've submitted a merge request with my fixes:

https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/716

While debugging, I did notice another issue that I was uncertain of how
to solve. The detection of absolute values vs. relative values is based
on the presence of a plus or minus at the start of the value. This is
fine for everything except decibels, since absolute decibel values will
often be negative numbers. The way the code sits now, it's impossible to
pass an absolute negative decibel value. Probably not a huge deal, but
it seemed worth pointing out.

--Sean



Re: [pulseaudio-discuss] pavucontrol : input device listed, but no signal

2022-05-11 Thread Sean Greenslade
On Fri, May 06, 2022 at 11:33:55AM +, Pieter J Voet wrote:
> Hi all,
> 
> I'm running Fedora 35 which has pipewire. Next, I have an external USB DAC ( 
> Behringer Firepower FCA610 ).
> My speakers are connected to the USB DAC, and it's configured as the default 
> output sink.
> This all works fine, audio on my laptop plays thru the USB DAC.
> I have three userspace processes running : 'pipewire', 'pipewire-pulse' and 
> 'wireplumber'.

In that case, this is probably not the right place to ask for help.
Pipewire bills itself as a replacement for pulseaudio. If you are
running pipewire, you should probably find a pipewire support list
instead.

> Now, I have a keyboard plugged in the USB DAC analog input, and can hear it's 
> sound on my speakers.
> I can  play audio on my laptop, play something on the keyboard 
> simultaneously, and it all plays fine
> with audio output on my speakers.
> 
> So far, so good. But what I want is to record from the USB DAC analog input.
> Unfortunately that's not working. Using Audacity, I can click 'Start 
> Monitoring' , but there's no sound.
> 
> To simplify things and rule out Audacity, I see that 'pavucontrol' ( GUI ) 
> lists the UDB DAC both as an Output and an
> Input Device. But the 'Input Devices' tab does not show output signal level 
> upon pressing the
> keys on the keyboard...
> Again, I can hear the keyboard on the USB DAC attached speakers. This means 
> that the input stream
> is somehow redirected to the output-sink right ?

Based on my limited skim of the pipewire docs, it seems that pipewire
just presents a pulseaudio-compatible API for the purpose of allowing
existing pulse client software to work as-is. They may not have gone to
the trouble of exposing all the APIs that pavucontrol needs. Using
pavucontrol with pipewire may not work as expected.

If you're looking for GUI tools to control pipewire, maybe check these
out:

https://wiki.archlinux.org/title/PipeWire#GUI

> I'm a long-time Linux user, but Pipewire/Pulseaudio really confuses me. I 
> don't know what to do..
> 
> To make the story even weirder : sometimes after a reboot the USB DAC 'Input 
> Device' actually has
> a signal !! And I can then record in Audacity.
> But that's 'sometimes'..  My latests attempts by rebooting do not  give me 
> inputsignal level anymore.
> 
> This all probably is caused by my lack of knowledge of pipewire/pulseaudio..  
> but hopefully somebody
> can educate me a bit on this.

Pipewire and pulseaudio are two different sound servers, and it's
unlikely that they will coexist cleanly on the same machine. If you want
to stick with pipewire, then seek help on a pipewire forum. If you want
to try pulseaudio, you will need to figure out how to disable pipewire
and install / enable pulseaudio.

--Sean



Re: [pulseaudio-discuss] call pa_stream_drain() for multiple streams

2022-03-12 Thread Sean Greenslade
On Fri, Mar 11, 2022 at 04:28:00AM +0800, su wrote:
> At first I would like to take this chance to express my gratitude to 
> PulseAudio dev. team and those warm-hearted members at this community  :)
> 
> I have a minor question about calling pa_stream_drain()  for multiple streams 
> at the same context. It seems I cannot issue this command 
> 
> for multiple streams at the same time : 
> 
> for ( int stream_index = 0 ; stream_index < 2 ; stream_index++)
> 
> {
> 
> pa_operation* pa_op= pa_stream_drain( pa_stream *  audio_stream[ 
> stream_index ]  ,
> 
> my_pa_stream_success_cb_t, NULL );
> 
> 
> 
> 
> while (pa_operation_get_state(pa_op) != PA_OPERATION_DONE) {
> 
> sleep(1);
> 
> }
> 
> }   
> 
> How to wait for the done signal to pa_stream_drain() the next stream  
> efficiently  ?

I don't believe there is any problem with issuing drains for multiple
streams. As far as I know, you could issue them all at once then wait
for them all to finish.

You example code above has some typos, so I'm assuming it's not exactly
what you are running. Can you describe more specifically what is going
wrong with your code? How exactly is it not working?

One possible bug I can foresee is that pa_operation_get_state() could
also return _CANCELLED, so it would be more robust to do something like
the following:

while(pa_operation_get_state(pa_op) == PA_OPERATION_RUNNING) sleep(1);


--Sean



Re: [pulseaudio-discuss] Can pa_stream_write be executed at the other thread ?

2022-02-25 Thread Sean Greenslade
On Sat, Feb 26, 2022 at 01:14:12AM +0800, su wrote:
> My application is to play a single stream with pulseaudio  Asynchronous API  
> based on "Main Loop - A minimal but fast implementation based on poll()."  
> implementation  .  I am going to set up an independent thread for pulseaudio 
> context and the related stream setup and I would like to use "Polled" model 
> instead of "Asynchronous " model to feed the audio raw data . 
> 
> 
> The point is : data is transferred  with  pa_stream_write() at "Polled" model 
> at the other thread.  Namely , at the other thread ,  both  
> pa_stream_writable_size()  and   pa_stream_write() will be executed from time 
> to time . Will it work ?

There is some useful information about thread safety in the docs here:

https://freedesktop.org/software/pulseaudio/doxygen/threaded_mainloop.html

The short answer is that you must use locks to prevent concurrent calls
to the pulse APIs. It is not safe for two threads to execute calls to
pa_stream_write() simultaneously.

--Sean



Re: [pulseaudio-discuss] Error running from procmail

2022-02-23 Thread Sean Greenslade
On Sun, Feb 20, 2022 at 09:09:32PM +0100, Adrian van Bloois wrote:
> Hi Sean,
> This seems a bit complicated, I tried something else.
> I set the sticky bit on the morse binary so it was rwsr-xr-x but that
> didn't work either.

I assume by that you mean the setuid bit. That should work in theory
(assuming the morse binary is actually owned by the local user), but it
may still require you to manually override bits of the environment (e.g.
your $HOME) to make it work. I think my suggestion of a sudo-able script
would be easier.

> Now I tried to run the same thing fron the crontab, on my laptops that
> works very well, but on the PC I get:
> 
> pa_simple_Write failed
> 
> 
> Somehow I feel it might be more of an alsa problem then an issue with
> pulseaudio, but I'm no export.

I don't think any of this is an alsa issue. You're just trying to use
pulseaudio in a way that it was not intended to operate. Pulse is
primarily intended for single-user, non-root, desktop / interactive
applications. What you're asking for is certainly possible, but it will
require some manual configuration to make it work.

An alternative configuration for allowing multiple users access to
pulseaudio simultaneously is the system-wide configuration. See this
page for details:

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/

--Sean



Re: [pulseaudio-discuss] Need help resolving audio recording/playback issues

2022-02-18 Thread Sean Greenslade
On Wed, Feb 16, 2022 at 10:57:18AM -0800, Rich Shepard wrote:
> On Wed, 16 Feb 2022, Sean Greenslade wrote:
> 
> > - The preamp gain knob on the Scarlett is set high enough. Dynamic mics
> >  can have pretty weak signals. On mine, I need to pretty much max out the
> >  preamp to get signals strong enough to light up the green ring.
> 
> Sean,
> 
> I turned the Scarlett Solo mic gain to maximum and the pre-amp green ring
> flickers when I speak. So this part's resolved; I must have turned down the
> gain without noticing.

Great, so now we know the signal is getting in to the audio interface.

> With audio-recorder started pavucontrol shows it present in the Recording
> tab, but the VU bar doesn't move when I speak into the microphone.

This is pretty strange. If you look on the Input Devices tab, do you see
the Scarlett device and its VU meter? Even with no application
recording, the Input Devices tab VU meter should be reacting to the
input.

Can you run the command "pactl list sources" and post its output? Also,
can you check the Configuration tab of pavucontrol and see what profile
the Scarlett is set to?

--Sean



Re: [pulseaudio-discuss] Error running from procmail

2022-02-18 Thread Sean Greenslade
On Fri, Feb 18, 2022 at 02:50:27PM +0100, Adrian van Bloois wrote:
> On Tue, Feb 15, 2022 at 12:25:40AM -0800, Sean Greenslade wrote:
> > Does procmail either run in a chroot or run subprocesses in one? If so,
> > you'll need to make sure that the pulse socket path is accessible. It's
> > typically in /run/user//pulse/native.
>
> The socket is in /run/user/MYuid/pulse, the permissions are such that
> only MYuid has access to that directory and lower.
> I tried to find out where that directory was made but I couldn't find any
> clue. I have been looking in all tmpfiles.d directories, no luck.
> Changeing the permissions by hand was nsuccessful, the next call to
> pulseaudio immediately reversed that action.
> Any suggestions?

The easiest thing would be to use sudo within the procmail command to
change effective user to the user that has the pulse session. You can
configure sudo to allow a password-less user change with a specific
command string. Here is an example sudoers line:

procmail ALL=(sounduser) NOPASSWD: /opt/scripts/do_sound_stuff

This allows the user "procmail" to run the command
"sudo -u sounduser /opt/scripts/do_sound_stuff" without requiring a
password. If "do_sound_stuff" is a script, make sure that it's
appropriately protected from editing.

You might also need to add the following line to sudoers to allow
headless commands:

Defaults !requiretty


--Sean



Re: [pulseaudio-discuss] Need help resolving audio recording/playback issues

2022-02-16 Thread Sean Greenslade
On Tue, Feb 08, 2022 at 01:21:24PM -0800, Rich Shepard wrote:
> Something(s) changed here and I don't know enough about linux audio to fix
> the problems.
> 
> Environment: Slackware64-14.2. Audio-Technica AT2005USB, Scarlett Solo Gen
> 3. The latter two are connected by an XLR cable.
> 
> All worked fine until a few days ago. Now pavucontrol Configuration tab sees
> the Scarlett Solo USB connected to the desktop, and the Input Devices tab
> shows three options: Front Microphone (unplugged, although that's where the
> Scarlett Solo is connected), Rear Microphone (plugged in, and the only one
> to show the vu bar responding to noise as well as flickering when there's no
> microphone connected or turned on), and Line In (unplugged).
> 
> Earlier today, using audio-recorder (version 2.2.3) and connecting the
> Audio-Technica AT2005USB with the USB cable I successfully made a test voice
> recording that mplayer sent to the Creative Pebble speakers. I could not
> repeat this later in the morning. While audio-recorder wrote a 327K file,
> aplay, mplayer, and vlc don't produce what I recorded in the .mp3 file.
> 
> Using a new Cable Masters XLR cable I'm still not seeing the Scarlett Solo
> input LED ring flicker when I speak. The AT2005 microphone does work ... at
> least it did earlier today with the USB cable.

On the Scarlett USB interfaces, the green/red LED ring around the input
gain knob is driven directly by the hardware. Pulseaudio has no
influence over this.  So if you're not seeing any signal there, the
issue is in hardware. Make sure:
- The XLR cable is OK and fully seated into the plugs on both ends.
- The switch on the side of the mic is on. It needs to be on to feed
  output to the XLR jack.
- The preamp gain knob on the Scarlett is set high enough. Dynamic mics
  can have pretty weak signals. On mine, I need to pretty much max out
  the preamp to get signals strong enough to light up the green ring.

--Sean



Re: [pulseaudio-discuss] Connect Alsa Input from hw:1, 0 to null-sink thru loopback

2022-02-16 Thread Sean Greenslade
On Sun, Feb 13, 2022 at 09:49:30PM +0100, corbeille wrote:
> Hello,
> 
> I would like to know if there is a possibility to create at startup
> (maybe in /etc/pulse/default.pa ?) a "connection" between Alsa
> input hw:1,0 and a null-sink thru a loopback ?
> To have something similar to :
> 
> $ pacmd load-module module-null-sink sink_name=MySink
> $ pacmd load-module module-loopback source=hw:1,0 sink=MySink
> 
> Instead of :
> 
> $ pacmd load-module module-null-sink sink_name=MySink
> $ pacmd load-module module-loopback source=alsa_input.usb-0d8c_C-
> Media_USB_Headphone_Set-00.mono-fallback sink=MySink
> 
> Thus, I will be able to link "MySink" with any sound card on hw:1,0.
> 
> Is it possible ?

I don't think it's possible with the normal pulseaudio setup, since the
alsa cards are added after everything in default.pa is processed. The
module-udev-detect module dynamically loads and unloads alsa cards as
they are sensed by the hardware. It's a limitation of the
module-loopback code that the requested source/sink must exist at
loading time.

One thing you could do if your machine only has one sound card on a
non-removable connection (i.e. not a USB device) is to statically define
it with module-alsa-card and disable module-udev-detect.

A more resilient option might be to make a script that checks for the
presence of the loopback and loads it if it's not present. Then just
fire that script unconditionally before launching your programs that use
it.

--Sean



Re: [pulseaudio-discuss] Seeking advice on use of padsp

2022-02-16 Thread Sean Greenslade
(Re-added the list again. Please make sure to Reply-List or Reply-All
when responding to mailing list messages.)

On Tue, Feb 15, 2022 at 10:56:55AM +, Geoff Browne wrote:
> Great!  You cracked it Sean.
> 
> > What user is the C code running as?
> 
> Thank you Sean, I should have realised - it felt like something silly
> all along.  The current C code has to be run with root privileges at
> the moment due to the need to access various low-level control
> registers.  I'd assumed that with root privileges it would just work
> for any user, not realising that pulseaudio uses daemon sockets on a
> per-user basis.
> 
> All I really want to do is to play short sine wave bleeps of varying
> frequency to the bluetooth speaker that i've paired with the Pi, maybe
> I'm making a mountain out of a molehill?

There is a way to get root to use your user's pulseaudio session. You
just need to point it to pulse's socket and connection cookie. This can
be done via environment variables. For example, I ran the following on
my machine:

# PULSE_SERVER=/run/user/1000/pulse/native 
PULSE_COOKIE=/home/sean/.config/pulse/cookie pactl list

Of course, you will need to substitute your user's correct UID and home
directory path. You should be able to set environment variables with the
setenv() C function in stdlib.h.

--Sean



Re: [pulseaudio-discuss] Error running from procmail

2022-02-15 Thread Sean Greenslade
On Fri, Feb 11, 2022 at 09:31:21AM +0100, Adrian van Bloois wrote:
> On Thu, Feb 10, 2022 at 11:39:13PM -0800, Sean Greenslade wrote:
> > On Tue, Feb 08, 2022 at 12:55:53PM +0100, Adrian van Bloois wrote:
> > > On Mon, Feb 07, 2022 at 10:10:47PM -0800, Sean Greenslade wrote:
> > > > On Mon, Feb 07, 2022 at 07:06:38PM +0100, Adrian van Bloois wrote:
> > > > > Hallo,
> > > > > I try to run a morse code program from procmail to produce an audible
> > > > > signal when mail arrives. My postfix(MTA) calls procmail(mail delivery
> > > > > agent) to deliver the mail. This obviously runs in the background.
> > > > > :rpocmail calls morse to give the signal that mail has arrived. 
> > > > > However
> > > > > morse produces an error:
> > > > > ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: 
> > > > > Connection refused
> > > > > 
> > > > > I'm using CentOS-7 right now, earlier I used CentOS-6 and then it 
> > > > > worked
> > > > > perfectly. I suspect it is a matter of permissions, but I can't figure
> > > > > out where it goes wrong.
> > > > > Do you experts have any ideas
> > > > 
> > > > Are you logging in directly to the CentOS machine and keeping a session
> > > > active, or is it running headless?
> > >
> > > Both, one machine is running headless the other I keep logged in on a
> > > text-based console.
> > 
> > OK, so there are two separate machines? Is the machine that is going to
> > be producing the sound the one that always has the console logged in?
> Yes, correct
> > 
> > Also, are you trying to do any sort of networked pulseaudio setup? Like:
> > 
> > https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Network/
> > 
> No, this machiine is fully stand-allone.
> 
> > > > And just to sanity check, can you see if the pulseaudio and
> > > > pulseaudio-utils packages are installed:
> > > > 
> > > > $ rpm -q pulseaudio pulseaudio-utils
> > >
> > > Both are installed
> > > > 
> > > > ...and running:
> > > > 
> > > > $ ps aux | grep pulseaudio
> > >
> > > Is running, it has my own userid, probably caused by my listening to a
> > > radio station earlier.
> > 
> > OK, so presumably this means that your machine has pulseaudio set up
> > correctly. Perhaps your issue is that the morse program is not running
> > as your logged-in user, so it cannot connect to your session's pulse
> > socket?
> I'll look in to that. The morse program is started by procmail which is
> able to write with my own userid.

A few other things that jump to mind:

CentOS has selinux enabled by default. Perhaps check for any selinux
denials, since the context will likely be different between a user shell
and the procmail process.

Does procmail either run in a chroot or run subprocesses in one? If so,
you'll need to make sure that the pulse socket path is accessible. It's
typically in /run/user//pulse/native.

--Sean



Re: [pulseaudio-discuss] Seeking advice on use of padsp

2022-02-14 Thread Sean Greenslade
(Re-added the mailing list)

On Fri, Feb 11, 2022 at 02:05:34PM +, Geoff Browne wrote:
> On 11/02/2022 07:49, Sean Greenslade wrote:
> > On Mon, Feb 07, 2022 at 01:21:34PM +, Geoff Browne wrote:
> > > If I type the following at the terminal I get the expected tone..
> > > 
> > > 
> > > ...but if I try this from within some C code on a R-Pi Zero...
> > > 
> > > system("/usr/bin/padsp  /usr/bin/tones sine 100 900");
> > > 
> > > I get...
> > > [tones] Connection refused : /dev/dsp
> > Are these commands both being run on the same device, same user, etc.?
> > What distro of linux are you running on the RPi?
> > 
> > > and with -d on...
> > > 
> > > utils/padsp.c: dsp_open()
> > > utils/padsp.c: fd_info_new()
> > > utils/padsp.c: pa_context_connect() failed: Connection refused
> > > utils/padsp.c: freeing fd info (fd=4)
> > > utils/padsp.c: Draining.
> > > utils/padsp.c: dsp_open()
> > > utils/padsp.c: fd_info_new()
> > > utils/padsp.c: pa_context_connect() failed: Connection refused
> > > utils/padsp.c: freeing fd info (fd=4)
> > > utils/padsp.c: Draining.
> > > [tones] Connection refused : /dev/dsp
> > > 
> > > Can anyone please put me right ?
> > "pa_context_connect() failed: Connection refused" typically means that
> > pulseaudio is not running. You can confirm this by running a pactl
> > command, for example:
> > 
> > $ pactl list sinks
> > 
> > Would output the following if pulse is not running:
> > 
> > Connection failure: Connection refused
> > pa_context_connect() failed: Connection refused
> > 
> Hi Sean,
> 
> Thank you, I really appreciate your coming back to me.
> 
> Yes, all on the same R-Pi ZeroW (PRETTY_NAME="Raspbian GNU/Linux 10 (buster)).
> '$ pactl list sinks' returns the details of my bluetooth speaker.
> 
> To clarify the issue, If I ssh into the pi and enter...
> "/usr/bin/tones sine 100 900", I get "[tones] No such file or directory : 
> /dev/dsp".
> 
> This is because a wrapper 'padsp' is required, so if I then enter...
> "/usr/bin/padsp  /usr/bin/tones sine 100 900", a sound is played as expected.
> 
> However, if I make the same call from some C running on same Pi:
> "system("/usr/bin/padsp  /usr/bin/tones sine 100 900");" I get error: 
> "[tones] Connection refused : /dev/dsp".
> If I add the -d switch to padsp, I get the
> 
> utils/padsp.c: pa_context_connect() failed: Connection refused
> 
>  Interesting that the two errors are not quite the same ?  Something to do 
> with how padsp works ?

What user is the C code running as? And what is executing it? If you,
for example, were running the program through a systemd service unit,
that would by default run as root and would not see your local user's
pulseaudio daemon socket.

I don't think there's anything specific to padsp in this regard. You
would probably see the same issue running any pulse utility, e.g. "pactl
list".

--Sean
 


Re: [pulseaudio-discuss] set media.role for VMware client

2022-02-11 Thread Sean Greenslade
On Thu, Feb 03, 2022 at 06:00:27PM +0100, sben1783 wrote:
> Am 2022-01-24 07:29, schrieb Sean Greenslade:
> > On Wed, Jan 19, 2022 at 05:36:10PM +0100, sben1783 wrote:
> > [...]
> > > BUT: it doesn't "uncork" when my phone call within vmware is done. I
> > > think
> > > this is supposed to work..? My media player just stays muted
> > > forever. Any
> > > hints here? Where would I have to start looking to possibly find
> > > details
> > > why it doesn't unmute the media player?
> > 
> > I'm assuming you're using module-role-cork for this.
> 
> Yes, at least that's what I am think being new to this issue:)
> 
> > If I had to guess at the issue (not being a VMWare user myself), the
> > vmware client might be holding open its audio stream indefinitely once
> > initialized.  You can check this by starting and ending a call, then
> > looking at the list of current sink inputs:
> > 
> > $ pactl list sink-inputs
> 
> Again you guessed right, the stream stays open until I finally close the
> vmware session. As you asked above whether I am using module-role-cork: is
> there any alternative I could use that would work even with the stream
> staying open? Like based on actual stream usage or so?

Nothing that I'm aware of, unfortunately. I don't think it would be all
that difficult to make, either as a modified pulseaudio module or as an
external helper utility. You would need to read the actual audio samples
to determine whether the sink input is actually producing sound, which
probably precludes using high-level libraries like python-pulsectl. The
C code to do this isn't particularly scary; in fact, I wrote a little
demo CLI VU meter that could pretty easily be adapted into an audio
detector:

https://seangreenslade.com/tmp/2016_pulseaudio_VU_demo.c

If you'd like to go down a slightly different route, and duck / fade the
audio instead of corking it, I have a somewhat meandering blog post
where I describe routing pulse's streams through JACK to make use of its
more complex nodegraph routing system and fancier audio plugins:

https://seangreenslade.com/projects/2020-05_stream_audio_processing/

--Sean



Re: [pulseaudio-discuss] Seeking advice on use of padsp

2022-02-10 Thread Sean Greenslade
On Mon, Feb 07, 2022 at 01:21:34PM +, Geoff Browne wrote:
> If I type the following at the terminal I get the expected tone..
> 
> /usr/bin/padsp  /usr/bin/tones sine 100 900
> 
> ...but if I try this from within some C code on a R-Pi Zero...
> 
> system("/usr/bin/padsp  /usr/bin/tones sine 100 900");
> 
> I get...
> [tones] Connection refused : /dev/dsp

Are these commands both being run on the same device, same user, etc.?
What distro of linux are you running on the RPi?

> and with -d on...
> 
> utils/padsp.c: dsp_open()
> utils/padsp.c: fd_info_new()
> utils/padsp.c: pa_context_connect() failed: Connection refused
> utils/padsp.c: freeing fd info (fd=4)
> utils/padsp.c: Draining.
> utils/padsp.c: dsp_open()
> utils/padsp.c: fd_info_new()
> utils/padsp.c: pa_context_connect() failed: Connection refused
> utils/padsp.c: freeing fd info (fd=4)
> utils/padsp.c: Draining.
> [tones] Connection refused : /dev/dsp
> 
> Can anyone please put me right ?

"pa_context_connect() failed: Connection refused" typically means that
pulseaudio is not running. You can confirm this by running a pactl
command, for example:

$ pactl list sinks

Would output the following if pulse is not running:

Connection failure: Connection refused
pa_context_connect() failed: Connection refused


--Sean



Re: [pulseaudio-discuss] Error running from procmail

2022-02-10 Thread Sean Greenslade
On Tue, Feb 08, 2022 at 12:55:53PM +0100, Adrian van Bloois wrote:
> On Mon, Feb 07, 2022 at 10:10:47PM -0800, Sean Greenslade wrote:
> > On Mon, Feb 07, 2022 at 07:06:38PM +0100, Adrian van Bloois wrote:
> > > Hallo,
> > > I try to run a morse code program from procmail to produce an audible
> > > signal when mail arrives. My postfix(MTA) calls procmail(mail delivery
> > > agent) to deliver the mail. This obviously runs in the background.
> > > :rpocmail calls morse to give the signal that mail has arrived. However
> > > morse produces an error:
> > > ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: 
> > > Connection refused
> > > 
> > > I'm using CentOS-7 right now, earlier I used CentOS-6 and then it worked
> > > perfectly. I suspect it is a matter of permissions, but I can't figure
> > > out where it goes wrong.
> > > Do you experts have any ideas
> > 
> > Are you logging in directly to the CentOS machine and keeping a session
> > active, or is it running headless?
>
> Both, one machine is running headless the other I keep logged in on a
> text-based console.

OK, so there are two separate machines? Is the machine that is going to
be producing the sound the one that always has the console logged in?

Also, are you trying to do any sort of networked pulseaudio setup? Like:

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Network/

> > And just to sanity check, can you see if the pulseaudio and
> > pulseaudio-utils packages are installed:
> > 
> > $ rpm -q pulseaudio pulseaudio-utils
>
> Both are installed
> > 
> > ...and running:
> > 
> > $ ps aux | grep pulseaudio
>
> Is running, it has my own userid, probably caused by my listening to a
> radio station earlier.

OK, so presumably this means that your machine has pulseaudio set up
correctly. Perhaps your issue is that the morse program is not running
as your logged-in user, so it cannot connect to your session's pulse
socket?

--Sean



Re: [pulseaudio-discuss] Error running from procmail

2022-02-07 Thread Sean Greenslade
On Mon, Feb 07, 2022 at 07:06:38PM +0100, Adrian van Bloois wrote:
> Hallo,
> I try to run a morse code program from procmail to produce an audible
> signal when mail arrives. My postfix(MTA) calls procmail(mail delivery
> agent) to deliver the mail. This obviously runs in the background.
> :rpocmail calls morse to give the signal that mail has arrived. However
> morse produces an error:
> ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: 
> Connection refused
> 
> I'm using CentOS-7 right now, earlier I used CentOS-6 and then it worked
> perfectly. I suspect it is a matter of permissions, but I can't figure
> out where it goes wrong.
> Do you experts have any ideas

Are you logging in directly to the CentOS machine and keeping a session
active, or is it running headless?

And just to sanity check, can you see if the pulseaudio and
pulseaudio-utils packages are installed:

$ rpm -q pulseaudio pulseaudio-utils

...and running:

$ ps aux | grep pulseaudio


--Sean



Re: [pulseaudio-discuss] set media.role for VMware client

2022-01-23 Thread Sean Greenslade
On Wed, Jan 19, 2022 at 05:36:10PM +0100, sben1783 wrote:
> That did the trick! I created a
>   /usr/share/applications/vmware-remotemks.desktop
> with
>   X-PulseAudio-Properties=media.role=phone
> and now the "cork" works. Thank you very  much!
> 
> BUT: it doesn't "uncork" when my phone call within vmware is done. I think
> this is supposed to work..? My media player just stays muted forever. Any
> hints here? Where would I have to start looking to possibly find details
> why it doesn't unmute the media player?

I'm assuming you're using module-role-cork for this.

If I had to guess at the issue (not being a VMWare user myself), the
vmware client might be holding open its audio stream indefinitely once
initialized.  You can check this by starting and ending a call, then
looking at the list of current sink inputs:

$ pactl list sink-inputs

--Sean



Re: [pulseaudio-discuss] pulseaudio module-combine-sink and network devices

2022-01-18 Thread Sean Greenslade
On Sun, Jan 16, 2022 at 09:59:43AM +, Dan MacDonald wrote:
> Is it possible to use module-combine-sink to combine a network PA
> device and a local device? I've been trying commands such as:
> 
> $ pactl load-module module-combine-sink sink_name=Combined2
> sink_properties=device.description=CombinedTwo
> slaves=tunnel.raspberrypi.local.alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40,alsa_output.usb-XMOS_HIFI_DSD-00.analog-stereo
> channels=2
> Failure: Module initialisation failed
> 
> Or sticking similar config into /etc/pulse/default.pa with no luck. I
> can use each device individually fine.
> 
> I wonder if I'd have more luck trying to do this with Pipewire? I'd
> have to upgrade both machines before that is an option so I'd rather
> get this working with PA if its possible.

I just tried this setup myself and it seems to work fine. I wonder if
maybe you are using the wrong name for the tunneled sink in the combine?
After you have the tunnel set up, can you run this command and see what
the "Name:" listed under your tunneled sink is?

$ pactl list sinks

--Sean



Re: [pulseaudio-discuss] set media.role for VMware client

2022-01-18 Thread Sean Greenslade
On Mon, Jan 17, 2022 at 10:38:31PM +0100, sben1783 wrote:
> Hi there,
> 
> I'm using VMware Horizon client from kubuntu to work on my companies windows
> machine. My idea was to play some music from my own machine while doing
> monkey work within VMware. I was very happy to read about the "cork"
> mechanism in order to mute that music as soon as I get a business call or am
> attending an online meeting within VMware. Unfortunately, I haven't been
> able to figure out how to set the "media.role" for the VMware binary. I see,
> f.ex., that vlc has media.role=video, but the VMware client doesn't have
> any. I tried to set it via a .desktop file, but that fails - probably
> because the VMware application I start (vmware-view) spawns some other
> binary and the media.role property is not passed on to the child process?

I think using the .desktop file is probably your best bet (though I
haven't tried it myself; this is just from a quick scan of the PA code).
You can see specifically which binary has spawned the pulseaudio
connection by running the command "pacmd list-sink-inputs" and looking
at the application.process.binary attribute. If that isn't specific
enough, you can use application.process.id to get the PID, then check it
like so:

$ stat /proc//exe

Which returns something like:
  File: /proc/1581/exe -> /usr/bin/mplayer

--Sean



Re: [pulseaudio-discuss] Never auto-select a device as the fallback

2021-10-22 Thread Sean Greenslade
On Mon, Oct 18, 2021 at 10:53:02AM -0600, Chris Keller wrote:
> Hello folks,
> 
> As I mentioned in a previous thread, I use some external sound cards as
> interfaces to amateur radios. For those sound cards, I never want them to
> be selected as the fallback or default, especially for output but also for
> input. I'd like to keep the behavior of automatically moving fallbacks so
> my Bluetooth headphones will be selected when they're connected, and go
> back to my speakers when they're disconnected, but the radio interfaces
> should never be eligible for auto-selection like that. Is that possible?

Hi, Chris.

As far as I know, the only time a device is forced to become the
fallback is if it's the only sound device present on the machine.
Otherwise, the device you select manually as the fallback should remain
selected. In your setup, is there ever a time where the external cards
are the only ones Pulse sees?

Internally, Pulseaudio uses some hardcoded rules for deciding port
priorities if the fallback is not selected / present. One slightly hacky
workaround I might suggest is to declare your low-priority sound cards
as modem-class devices. This would put them at minimum priority, so the
auto-select routine would never choose them. You could probably craft a
Udev rule to it. I'd look to [1] for inspiration.

--Sean

[1]: 
https://kernel.googlesource.com/pub/scm/linux/hotplug/udev/+/427c9ba24a8138ea3a9c17ebc661df9290dfbcf2/rules/78-sound-card.rules


Re: [pulseaudio-discuss] troubleshooting switch-on-connect and switch-on-port-available

2021-10-22 Thread Sean Greenslade
On Thu, Oct 21, 2021 at 09:42:51AM +0200, Krister wrote:
> I have a new Inspiron 7320 detachable, and was able to get sound
> working by compiling a recent SOF kernel (see
> https://github.com/thesofproject/linux/issues/3161). Both the input
> and output device are detected automatically but I have to manually
> choose the Headphones output device every time I plug them in.
> 
> I followed the instructions on this link
> (https://askubuntu.com/a/1268529/14747) in order to try to see the
> plugged in event using `log-level = debug` and journalctrl but there
> is no message printed when I plug in the headphones. Could someone
> please give me some hints on how to troubleshoot this situation?

Hi, Krister.

Can you try installing and running "evtest" and seeing if that displays
a SW_HEADPHONE_INSERT event when you plug or unplug the headphones? Be
sure to select the event number that corresponds to your headphone jack.
Mine was called "HDA Intel PCH Headphone", yours may differ.

One other thing I can think of is to try different headphones. A lot of
newer devices use electrical detection (e.g. impedence sensing) to
determine if headphones are plugged in, and some types of headphones
might not reliably detect. You might also try some TRS vs. TRRS style
headphones to see if that makes any difference.

--Sean



Re: [pulseaudio-discuss] Understanding PulseSimple Large Memory Allocations

2021-10-04 Thread Sean Greenslade
On Sun, Oct 03, 2021 at 07:44:13AM +, Ryan McClue wrote:
> I'm on an Ubuntu system and want to write to a PCM buffer and play it.
> I created the most basic C program that only calls pa_simple_new().  I
> launched this program into Intel VTune and performed a Memory
> Consumption analysis. It showed that libpulsecommon.so allocates
> ~200MB and pa_simple_new() allocates ~67MB.  Why is so much memory
> allocated?

Hi, Ryan.

There are a few subtleties in Linux with regards to memory usage. First,
I recommend taking a look at the usage through a tool like "top", and
notice that it reports three separete values for memory usage: VIRT,
RES, and SHR. These stand for Virtual, Resident, and Shared. Each of
these behaves a little differently.

VIRT is how many kilobytes of memory address space is currently used by
the application. This includes all memory allocations, memory mapped
files, libraries, and anything else that gets addressed by memory. But
just because something is using memory address space doesn't necessarily
mean that it's using physical memory.

RES is how many kilobytes of physical memory are in use by
the application. This is more or less the "true memory usage" of the
application.

The SHR number is how much shared memory is in use by the application.
This can be things like libraries or shared buffers (which pulse uses to
transfer audio data between processes).

I ran a test of pacat-simple.c on my machine and got the following
values:
VIRT - 339 MB
RES  - 5.3 MB
SHR  - 4.6 MB

So you can see that despite the fact that ~300 MB of address space is
used, only ~5 MB of actual RAM is consumed, and most of that is shared
memory (likely the libraries and IPC audio buffers).

Also, something a little unintuitive about Linux and the way it
allocates memory is that allocations don't actually get assigned to
physical memory until they are used. If you call malloc(), you will get
address space assigned which will add to your VIRT count but your RES
count will stay the same. Once you insert values into those memory
addresses, then the RES count will increase, but only by the amount you
actually fill.  This causes mallocs to be almost no cost memory-wise,
and there's pretty much no harm in over-allocating memory if it's not
used.

In summary, don't worry about the VIRT memory consumed by a process;
it's not the amount of physical RAM used.

> Also, as pulseaudio is what is adopted by Ubuntu, is it
> true that I have no other choice than to use pulseaudio as it owns all
> the sound devices?

This question would be better asked on an Ubuntu-specific list. That
said, if your audio needs are very simple (e.g. only one application
ever playing audio at a time), then it should be possible to disable
pulseaudio and use ALSA directly. 

--Sean



Re: [pulseaudio-discuss] Streaming audio from a game to voice chat, mixed with audio from microphone

2021-09-29 Thread Sean Greenslade
On Tue, Sep 28, 2021 at 03:38:59PM +0100, Patrick May wrote:
> Hello,
> 
> I want to stream audio from a game to discord, while also sharing my mic at
> the same time.
> 
> This is a very common thing that people do all the time on other operating
> systems. For some reason this seems to be almost impossible to do with
> Pulseaudio.
> 
> Why is it so difficult?

It's certainly not impossible, but it's more of an advanced feature so
not many of the user utilities expose an easy way of doing this. There
was actually a discussion about something pretty similar last year on
the mailing list. This message here:

https://lists.freedesktop.org/archives/pulseaudio-discuss/2020-May/031770.html

...was my response describing the setups for doing a simple "mic +
program audio" mix, as well as a more complicated "mic + program audio
with separate monitoring bus" mix. The audio routing gets a bit
complicated since you need to be careful not to create feedback loops.
Feel free to read through that whole message thread, there's a lot of
info in it.

To your other question about how to make loopbacks work, you need to
use the pulseaudio source or sink names. To find these, run one of the
following commands:

$ pactl list sinks
$ pactl list sources

...and look for the "Name:" line under each listed source / sink.

Feel free to ask if there's still anything that's unclear.

--Sean



Re: [pulseaudio-discuss] how to pass correct channel map

2021-09-18 Thread Sean Greenslade
>On Wed, Sep 15, 2021 at 10:36:23PM -0700, Sean Greenslade wrote:
>> On Wed, Sep 15, 2021 at 09:59:00PM +0530, Vijendar Reddy Mukunda wrote:
>> > Hello,
>> > 
>> > I was just experimenting with a null sink.
>> > I have created null sink with 48000Hz sample rate, s16le, channels as 6.
>> > Tried to record from null sink monitor source.
>> > But when i run parecord command, I am seeing the below error.
>> > Warning: failed to write channel map to file.
>> > I have also tried null sink creation
>> > with 
>> > channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe.
>> > But no luck.
>> > Need inputs on fixing this channel map issue.
>> 
>> That error is just a warning, and can most likely be ignored. Not all
>> sound formats actually support writing the channel map into them. In
>> fact, according to the libsndfile docs, only AIFF and CAF are supported:
>> 
>> https://libsndfile.github.io/libsndfile/command.html#sfc_set_channel_map_info
>> 
>> What file format are you using?
>
> Thank you for your explanation.
> We are trying to play youtube content.
> One more question on the same line.
> we have created a null sink with 192khz/8ch/s32le and channel map as
> "front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right"
> When we record null sink monitor output, we are seeing complete silence
> in one channel.
> As we are using lfe as one channel, do we need to do any extra settings
> on lfe channel?

Well, does your source media have 7.1 channel audio? If not, you'll need
to turn on the "remixing-produce-lfe" setting in daemon.conf. If it
does, then you'll need to dig deeper into what exactly your playback
software is doing.

--Sean



Re: [pulseaudio-discuss] how to pass correct channel map

2021-09-15 Thread Sean Greenslade
On Wed, Sep 15, 2021 at 09:59:00PM +0530, Vijendar Reddy Mukunda wrote:
> Hello,
> 
> I was just experimenting with a null sink.
> I have created null sink with 48000Hz sample rate, s16le, channels as 6.
> Tried to record from null sink monitor source.
> But when i run parecord command, I am seeing the below error.
> Warning: failed to write channel map to file.
> I have also tried null sink creation
> with channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe.
> But no luck.
> Need inputs on fixing this channel map issue.

That error is just a warning, and can most likely be ignored. Not all
sound formats actually support writing the channel map into them. In
fact, according to the libsndfile docs, only AIFF and CAF are supported:

https://libsndfile.github.io/libsndfile/command.html#sfc_set_channel_map_info

What file format are you using?

--Sean



Re: [pulseaudio-discuss] need to run `pulseaudio -k` to record from null sink

2021-09-09 Thread Sean Greenslade
On Tue, Sep 07, 2021 at 08:18:48AM +0100, Gareth Walker wrote:
> On Tue, 7 Sept 2021 at 00:12, Sean Greenslade 
> wrote:
> 
> > Can you look at the logs to see if there are any errors listed when you
> > load the modules. The logs should be in your user journal, try this:
> >
> > $ journalctl --user -u pulseaudio.service -e
> >
> 
> Thanks for the tip. This is what appears in the user journal after reboot:
> 
> systemd[1679]: Starting Sound Service...
> pulseaudio[1685]: No such source.

OK, so the above line confirms my theory. The loopback module is loaded
too soon, and the automatic loader hasn't had time to load in the alsa
soundcards yet.

> 

I've run into this myself, and I can't really think of any great
workarounds to handle this entirely within pulse. If your alsa
identifiers are suitably stable, you could maybe manually load the
module-alsa-* modules before the loopback, but that seems fragile,
especially with USB devices.

What would be ideal is if there were an option for module-loopback to
treat the source= and sink= options as soft-preferences, automatically
switching to them when they become available. While I can't commit to
writing a patch right now, it looks reasonably straightforward. Pulse
devs, would you be open to accepting such a patch? Or do you see a more
straightforward way of accomplishing this task?

--Sean



Re: [pulseaudio-discuss] pulseaudio parec recording short interrupt at user switch

2021-09-06 Thread Sean Greenslade
On Sun, Sep 05, 2021 at 10:37:16PM +0200, Istvan Gabor wrote:
> Sat, 4 Sep 2021 20:36:35 -0700 időpontban Sean Greenslade írta:
> > Are these actually different system (unix) users? With different UIDs?
> > If so, pulse doesn't really work in a multi-user environment by default.
> > How have you configured pulse to use multiple users? That may shed some
> > light on what's causing your cut-outs.
> 
> Thank you.
> 
> These are two different users with different UIDs.
> 
> They work alternately in the system. User2 records the stream in his session
> in VT8 X11 terminal. After starting to record user1 switches to his VT7
> X11 session. Occasionally user2 switches bacj to his session. During the
> record they switch sessions several times.
> 
> I haven't configured pulseaudio, just use the default openSUSE setup.
> Earlier I tried system-wide pulseaudio to be able to listen to the stream
> in both sessions. It worked, but pacmd doesn't work in system wide mode,
> therefore I removed it (the pulseaudio system wide package).

I suppose this setup should work in theory, assuming you're only feeding
streams to a null sink and not to actual hardware ALSA devices.

Can you check the logs to see if pulse is doing anything odd during the
VT switches? I'm assuming openSUSE is systemd-based, so pulse is
probably launched / killed by user units. See what's returned by these
commands after reproducing your issue:

$ journalctl --user -u pulseaudio.service -b

$ journalctl --user -u pulseaudio.socket -b

--Sean



Re: [pulseaudio-discuss] need to run `pulseaudio -k` to record from null sink

2021-09-06 Thread Sean Greenslade
On Mon, Sep 06, 2021 at 08:45:57AM +0100, Gareth Walker wrote:
> Hello,
> 
> I want to be able to capture both the microphone and the system sounds at
> the same time. To help me do that I have put the following commands in
> ~/.config/pulse/default.pa which create a null sink:
> 
> .include /etc/pulse/default.pa
> load-module module-null-sink sink_name=MySink
> sink_properties=device.description=Mic_and_system_sounds
> load-module module-loopback
> source=alsa_input.usb-0c76_USB_PnP_Audio_Device-00.mono-fallback sink=MySink
> load-module module-loopback
> source=alsa_output.pci-_0a_00.3.analog-stereo.monitor sink=MySink
> 
> When I first log in I can't record the monitor of Mic_and_system_sounds:
> but I can once I've run `pulseaudio -k`. Before I run that command, I can
> see Mic_and_system_sounds listed in the output devices in pavucontrol and
> nothing in the recording tab; once I've run `pulseaudio -k` I can also see
> the loopback to Mic_and_system_sounds from the microphone and from the
> soundcard in the recording tab of pavucontrol, and I can record the monitor
> of Mic_and_system_sounds.
> 
> Is there a way around having to run `pulseaudio -k` each time I log in in
> order to be able to record the monitor of Mic_and_system_sounds? I hoped
> that by putting the commands in ~/.config/pulse/default.pa I would be able
> to do that right away on logging in. I am on Ubuntu 20.04.

Can you look at the logs to see if there are any errors listed when you
load the modules. The logs should be in your user journal, try this:

$ journalctl --user -u pulseaudio.service -e

My guess would be that the loopback module is trying to load before your
ALSA devices have enumerated. I ran into something similar when I was
working on advanced routing; my solution was to not load the loopback
modules from my default.pa file, but instead with an external script
that could verify the presence of the target sink before it ran.

--Sean



Re: [pulseaudio-discuss] pulseaudio parec recording short interrupt at user switch

2021-09-04 Thread Sean Greenslade
On Sat, Sep 04, 2021 at 10:34:34PM +0200, Istvan Gabor wrote:
> Hello:
> 
> I use pulseaudio's parec to record an audio stream played
> in a browser. I use openSUSE 15.1 with its default pulseaudio
> version pulseaudio-11.1-lp151.5.3.
> 
> This is what I do:
> 
> load null sink:
> pactl load-module module-null-sink  sink_name=stream
> 
> I move the firefox browser sound to null output in pavucontrol GUI.
> 
> I record the stream with parec:
> parec -d stream.monitor --file-format out.wav
> 
> This works well. But I also want to switch between two user's desktop.
> User1 is on VT7, user2 is on VT8.
> I start to record on VT8, then I switch to VT7; the record is OK.
> But when I switch back to VT8, the record gets a short interrupt
> (pause), which is annoying. An image of the waveform showing the
> short pause in the can be seen here:
> 
> https://paste.opensuse.org/85986435
> 
> How could I fix this, to get an uninterrupted recording?

Are these actually different system (unix) users? With different UIDs?
If so, pulse doesn't really work in a multi-user environment by default.
How have you configured pulse to use multiple users? That may shed some
light on what's causing your cut-outs.

--Sean



Re: [pulseaudio-discuss] execute commands on suspend/resume?

2021-09-04 Thread Sean Greenslade


[Re-adding the mailing list and reformatting]

On Sun, Sep 05, 2021 at 10:23:14AM +1000, Bernd Wechner wrote:
> On 5/9/21 06:13, Sean Greenslade wrote:
> > On Tue, Jun 08, 2021 at 08:17:00PM -0700, Peter Meilstrup wrote:
> > > Hello pulseaudio list,
> > > I am wondering if it is possible to have a command be executed when a
> > > sink is suspended or resumed (via module-suspend-on-idle).
> > > Specifically I want to switch my amplifier on and off automatically
> > > via home automation. Is this supported in pulseaudio?
> > 
> > I realize this is a reply to a pretty old message, but in case you or
> > others are still wondering about this:
> > 
> > It's pretty straightforward to do this with a custom pulseaudio client
> > application. I took a quick stab at it with the "pulsectl" python
> > library. Example script attached, just modify the sink.name line to
> > match your target device.
> 
> This looks awesome, been wondering for a while if there was a way I could
> watch for pulse events and enforce a default device. I have endless trouble
> on a HTPC that seems when the projector is switched on or off seeing the
> surround sound device disappear and reappear and with that cycle a new
> device inadvertently selected. I would like to somehow say, no matter what
> the F happens, unless it's user specified  select the surround sound system
> and configure it for 5.1 (it also flips to stereo a lot on such power
> cycles).

This part of your particular issue was solved in the most recent pulse
release (15.0). From the release notes:

>> Card profiles can be set to sticky
>> 
>> Card profiles can be set to sticky using the command "pactl send-message
>> /card/ set-profile-sticky 'true|false'". The current status
>> can be queried using pactl send-message /card/
>> get-profile-sticky. If a card profile is sticky, it will always be
>> restored, even if the profile is unavailable. Also port availability
>> changes on the card will not impact the profile choice. This is for
>> example useful to set the card profile permanently to "off" for HDMI
>> devices. Setting profiles to sticky is already implemented in
>> pavucontrol and will be provided with the next pavucontrol release.

The various module-*-restore modules should also migrate wayward streams
back to the originally selected sound card once it reappears, though
it's possible that applications might be trying to outsmart pulse and do
their own output selection / migration.

> I see some scope with pulse.event_listen() but looking at the scant docs I
> see also event_callback_set() which seems more appropriate (setting a
> callback and parking) but I find the docs are very poor here as to what
> either of these actually do, and I'm a bit concerned running a script like
> yours with a "while True" loop as a daemon monitoring changes.
> 
> Thoughts? Perhaps theres another approach to this altogether I'm no aware
> of?

I agree the docs are a little sparse for pulsectl. I did have to do some
source reading to figure it out. Maybe I should have put some more
comments in that script.

The event_mask_set and event_callback_set lines outside the while loop
establish which types of events will be received and establish the
callback function as the handler of those events. Once inside the loop,
the event_listen() function when called with no arguments will block
indefinitely until an event is received. It's not busy-waiting; the
script will sleep and use no CPU until a matching event happens. At that
point, the script is woken up and the callback is fired. Since this
callback is called from within the pulse mainloop, we can't call other
pulse functions (for reasons related to the way the pulseaudio C APIs
are structured). So we use the callback to store the sink index that
triggered it and then break out of event_listen function. Once that
happens, our while loop goes on to process the event. We can now call
other pulseaudio functions (like sink_list() to get the state of the
sink that triggered our callback). Once we're done processing, the while
loop re-fires the event_listen(), and thus goes back to sleep until the
next event.

There may be a small race condition in this code, as I'm not certain if
events that happen while we're not in event_listen() get queued up. In
this example it's probably fine, as the default auto-suspend takes 5
seconds to transition state. If you were really concerned about not
losing any events, you could rearchitect the script to spawn a separate
processing thread and just flag processing events from the main thread
using a thread-safe shared object (e.g. queue.Queue) without exiting the
event_listen function.

--Sean



Re: [pulseaudio-discuss] execute commands on suspend/resume?

2021-09-04 Thread Sean Greenslade
On Tue, Jun 08, 2021 at 08:17:00PM -0700, Peter Meilstrup wrote:
> Hello pulseaudio list,
> 
> I am wondering if it is possible to have a command be executed when a
> sink is suspended or resumed (via module-suspend-on-idle).
> Specifically I want to switch my amplifier on and off automatically
> via home automation. Is this supported in pulseaudio?

I realize this is a reply to a pretty old message, but in case you or
others are still wondering about this:

It's pretty straightforward to do this with a custom pulseaudio client
application. I took a quick stab at it with the "pulsectl" python
library. Example script attached, just modify the sink.name line to
match your target device.

--Sean

#!/usr/bin/python3

import pulsectl

with pulsectl.Pulse('event-printer') as pulse:
sink_idx = None
sink_was_suspended = False

# Get the desired sink.
for sink in pulse.sink_list():
if sink.name == 
"alsa_output.usb-Focusrite_Scarlett_Solo_USB-00.analog-stereo":
sink_idx = sink.index
sink_old_state = (sink.state == 'suspended')

def print_events(ev):
#print('Pulse event:', ev)
if sink_idx == ev.index:
raise pulsectl.PulseLoopStop # Break out of the 
event_listen to process the event in the main app.

pulse.event_mask_set('sink')
pulse.event_callback_set(print_events)

while True:
pulse.event_listen()

sink = pulse.sink_list()[sink_idx]
sink_new_state = (sink.state == 'suspended')
#print(sink_new_state, sink.state)

if sink_new_state != sink_old_state:
print("Sink has changed state")
if sink.state == 'suspended':
print("Now suspended.")
# <<< TAKE ACTION HERE >>>
elif sink.state == 'idle' or sink.state == 'running':
print("Now active.")
# <<< TAKE ACTION HERE >>>
sink_old_state = sink_new_state



Re: [pulseaudio-discuss] Audible plop at beginning when using pcat-simple

2021-09-03 Thread Sean Greenslade
On Fri, Sep 03, 2021 at 11:54:04AM +0200, mindfsck wrote:
> > Apologies for leading you down a dead-end. I've taken a closer look
> > at the code and found what the problem is. The pacat-simple.c example is
> > expecting raw PCM sample data in the file. Since you're giving it a .WAV
> > file, there is a metadata header at the beginning that it is trying to
> > interpret as audio.
> >
> > Try inserting this line just above the /* Read some data ... */ line:
> >
> > read(STDIN_FILENO, buf, 44); // Discard the .WAV header
>
> Thank you Sean, that did indeed the trick and my files play nicely now!
> Do you expect to add this WAV header detection (and skipping) in a future
> release or do you restrict it to PCM (and user code must skip)?

To be clear, I'm not a pulseaudio dev, just a [power] user. But it seems
to me that it's not within the purview of pulseaudio to do file parsing
/ interpretation. Especially in what purports to be a "simple" API.

Also, the code I showed above was just a quick and dirty hack to prove
what the issue was. If you're making an actual program, you would want
to do at least some basic parsing of the WAV header to select the
correct bitrate / channel / sample size values to fill out the
pa_sample_spec struct. As it sits now, those values are hard-coded, and
you would get glitchy / incorrect audio if you fed it a WAV file with
different parameters.

--Sean



Re: [pulseaudio-discuss] Audible plop at beginning when using pcat-simple

2021-09-02 Thread Sean Greenslade
On Sun, Aug 29, 2021 at 07:02:25PM +0200, mindfsck wrote:
> or use 'vlc' or use any Video/Audio playback you have on your machine.Sigh,
> I may just reach out for alternative APIs instead of trying to convince
> people that this might be a bug in the simple API you provide.

Apologies for leading you down a dead-end. I've taken a closer look
at the code and found what the problem is. The pacat-simple.c example is
expecting raw PCM sample data in the file. Since you're giving it a .WAV
file, there is a metadata header at the beginning that it is trying to
interpret as audio.

Try inserting this line just above the /* Read some data ... */ line:

read(STDIN_FILENO, buf, 44); // Discard the .WAV header

--Sean



Re: [pulseaudio-discuss] Audible plop at beginning when using pcat-simple

2021-08-28 Thread Sean Greenslade
On Fri, Aug 27, 2021 at 04:57:07PM +0200, mindfsck wrote:
> I seem to be to silly for it:
> # sox in.wav -r 22050 out.wav resample
> sox FAIL formats: can't open input file `out.wav': No such file or directory
> 
> Of course there is no out.wav since that's what I want to create!

I would not bother with trying to change sample rates, that's very
unlikely to be the issue. Plus, a lot of sound cards only support 44.1
kHz and 48 kHz, so pulse would just have to resample it again on playback.

One thing you could try is making use of the buffering attributes in
pa_simple_new. Specifically, setting prebuf to a suitable value. There's
some helpful info in the buffer_attr docs page here:

https://www.freedesktop.org/software/pulseaudio/doxygen/structpa__buffer__attr.html

Another thing to check is if there are a couple of silent samples at the
beginning of the problematic wav files. If the first sample is non-zero,
that could potentially cause pops on playback.

--Sean



Re: [pulseaudio-discuss] Audible plop at beginning when using pcat-simple

2021-08-26 Thread Sean Greenslade
On Thu, Aug 26, 2021 at 09:43:23PM +0200, mindfsck wrote:
> Hi there,
> 
> I was using this example to simply play a WAV file without having much clue
> of audio:
> https://www.freedesktop.org/software/pulseaudio/doxygen/pacat-simple_8c-example.html
> I changed the sources to match (IMHO) my settings, i.e. channels=1 and
> rate=48000.
> 
> I have two wavefiles, the first plays as it should (compared with command
> line paplay or aplay) and the second one has an audible PLOP (but only
> around 90% of the time) at the very beginning of playback:
> 
> (1 - OK)
> General
> Complete name: out_clean.wav
> Format   : Wave
> File size: 81.3 KiB
> Duration : 866 ms
> Overall bit rate mode: Constant
> Overall bit rate : 769 kb/s
> Audio
> Format   : PCM
> Format settings  : Little / Signed
> Codec ID : 1
> Duration : 866 ms
> Bit rate mode: Constant
> Bit rate : 768 kb/s
> Channel(s)   : 1 channel
> Sampling rate: 48.0 kHz
> Bit depth: 16 bits
> Stream size  : 81.2 KiB (100%)
> 
> (2 - NOK)
> General
> Complete name: out_short_clean.wav
> Format   : Wave
> File size: 22.8 KiB
> Duration : 242 ms
> Overall bit rate mode: Constant
> Overall bit rate : 772 kb/s
> Audio
> Format   : PCM
> Format settings  : Little / Signed
> Codec ID : 1
> Duration : 242 ms
> Bit rate mode: Constant
> Bit rate : 768 kb/s
> Channel(s)   : 1 channel
> Sampling rate: 48.0 kHz
> Bit depth: 16 bits
> Stream size  : 22.8 KiB (100%)
> 
> I tried using different BUFSIZE and my systemload is also not an issue...
> Any ideas?

I've experienced something like this with a few built-in audio cards on
various laptops. It's never bothered me enough to track it down, but I
suspect it's due to the suspending and resuming of cards. Can you try
disabling the autosuspend module and see if it still happens? Use this
command to temporarily disable it until the next time pulse reloads:

$ pactl unload-module module-suspend-on-idle

--Sean



Re: [pulseaudio-discuss] Pulse Audio serious Issue- required sincere help

2021-08-13 Thread Sean Greenslade
On Thu, Aug 12, 2021 at 06:18:31PM +0530, anantha lavanya wrote:
> Dear sir/madam,
> I am lavanya. I am facing some critical issue with pulseaudio on arm board
> of am5728 with embedded linux os loaded in to. I am requesting sincere
> help. Please help me with this issue.
> Please respond to me back, awaiting for the reply.

You'll need to provide some details about what exactly the issue you're
experiencing is, otherwise no one can help you.

--Sean



Re: [pulseaudio-discuss] Why does PA need to rewrite and rewind when I change the volume while playing audio?

2021-08-06 Thread Sean Greenslade
On July 26, 2021 8:18:19 PM PDT, Chengyi Zhao  wrote:
>Hi guys,
>
>I found the following logic when I change the volume while playing 
>audio.I guess there is some audio expertise here, would you please tell
>
>me the principle, thanks a lot!
>
>In the file sink-input.c(./src/pulsecore/sink-input.c), why does pa
>need 
>to invoke the function pa_sink_input_request_rewind to rewrite and 
>rewind the data?
>
>void pa_sink_input_set_volume(...) {
> ...
>
>   pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), 
>PA_SINK_INPUT_MESSAGE_SET_SOFT_VOLUME, NULL, 0, NULL) == 0);
> }
>
> ...
>}
>
>int pa_sink_input_process_msg(...) {
> ...
>
> switch (code) {
>
> case PA_SINK_INPUT_MESSAGE_SET_SOFT_VOLUME:
> if (!pa_cvolume_equal(&i->thread_info.soft_volume, 
>&i->soft_volume)) {
> i->thread_info.soft_volume = i->soft_volume;
>pa_sink_input_request_rewind(i, 0, true, false, false);
> }
>
>return 0;
>
> ...
>}

There's some helpful docs about what rewinding is in the context of pulseaudio 
here:

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Rewinding/

But in summary, pulse will try to get ahead of things by buffering up processed 
audio data. When the requested processing changes, for example a new volume 
level is requested, rewinding clears out the (now out of date) buffered audio 
samples and rewrites them with the new processing.

--Sean



Re: [pulseaudio-discuss] two sound files at the same time - problem with crontab (pulseaudio involved)

2021-05-16 Thread Sean Greenslade
On Sat, May 15, 2021 at 04:34:36PM +0200, Christian wrote:
> Hi altogether,
> 
> 
> I am curious as how to solve a peculiar "problem".
>
> 
>
> That works very well. But I run into problems *if* I have some other noise
> (sound-file) played out *at the same time*.
> 
> 
>
> ==
> AO: [pulse] Init failed: Connection refused
> Failed to initialize audio driver 'pulse'

^^^ Here is your problem ^^^

Pulseaudio is either not installed, not running, or has some sort of
permissions issue. Can you run the command "pactl info" and report what
it returns? Also, can you describe your system a bit? Mainly the
hardware, sound card type, and Linux distro / version.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] No audio output; same setup worked before [RESOLVED]

2021-02-15 Thread Sean Greenslade
On Mon, Feb 15, 2021 at 04:41:49PM -0800, Rich Shepard wrote:
> Ah! There is no sound.wav here in any partition or directory. I was using
> vokoscreenNG to record sound while the webcam captured me speaking. When I
> played the video with vlc there was no sound. But, ffprobe showed the output
> file had both video and audio streams.
> 
> Have you a suggestion how I can ensure my videos also produce audio output
> when played and I've specified a .mp4 output for the recording?

I'm not familiar with vokoscreenNG, but from a quick look at its github
page, it seems like it has native pulseaudio support. I would suggest
going through its settings and verifying that the correct audio input
device is selected before starting a recording. You can also verify that
it is indeed respecting your source selection by checking the
"Recording" tab of pavucontrol during a recording session.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] No audio output; same setup worked before [RESOLVED]

2021-02-15 Thread Sean Greenslade
On Mon, Feb 15, 2021 at 09:55:28AM -0800, Rich Shepard wrote:
> On Sun, 14 Feb 2021, Rich Shepard wrote:
> 
> > Aha! I found the problem, at least with audacity. Audacity has a drop down
> > combobox with output options. The default is, "HD-Audio Generic: ALC1220
> > digital (HW:1,1)" and there's no speaker output. And, when I change the
> > output to "HD-Audio Generic: ALC1220 digital (HW:1,0)" the same test
> > recoding is heard from the speakers.
> 
> Sean, et al.:
> 
> Now I've resolved the issue with direct recording and playback using pacat.
> Two things changed since when I logged out yesterday: 1) I had downgraded
> pavucontrol from version 4.0 (which is in Slackware-current) to version 3.0
> (which is the default in Slackware-14.2) and 2) I logged off the desktop and
> logged back in this morning.
> 
> I created a recording:
> $ pacat -v -r --file-format=wav direct-pacat-recording.wav
> Opening a recording stream with sample specification 's16le 2ch 44100Hz' and 
> channel map 'front-left,front-right'.
> Connection established.
> Stream successfully created.
> Buffer metrics: maxlength=4194304, fragsize=352800
> Using sample spec 's16le 2ch 44100Hz', channel map 'front-left,front-right'.
> Connected to device 
> alsa_input.usb-Focusrite_Scarlett_Solo_USB_Y7R5BX40493137-00.analog-stereo 
> (index: 25, suspended: no).
> 
> and played it back to the external speakers:
> $ pacat -v -p --file-format=wav direct-pacat-recording.wav
> Opening a playback stream with sample specification 's16le 2ch 44100Hz' and 
> channel map 'front-left,front-right'.
> Connection established.
> Stream successfully created.
> Buffer metrics: maxlength=4194304, tlength=352800, prebuf=349276, minreq=3528
> Using sample spec 's16le 2ch 44100Hz', channel map 'front-left,front-right'.
> Connected to device alsa_output.pci-_0a_00.3.analog-stereo (index: 20, 
> suspended: no).
> Stream started.
> Stream underrun.
> Playback stream drained.y: 100160 usec. Draining connection to server.
> (when I stopped it)
> 
> So there must be something (perhaps in pulseaudio or alsa) that's different
> in the soon-to-be Slackware-15.0 that is not supported in Slackware-14.2.
> But, since I first faced this problem with the default pavucontrol-3.0 I
> honestly don't know why it stopped working then started again.

For the record, I would be very surprised if your version of pavucontrol
had anything to do with these issues. In your other email, you show this
output from your pacat record attempt:

> $ pacat -v -r --file-format=wav /tmp/sounds.wav
> Opening a recording stream with sample specification 's16le 2ch 44100Hz' and 
> channel map 'front-left,front-right'.
> Connection established.
> Stream successfully created.
> Buffer metrics: maxlength=4194304, fragsize=352800
> Using sample spec 's16le 2ch 44100Hz', channel map 'front-left,front-right'.
> Connected to device alsa_output.pci-_0a_00.3.analog-stereo.monitor 
> (index: 0, suspended: no).

Notice the last line, where it reports the source it has attached to is
the alsa output monitor source. This was recording the _output_ of your
built-in sound card, hence why you heard nothing upon playback.

Pacat / parec will respect the fallback selection as the default
recording source if you don't supply one explicitly, so that will most
likely be what made the difference between your tests.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] No audio output; same setup worked before

2021-02-13 Thread Sean Greenslade
On Sat, Feb 13, 2021 at 01:25:22PM -0800, Rich Shepard wrote:
> On Sat, 13 Feb 2021, Sean Greenslade wrote:
> > Are you referring to the Kodi project's PAPlayer, or did you use "paplay"?
> > What happens if you try paplay? What are the error messages you get, if
> > any?
> 
> No, 'paplay':
> $ paplay test-recording.flac Failed to open audio file.
> 
> But,
> $ pacat -p test-recording.flac
> 
> no sound.
> 
> > Also, can you open the generated .flac file with an audio editor to see
> > if the audio actually got recorded in the first place?
> 
> Ah, nope. Audacity can't find content and 'ffprobe' returns,
> $ ffprobe -hide_banner test-recording.flac [flac @ 0xc60d60] Format flac
> detected only with low score of 1, misdetection possible!
> [flac @ 0xc60d60] Could not find codec parameters for stream 0 (Audio: flac, 
> 0 channels): unspecified sample format
> Consider increasing the value for the 'analyzeduration' and 'probesize' 
> options
> Input #0, flac, from 'test-recording.flac':
>   Duration: N/A, bitrate: N/A
> Stream #0:0: Audio: flac, 0 channels

OK, all of this suggests that the file did not record correctly. And
after some experimentation myself, it seems like this is a known bug:

https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/822

It seems like the wav format does work, so give this variant a try:

$ pacat -v -r --file-format=wav /tmp/sounds.wav

and

$ pacat -v -p --file-format=wav /tmp/sounds.wav

> On a different file (created yesterday):
> $ ffprobe -hide_banner test-mic.wav Input #0, wav, from 'test-mic.wav':
>   Duration: 00:00:16.00, bitrate: 64 kb/s
> Stream #0:0: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 8000 Hz, 1 channels, 
> u8, 64 kb/
> and
> $ pacat -p test-mic.wav
> produced two clicks from the speaker.
> 
> Found one potential issue: the Focusrite had the 'Air' button pressed under
> the input volumn knob. Turned that off. Now when I speak into the mic the
> green ring light around the volumn knob fluctuates as does the pavucontrol
> VU meter. But, still no output from the speakers.

My Scarlett solo is an older gen, so it doesn't have an "air" switch. I
was curious what that was, so here's what their docs have to say:

>> An important feature of all 3rd Generation Scarlett interfaces is
>> Focusrite’s exclusive AIR function.  Individually selectable on all
>> mic input channels, AIR subtly modifies the preamp’s frequency
>> response to model the sonic characteristics of our classic
>> transformer-based ISA microphone preamps. When recording with good
>> quality microphones, you will notice an enhanced clarity and
>> definition in the important mid to high frequency range, just where it
>> is most needed for vocals and many acoustic instruments.

Lol, it's just a fixed EQ curve. This should not be the cause of your
issues, though feel free to use it if you like the tone it produces.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] No audio output; same setup worked before

2021-02-13 Thread Sean Greenslade
On Sat, Feb 13, 2021 at 11:45:07AM -0800, Rich Shepard wrote:
> On Fri, 12 Feb 2021, Sean Greenslade wrote:
> 
> > I would suggest using the "parecord" and "paplay" utilities, which are
> > meant to directly interact with Pulse.
> 
> Sean,
> 
> After reading the pacat man page, and checking that pavucontrol shows the
> AT2500 as the input device and the external speakers [HD Audio Generic
> Analog Stereo; Port is line out (plugged in)] I spoke to the mic and watched
> the 'Recording' tab VU meter change as I spoke. I used 'papac -r
> .flac' for the recording. I didn't try 'parecord ...'.

Not sure what "papac" is. Do you mean "pacat"?

> Then I switched to the pavucontrol 'Playback' tab showing Applications. When
> I ran 'papac -p .flac' that tab showed the application but there
> was no VU meter response.
> 
> Running 'paplayer .flac' the file couldn't be opened.

Are you referring to the Kodi project's PAPlayer, or did you use
"paplay"? What happens if you try paplay? What are the error messages
you get, if any?

Also, can you open the generated .flac file with an audio editor to see
if the audio actually got recorded in the first place?

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] No audio output; same setup worked before

2021-02-12 Thread Sean Greenslade
On Fri, Feb 12, 2021 at 12:14:00PM -0800, Rich Shepard wrote:
> Before getting the USB headsets working (thank you very much!) I used my
> AudioTechnica AT2500USB condenser microphone to record the audio portion of
> videos. Today I decided to again use it for recording and leave the headsets
> for online, virtual meetings. So I set up the AT again.
> 
> The AT mic is connected via XLR to a Focusrite Scarlett Solo pre-amp. The
> Focusrite is connected via USB to a front panel port on the desktop's case.

I'm a little confused by this description. As far as I know, the
ATR2500-USB only supports USB connection, not XLR. I'll assume you meant
you have a different XLR microphone plugged in to your Focusrite
interface.

> I configured pavucontrol so it sees the webcam and the AT mic as inputs; the
> audio device is seen as Scarlett Solo USB (rather than AudioTechnica
> AT2500USB) and the Input Devices tab shows that same device name with the vu
> meter responding to microphone input. A test file created with arecord shows
> the audio stream:
> $ ffprobe -hide_banner test-mic.wav Input #0, wav, from 'test-mic.wav':
>Duration: 00:00:16.00, bitrate: 64 kb/s
>  Stream #0:0: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 8000 Hz, 1 channels, 
> u8, 64 kb/s
> 
> The Output Devices tab has only one device: HD Audio Generic Analog Stereo
> with the Port Line Out (Plugged In). The external speakers are turned on and
> I hear clicks when I adjust the volume on pavucontrol, but no sound when I
> play 'test-mic.wav' with aplay.
> 
> I've looked at pavucontrol tabs and don't see why I'm not hearing that audio
> stream.
> 
> What have I missed? Wrong arecord parameters?

I see you referencing "arecord" and "aplay", both of which are ALSA
utilities. While those should work (assuming you have the
pulseaudio-alsa package installed), they are a little harder to to make
behave nicely in Pulseaudio due to the limitations of the ALSA APIs that
Pulse has to emulate. I would suggest using the "parecord" and "paplay"
utilities, which are meant to directly interact with Pulse.

These utilities let you specify a recording or playback device directly,
or you can leave it unspecified and they should default to the fallback
device (as selected by the check marks in the Output Devices and Input
Devices tabs of Pavucontrol).

Note that you can check the recording source of a currently-recording
app in Pavucontrol just the same way you can check the playback sink of
a currently-playing app. So I would recommend checking the "Recording"
tab of Pavucontrol while recording to make sure that your app is indeed
recording from the source you want, and that the VU meter is showing
appropriate response.

You can also visually check the produced WAV file with an editor like
Audacity to be sure that the audio is making its way into the file.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] USB-connected headsets: no sound

2021-02-07 Thread Sean Greenslade
On Sun, Feb 07, 2021 at 06:30:18AM -0800, Rich Shepard wrote:
> On Thu, 4 Feb 2021, Sean Greenslade wrote:
> 
> > Under the "Output Devices" tab, some of the outputs may have a "Port"
> > dropdown selector. ... The "Logitach H5703 Stereo Analog Stereo" device is
> > the important one, and it should be left on its default port selection of
> > "Headphones." Also verify that the device is not muted, and that the
> > volume slider is at a reasonable position.
> 
> Sean,
> 
> Yes, it has the port of Headphones, is unmulted, and has the volume slider
> at 100%
> 
> > Under the "Playback" tab, there will be a list of programs currently
> > playing sound.
> 
> Audacious is running and a song is playing.
> 
> > Now, next to the title of each application, there is an unlabeled dropdown
> > box that shows which sound device the application is currently playing to.
> > Find the actively-playing application and switch its dropdown to the
> > "Logitach H5703 Stereo Analog Stereo" option.
> 
> Well! The last time I lookat at the 'Playback' tab I missed your point that
> the dropdown box being unmarked meant there wasn't the usual triangle common
> to comboboxes. I didn't click on it becuase the symbol wasn't there. Just
> now I did and, sure enough, there was another option there: the Logitech
> headphones.

I'm glad you were able to get it working.

> I'm so used to GUI widgets being self-explanatory that I didn't try clicking
> on what appeared to be a label widget. I apologize for not groking what you
> wrote.

Interestingly, there's a commit in the pavucontrol master that changes
the button->radiolist behavior to a standard drop-down selector:

https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/commit/ae278b8643cf1089f66df18713c8154208d9a505

It just hasn't made its way into a release yet.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-06 Thread Sean Greenslade
On Fri, Feb 05, 2021 at 10:12:18AM +0100, Renaud GHIA wrote:
> Our application is pulseaudio only.
> So in this case I suppose that Jack must be interconnected with pulseaudio.
> Do you think that even interconnected, I wouldn't have cpu usage problems ?

There will almost certainly be a resampling stage if you pipe audio
between JACK and Pulseaudio.

> Concerning  the remap module, without remap the virtual device is not
> visible by our application...

It's common for applications to ignore monitor sources when presenting a
list of sources to pick from, however if your application allows for a
device name to be specified directly, you can select the monitor source
that way.

Alternatively, you can redirect an existing source output to a different
source programmatically by using "pactl move-source-output", or by using
a grapical utility like pavucontrol.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] USB-connected headsets: no sound

2021-02-06 Thread Sean Greenslade
On Fri, Feb 05, 2021 at 08:20:00AM -0800, Rich Shepard wrote:
> On Thu, 4 Feb 2021, Sean Greenslade wrote:
> 
> > There are two places in pavucontrol where you will need to verify
> > things.

Did you try the things I recommended in my previous email? What were the
results?

By the way, I noticed in the pactl output you provided that you have the
stereo volumes unlocked, and that the left channel is set to 8% while
the right channel is set to 100%. If that was not intentional, you
should go into pavucontrol, go to the "Output Devices" tab, set both
volume sliders to 100%, and click the padlock symbol ("Lock channels
together").

> I did a lot of poking in the system. Here's the relevant lines in dmesg:
> # dmesg
> [4721657.287134] usb 1-11: new full-speed USB device number 49 using xhci_hcd
> [4721657.877083] usb 1-11: New USB device found, idVendor=046d, 
> idProduct=0a56, bcdDevice= 1.03
> [4721657.877086] usb 1-11: New USB device strings: Mfr=1, Product=2, 
> SerialNumber=3
> [4721657.877088] usb 1-11: Product: Logitech H570e Stereo
> [4721657.877089] usb 1-11: Manufacturer: Logitech Inc
> [4721657.877091] usb 1-11: SerialNumber: 
> [4721658.041812] usb 1-11: Warning! Unlikely big volume range (=4125), 
> cval->res is probably
> wrong.
> [4721658.041816] usb 1-11: [11] FU [Sidetone Playback Volume] ch = 1, val = 
> 0/4125/1
> [4721658.180916] input: Logitech Inc Logitech H570e Stereo Consumer Control as
> /devices/pci:00/:00:01.3/:01:00.0/usb1/1-11/1-11:1.3/0003:046D:0A56.0014/input/input
> 53
> [4721658.233326] input: Logitech Inc Logitech H570e Stereo as
> /devices/pci:00/:00:01.3/:01:00.0/usb1/1-11/1-11:1.3/0003:046D:0A56.0014/input/input
> 54
> [4721658.233482] hid-generic 0003:046D:0A56.0014: input,hiddev96,hidraw1: USB 
> HID v1.11 Device
> [Logitech Inc Logitech H570e Stereo] on usb-:01:00.0-11/input3

This warning is probably irrelevant to your issue. Note that it refers
to the "Sidetone Playback Volume", which is a feature of some headsets
where some of the microphone's signal is played back through the
headphones to help you modulate your speech better. That likely won't
have any effect on normal audio playback.

> When I entered the Warning! in duckduckgo I found a 7-year-old thread on a
> red hat forum. There I learned about the 'pactl list' command. Running that
> here poured out a lot of output. The sections on the Logitech headset are in
> the attached gzipped text file.
> 
> I don't understand why but I see what's probably the underlying cause. I
> hope that your expertise can translate it to explain what I need to do about
> the suspended and other non-working parts.

The sound cards are all suspended because there are no active programs
playing sound, called "sink inputs" in pulseaudio parlance. Try starting
up an audio player and running "pactl list sink-inputs". You should see
the details of the application, as well as the sink number that it is
feeding its audio to. "pactl list sinks" will show the sound cards and
their states. Once something is feeding audio to a card, its state
should automatically transition to RUNNING.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] USB-connected headsets: no sound

2021-02-04 Thread Sean Greenslade
On Wed, Feb 03, 2021 at 12:05:25PM -0800, Rich Shepard wrote:
> On Wed, 3 Feb 2021, Sean Greenslade wrote:
> 
> > The menu I was referring to is attached to each of the clients. In your
> > screenshot, it's the box that says "HD-Audio Generic Analog Stereo".
> > Click that and change it to "Logitech H570e Stereo Analog Stereo".
> 
> Sean,
> 
> Thanks for correcting me. When I change the upper port it displays "Headset
> (unplugged)" while the headset is plugged in.
> 
> The lower port sill shows "Logitach H5703 Stereo Analog Stereo" with the
> port remaining "Headphones".
> 
> Unfortuately, changing the upper port to read "Headset (unplugged)" did not
> make a difference; still no audio output.

There are two places in pavucontrol where you will need to verify
things.

Under the "Output Devices" tab, some of the outputs may have a "Port"
dropdown selector. Generally you will not need to adjust this. The one
that says "Headphones (unplugged)" is referring to your motherboard's
built-in sound card, and it is correctly detecting that there is nothing
plugged into the 3.5mm jack on the motherboard. The "Logitach H5703
Stereo Analog Stereo" device is the important one, and it should be left
on its default port selection of "Headphones." Also verify that the
device is not muted, and that the volume slider is at a reasonable
position.

Under the "Playback" tab, there will be a list of programs currently
playing sound. If there are none, start up an application and get it
playing something. Now, next to the title of each application, there is
an unlabeled dropdown box that shows which sound device the application
is currently playing to. Find the actively-playing application and
switch its dropdown to the "Logitach H5703 Stereo Analog Stereo" option. 

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-04 Thread Sean Greenslade
On Thu, Feb 04, 2021 at 06:29:47PM +0100, Renaud GHIA wrote:
> >> Thank you for the tip.
> >> Now I am sure that resampling does not apply (see below).
> >> But unfortunately pulseaudio always consumes 30% of one CPU core!
> >>
> >
> > The reason is that you are using module-loopback. Due to a potential
> > difference between the clocks on the null sink and on the real sound card
> > (even though both report 44100 Hz), it always has to resample in order to
> > correct for the clock skew. If you don't understand, here is an analogy:
> > you have two mechanical watches. Even though both claim that their hour
> > hand makes one full circle every 12 hours, in fact, if left unattended,
> > they will diverge over time. There is no way to avoid that, except by
> > moving to Jack or PipeWire which simply don't introduce a null sink with an
> > independent clock.
> >
> > If you decide to stay on PulseAudio, you can tweak the resampling method.
> > The default, speex-float-1, is light on the CPU resources and should
> > produce no distortions detectable by human ear on typical speech and music.
> > It does produce easily detectable distortions on specifically crafted
> > signals. If you want to make sure that the resampler is transparent no
> > matter what is thrown at it, use speex-float-5. There is no point in going
> > higher than that.
>
> Thanks for your response.
> I understand the problem of clock drift when we have several audio hardware
> devices (with different qwartz).
> But here, it's a pity that the null video driver has an independent clock...
> Concerning pipewire, for now it doesn't work with our particular
> application (no sound), but it seems to evolve quickly.
> I haven't tried jack for now, but if it depends on pulseaudio, won't I have
> the same problem?

Jack doesn't depend on pulseaudio, it's an independent sound server.
Though there are ways to make the two interconnect.

As far as I know, jack solves this problem by only allowing one hardware
sound device and locking all clocks to that. See:

https://jackaudio.org/faq/multiple_devices.html

One thing that just occured to me was to ask whether you acutally need
to use the remap module at all. I just did a quick test on a very weak
machine of mine: a null sink, a music player outputting to that sink,
and ffmpeg recording the null sink's monitor-source, all with matching
44.1 kHz sample rates. This resulted in no resamplers in the chain, and
only 9% CPU usage on a 2010 Atom CPU.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-03 Thread Sean Greenslade
On Tue, Feb 02, 2021 at 10:40:51AM +0100, Renaud GHIA wrote:
> Hi,
> 
> Below the result of the command "pacmd list".
> Here without any change of resampling method.

This part here shows your ffmpeg client:

> index: 1
> driver: 
> flags:
> state: RUNNING
> source: 2 
> volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% /
> 0.00 dB
>balance 0.00
> muted: no
> current latency: 0.50 ms
> requested latency: 2000.00 ms
> sample spec: s16le 2ch 48000Hz
> channel map: front-left,front-right
> Stereo
> resample method: speex-float-1

It seems like ffmpeg is requesting 48 kHz audio, so pulse is forced to
resample. If possible, can you try running your ffmpeg process with the
flag "-sample_rate 44100" and see if that reduces the CPU usage?

Everything else in your pulse chain is 44.1 kHz, so with that change
there should be no resampling at all.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] USB-connected headsets: no sound

2021-02-03 Thread Sean Greenslade
On Wed, Feb 03, 2021 at 07:25:31AM -0800, Rich Shepard wrote:
> On Tue, 2 Feb 2021, Sean Greenslade wrote:
> 
> > By default, new sound devices don't take over existing streams. In
> > pavucontrol under the playback tab, there should be a dropdown menu for
> > each client listing which card it is currently sending audio to. Try
> > starting a sound playback and switching its dropdown to the USB device.
> 
> Sean,
> 
> Thanks for the quick response.
> 
> I started a .mp3 using Audacious and pavucontrol's Playback tab shows
> Applications (see attached screenshot.)

The menu I was referring to is attached to each of the clients. In your
screenshot, it's the box that says "HD-Audio Generic Analog Stereo".
Click that and change it to "Logitech H570e Stereo Analog Stereo".

> > Under the "output devices" tab, there is a checkmark button next to the
> > sound devices. This lets you specify which device is the default. It won't
> > force existing streams over to it, however, and it won't prevent some
> > clients from remembering their previous soundcard, so you may still need
> > to manually move some clients over to the new soundcard.
> 
> There are two devices shown, including the headphones. The checkmark box has
> 2 states represented by light grey and lighter grey (see attached
> screenshot). Both tooltips say the active checkmark is to 'Set for
> fallback.' By trial-and-error I think the darker grey is the active state
> (it is for the mute button.) Regardless, no sound is heard with any
> combination of checkmark button states for the two output devices.

Your system theme makes it a little hard to tell, but yes, the one that
is in the darkened state is the selected one. As I mentioned, this won't
directly affect existing streams, it simply sets the "fallback" device
that is selected if a new client appears and doesn't explicitly specify
which sound card it wants to send audio to.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] USB-connected headsets: no sound

2021-02-02 Thread Sean Greenslade
On Tue, Feb 02, 2021 at 08:08:06AM -0800, Rich Shepard wrote:
> I have an issue and hope someone here can help me resolve it. Short version:
> USB-connected headsets have no audible output.
> 
> Long version: I run Slackware-14.2/x86_64 with pulseaudio-9.0-x86_64-1 on a
> desktop workstation using an Asus Prime X470 Pro motherboard.
> 
> I have three headsets and external speakers on this desktop. The speakers
> and the Yamaha CM500 headset are analog and connect via the audio green and
> red phone sockets; the Logitech H570e and Mpow HC headsets are digital (at
> least they connect via a USB port).
> 
> Audio from any source is heard from the analog speakers and the Yamaha
> headphones. No sound is heard from any source using the digital headphones.
> 
> pavucontrol recognizes the digital headsets and both microphones work when
> selected as input devices; the vu meter fluctuates as I speak. But no sound
> is heard from any source. With the Logitech connected to a USB3.x port on
> the desktop's case pavucontrol's output devices tab sees 'Logitech H5703
> Stereo Analog Stereo and the port is Headphones. In the configuration tab
> the profile choices for the Logitech are: Analog Stereo Duplex (the
> default), Analog Stereo Output, Analog Stereo Input, and Off.
> 
> With the Mpow headset connected pavucontrol configuration has its profile as
> Analog Stereo Output + Analog Mono Input. The output devices tab uses the
> only available port: Analog Output.
> 
> How can I identify the source of this problem and fix it?

By default, new sound devices don't take over existing streams. In
pavucontrol under the playback tab, there should be a dropdown menu for
each client listing which card it is currently sending audio to. Try
starting a sound playback and switching its dropdown to the USB device.

Under the "output devices" tab, there is a checkmark button next to the
sound devices. This lets you specify which device is the default. It
won't force existing streams over to it, however, and it won't prevent
some clients from remembering their previous soundcard, so you may still
need to manually move some clients over to the new soundcard.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-01 Thread Sean Greenslade
On Sat, Jan 30, 2021 at 12:29:46PM +0100, Renaud GHIA wrote:
> Hi,
> 
> I use pulseaudio in a use case where the cpu usage is very high (30%) and
> IHMO this is not normal.
> I tried all the tricks to decrease the cpu load without success
> (resampling-method etc...). The cpu remains high.
> 
> My use case is simple. I redirect the sound output of an application to the
> sound input of another application (in this case ffmpeg). I load two
> modules to create my virtual audio cable like this:
> 
> pactl load-module module-null-sink sink_name=VAC_spk
> sink_properties=device.description=VAC
> 
> pactl load-module module-remap-source master=VAC_spk.monitor
> source_name=VAC1_mic source_properties=device.description=VAC
> 
> Everything works perfectly, except the cpu which is 30% for this simple use
> case.
> My cpu is a AMD threadripper and i'am with the latest stable release
> pulseaudio 14.2 freshly compiled,
> Do you know how to lower the CPU usage?

Have you made sure that everything in the chain is operating at the same
sample rate? That could be a cause of high CPU usage.

Also, I've seen high CPU usage on my setups when I have a large number
of pulse clients running and I open pavucontrol, since pavucontrol
creates a source output for every client in order to display its VU
meters.

If neither of those are the cause, can you share the output of the
command "pacmd list" when you're seeing high CPU usage? That might shed
additional light on what's happening in your setup.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Latency/lag with tcp tunnel

2021-01-29 Thread Sean Greenslade
On Fri, Jan 29, 2021 at 08:16:15AM -0600, Matt Garman wrote:
> Hi Matt and Sean, thank you so much for your help!  I was planning to
> try removing the Kali, but Sean's email pushed me to try it sooner
> than later.  I did just that last night, and now the lag is all but
> gone.  Using paplay directly on the RPI results in *immediate*
> playback, as soon as I hit enter (before there was a very noticeable
> delay).  VIdeos are once again watchable (using my PC for the monitor
> and as a pulseaudio client to the RPI server).  There's still a very
> tiny latency that is perceptible in some cases - but this is the same
> as what I experienced with the RPI 4 and different DAC/amp combo.
> This I can live with, though I might try to further tweak a bit to see
> if it can be completely eliminated.

Glad you were able to solve your issue! For small video sync issues, I
would look to your video player's settings. For example, smplayer has an
"autosync" feature that inspects the reported delay from the pulse chain
and tweaks the A/V sync to compensate. There's also a coarse sync adjust
with the +/- buttons (in 100 ms increments). I'm sure other video
players have similar features.

> A few somewhat off-topic comments below...
> 
> I think it is true that, for 44.1khz sample rates (and its multiples),
> indeed the RPI cannot exactly generate that clock, as it's master
> clock is not an integer multiple of that (looks like 19.2 MHz for RPI3
> and earlier, 54.0 MHz for RPI4).

This digs into some pretty deep details of microprocessor clocking, but
it does not need to be an exact integer multiple.

The Pi's clocking system uses something called a PLL, or Phase-Locked
Loop, to generate higher-speed clocks than the input reference clock.
Think of it as an integer multiplier; you give it 19.2 MHz, then it can
give you 2*19.2, or 3*19.2, or 43*19.2 (up to some maximum limit that
the hardware is capable of). Once you have your faster clock, it is
passed to an integer divider to get to the final clock speed you want.
This divider can be set to any integer value, thus you have a
"fractional" PLL. In this case, you want 2.8224 MHz from 19.2 MHz. Using
some least common multiple math, we get a multiplier of 147 and a
divider of 1000. 19.2 MHz * 147 = 2.8224 GHz / 1000 = 2.8224 MHz exactly.

Now, 2.8 GHz is pretty fast, so it may be the case that the Pi's PLLs
can't get to that speed. Without the full datasheet for the chip (which
Broadcom has refused to publically publish), I can't say for sure if the PLL
would tolerate a clock that fast. I did find an article [0] on
raspberrypi.org that mentions a PLL max of 3.2 GHz, so it may be OK.

Now, there may be any number of other reasons why the Pi specifically
can't do this (the most likely being that the PLLs and clock domains are
shared among a number of peripherals, so their frequencies may be fixed
or restricted), but I wanted to point out why the non-integer division
factor is not fundamentally a problem. 

> However, whether or not that makes a difference is dependent on the
> downstream component's ability to adapt.

And even if the clock is using an imperfect multiple, that generally
won't cause actual problems. If your 44.1 kHz audio is being fed out to
the DAC at 44.05 kHz, your audio will simply be reproduced a tiny bit
slower and lower-pitched than the original. You probably wouldn't even
notice it. Hell, TV broadcasts of 24 fps movies in PAL regions will
often times just play it back at 25 fps (though I would imagine anyone
with perfect pitch would be rather annoyed by this).

--Sean

[0]: https://hackspace.raspberrypi.org/articles/ultimate-overclocking
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Latency/lag with tcp tunnel

2021-01-28 Thread Sean Greenslade
On Wed, Jan 27, 2021 at 12:32:10PM -0600, Matt Feifarek wrote:
> On Tue, Jan 26, 2021 at 2:09 PM Matt Garman 
> wrote:
> 
> >
> > The ma12070p is a newish digital input (I2S) class D amplifier
> > (essentially, a "power DAC" or a DAC and amplifier in one chip).
> > Between the RPI and amp is an Allo Kali I2S reclocker.  I don't think
> > the Kali adds any meaningful latency, as I've used it extensively with
> > other I2S DACs, and never before noticed lag.
> 
> 
> I've got a Kali too; it's definitely a buffer; that's its design, I
> believe; essentially a FIFO buffer with good outgoing clocks. You can
> actually see an LED on the board that indicates whether the buffer is full,
> and see that it lags behind audio starting and flushing out. I get that you
> didn't hear a latency before, but I bet that the ma12070 ALSO has a buffer,
> and you're just seeing buffer + buffer + network add up to "perceptible".
> 
> That setup sounds cool, though! I might ask you more about it off list;
> I've been interested in using I2S with the PI, but have always been a bit
> spooked by the details.

I took a brief look into the Kali, and I have to say I'm extremely
skeptical of its benefits. Their marketing copy is full of ridiculous
claims like this:

>>> Furthermore, there are 2 kinds of frequencies for digital files:
>>> 44.1Khz (wave files) and 48khz (streamed music). Some SBCs (like
>>> RPIs) can output only 48Khz, so imagine the degradation of the sound
>>> that was recorded at a different frequency.

44.1 kHz and 48 kHz are just different sample rates, and are not
restricted to specific types of audio. And with a decent resampler,
there is no noticable "degredation of the sound" (though there is
additional latency).

They go on with other silly claims involving a "sea of digital mud"
which border on absurd, but I'll focus on the specific claim that "clock
jitter is bad on the Pi". Since the Allo website does not provide any
actual evidence of this, I had to go searching.

The first blog post I came across alleging clock jitter was this one:

http://www.dimdim.gr/2014/12/the-rasberry-pi-audio-out-through-i2s/

The author of this post uses one of those cheapo knockoff $10 Saleae
clones, sees some noise well within the sampling error, and declares it
"jittery". In my electrical engineering opinion, that test setup is
terrible and those results are meaningless.

Also, the author's claim about the crystal frequency not being an even
multiple of the target frequency is misleading. The Pi, like nearly all
high-speed microprocessors, has a host of fractional PLLs and dividers
for generating its various internal clocks. See:

https://elinux.org/The_Undocumented_Pi#Clocks

So I went on the hunt for a better analysis of the I2S outputs on the
Pi, and lo and behold, someone had a proper scope capture:

http://www.crazy-audio.com/2013/09/raspberry-pi-i2s-output-working/

Amusingly, this was posted over a year _before_ the dimdim.gr post. This
post's author claims to be getting 800 ps of jitter on a 2.822 MHz
clock. That comes out to a 0.2% deviation. I would be amazed if that
added any perceivable distortions to the output.

But wait, there's more. Since you're feeding the signal into an
MA12070P, let's take a look at what that does with its clocks
internally:

>>> The MA12070P incorporates a clock system consisting of an input
>>> clock divider, a PLL, a low-jitter low-TC oscillator (2.8224 MHz),
>>> and control logic. At the CLK input pin the MA12070P requires a
>>> clock signal that is in phase-lock with the incoming digital serial
>>> audio samples. This CLK input signal provides the reference for the
>>> internal PLL through the input clock divider circuit.

It has its own PLL and internal clock, so the incoming I2S signal isn't
even being used to directly clock the DAC output. Yes, having a very
jittery input to a PLL wouldn't be great, but PLLs can tolerate a fair
amount of it. This part didn't spec a jitter tolerance, but an app note
from Maxim claims they have DACs that will tolerate 12 ns(!) of jitter
with clock rates above 40 kHz:

https://www.maximintegrated.com/en/design/technical-documents/app-notes/5/5477.html


Wow, that was kind of a long tangent. Long story short, I would take
that reclocker out of the picture and try feeding your I2S signals
directly to the DAC. Use short connections, shielded if possible, since
I2S is not really meant to be used as a board-to-board protocol.

This may actually help your latency issues, since the Allo claims to
have a 0.7 second (!) buffer.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Latency/lag with tcp tunnel

2021-01-27 Thread Sean Greenslade
On Tue, Jan 26, 2021 at 03:37:02PM -0600, Matt Garman wrote:
> On Mon, Jan 25, 2021 at 10:58 PM Sean Greenslade
>  wrote:
> > As a data point, I routinely use networked TCP streams with pulse, and
> > on wired ethernet links I tend to see only ~50 ms of delay.
> >
> > One avenue to investigate is to see what pulseaudio thinks the latency
> > is. If you run the command "pactl list sink_inputs" on the device with
> > the sound card, you'll get something like this:
> >
> > [sean@bailey ~]$ pactl list sink-inputs
> > Sink Input #2
> > Driver: protocol-native.c
> > Owner Module: 9
> > Client: 17
> > Sink: 3
> > Sample Specification: float32le 2ch 48000Hz
> > Channel Map: front-left,front-right
> > Format: pcm, format.sample_format = "\"float32le\""  format.rate = 
> > "48000"  format.channels = "2"  format.channel_map = 
> > "\"front-left,front-right\""
> > Corked: no
> > Mute: no
> > Volume: front-left: 60293 /  92% / -2.17 dB,   front-right: 60293 / 
> >  92% / -2.17 dB
> > balance 0.00
> > Buffer Latency: 226791 usec
> > Sink Latency: 16780 usec
> > Resample method: speex-float-1
> >
> > Note the reported "Sink Latency" of ~16 ms (in my setup, I saw it vary
> > from 4 ms to 25 ms). What does your setup report? And what is the
> > reported latency of your audio device itself (pactl list sinks).
> 
> 
> Thank you for the suggestion.  Here are the two sink-inputs on the RPI
> server.  They are the tcp and unix domain sockets, respectively.  In
> both cases, the sink latency is around 10ms, which is roughly the same
> as you.  That's the "Sink Latency", is the "Buffer Latency" important?

Yes, the "Sink Latency" is the actual calculated latency that the sink
input is currently experiencing. The "Buffer Latency" is the size
(converted to time) of the buffer that pulseaudio is maintaining for the
application to write sound data into. Media sources that are able to
look ahead (like video players that are reading local files) can
maintain large buffers of future content so that they don't have to fill
them as frequently.

To answer your question directly, the buffer latency isn't really
important, you don't actually see that latency.

> root@dietpi-ma12070p:~# pactl list sink-inputs
> Sink Input #0
>Driver: protocol-native.c
>Owner Module: 7
>Client: 1
>Sink: 0
>Sample Specification: s32le 2ch 44100Hz
>Channel Map: front-left,front-right
>Format: pcm, format.sample_format = "\"s32le\""  format.rate =
> "44100"  format.channels = "2"  format.channel_map =
> "\"front-left,front-right\""
>Corked: yes
>Mute: no
>Volume: front-left: 65536 / 100% / 0.00 dB,   front-right:
> 65536 / 100% / 0.00 dB
>balance 0.00
>Buffer Latency: 139841 usec
>Sink Latency: 9718 usec
>Resample method: n/a
>Properties:
>media.name = "Built-in Audio for matt@sewage"
>media.role = "abstract"
>application.name = "pulseaudio"
>native-protocol.peer = "TCP/IP client from 10.18.51.34:46968"
>native-protocol.version = "34"
>application.id = "org.PulseAudio.PulseAudio"
>application.version = "14.0"
>application.process.id = "947578"
>application.process.user = "matt"
>application.process.host = "sewage"
>application.process.binary = "pulseaudio"
>application.language = "en_US.UTF-8"
>window.x11.display = ":0"
>application.process.machine_id =
> "31d757b445f140b1b50278a35a34a1e5"
>application.process.session_id = "2"
>module-stream-restore.id = "sink-input-by-media-role:abstract"
> 
> Sink Input #2
>Driver: protocol-native.c
>Owner Module: 6
>Client: 5
>Sink: 0
>Sample Specification: s16le 2ch 44100Hz
>Channel Map: front-left,front-right
>Format: pcm, format.sample_format = "\"s16le\""  format.rate =
> "44100"  format.channels = "2"  format.

Re: [pulseaudio-discuss] Latency/lag with tcp tunnel

2021-01-25 Thread Sean Greenslade
On Mon, Jan 25, 2021 at 07:33:56PM -0600, Matt Garman wrote:
> I am using a Raspberry Pi as a "sound server".  Essentially, the RPI
> is connected to the actual audio hardware.  The RPI advertises itself
> via module-native-protocol-tcp and module-zeroconf-publish.  My
> desktop/workstation in turn uses the RPI for playback via
> module-tunnel.
> 
> Everything seems to work as expected, except there is a noticeable lag
> between doing something on the PC, and having the audio "catch up" on
> the RPI.  For example, watching YouTube - the audio and video are out
> of sync to the point of being unwatchable.  Or using a simple audio
> player on the PC, hitting "play" or "stop", there is a noticeable
> delay from when the button is pressed to when the action actually
> takes effect.
> 
> I can't think of a good way to measure the lag, but I'm guessing it's
> around half to three fourths of a second.
> 
> To be clear, there are no stutters or skips or other audio artifacts.
> Playback is smooth and sounds as good as I expect - but the lag is a
> problem.
> 
> What's interesting is, this is actually the second RPI sound server
> I've built.  The first one had this lag, but to a much smaller degree,
> as in, barely noticeable.  The differences between the systems are:
> the first (barely noticeably lag) is an RPI 4, connected to a Topping
> D70 DAC.  The new system (with the obvious latency issue) is an RPI 3,
> connected to an MA12070P-based amplifier.  IOW, the RPI hardware and
> audio hardware are different.  But the network is the same, and the
> devices are all in the same physical location (i.e. same cable
> length).
> 
> The RPI 3 does have only 100mbps network, and the RPI 4 has gigabit.
> The rest of the network chain is all gigabit.  These are all hardwired
> networks (i.e. no wireless).  I feel like 100mbps is more than
> sufficient for CD-quality audio.  The RPI isn't running any other
> services or doing any other work.
> 
> Any thoughts on how I might track this down?  Or what config options I
> can play with to see if it improves the situation?  Also, as the RPI
> is headless, I can't think of a good way to determine if the latency
> is on the RPI itself, or comes from the network between the PC and
> RPI.

As a data point, I routinely use networked TCP streams with pulse, and
on wired ethernet links I tend to see only ~50 ms of delay.

One avenue to investigate is to see what pulseaudio thinks the latency
is. If you run the command "pactl list sink_inputs" on the device with
the sound card, you'll get something like this:

[sean@bailey ~]$ pactl list sink-inputs
Sink Input #2
Driver: protocol-native.c
Owner Module: 9
Client: 17
Sink: 3
Sample Specification: float32le 2ch 48000Hz
Channel Map: front-left,front-right
Format: pcm, format.sample_format = "\"float32le\""  format.rate = 
"48000"  format.channels = "2"  format.channel_map = 
"\"front-left,front-right\""
Corked: no
Mute: no
Volume: front-left: 60293 /  92% / -2.17 dB,   front-right: 60293 /  
92% / -2.17 dB
balance 0.00
Buffer Latency: 226791 usec
Sink Latency: 16780 usec
Resample method: speex-float-1

Note the reported "Sink Latency" of ~16 ms (in my setup, I saw it vary
from 4 ms to 25 ms). What does your setup report? And what is the
reported latency of your audio device itself (pactl list sinks).

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Unable to create SPDIF profile (VT1828S)

2021-01-23 Thread Sean Greenslade
On Mon, Jan 18, 2021 at 07:40:15PM +0530, stry...@hotmail.com wrote:
> Hi,
> 
> I have an onboard sound card which has an SPDIF output via motherboard
> header that I cannot get Pulseaudio to detect and manage.
> ALSA sees it, (https://i.imgur.com/p4TdEAl.png) and it works fine under
> Windows 10, though for some reason PA does not and instead lists a
> Digital HDMI Profile on the card (in pavucontrol) when there is no HDMI
> connector on the motherboard.
> 
> I have tried all the troubleshooting steps on the Arch linux wiki and
> then some: https://termbin.com/w9do
> alsa-info.sh log:
> http://alsa-project.org/db/?f=d4b7b6cbf6b3b83cc42cc209a38a62b598332b6b
> 
> The card name is (alsa_card.pci-_00_1b.0) and 'aplay -l' lists it
> as a VT1828S chip using the snd_hda_intel kmod.
> If I try to manually add it with 'set-card-profile', PA fails to start.
> 
> 
> Looking at termbin log, under "!!HDA-Intel Codec information" it shows:
> 
> Node 0x0d [Vendor Defined Widget] wcaps 0xf0: Mono
> Node 0x0e [Audio Output] wcaps 0x611: Stereo Digital
>   Control: name="IEC958 Playback Con Mask", index=0, device=0
>   Control: name="IEC958 Playback Pro Mask", index=0, device=0
>   Control: name="IEC958 Playback Default", index=0, device=0
>   Control: name="IEC958 Playback Switch", index=0, device=0
>   Control: name="IEC958 Default PCM Playback Switch", index=0, device=0
>   Device: name="VT1828S Digital", type="HDMI", device=3
>   Converter: stream=5, channel=0
>   Digital: Enabled GenLevel
>   Digital category: 0x2
>   IEC Coding Type: 0x0
>   PCM:
> rates [0x5e0]: 44100 48000 88200 96000 192000
> bits [0xe]: 16 20 24
> formats [0x1]: PCM
>   Power states:  D0 D1 D2 D3
>   Power: setting=D0, actual=D0
> Node 0x0f [Audio Output] wcaps 0x611: Stereo Digital
>   Converter: stream=5, channel=0
>   Digital: Enabled GenLevel
>   Digital category: 0x2
>   IEC Coding Type: 0x0
>   PCM:
> rates [0x5e0]: 44100 48000 88200 96000 192000
> bits [0xe]: 16 20 24
> formats [0x1]: PCM
>   Power states:  D0 D1 D2 D3
>   Power: setting=D0, actual=D0
> 
> I had managed to get this working a long time ago based on some tips
> from #archlinux, but since it was a bit buggy, I stuck with the analog
> line out and did not save that config sadly.
> It was definitely on a 4.x kernel if that makes any difference.
> 
> What am I missing here?

Can you share the output of "pactl list cards" when pulse is in control
of the motherboard sound device? It may just need the correct profile
selected.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Delayed muting of studio speakers

2020-12-27 Thread Sean Greenslade
On Tue, Dec 22, 2020 at 08:04:36PM -0700, Chris Mayes wrote:
> Yeah, I've had fewer issues since I've adjusted the output level.  The
> thread you cited seemed to indicate that it's a build quality issue, which
> may be, but I don't think that the signal breaks up due to faulty internal
> wiring.  I've had plenty of bad solders with audio equipment in my time, so
> I'd definitely recognize that sort of noise.
> 
> In this case, the speakers more-or-less cleanly stop responding for both
> drivers.  Once the signal reaches a certain threshold, the sound comes
> back, again fairly cleanly.
> 
> I'm reminded of my Nashville recording studio tour with Ohio University's
> chapter of the Audio Engineering Society ~1996: one of the engineers had a
> pair of KRKs (they have distinctively yellow woofer cones) that he
> demonstrated by blasting his latest studio session.  Maybe the manufacturer
> assumes that the average user will crank the volume, so they don't normally
> test the speakers at low signal levels?  I've managed to preserve my
> hearing thus far, so I prefer to keep things quiet.
> 
> It's a weird problem, but no more than a minor annoyance.  They still
> produce fantastically detailed sound, so it's hard to complain.

If you check the manual for these monitors, I think this would explain
the phenomenon you're experiencing:

> Standby
> 
> Your monitors have the ability to power down when you are not using them
> for 30 minutes. If you don’t want them doing that, you simply switch the
> standby feature off in the SETUP menu. But if you use standby to save
> energy or because the power switches are hard to reach in your studio,
> leave the standby on. You will know that they are in standby because the
> KRK logo will pulse (even if you normally have the KRK logo light off).
> 
> To wake up your monitors after they go into standby. Just like when you
> first turn them on, there is a three second delay until the light on the
> front comes on and a second later you get signal to the speaker. If your
> speakers go into standby, ease your source volume up slowly. You only
> have to break -50 dBu for them to come out of standby. This will keep
> you from excessive volume spikes if you ease it up slowly. Also, as you
> raise the volume, you can use the light going solid as an indication to
> turn your source back down to avoid any loud spikes. Or if your setting
> is KRK logo light out, you can use the pulsing light going off to
> indicate you are about a second from the speaker coming on.

Generally speaking, if you're hooking up devices that expect line-level
audio signals to a consumer PC audio card, you'll want to set the volume
level of the output to between 75 and 100%, then adjust the volume
controls on the speakers themselves to achieve a comfortable listening
volume. This will help reduce interference / cable noise as well.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Pulseaudio inside docker container

2020-12-11 Thread Sean Greenslade
On Wed, Dec 09, 2020 at 07:37:22AM +1300, Gino Lisignoli wrote:
> I've been trying to create a lightweight docker container that runs a
> single application with wine and xvfb, except the application requires
> pulseaudio otherwise it crashes. Specifically with the error:
> 
> Assertion 'clock_gettime(CLOCK_REALTIME, &ts) == 0' failed at
> pulsecore/core-rtclock.c:93, function pa_rtclock_get(). Aborting.
> 
> I'm using the following startup script:
> 
> /root/.config/pulse/default.pa
>   .include /etc/pulse/default.pa
>   load-module module-native-protocol-unix auth-anonymous=1
> socket=/tmp/pulse-socket
> 
> Then starting pulseaudio with:
> pulseaudio -v --start --log-target=file:/root/pulse.log
> 
> One line that seems relevant to me is:
> I: [null-sink] util.c: Failed to acquire real-time scheduling:
> Input/output error
> 
> That's as far as I have gotten. If  there any ideas on how I could
> troubleshoot this that would be awesome. Thanks!

Not being someone who uses docker, all I can do is give you some general
hints at places to look.

clock_gettime() returning an error is pretty weird. CLOCK_REALTIME is
supposed to always be available, and the vast majority of possible
errors are related only to settime, not gettime. My guess would be that
docker is doing something weird and breaking the clock_gettime syscall
somehow. A quick google didn't turn up anything relevant, so this may be
a question for a docker support forum.

The line you mentioned in the logs:

> I: [null-sink] util.c: Failed to acquire real-time scheduling:

Is not relevent to this issue. It's referring to getting high-priority
"real-time" scheduling from the CPU scheduler. The assert fail is about
reading the wall clock time of the computer. The scheduling warning will
not hurt anything, real-time scheduling is not required for Pulse to
work.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] PulseAudio is not working properly

2020-10-20 Thread Sean Greenslade
On Sun, Oct 18, 2020 at 10:52:07AM +0200, BaBa wrote:
> 
> >This question is probably better suited for a Debian forum, as it seems
> >to more be an issue of how your environment is set up.
> 
> I already asked at the Debian ML and forum but I got no solution.
> 
> >That said, I have
> >a suspicion that you may have enabled system daemon mode.
> 
> Do you mean set daemonize = yes in /etc/daemon.conf?
> If that case, I did not touch anything (default value is "; daemonize = no").
> 
> >Did you
> >manually add or enable any services after installing pulseaudio?
> 
> Yes I installed and enabled a personal service but not related to PulseAudio.

OK, then I would suggest doing the following to investigate:

Reboot your machine to start everything fresh. By default, pulse should
not be running, but it is supposed to auto-launch the first time
something tries to access it (triggered via the pulseaudio.socket
systemd unit).

Launch "pavucontrol" to trigger the pulseaudio auto-spawn. Look through
pavucontrol and see if it's detecting your sound cards correctly. Also
you can check that pulse is correctly running under your user:

$ ps aux | grep [p]ulseaudio

The first column of the result should be your username.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] PulseAudio is not working properly

2020-10-17 Thread Sean Greenslade
On Wed, Oct 14, 2020 at 01:38:48PM +0200, BaBa wrote:
> Hello,
> 
> I installed PulseAudio without specific configuration.
> In Firefox it uses Alsa instead of PulseAudio and in media players it does 
> not work.
> 
> If I do
> killall pulseaudio
> pulseaudio --start
> Works in Firefox and media players.
> My user and pulse user are in the "audio" group.
> 
> sudo grep "pulseaudio" /var/log/syslog
> Oct  7 10:09:32 debian systemd[669]: Not generating service for XDG autostart 
> app-pulseaudio-autostart.service, startup phases are not supported.
> Oct  7 10:10:20 debian pulseaudio[671]: E: [alsa-sink-ALC898 Analog] 
> alsa-sink.c: Error opening PCM device front:0: Aucun fichier ou dossier de ce 
> type
> Oct  7 10:10:20 debian systemd[735]: Not generating service for XDG autostart 
> app-pulseaudio-autostart.service, startup phases are not supported.
> Oct  7 10:10:20 debian systemd[651]: pulseaudio.service: Succeeded.
> Oct  7 10:10:22 debian pulseaudio[737]: W: [pulseaudio] authkey.c: Failed to 
> open cookie file '/home/tupo/.config/pulse/cookie': Aucun fichier ou dossier 
> de ce type
> Oct  7 10:10:22 debian pulseaudio[737]: W: [pulseaudio] authkey.c: Failed to 
> load authentication key '/home/tupo/.config/pulse/cookie': Aucun fichier ou 
> dossier de ce type
> Oct  7 10:10:30 debian systemd[651]: pulseaudio.socket: Succeeded.

This question is probably better suited for a Debian forum, as it seems
to more be an issue of how your environment is set up. That said, I have
a suspicion that you may have enabled system daemon mode. Did you
manually add or enable any services after installing pulseaudio?

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] How to create a virtual microphone with source set as default monitor device?

2020-09-28 Thread Sean Greenslade
On Tue, Sep 22, 2020 at 06:29:05AM -0700, guest271314 wrote:
> > Point Espeak's output to the "Feed Espeak" sink, and point your
> recording application at the "ESpeak output virtual mic".
> 
> What is meant by "point" here? How to do that?

It depends on the application. Most applications that use the pulse APIs
will offer some sort of selection box or drop-down for this. Otherwise
you may need to use pavucontrol / pacmd / your own app that interacts
with the pulse API.

> Were you able to successfully carry out the procedure yourself?

Yes, everything I listed in my previous email was tested on my Arch
setup.

> What would be ideal is to be able to control pavucontrol -t 2 GTK or
> Qt page from HTML.
> 
> Where in pavucontrol source code is Recording tab implemented?

https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/blob/master/src/mainwindow.cc

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] How to create a virtual microphone with source set as default monitor device?

2020-09-15 Thread Sean Greenslade
On Sun, Sep 13, 2020 at 05:18:23PM +, guest271314 wrote:
> This project started attempting to capture the output of
> window.speechSynthesis.speak().
> 
> Consider https://stackoverflow.com/a/43553706.
> 
> If run $ pacmd list-sink-inputs will get
> 
> index: 219
> driver: 
> flags:
> state: RUNNING
> sink: 4 
> volume: mono: 64460 /  98% / -0.43 dB
> balance 0.00
> muted: no
> current latency: 0.00 ms
> requested latency: 0.59 ms
> sample spec: s16le 1ch 22050Hz
> channel map: mono
>  Mono
> resample method: speex-float-1
> module: 14
> client: 192 
> properties:
> media.name = "playback"
> application.name = "speech-dispatcher-espeak-ng"
> native-protocol.peer = "UNIX socket client"
> native-protocol.version = "33"
> application.process.id = "45464"
> application.process.user = "ubuntu-studio"
> application.process.host = "ubuntu-studio"
> application.process.binary = "sd_espeak-ng"
> application.language = "C"
> window.x11.display = ":0.0"
> application.process.machine_id = ""
> application.process.session_id = ""
> module-stream-restore.id =
> "sink-input-by-application-name:speech-dispatcher-espeak-ng"
> 
> $ pacmd list-sources
> 
> 2 source(s) available.
>   * index: 4
> name: 
> driver: 
> flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
> DYNAMIC_LATENCY
> state: RUNNING
> suspend cause: (none)
> priority: 9040
> volume: mono: 0 /   0% / -inf dB
> balance 0.00
> base volume: 20724 /  32% / -30.00 dB
> volume steps: 65537
> muted: yes
> current latency: 4.60 ms
> max rewind: 0 KiB
> sample spec: s16le 1ch 48000Hz
> channel map: mono
>  Mono
> used by: 1
> linked by: 1
> configured latency: 40.00 ms; range is 0.50 .. 2000.00 ms
> card: 1 
> module: 8
> properties:
> alsa.resolution_bits = "16"
> device.api = "alsa"
> device.class = "sound"
> alsa.class = "generic"
> alsa.subclass = "generic-mix"
> alsa.name = "USB Audio"
> alsa.id = "USB Audio"
> alsa.subdevice = "0"
> alsa.subdevice_name = "subdevice #0"
> alsa.device = "0"
> alsa.card = "1"
> alsa.card_name = "USB Device 0x46d:0x804"
> alsa.long_card_name = "USB Device 0x46d:0x804 at
> usb-:00:12.0-1.4, high speed"
> alsa.driver_name = "snd_usb_audio"
> device.bus_path = "pci-:00:12.0-usb-0:1.4:1.2"
> sysfs.path =
> "/devices/pci:00/:00:12.0/usb1/1-1/1-1.4/1-1.4:1.2/sound/card1"
> udev.id = "usb-046d_0804_0B17FC60-02"
> device.bus = "usb"
> device.vendor.id = "046d"
> device.vendor.name = ""
> device.product.id = "0804"
> device.product.name = ""
> device.serial = "046d_0804_0B17FC60"
> device.form_factor = "webcam"
> device.string = "hw:1"
> device.buffering.buffer_size = "192000"
> device.buffering.fragment_size = "96000"
> device.access_mode = "mmap+timer"
> device.profile.name = "mono-fallback"
> device.profile.description = "Mono"
> device.description = ""
> module-udev-detect.discovered = "1"
> device.icon_name = "camera-web-usb"
> ports:
> analog-input-mic: Microphone (priority 8700, latency offset 0
> usec, available: unknown)
> properties:
> device.icon_name = "audio-input-microphone"
> active port: 
> 
> One part of what am trying to do is create a virtual microphone that
> takes input from speech-dispatcher-espeak-ng persistently or route
> output from speech-dispatcher-espeak-ng to the microphone, so that
> when capture the microphone the output will be from speech-dispatcher.
> How to achieve that?

$ pacmd load-module module-null-sink sink_name=feed_espeak_to_me
$ pacmd update-sink-proplist feed_espeak_to_me device.description="\"Feed 
Espeak\""
$ pacmd update-source-proplist virtual_mic_espeak_output 
device.description="\"ESpeak output virtual mic\""

Point Espeak's output to the "Feed Espeak" sink, and point your
recording application at the "ESpeak output virtual mic".

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] How to create a virtual microphone with source set as default monitor device?

2020-09-08 Thread Sean Greenslade
On Mon, Sep 07, 2020 at 05:03:59PM -0700, guest271314 wrote:
> > I doubt that will be possible. Pavucontrol makes use of the native
> > pulseaudio APIs, which are not exposed to javascript.
> 
> If mpv can be embedded in an HTML document
> https://github.com/Kagami/mpv.js it should be possible to embed
> pavucontrol or pavucontrol-qt
> (https://doc.qt.io/qt-5/qtwebchannel-javascript.html ;
> https://medium.com/@petar.koretic/why-you-should-use-qt-qml-for-you-next-cross-platform-application-part-1-desktop-5e6d8856b7b4)
> in particular in a browser; for example using WebAssembly; WASI;
> Native Messaging; at least the ability to control Recording tab (-t 2)
> from JavaScript or an HTML form.

Electron is a whole separate discussion. Electron applications have
different levels of access to the system than the vanilla chromium
browser.

> > After reading through those bug reports and related issue links, it's
> > pretty clear that this is not a use case that they are particularly
> > interested in supporting.
> 
> The majority of own repositories at github are dedicated to fixing
> WontFix; supporting SSML parsing; variable width and height video
> capture with ability to merge multiple tracks into a single media
> container, or stream media without a container; streaming audio
> potentially infinite input streams, that is, a dynamic Internet radio
> station; capturing speech synthesis output from Web Speech API, which
> is the origin of this use case of capturing system audio output.
> 
> > May I perhaps suggest using a different
> > browser?  Firefox had no problem with monitor inputs last time I
> > checked.
> 
> Interestingly, am completing testing of another workaround where since
> Firefox does capture monitor devices, a new, dedicated instance of
> Nightly is started prior to launching Chromium, the MediaStreamTrack
> and MediaStream therefrom are added to a WebRTC RTCPeerConnection, and
> currently using clipboard for signaling which is not ideal though is
> one way to exchange text data between different browsers, accessing
> the monitor device at Chromium instance generated at Nightly
> https://gist.github.com/guest271314/04a539c00926e15905b86d05138c113c.
> That approach avoids writing and reading raw PCM to memory.

With the amount of work you're seeming to have put into workarounds,
maybe you would be better off writing a proper native application?

> > No idea, I've never done it myself. The example listed in the online
> > docs shows a simple stereo swap, so you could presumably adapt it by
> > switching the channels to be non-swapped (and of course substitute your
> > specific master source name).
> 
> Not sure precisely how to begin.
> 
> Am still trying to gather the specific commands in code that
> pavucontrol uses when setting the stream at the UI. Am not certain
> what to pass to pactl move-source-output at what time
> https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/issues/91#note_590795.

If you read the documentation (e.g. man pactl), it seems pretty
straightforward:

> move-source-output ID SOURCE
>  Move the specified recording stream (identified by its numerical index) 
> to the specified source (identified by its symbolic name or numerical index).

So you need to find the specific source output index (ID) and your new
target source (SOURCE). I started an audacity session recording my
microphone, and ran the "pactl list source-outputs" command. This gave
me the index. I then ran the "pactl list sources" to find my target
source name. The switch command (for my setup) then looked like this:

> pactl move-source-output 203 pulse_send_nofx.monitor

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] How to create a virtual microphone with source set as default monitor device?

2020-09-07 Thread Sean Greenslade
On Mon, Sep 07, 2020 at 12:31:22AM -0700, guest271314 wrote:
> > There are a couple of options. One is to simply redirect the sink input
> > once it is opened (e.g. with pavucontrol).
> 
> That option is used at
> https://github.com/guest271314/captureSystemAudio#launch_pavucontrol.
> 
> For the pavucontrol option the next goal is to embed pavucontrol in an
> HTML document.

I doubt that will be possible. Pavucontrol makes use of the native
pulseaudio APIs, which are not exposed to javascript.

> > If you really need a non-monitor source device to be present, I think
> > your best option would be module-remap-source. It shouldn't be too hard
> > to come up with a "remap" that's just a passthrough:
> >
> > https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#module-remap-source
> 
> Chromium is expecting a microphone device. Currently if a monitor is
> set at command line the capture throws an exception, see
> https://bugs.chromium.org/p/chromium/issues/detail?id=931749.

After reading through those bug reports and related issue links, it's
pretty clear that this is not a use case that they are particularly
interested in supporting. May I perhaps suggest using a different
browser?  Firefox had no problem with monitor inputs last time I
checked.

> Have so far tried kernel module and null-sink without achieving
> capture of system audio.
> 
> What is the command for the remap option for this case?

No idea, I've never done it myself. The example listed in the online
docs shows a simple stereo swap, so you could presumably adapt it by
switching the channels to be non-swapped (and of course substitute your
specific master source name).

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#module-remap-source

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] How to create a virtual microphone with source set as default monitor device?

2020-09-06 Thread Sean Greenslade
On Sat, Sep 05, 2020 at 09:10:36AM -0700, guest271314 wrote:
> Chromium browser does not support capture of monitor devices when
> navigator.mediaDevices.getUserMedia() is called. Chromium only
> supports capture of non-monitor microphone input devices.
> 
> How to create a virtual microphone with source set as default monitor
> device so that Chromium browser recognizes the virtual device as a
> microphone while the source input for the microphone is the default
> monitor?

There are a couple of options. One is to simply redirect the sink input
once it is opened (e.g. with pavucontrol).

If you really need a non-monitor source device to be present, I think
your best option would be module-remap-source. It shouldn't be too hard
to come up with a "remap" that's just a passthrough:

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#module-remap-source

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


  1   2   >