Pulseaudio Choppy Playback (also slowed down)

Started by aaronegger, 27 Jun '22 - 18:39

aaronegger

Hi there,

i have an issue with bass in combination with pulseaudio (12.2) and raspbian on a raspberry pi model 3b+.
Since the application needs to be started after booting pulseaudio runs in system mode.
Therefore a unit file for the service has been created:

Description=PulseAudio system server

[Service]
Type=notify
ExecStart=/usr/bin/pulseaudio --daemonize=no -vvvv --high-priority --system --disallow-exit --no-cpu-limit --log-target=journal
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
Nice=-11
CPUSchedulingPolicy=rr
CPUSchedulingPriority=90
IOSchedulingClass=realtime
IOSchedulingPriority=0

[Install]
WantedBy=multi-user.target" > /etc/systemd/system/pulseaudio.service

And pulseaudio reconfigured to not autospawn:
/etc/pulse/client.conf

default-server = /var/run/pulse/native
autospawn = no


Normally we use the usb card, which works most of the time good.
But the issue is that it is only most of the time.
The issue occurs immedialty on the onboard chip.

The sound get choppy (stuttering) and the playback seems to be slower. It is like a distorted slow motion playback.

As soon as try to play an audio file with the vlc the slow motion effects disappears. And after a while the playback is nearly normal.
But if restart the pulseaudio service this issue occurs again.
On some devices this issue occurs on the usb soundchip after several hours. At this period of time (about 30min) the playback is also reported as stalled by bass.

I have tried a lot of things like setting the BASS_CONFIG_DEV_BUFFER to 150, BASS_CONFIG_BUFFER to 1000 (prior Bass_init).
Editing the /etc/pulse/daemon.conf file by adjusting the default-fragemnts, default-fragment-size-msec.
Adjusting the Nice, CPUSchedulingPolicy, CPUSchedulingPriority, IOSchedulingClass and IOSchedulingPriority values at the service unit files (the audioplaying software using bass is also managed by systemd).

I googled a lot. Looked through the issues at the pulseaudio project and tried the recommendations of several users.
But nothing changed a thing.
The next thing we will try would be to remove pulseaudio completely. But i am not sure about the sideeffects this could cause.

But maybe anybody already had similar issues with bass and/or pulseaudio on a raspberry pi and could help.
i appreciate any help you can give me

Best wishes
Aaron

aaronegger

Pulseaudio reports following devices:

Sink #1
        State: SUSPENDED
        Name: alsa_output.platform-bcm2835_audio.analog-stereo
        Description: Built-in Audio Analog Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 5
        Mute: no
        Volume: front-left: 9830 /  15% / -49.44 dB,   front-right: 9830 /  15% / -49.44 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.platform-bcm2835_audio.analog-stereo.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "bcm2835 Headphones"
                alsa.id = "bcm2835 Headphones"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "2"
                alsa.card_name = "bcm2835 Headphones"
                alsa.long_card_name = "bcm2835 Headphones"
                alsa.driver_name = "snd_bcm2835"
                device.bus_path = "platform-bcm2835_audio"
                sysfs.path = "/devices/platform/soc/3f00b840.mailbox/bcm2835_audio/sound/card2"
                device.form_factor = "internal"
                device.string = "hw:2"
                device.buffering.buffer_size = "131072"
                device.buffering.fragment_size = "131072"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "Built-in Audio Analog Stereo"
                alsa.mixer_name = "Broadcom Mixer"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
        Ports:
                analog-output: Analog Output (priority: 9900)
        Active Port: analog-output
        Formats:
                pcm

Sink #2
        State: RUNNING
        Name: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo
        Description: Audio Adapter (Unitek Y-247A) Analog Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 6
        Mute: no
        Volume: front-left: 52428 /  80% / -5.81 dB,   front-right: 52428 /  80% / -5.81 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo.monitor
        Latency: 118675 usec, configured 126000 usec
        Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
        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 Audio Device"
                alsa.long_card_name = "C-Media Electronics Inc. USB Audio Device at usb-3f980000.usb-1.4, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "platform-3f980000.usb-usb-0:1.4:1.0"
                sysfs.path = "/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4: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 = "front:1"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "Audio Adapter (Unitek Y-247A) Analog Stereo"
                alsa.mixer_name = "USB Mixer"
                alsa.components = "USB0d8c:0014"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        Ports:
                analog-output-speaker: Speakers (priority: 10000)
        Active Port: analog-output-speaker
        Formats:
                pcm

aaronegger

Pulseaudio log when playing using the onboard audio chip (while the sound is stuttering)

