Lag when pause/resume

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

xtal256
Junior
Posts: 22
Joined: Sat Aug 09, 2025 10:43 pm
Australia

Lag when pause/resume

Post by xtal256 »

Hello,

When pausing or resuming a show (either live TV or a video), it does not pause/resume immediately but there is a lag of a few hundred milliseconds before it pauses / starts playing, and the audio lags behind that. When resuming, the audio lags even more, taking up to 1 second before it starts again.
Same thing happens in Kodi and MythTV frontend.

I have already done what is described here (the rlimits option): https://mizar.mythtv.org/wiki/Real-time ... eo_Display

My hardware:
ODROID H4+, Intel N97 CPU, Intel UHD Graphics
RAM: Crucial 8GB DDR5 4800MHz SODIMM
SSD: Crucial P3 1TB PCIe 3.0 NVMe M.2 2280
Tuner: Hauppauge WinTV dualHD

Logs:
mythbackend.log
mythfrontend.log
kodi.log
xtal256
Junior
Posts: 22
Joined: Sat Aug 09, 2025 10:43 pm
Australia

Re: Lag when pause/resume

Post by xtal256 »

I tried choosing a different audio output in Myth frontend. By default it appears to be using PulseAudio, so I tried sending directly to HDMI as well as "plughw", but neither made any difference.
It also made the sound a bit choppy (i.e. cuts out for a fraction of a second every few seconds) for a while after changing channels.

Are there any options to control audio buffering?
white_haired_uncle
Senior
Posts: 557
Joined: Thu Feb 23, 2023 8:55 pm
Location: Safe outside my gilded cage
United States of America

Re: Lag when pause/resume

Post by white_haired_uncle »

xtal256 wrote:
Thu Sep 11, 2025 1:57 am
I tried choosing a different audio output in Myth frontend. By default it appears to be using PulseAudio, so I tried sending directly to HDMI as well as "plughw", but neither made any difference.
It also made the sound a bit choppy (i.e. cuts out for a fraction of a second every few seconds) for a while after changing channels.

Are there any options to control audio buffering?
If you're running pulse and it's configured to output to HDMI, which sounds like your situation, I can't imagine anything good coming out of another application, mythtv for example, writing directly to HDMI audio.

There's an audio read-ahead setting, though I suspect that sort of thing making any difference is pretty unlikely these days and if you're worried about lag time on resuming I kind of wonder if increasing this might make things worse.