pulseaudio[2476]: memblockq requested: maxlength=4194304, tlength=0, base=4, prebuf=1, minreq=0 maxrewind=0
pulseaudio[2476]: memblockq sanitized: maxlength=4194304, tlength=4194304, base=4, prebuf=4, minreq=4 maxrewind=0
pulseaudio[2476]: Final latency 80,00 ms = 40,00 ms + 40,00 ms
pulseaudio[2476]: Latency set to 26,00ms
pulseaudio[2476]: hwbuf_unused=126488
pulseaudio[2476]: setting avail_min=32416
pulseaudio[2476]: Latency set to 26,00ms
pulseaudio[2476]: hwbuf_unused=126488
pulseaudio[2476]: setting avail_min=32416
pulseaudio[2476]: Wakeup from ALSA!
pulseaudio[2476]: Underrun!
pulseaudio[2476]: Increasing wakeup watermark to 15,99 ms
pulseaudio[2476]: Underrun!
pulseaudio[2476]: Increasing minimal latency to 36,00 ms
pulseaudio[2476]: Latency set to 36,00ms
pulseaudio[2476]: hwbuf_unused=124724
pulseaudio[2476]: setting avail_min=32064
pulseaudio[2476]: Latency set to 36,00ms
pulseaudio[2476]: hwbuf_unused=124724
pulseaudio[2476]: setting avail_min=32064
pulseaudio[2476]: Requesting rewind due to corking
pulseaudio[2476]: Requested to rewind 6348 bytes.
pulseaudio[2476]: Limited to 6092 bytes.
pulseaudio[2476]: before: 1523
pulseaudio[2476]: after: 0
pulseaudio[2476]: Tried rewind, but was apparently not possible.
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 1832 bytes ago (4516 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 1832 bytes ago (4516 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 5292 bytes ago (1056 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 5292 bytes ago (1056 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 5292 bytes ago (1056 bytes ahead in playback buffer)
pulseaudio[2476]: Underrun!
pulseaudio[2476]: Increasing wakeup watermark to 25,99 ms
pulseaudio[2476]: Requesting rewind due to end of underrun.
pulseaudio[2476]: Requested to rewind 6348 bytes.
pulseaudio[2476]: Limited to 6092 bytes.
pulseaudio[2476]: before: 1523
pulseaudio[2476]: after: 0
pulseaudio[2476]: Tried rewind, but was apparently not possible.
pulseaudio[2476]: Requesting rewind due to end of underrun.
pulseaudio[2476]: Requested to rewind 6348 bytes.
pulseaudio[2476]: Limited to 6092 bytes.
pulseaudio[2476]: before: 1523
pulseaudio[2476]: after: 0
pulseaudio[2476]: Tried rewind, but was apparently not possible.
pulseaudio[2476]: Wakeup from ALSA!
pulseaudio[2476]: Implicit underrun of 'ALSA Playback'
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 24 bytes ago (6324 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 24 bytes ago (6324 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 24 bytes ago (6324 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 1788 bytes ago (4560 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 1788 bytes ago (4560 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 1788 bytes ago (4560 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 3552 bytes ago (2796 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 5316 bytes ago (1032 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 5316 bytes ago (1032 bytes ahead in playback buffer)
pulseaudio[2476]: Requesting rewind due to end of underrun.
pulseaudio[2476]: Requesting rewind due to uncorking
pulseaudio[2476]: Requested to rewind 6348 bytes.
pulseaudio[2476]: Limited to 6092 bytes.
pulseaudio[2476]: before: 1523
pulseaudio[2476]: after: 0
pulseaudio[2476]: Tried rewind, but was apparently not possible.
pulseaudio[2476]: Requesting rewind due to corking
pulseaudio[2476]: Requested to rewind 6348 bytes.
pulseaudio[2476]: Limited to 6092 bytes.
pulseaudio[2476]: before: 1523
pulseaudio[2476]: after: 0
pulseaudio[2476]: Tried rewind, but was apparently not possible.
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 1816 bytes ago (4532 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 1816 bytes ago (4532 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 3652 bytes ago (2696 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 5296 bytes ago (1052 bytes ahead in playback buffer)
pulseaudio[2476]: alsa_output.platform-bcm2835_audio.analog-stereo: Found underrun 5296 bytes ago (1052 bytes ahead in playback buffer)
pulseaudio[2476]: Requesting rewind due to end of underrun.
pulseaudio[2476]: Requesting rewind due to uncorking
pulseaudio[2476]: Requested to rewind 6348 bytes.
pulseaudio[2476]: Limited to 6092 bytes.
pulseaudio[2476]: before: 1523
pulseaudio[2476]: after: 0
pulseaudio[2476]: Tried rewind, but was apparently not possible.
pulseaudio[2476]: Wakeup from ALSA!

aaronegger

Pulseaudio log when playing using the usb audio chip (while the sound is stuttering)

pulseaudio[457]: hwbuf_unused=332340
pulseaudio[457]: setting avail_min=83968
pulseaudio[457]: Requesting rewind due to latency change.
pulseaudio[457]: Requested volume: front-left: 52428 /  80% / -5.81 dB,   front-right: 52428 /  80% / -5.81 dB
pulseaudio[457]: Got hardware volume: front-left: 54094 /  83% / -5.00 dB,   front-right: 54094 /  83% / -5.00 dB
pulseaudio[457]: Calculated software volume: front-left: 63518 /  97% / -0.81 dB,   front-right: 63518 /  97% / -0.81 dB (accurate-enough=no)
pulseaudio[457]: Volume not changing
pulseaudio[457]: Requested to rewind 352800 bytes.
pulseaudio[457]: Limited to 351488 bytes.
pulseaudio[457]: before: 87872
pulseaudio[457]: after: 87872
pulseaudio[457]: Rewound 351488 bytes.
pulseaudio[457]: Processing rewind...
pulseaudio[457]: latency = 3515
pulseaudio[457]: Have to rewind 351488 bytes on render memblockq.
pulseaudio[457]: Processing rewind...
pulseaudio[457]: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo: state: IDLE -> RUNNING
pulseaudio[457]: Requesting rewind due to end of underrun.
pulseaudio[457]: Requested to rewind 20460 bytes.
pulseaudio[457]: Limited to 19148 bytes.
pulseaudio[457]: before: 4787
pulseaudio[457]: after: 4787
pulseaudio[457]: Rewound 19148 bytes.
pulseaudio[457]: Processing rewind...
pulseaudio[457]: latency = 7463
pulseaudio[457]: Have to rewind 19148 bytes on render memblockq.
pulseaudio[457]: Processing rewind...
pulseaudio[457]: Implicit underrun of 'ALSA Playback'
pulseaudio[457]: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo: Found underrun 14912 bytes ago (5548 bytes ahead in playback buffer)
pulseaudio[457]: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo: Found underrun 14912 bytes ago (5548 bytes ahead in playback buffer)
[...]
pulseaudio[457]: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo: Found underrun 17032 bytes ago (2372 bytes ahead in playback buffer)
pulseaudio[457]: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo: Found underrun 17032 bytes ago (2372 bytes ahead in playback buffer)
pulseaudio[457]: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo: Found underrun 17032 bytes ago (2372 bytes ahead in playback buffer)
pulseaudio[457]: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo: Found underrun 17032 bytes ago (2372 bytes ahead in playback buffer)
pulseaudio[457]: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo: Found underrun 17032 bytes ago (2372 bytes ahead in playback buffer)
pulseaudio[457]: Sink alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo becomes idle, timeout in 5 seconds.
pulseaudio[457]: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo: Found underrun 17032 bytes ago (2372 bytes ahead in playback buffer)
pulseaudio[457]: hwbuf_unused=0
pulseaudio[457]: setting avail_min=83968
pulseaudio[457]: Requested volume: front-left: 52428 /  80% / -5.81 dB,   front-right: 52428 /  80% / -5.81 dB
pulseaudio[457]: Got hardware volume: front-left: 54094 /  83% / -5.00 dB,   front-right: 54094 /  83% / -5.00 dB
pulseaudio[457]: Calculated software volume: front-left: 63518 /  97% / -0.81 dB,   front-right: 63518 /  97% / -0.81 dB (accurate-enough=no)
pulseaudio[457]: Volume not changing
pulseaudio[457]: Requested to rewind 352800 bytes.
pulseaudio[457]: Limited to 19148 bytes.
pulseaudio[457]: before: 4787
pulseaudio[457]: after: 4787
pulseaudio[457]: Rewound 19148 bytes.
pulseaudio[457]: Processing rewind...
pulseaudio[457]: latency = 4130
pulseaudio[457]: Processing rewind...
pulseaudio[457]: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo: state: RUNNING -> IDLE
pulseaudio[457]: Sink alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo becomes idle, timeout in 5 seconds.
pulseaudio[457]: Hmm, no streams around, trying to vacuum.
pulseaudio[457]: Freeing input 2686 "ALSA Playback"
pulseaudio[457]: Negotiated format: pcm, format.sample_format = "\"float32le\""  format.rate = "44100"  format.channels = "2"  format.channel_map = "\"front-left,front-right\""
pulseaudio[457]: Trying to change sample rate
pulseaudio[457]: Sink alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo becomes busy, resuming.
pulseaudio[457]: Sink alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo becomes idle, timeout in 5 seconds.
pulseaudio[457]: Forcing resampler 'copy', because of fixed, identical sample rates.
pulseaudio[457]: Resampler:
pulseaudio[457]:   rate 44100 -> 44100 (method copy)
pulseaudio[457]:   format float32le -> s16le (intermediate s16le)
pulseaudio[457]:   channels 2 -> 2 (resampling 2)
pulseaudio[457]: memblockq requested: maxlength=33554432, tlength=0, base=4, prebuf=0, minreq=1 maxrewind=0
pulseaudio[457]: memblockq sanitized: maxlength=33554432, tlength=33554432, base=4, prebuf=0, minreq=4 maxrewind=0
pulseaudio[457]: Created input 2687 "ALSA Playback" on alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo with sample spec float32le 2ch 44100Hz and channel map front-left,front-right
pulseaudio[457]:     media.name = "ALSA Playback"
pulseaudio[457]:     application.name = "ALSA plug-in [audioplayer]"
pulseaudio[457]:     native-protocol.peer = "UNIX socket client"
pulseaudio[457]:     native-protocol.version = "32"
pulseaudio[457]:     application.process.id = "677"
pulseaudio[457]:     application.process.user = "audioplayer"
pulseaudio[457]:     application.process.host = "e27-EC-86-6A-40"
pulseaudio[457]:     application.process.binary = "audioplayer"
pulseaudio[457]:     application.language = "C"
pulseaudio[457]:     application.process.machine_id = "51149e1e30c0416c8c6ebf5d3e0bf457"
pulseaudio[457]:     module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [audioplayer]"
pulseaudio[457]: Requested tlength=40.00 ms, minreq=10.00 ms
pulseaudio[457]: Early requests mode enabled, configuring sink latency to minreq.
pulseaudio[457]: Could not configure a sufficiently low latency. Early requests might not be satisifed.
pulseaudio[457]: Requested latency=10.00 ms, Received latency=116.00 ms
pulseaudio[457]: memblockq requested: maxlength=4194304, tlength=47984, base=8, prebuf=10584, minreq=3528 maxrewind=0
pulseaudio[457]: memblockq sanitized: maxlength=4194304, tlength=47984, base=8, prebuf=10584, minreq=3528 maxrewind=0
pulseaudio[457]: Final latency 252.01 ms = 116.01 ms + 2*10.00 ms + 116.00 ms

Ian @ un4seen

Please confirm what BASS version is currently being used (with BASS_GetVersion), and whether it's hardfp or aarch64. Here also is the latest build that you could try:

   www.un4seen.com/stuff/bass-linux-arm.zip

Regarding removing PulseAudio, it should usually be possible to just not use it without having to totally remove it, by simply changing the "device" parameter in your BASS_Init call. So long as nothing else is using PulseAudio at the time, that should work fine. The first hardware "hw" device (if there are any) is at number 2. If you have multiple devices then you can use BASS_GetDeviceInfo to enumerate them and find the one you want.

aaronegger

Hi Ian,

thank you for answering  :)

The bass version is 2.4.16.11 and bass fx has the version 2.4.12.5.
Both are hardfp.
I got the last bass version at the end of december 2021 to fix an volume issue, where system volume changes were not detected if changed externally.
But i will try with the current version.

I know that this issue could have a ton of different reasons with most of them not caused by bass, but maybe you already saw a similiar situations and found possible solutions for that.

We found some things that could caused these buffer underruns, but since we don't know the actual reason we are just poking around and keep observating if the issue occurs again.

Do you have any idea what could cause buffer underuns? Or is the buffer underrun the main issue or just an issue caused by another issue?
The only thing i found about buffer underun is that the input buffer is not filled fast enough for a smooth playback. But i have no clue what could cause this..

We suspected that the sd card of the pi is overloaded or that the files are written and read from the swap instead the ram which maybe cause issues like that.
But only time will tell if this was indeed the root or one of the issues that caused this.

So if you have any idea, also ideas that not belong to bass, please let me know.
I would appreciate it very much.




Ian @ un4seen

No, I'm not sure what would be causing the problem, but to perhaps narrow it down please see if you can reproduce it with ALSA alone (no PulseAudio) and also the examples from the Linux BASS package. To build the examples, you should replace the makefile.in file with the one from the ARM Linux package. The CONTEST example includes a device selection option, so you could also use that to try ALSA alone.

aaronegger

#7
Sorry for the late answer, but we have been testing our application over various devices (Radxa Rockpi 3a and 4se).
On the raspberry pi model 3b alsa playback using the internal soundchip didn't work at all.
But since we are using an usb soundcard that works stable with pulseaudio we can live with this.

The Rockpi 3a and 4se have far better audiochips and therefore they do not need an usb soundcard.

But here comes the next issue. The Rockpi 3a has the exact same issue as the rasppi model 3b.
The sound start to stutter auf several hours (pretty random) and pulseaudio logs a lot of freed and recreated sinks. Within a few hours over 10 million streams are freed and created.
The following snippet is logged like in a loop:
Quote13:32:48 DEV pulseaudio[275035]: Freeing input 1004305 "ALSA Playback"
13:32:48 DEV pulseaudio[275035]: Negotiated format: pcm, format.sample_format = ""float32le""  format.rate = "44100"  format.channels = "2"  format.channel_map = ""front-left,front-right""
13:32:48 DEV pulseaudio[275035]: Trying to change sample spec
13:32:48 DEV pulseaudio[275035]: Sink alsa_output.platform-rk809-sound.stereo-fallback becomes busy, resuming.
13:32:48 DEV pulseaudio[275035]: Sink alsa_output.platform-rk809-sound.stereo-fallback becomes idle, timeout in 5 seconds.
13:32:48 DEV pulseaudio[275035]: Forcing resampler 'copy', because of fixed, identical sample rates.
13:32:48 DEV pulseaudio[275035]: Resampler:
13:32:48 DEV pulseaudio[275035]:   rate 44100 -> 44100 (method copy)
13:32:48 DEV pulseaudio[275035]:   format float32le -> s16le (intermediate s16le)
13:32:48 DEV pulseaudio[275035]:   channels 2 -> 2 (resampling 2)
13:32:48 DEV pulseaudio[275035]: memblockq requested: maxlength=33554432, tlength=0, base=4, prebuf=0, minreq=1 maxrewind=0
13:32:48 DEV pulseaudio[275035]: memblockq sanitized: maxlength=33554432, tlength=33554432, base=4, prebuf=0, minreq=4 maxrewind=0
13:32:48 DEV pulseaudio[275035]: Created input 1004306 "ALSA Playback" on alsa_output.platform-rk809-sound.stereo-fallback with sample spec float32le 2ch 44100Hz and channel map front-left,front-right
13:32:48 DEV pulseaudio[275035]:     media.name = "ALSA Playback"
13:32:48 DEV pulseaudio[275035]:     application.name = "ALSA plug-in [audioplayer]"
13:32:48 DEV pulseaudio[275035]:     native-protocol.peer = "UNIX socket client"
13:32:48 DEV pulseaudio[275035]:     native-protocol.version = "34"
13:32:48 DEV pulseaudio[275035]:     application.process.id = "271089"
13:32:48 DEV pulseaudio[275035]:     application.process.user = "echionaudioplayer"
13:32:48 DEV pulseaudio[275035]:     application.process.host = "DEV"
13:32:48 DEV pulseaudio[275035]:     application.process.binary = "audioplayer"
13:32:48 DEV pulseaudio[275035]:     application.language = "C"
13:32:48 DEV pulseaudio[275035]:     application.process.machine_id = "f00fd94949434ada8268f65b46c87927"
13:32:48 DEV pulseaudio[275035]:     module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [audioplayer]"
13:32:48 DEV pulseaudio[275035]: Requested tlength=150.00 ms, minreq=10.00 ms
13:32:48 DEV pulseaudio[275035]: Early requests mode enabled, configuring sink latency to minreq.
13:32:48 DEV pulseaudio[275035]: Could not configure a sufficiently low latency. Early requests might not be satisfied.
13:32:48 DEV pulseaudio[275035]: Requested latency=10.00 ms, Received latency=99.95 ms
13:32:48 DEV pulseaudio[275035]: memblockq requested: maxlength=4194304, tlength=52920, base=8, prebuf=3528, minreq=3528 maxrewind=0
13:32:48 DEV pulseaudio[275035]: memblockq sanitized: maxlength=4194304, tlength=52920, base=8, prebuf=3528, minreq=3528 maxrewind=0
13:32:48 DEV pulseaudio[275035]: Final latency 249.95 ms = 130.00 ms + 2*10.00 ms + 99.95 ms
13:32:48 DEV pulseaudio[275035]: Requested volume: front-left: 26214 /  40% / -23.88 dB,   front-right: 26214 /  40% / -23.88 dB
13:32:48 DEV pulseaudio[275035]: Got hardware volume: front-left: 26241 /  40% / -23.85 dB,   front-right: 26241 /  40% / -23.85 dB
13:32:48 DEV pulseaudio[275035]: Calculated software volume: front-left: 65469 / 100% / -0.03 dB,   front-right: 65469 / 100% / -0.03 dB (accurate-enough=yes)
13:32:48 DEV pulseaudio[275035]: Volume not changing
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: state: IDLE -> RUNNING
13:32:48 DEV pulseaudio[275035]: Requesting rewind due to end of underrun.
13:32:48 DEV pulseaudio[275035]: Requested to rewind 17632 bytes.
13:32:48 DEV pulseaudio[275035]: Limited to 17312 bytes.
13:32:48 DEV pulseaudio[275035]: before: 4328
13:32:48 DEV pulseaudio[275035]: after: 4328
13:32:48 DEV pulseaudio[275035]: Rewound 17312 bytes.
13:32:48 DEV pulseaudio[275035]: Processing rewind...
13:32:48 DEV pulseaudio[275035]: latency = 1237
13:32:48 DEV pulseaudio[275035]: Have to rewind 17312 bytes on render memblockq.
13:32:48 DEV pulseaudio[275035]: Processing rewind...
13:32:48 DEV pulseaudio[275035]: Implicit underrun of 'ALSA Playback'
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 15676 bytes ago (1924 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 15708 bytes ago (1924 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 15740 bytes ago (1892 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 15868 bytes ago (1764 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 15900 bytes ago (1732 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16092 bytes ago (1508 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16156 bytes ago (1476 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16252 bytes ago (1380 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16284 bytes ago (1348 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16380 bytes ago (1252 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16412 bytes ago (1220 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16476 bytes ago (1156 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16508 bytes ago (1124 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16572 bytes ago (1060 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16604 bytes ago (1028 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16636 bytes ago (996 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16668 bytes ago (964 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16732 bytes ago (900 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16732 bytes ago (900 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: Sink alsa_output.platform-rk809-sound.stereo-fallback becomes idle, timeout in 5 seconds.
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: Found underrun 16828 bytes ago (804 bytes ahead in playback buffer)
13:32:48 DEV pulseaudio[275035]: Requested volume: front-left: 26214 /  40% / -23.88 dB,   front-right: 26214 /  40% / -23.88 dB
13:32:48 DEV pulseaudio[275035]: Got hardware volume: front-left: 26241 /  40% / -23.85 dB,   front-right: 26241 /  40% / -23.85 dB
13:32:48 DEV pulseaudio[275035]: Calculated software volume: front-left: 65469 / 100% / -0.03 dB,   front-right: 65469 / 100% / -0.03 dB (accurate-enough=yes)
13:32:48 DEV pulseaudio[275035]: Volume not changing
13:32:48 DEV pulseaudio[275035]: Requested to rewind 17632 bytes.
13:32:48 DEV pulseaudio[275035]: Limited to 17280 bytes.
13:32:48 DEV pulseaudio[275035]: before: 4320
13:32:48 DEV pulseaudio[275035]: after: 4320
13:32:48 DEV pulseaudio[275035]: Rewound 17280 bytes.
13:32:48 DEV pulseaudio[275035]: Processing rewind...
13:32:48 DEV pulseaudio[275035]: latency = 1303
13:32:48 DEV pulseaudio[275035]: Processing rewind...
13:32:48 DEV pulseaudio[275035]: alsa_output.platform-rk809-sound.stereo-fallback: state: RUNNING -> IDLE
13:32:48 DEV pulseaudio[275035]: Sink alsa_output.platform-rk809-sound.stereo-fallback becomes idle, timeout in 5 seconds.
13:32:48 DEV pulseaudio[275035]: Hmm, no streams around, trying to vacuum.

But when this issue occurs also playback via paplay (pulseaudio cli playback utility) has the same issue.
So i think this is pulseaudio related.
I have already created an issue for that:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1404

The rockpi 4se works fine with the internal audiochip.
The rockpi 3a works fine using alsa playback directly.

But using alsa breaks the volume control.
Switching to logarithmic volume curve made this issue even worse.
The volume changes a lot in the lower value range and above 50 it doesn't change a lot.
Do you know why this happens? Or how to fix this issue?

An interesting correlation between these devices is that only those with integrated soundchips at the soc have this issue.
The rockpi 3a uses the rk809 chip, the rasppi model 3b uses the bcm2835, but the rockpi 4 se uses a chip from everest  called es8316.
So maybe this is a driver issue.

Ian @ un4seen

Quote from: aaronegger on  5 Dec '22 - 14:48But using alsa breaks the volume control.
Switching to logarithmic volume curve made this issue even worse.
The volume changes a lot in the lower value range and above 50 it doesn't change a lot.
Do you know why this happens? Or how to fix this issue?

I think the issue here may be that BASS is assuming that ALSA's volume control uses a linear curve but I don't think it's actually specified. ALSA does also have a logarithmic volume option, but that doesn't appear to have great granularity - it had 1dB steps when I checked just now.

Perhaps you could just leave the device volume at the maximum and use the BASS_ATTRIB_VOL or BASS_CONFIG_GVOL_STREAM settings to control the volume level of your app?

aaronegger

Sadly we need to change the system volume, therefore we need to use the setvolume function. But i will create a function like i did for windows to manually translate the values.
But primarily we would like to use pulseaudio so this is not an urgent issue for us.

The developer/maintainer of pulseaudio wrote me that the application seems to cause the issue. He wrote me following message:

QuoteIt still looks as if the problem is not really on pulseaudio side and it is rather the client that has some issue. One thing I notice is that the client requests 10ms latency but can only get 16ms. I know that under certain conditions (repeated underruns) pulseaudio raises the minimum possible latency for the sink. Normally an alsa device has 0.5ms minimum latency. Can you check with "pacmd list-sinks" what latency range is displayed for your sink immediately after restart of PA and after some run-time? Maybe the problem occurs when the 16ms minimum latency is reached? Can you change the latency that is requested by the player? If yes, could you try something like 50ms?
Also can you check if it helps or changes anything when you use the default configuration?

How can i change the latency requested from bass?
I looked the possible config options but couldn't find anything that fits.

We already tried following config options to increase the buffersize:

Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_DEV_BUFFER, 150);
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, 1000);
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_ASYNCFILE_BUFFER, 262144);
           
But this seems to not affect the requested latency.

Ian @ un4seen

From the mention of 10ms, it looks like they're referring to the period, as 10ms is BASS's default. That can be adjusted via the BASS_CONFIG_DEV_PERIOD option (before calling BASS_Init). If 10ms isn't possible then BASS should be fine with whatever ALSA says instead. Please check the BASS_INFO "minbuf" value with BASS_GetInfo to find out what period is actually being used. Also check the "latency" value.

aaronegger

It was indeed the latency.
It seems that bass keeps the update period. But pulseaudio keeps increasing the latency step by step.
The maintainer/developer of pulseaudio told me following regarding the latency range:
"It is increased when too many underruns happen, you will find messages like "Increasing minimal latency to ...ms" in your log."

So when this happens and the minimal latency has been increased over 10ms the output of bass starts to get choppy.

Changing the update period from 10ms to 50ms seems to fix this issue.
The minimal latency will most likely never reach these values.

Correct me please if anything of this is wrong.
I am not an expert on this topic.

But i am very happy that this issue seems to be fixed for us  :)

Ian @ un4seen

Good to hear that you found a solution. Would be even better if it could somehow be handled automatically though :)

If I understand correctly, the problem begins when PulseAudio's latency goes above the configured ALSA period, ie. 10ms by default? I'll send you a debug BASS version to get more info on what's happening, to see if BASS can perhaps detect and do something about it.

aaronegger

Would be neat if it is handled automatically. For our purpose though this is already fine.
But of course i can help to investigate this issue further.
For debug purposes i would set a very low update period (1-2ms) because this will cause this issue immediatly.

And yes as far as i understood the dev of pulseaudio the issue occurs when the minimal latency has been increased above the default 10ms.
I hope i understood it correctly, but if pulseaudio increased the minimal latency above the configured update period of bass, the data of each update is too short and therefore the stream will be closed and recreated after the minmal latency time has been reached and after it received the next data from bass.

I will create a sample application that will print the information from BASS_GetInfo and compare it to the output of pacmd list-sinks and post it here.


aaronegger

So i have following outputs.

I created for both scenarios output that has been generated before the playback started and one immediatly after the playback finished.

This one is if i don't set the update period manually to 50ms, so it is the default 10ms.
The sound is stuttering here:

Before playback:

dsver: 0,
eax: False,
flags: DSCAPS_NONE,
free3d: 0,
freesam: 0,
freq: 44100,
hwfree: 0,
hwsize: 0,
initflags: BASS_DEVICE_STEREO,
latency: 35,
maxrate: 0,
minbuf: 10,
minrate: 0,
speakers: 2,
IsCertified: False,
Supports16BitSamples: False,
Supports8BitSamples: False,
SupportsContinuousRate: False,
SupportsDirectSound: True,
SupportsStereoSamples: False,
SupportsStereoSamples: False

1 sink(s) available.
  * index: 1
name: <alsa_output.RK809.stereo-fallback>
driver: <module-alsa-card.c>
flags: HARDWARE HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: RUNNING
suspend cause: (none)
priority: 9000
volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
        balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 35.92 ms
max request: 6 KiB
max rewind: 6 KiB
monitor source: 1
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
             Stereo
used by: 2
linked by: 2
configured latency: 36.00 ms; range is 36.00 .. 2972.15 ms
card: 0 <alsa_card.RK809>
module: 8
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "fe410000.i2s-rk817-hifi rk817-hifi-0"
alsa.id = "fe410000.i2s-rk817-hifi rk817-hifi-0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "Analog RK809"
alsa.long_card_name = "Analog RK809"
alsa.driver_name = "snd_soc_simple_card"
device.bus_path = "platform-rk809-sound"
sysfs.path = "/devices/platform/rk809-sound/sound/card1"
device.form_factor = "internal"
device.string = "hw:RK809"
device.buffering.buffer_size = "524288"
device.buffering.fragment_size = "262144"
device.access_mode = "mmap+timer"
device.profile.name = "stereo-fallback"
device.profile.description = "Stereo"
device.description = "Built-in Audio Stereo"
device.icon_name = "audio-card"
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:

active port: <analog-output>




After playback:

dsver: 0,
eax: False,
flags: DSCAPS_NONE,
free3d: 0,
freesam: 0,
freq: 44100,
hwfree: 0,
hwsize: 0,
initflags: BASS_DEVICE_STEREO,
latency: 35,
maxrate: 0,
minbuf: 10,
minrate: 0,
speakers: 2,
IsCertified: False,
Supports16BitSamples: False,
Supports8BitSamples: False,
SupportsContinuousRate: False,
SupportsDirectSound: True,
SupportsStereoSamples: False,
SupportsStereoSamples: False

1 sink(s) available.
  * index: 1
name: <alsa_output.RK809.stereo-fallback>
driver: <module-alsa-card.c>
flags: HARDWARE HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: RUNNING
suspend cause: (none)
priority: 9000
volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
        balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 35.20 ms
max request: 6 KiB
max rewind: 6 KiB
monitor source: 1
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
             Stereo
used by: 2
linked by: 2
configured latency: 36.00 ms; range is 36.00 .. 2972.15 ms
card: 0 <alsa_card.RK809>
module: 8
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "fe410000.i2s-rk817-hifi rk817-hifi-0"
alsa.id = "fe410000.i2s-rk817-hifi rk817-hifi-0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "Analog RK809"
alsa.long_card_name = "Analog RK809"
alsa.driver_name = "snd_soc_simple_card"
device.bus_path = "platform-rk809-sound"
sysfs.path = "/devices/platform/rk809-sound/sound/card1"
device.form_factor = "internal"
device.string = "hw:RK809"
device.buffering.buffer_size = "524288"
device.buffering.fragment_size = "262144"
device.access_mode = "mmap+timer"
device.profile.name = "stereo-fallback"
device.profile.description = "Stereo"
device.description = "Built-in Audio Stereo"
device.icon_name = "audio-card"
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:

active port: <analog-output>


And this one is after i set the update period to 50ms.
The playback is totally fine here:

Before playback:

dsver: 0,
eax: False,
flags: DSCAPS_NONE,
free3d: 0,
freesam: 0,
freq: 44100,
hwfree: 0,
hwsize: 0,
initflags: BASS_DEVICE_STEREO,
latency: 125,
maxrate: 0,
minbuf: 50,
minrate: 0,
speakers: 2,
IsCertified: False,
Supports16BitSamples: False,
Supports8BitSamples: False,
SupportsContinuousRate: False,
SupportsDirectSound: True,
SupportsStereoSamples: False,
SupportsStereoSamples: False

1 sink(s) available.
  * index: 1
name: <alsa_output.RK809.stereo-fallback>
driver: <module-alsa-card.c>
flags: HARDWARE HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: RUNNING
suspend cause: (none)
priority: 9000
volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
        balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 48.02 ms
max request: 8 KiB
max rewind: 8 KiB
monitor source: 1
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
             Stereo
used by: 2
linked by: 2
configured latency: 50.00 ms; range is 36.00 .. 2972.15 ms
card: 0 <alsa_card.RK809>
module: 8
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "fe410000.i2s-rk817-hifi rk817-hifi-0"
alsa.id = "fe410000.i2s-rk817-hifi rk817-hifi-0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "Analog RK809"
alsa.long_card_name = "Analog RK809"
alsa.driver_name = "snd_soc_simple_card"
device.bus_path = "platform-rk809-sound"
sysfs.path = "/devices/platform/rk809-sound/sound/card1"
device.form_factor = "internal"
device.string = "hw:RK809"
device.buffering.buffer_size = "524288"
device.buffering.fragment_size = "262144"
device.access_mode = "mmap+timer"
device.profile.name = "stereo-fallback"
device.profile.description = "Stereo"
device.description = "Built-in Audio Stereo"
device.icon_name = "audio-card"
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:

active port: <analog-output>




After playback:

dsver: 0,
eax: False,
flags: DSCAPS_NONE,
free3d: 0,
freesam: 0,
freq: 44100,
hwfree: 0,
hwsize: 0,
initflags: BASS_DEVICE_STEREO,
latency: 125,
maxrate: 0,
minbuf: 50,
minrate: 0,
speakers: 2,
IsCertified: False,
Supports16BitSamples: False,
Supports8BitSamples: False,
SupportsContinuousRate: False,
SupportsDirectSound: True,
SupportsStereoSamples: False,
SupportsStereoSamples: False

1 sink(s) available.
  * index: 1
name: <alsa_output.RK809.stereo-fallback>
driver: <module-alsa-card.c>
flags: HARDWARE HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: RUNNING
suspend cause: (none)
priority: 9000
volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
        balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 49.59 ms
max request: 8 KiB
max rewind: 8 KiB
monitor source: 1
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
             Stereo
used by: 2
linked by: 2
configured latency: 50.00 ms; range is 36.00 .. 2972.15 ms
card: 0 <alsa_card.RK809>
module: 8
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "fe410000.i2s-rk817-hifi rk817-hifi-0"
alsa.id = "fe410000.i2s-rk817-hifi rk817-hifi-0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "Analog RK809"
alsa.long_card_name = "Analog RK809"
alsa.driver_name = "snd_soc_simple_card"
device.bus_path = "platform-rk809-sound"
sysfs.path = "/devices/platform/rk809-sound/sound/card1"
device.form_factor = "internal"
device.string = "hw:RK809"
device.buffering.buffer_size = "524288"
device.buffering.fragment_size = "262144"
device.access_mode = "mmap+timer"
device.profile.name = "stereo-fallback"
device.profile.description = "Stereo"
device.description = "Built-in Audio Stereo"
device.icon_name = "audio-card"
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:

active port: <analog-output>


The diff between both:
Left is from the broken playback, right from the working one.

Before playback:
latency: 35 <-> latency: 125
minbuf: 10 <-> minbuf: 50
current latency: 35.92 ms <-> current latency: 48.02 ms
max request: 6 KiB <-> max request: 8 KiB
max rewind: 6 KiB <-> max rewind: 8 KiB
configured latency: 36.00 ms; range is 36.00 .. 2972.15 ms <-> configured latency: 50.00 ms; range is 36.00 .. 2972.15 ms

After playback:
latency: 35 <-> latency: 125
minbuf: 10 <-> minbuf: 50
current latency: 35.20 ms <-> current latency: 49.59 ms
max request: 6 KiB <-> max request: 8 KiB
max rewind: 6 KiB <-> max rewind: 8 KiB
configured latency: 36.00 ms; range is 36.00 .. 2972.15 ms <-> configured latency: 50.00 ms; range is 36.00 .. 2972.15 ms

Do these information help?

Ian @ un4seen

Really need to see what BASS sees when the problem happens, to see if it can detect the problem happening and perhaps do something about it. So I've sent you a debug BASS version (armhf) to get some info on that. If you don't see it in your mailbox, please check your junk/spam folder.

aaronegger

Oh i didn't check my emails. But i got the mail. I will make a very basic application that doesn't modify the latency, so that the issue will occur.
It will simply play an file for about 10s and the stop the playback.
I will answer the mail with the log file attached as soon as i have done this.