My laptop has pulse and it works fine (never thought I'd say that). My main frontend doesn't, I use the HDMI output in myth (ALSA:hdmi:CARD=HDMI,DEV=0 in my case). In both cases I'm using the TV speakers via HDMI.
xtal256
Junior
Posts: 22
Joined: Sat Aug 09, 2025 10:43 pm
Australia

Re: Lag when pause/resume

Post by xtal256 »

white_haired_uncle wrote:
Sat Sep 13, 2025 4:44 am
If you're running pulse and it's configured to output to HDMI, which sounds like your situation, I can't imagine anything good coming out of another application, mythtv for example, writing directly to HDMI audio.
Can you explain what you mean by this?

I don't have much experience with audio in Linux, but from what I've read Pulse Audio is a "sound server". Would this mean that is is constantly running and could interfere with MythTV even if it is configured to output directly to HDMI?
I also see on this page that PulseAudio was replaced by PipeWire in Ubuntu 22.10, but I have 24 (technically it's Xubuntu) and I seem to have both pulseaudio and pipewire packages installed.

Should I uninstall / disable PulseAudio and PipeWire and opt for outputting sound directly to HDMI? Or is it a good to use them?
xtal256
Junior
Posts: 22
Joined: Sat Aug 09, 2025 10:43 pm
Australia

Re: Lag when pause/resume

Post by xtal256 »

By the way, I just tried reducing the "Audio read ahead" value to 10ms but it did not help.
white_haired_uncle
Senior
Posts: 557
Joined: Thu Feb 23, 2023 8:55 pm
Location: Safe outside my gilded cage
United States of America

Re: Lag when pause/resume

Post by white_haired_uncle »

If you have multiple things trying to play to the same "speakers" at the same time, like playing a video game while listening to music, there needs to be something, like pulse, to make sure they play nice together, kind of like how a bus has lots of seats but only has one steering wheel. Your game and music player don't write directly to HDMI, they write to pulse and it and only it writes to the HDMI device. With a machine that just runs mythtv, there's no need for pulse. So you probably just want to pick one approach and stick with it.

There was a time when pretty much every audio problem was caused by pulse. It had good intentions, but was forced down our throats about 10 years before it was actually ready (kind of like systemd, except the good intentions part). So I'm always going to hate it, even though it may (should) work fine now. I'd still uninstall it on a dedicated frontend. One of the big problems was lag, BTW.

Speaking of garbage released before it's ready, have you always ran ubuntu 24? I'm sure it works for a lot of people, but it's seen a lot more complaints than usual and my experience with it lasted about 10 minutes before I knew it was out the door.

BTW, have you tried watching your recordings in something else (not myth or kodi which AIUI uses myth) like mpv or vlc just to see how they work?
xtal256
Junior
Posts: 22
Joined: Sat Aug 09, 2025 10:43 pm
Australia

Re: Lag when pause/resume

Post by xtal256 »

white_haired_uncle wrote:
Sat Sep 13, 2025 12:27 pm
have you always ran ubuntu 24?
I only just started building my system, so I started with 24 as it is the latest LTS. Then as I started setting up MythTV I was reading comments about people using 22 and I thought maybe I should have got that version instead as it might be more reliable, but then I didn't want to re-install everything at that point.

The main reason for getting MythTV is that I was fed up with how slow modern "smart" TVs are and thought that I could do a better job by building it myself using a reasonably fast CPU/GPU and SSD. Turns out it's been way worse, slower even than my TV which is almost 10 years old.

I guess I can't say I'm surprised. My experience of software for the past ~15 years has been that each new release is slower, more bloated, AND removes useful features.
xtal256
Junior
Posts: 22
Joined: Sat Aug 09, 2025 10:43 pm
Australia

Re: Lag when pause/resume

Post by xtal256 »

I uninstalled PulseAudio and disabled/masked the following PipeWire services:

Code: Select all

pipewire.service pipewire.socket pipewire-pulse.service pipewire-pulse.socket wireplumber.service
But the lag still happens. Audio keeps playing for about 1 second after pausing, and doesn't start immediately after unpausing.

Given the hardware that I have (i.e. it's not a piece of junk) I would expect no noticeable delay at all.
white_haired_uncle
Senior
Posts: 557
Joined: Thu Feb 23, 2023 8:55 pm
Location: Safe outside my gilded cage
United States of America

Re: Lag when pause/resume

Post by white_haired_uncle »

I know uninstalling packages does not always stop processes. Not a systemd guy, but I don't think disable would also stop a service w/o --now. No idea about mask - to me disable/mask should mean "Do not start", not "stop and do not start". I'd probably do a

Code: Select all

lsof /dev/snd/*
anyway. The lag you describe certainly sounds like there's something between the app and the "speakers".

Be interesting to know if it happens in VLC, or when playing music, etc. If so, maybe boot into a live distribution of something that's not u2404 and see if it still happens.

BTW, you mentioned HDMI. Are you going straight from PC to TV with that, or is there an amp or one of those dirty rotten HDMI switches or anything in the path?
xtal256
Junior
Posts: 22
Joined: Sat Aug 09, 2025 10:43 pm
Australia

Re: Lag when pause/resume

Post by xtal256 »

Just straight from the Odroid to the TV.
xtal256
Junior
Posts: 22
Joined: Sat Aug 09, 2025 10:43 pm
Australia

Re: Lag when pause/resume

Post by xtal256 »

The output of lsof /dev/snd/* when running Myth frontend is:

Code: Select all

COMMAND     FD   TYPE DEVICE SIZE/OFF NODE NAME
mythfront   mem   CHR  116,5           751 /dev/snd/pcmC0D3p
mythfront   97u   CHR 116,11      0t0  763 /dev/snd/controlC0
mythfront   98u   CHR  116,5      0t0  751 /dev/snd/pcmC0D3p
mythfront   99u   CHR 116,11      0t0  763 /dev/snd/controlC0
And with Kodi:

Code: Select all

COMMAND    FD   TYPE DEVICE SIZE/OFF NODE NAME
kodi.bin   mem   CHR  116,5           751 /dev/snd/pcmC0D3p
kodi.bin   20u   CHR 116,11      0t0  763 /dev/snd/controlC0
kodi.bin   21u   CHR  116,5      0t0  751 /dev/snd/pcmC0D3p
xtal256
Junior
Posts: 22
Joined: Sat Aug 09, 2025 10:43 pm
Australia

Re: Lag when pause/resume

Post by xtal256 »

I just tried playing a video through the built-in player (Parole Media Player) I get no sound at all. Since I've removed PulseAudio and disabled PipeWire, I'm not sure how to configure the OS to always use ALSA.
white_haired_uncle
Senior
Posts: 557
Joined: Thu Feb 23, 2023 8:55 pm
Location: Safe outside my gilded cage
United States of America

Re: Lag when pause/resume

Post by white_haired_uncle »

First a note: on my system, parole is awful playing a sample with alsa. The audio and video are way out of sync. mpv works just fine. But both output to HDMI when I do the following:

Code: Select all

spartan$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC3227 Analog [ALC3227 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [32S357]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
There's my HDMI output, it's on card 0 (or card PCH) at device 3.

Code: Select all

spartan$ cat ~/.asoundrc 
pcm.!default {
	type hw
	card PCH
	device 3
}
If you've been using HDMI, it's probably not muted which is why most people first learn about alsamixer, but it's still something you should know about.

Some other toys:

Code: Select all

spartan$ aplay -L
hdmi:CARD=PCH,DEV=0
    HDA Intel PCH, 32S357
    HDMI Audio Output

spartan$ speaker-test -D hdmi:CARD=PCH,DEV=0 -c 2

spartan$ spartan$ mpv --audio-device=alsa/hdmi:CARD=PCH,DEV=0  /export/share/tmp/Last\ Man\ Standing\ -\ S7E16\ -\ Urban\ Exploring.ts 

xtal256
Junior
Posts: 22
Joined: Sat Aug 09, 2025 10:43 pm
Australia

Re: Lag when pause/resume

Post by xtal256 »

I set up that asoundrc file like you said (I had to create it since it didn't already exist), and I installed mpv.
I still don't get sound in Parole but mpv works, and it works beautifully. No lag when pausing or resuming, fast forward and rewind (i.e. skip forward/back) works smoothly. I don't understand why Myth and Kodi can't be like this!
white_haired_uncle
Senior
Posts: 557
Joined: Thu Feb 23, 2023 8:55 pm
Location: Safe outside my gilded cage
United States of America

Re: Lag when pause/resume

Post by white_haired_uncle »

What version are you running (

Code: Select all

mythbackend --version
), and where did you get it (build from source, install from the mythbuntu ppa, etc)?

Is Enable Music Choice checked?

Your problems happen watching live tv, watching recordings, and watching videos?

It happens on all recordings/videos, not just one file or something?

You tested mpv with the same file you had issues with in myth/kodi?

What audio device are you using in mythtv?

What does ~/.asoundrc look like? (and it is .asoundrc, not asoundrc?)

aplay -L ?

What is the exact command line you used when running mpv?

EDIT: just noticed in the frontend log, it looks like '/data/videos//shows/Rick and Morty/S02E04 - Total Rickall.mkv' probably has three audio tracks. You're testing the same audio track in mpv as myth/kodi? Tried switching tracks in myth?
Post Reply