Opened 14 years ago

Closed 13 years ago

#8894 closed defect (Invalid)

Trunk: PulseAudio... blast of static when playing recording first try

Reported by: databubble Owned by: JYA
Priority: minor Milestone: 0.24.1
Component: MythTV - Audio Output Version: Master Head
Severity: low Keywords: pulseaudio
Cc: Ticket locked: yes

Description

I've recently upgraded to ubuntu 10.10 beta... so this may be the fault of Pulse in that distribution...feel free to ignore if so.

I'm getting a blast of static the first time I start playing a recording. If I stop the recording, and immediately re-start it the audio plays normally.

This is with PulseAudio:Default. Trunk 26179. I re-sample to 48KHz because when I first tried the new audio support, I found that I just got static without it. Since then, I've upgraded both trunk many times, and my distribution. Without re-sampling, I get the same behaviour except that it make take more attempts to play before I get normal audio.

Here's a portion of mythfrontend.log where I start, stop and re-start a recording:

2010-09-09 04:08:20.514 SendReceiveStringList(MESSAGE,SYSTEM_EVENT PLAY_STARTED HOSTNAME family CHANID 2132 STARTTIME 2010-09-08T23:00:00 SENDER family) called from UI thread
2010-09-09 04:08:20.520 TV: Attempting to change from None to WatchingPreRecorded
2010-09-09 04:08:20.584 AudioPlayer: Disabling Audio, params(0,2,44100)
2010-09-09 04:08:20.595 AO: Resampling from 44 kHz to 48 kHz with quality medium
2010-09-09 04:08:20.595 AO: Opening audio device 'PulseAudio:default' ch 2(2) sr 48000 sf 32 bit floating point reenc 0
2010-09-09 04:08:20.627 AudioPlayer: Enabling Audio
2010-09-09 04:08:20.628 CommFlagFast: 0
2010-09-09 04:08:20.628 special_decode: 0
2010-09-09 04:08:20.659 AFD: Opened codec 0x3797410, id(H264) type(Video)
2010-09-09 04:08:20.659 AFD: codec AC3 has 2 channels
2010-09-09 04:08:20.659 AFD: Opened codec 0x3797c50, id(AC3) type(Audio)
2010-09-09 04:08:20.679 AO: Resampling from 48 kHz to 44 kHz with quality medium
2010-09-09 04:08:20.679 AO: Opening audio device 'PulseAudio:default' ch 2(2) sr 44100 sf 32 bit floating point reenc 0
2010-09-09 04:08:20.818 VDPAU: Created 2 output surfaces.
2010-09-09 04:08:20.818 VDPAU: Created VDPAU render device 1280x720
2010-09-09 04:08:20.921 Player(7): Forcing decode extra audio option on (Video method requires it).
2010-09-09 04:08:20.921 FilterManager: Failed to load filter 'studio', no such filter exists
2010-09-09 04:08:21.022 Player(7): Video sync method can't support double framerate (refresh rate too low for 2x deint)
2010-09-09 04:08:21.025 Player(7): Video timing method: USleep with busy wait
2010-09-09 04:08:21.025 SendReceiveStringList(MESSAGE,COMMFLAG_REQUEST 2132_2010-09-08T23:00:00) called from UI thread
2010-09-09 04:08:21.026 TV: Changing from None to WatchingPreRecorded
2010-09-09 04:08:21.089 ScreenSaverX11Private: DPMS Deactivated 1
2010-09-09 04:08:21.115 VDPAU: Added 2 output surfaces (total 4, max 4)
2010-09-09 04:08:22.181 Marking recording as unwatched
2010-09-09 04:08:22.280 TV: Attempting to change from WatchingPreRecorded to None
2010-09-09 04:08:22.329 VDPAU Painter: Clearing VDPAU painter cache.
2010-09-09 04:08:22.369 TV: Changing from WatchingPreRecorded to None
2010-09-09 04:08:22.370 ScreenSaverX11Private: DPMS Reactivated 1
2010-09-09 04:08:22.385 SendReceiveStringList(MESSAGE,SYSTEM_EVENT PLAY_STOPPED HOSTNAME family CHANID 2132 STARTTIME 2010-09-08T23:00:00 SENDER family) called from UI thread
010-09-09 04:08:20.514 SendReceiveStringList(MESSAGE,SYSTEM_EVENT PLAY_STARTED HOSTNAME family CHANID 2132 STARTTIME 2010-09-08T23:00:00 SENDER family) called from UI thread
2010-09-09 04:08:20.520 TV: Attempting to change from None to WatchingPreRecorded
2010-09-09 04:08:20.584 AudioPlayer: Disabling Audio, params(0,2,44100)
2010-09-09 04:08:20.595 AO: Resampling from 44 kHz to 48 kHz with quality medium
2010-09-09 04:08:20.595 AO: Opening audio device 'PulseAudio:default' ch 2(2) sr 48000 sf 32 bit floating point reenc 0
2010-09-09 04:08:20.627 AudioPlayer: Enabling Audio
2010-09-09 04:08:20.628 CommFlagFast: 0
2010-09-09 04:08:20.628 special_decode: 0
2010-09-09 04:08:20.659 AFD: Opened codec 0x3797410, id(H264) type(Video)
2010-09-09 04:08:20.659 AFD: codec AC3 has 2 channels
2010-09-09 04:08:20.659 AFD: Opened codec 0x3797c50, id(AC3) type(Audio)
2010-09-09 04:08:20.679 AO: Resampling from 48 kHz to 44 kHz with quality medium
2010-09-09 04:08:20.679 AO: Opening audio device 'PulseAudio:default' ch 2(2) sr 44100 sf 32 bit floating point reenc 0
2010-09-09 04:08:20.818 VDPAU: Created 2 output surfaces.
2010-09-09 04:08:20.818 VDPAU: Created VDPAU render device 1280x720
2010-09-09 04:08:20.921 Player(7): Forcing decode extra audio option on (Video method requires it).
2010-09-09 04:08:20.921 FilterManager: Failed to load filter 'studio', no such filter exists
2010-09-09 04:08:21.022 Player(7): Video sync method can't support double framerate (refresh rate too low for 2x deint)
2010-09-09 04:08:21.025 Player(7): Video timing method: USleep with busy wait
2010-09-09 04:08:21.025 SendReceiveStringList(MESSAGE,COMMFLAG_REQUEST 2132_2010-09-08T23:00:00) called from UI thre

Attachments (1)

mythmusic-pause-2.diff (498 bytes) - added by anonymous 13 years ago.

Download all attachments as: .zip

Change History (23)

comment:1 Changed 14 years ago by Nicolas Riendeau

Status: newinfoneeded_new

I gather that the problem was not present, on the same hardware, before you upgraded?

comment:2 Changed 14 years ago by Nicolas Riendeau

Version: UnspecifiedTrunk Head

comment:3 Changed 14 years ago by robertm

Status: infoneeded_newassigned

This should not have been infoneeded in the first place, the ticket exists because he sees the problem now.

comment:4 Changed 14 years ago by JYA

Milestone: unknown0.24
Severity: mediumlow
Status: assignedinfoneeded

I think the question asked was a valid one, especially as the OP himself states "I've recently upgraded to ubuntu 10.10 beta... so this may be the fault of Pulse in that distribution...feel free to ignore if so."

Could you please say if you had this problem before with 10.04 LTS?

Also, try changing the default sampling rate in pulse server from the default 44.1kHz to 48kHz in /etc/pulse/daemon.conf uncomment the line ;default-sample-rate = 44100 and change it to: default-sample-rate = 48000.

If you only force myth to resample to 48kHz when you play through pulse it will do 44.1kHz -> 48kHz -> 44.1kHz

so do not force resampling in myth ; let pulse do it.

comment:5 Changed 13 years ago by anonymous

I'm facing a similar problem. When watching LiveTV on most channels I occasionally get this blast of static (white noise) too. Pausing the playback and immediate restart quite often fixes the problem. On the console this scenario seems to be coming along with the following line:

Player(0): Waited 100ms for video buffers AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

I am using mythfrontend version: trunk [26972M] www.mythtv.org , PulseAudio? output on Fedora 13.

Amazingly, there is exactly one channel (Eurosport via DVB-S from Astra) where I get only noise - no real audio at anytime. Also pausing/resuming or anything else does not help on this channel.

comment:6 Changed 13 years ago by robertm

Rather than "me too"ing, why not respond to the request for information/reconfiguring pulse properly to work with myth?

comment:7 Changed 13 years ago by databubble

10.10 has released, and I still frequent blasts of static when using Pulse and 0.24-fixes branch. I have not experienced any similar bursts of static/white-noise from any other audio source (amarok, systems sounds, etc.).

With 10.04 and earlier, and 0.23/0.22 I was running ALSA through pulse, with "EXPERIMENTALLY_ALLOW_PULSE_AUDIO=1", if needed. The static issues appeared after the (otherwise excellent) audio work in 0.24.

I get the static whether I force re-sampling to 40KHz or not.

I have seen similar "Player(0): Waited 100ms for video buffers..." messages, but had not previously associated them with the static. I'll do some testing and monitor the logs and see if I can narrow it down.

Seems reasonable to assume for the moment that it's a myth audio (or pulse configuration) issue, and not a 10.10 pulse issue.

comment:8 Changed 13 years ago by JYA

The changing of sampling rate shouldn't be done in myth ; but in pulseaudio server config. As mentioned above, try: Also, try changing the default sampling rate in pulse server from the default 44.1kHz to 48kHz in /etc/pulse/daemon.conf uncomment the line ;default-sample-rate = 44100 and change it to: default-sample-rate = 48000.

You can still use ALSA pulse compatibility by selecting the device ALSA:pulse

comment:9 Changed 13 years ago by JYA

Resolution: Fixed
Status: infoneededclosed

(In [27010]) Do not write anything to pulseaudio server if audio is paused. Hopefully prevent having some static noise at start of playback. May fix #8894.

comment:10 Changed 13 years ago by JYA

Resolution: Fixed
Status: closednew

didn't mean to close the ticket..

comment:11 Changed 13 years ago by Kenni Lund [kenni a kelu dot dk]

Status: newassigned

comment:12 Changed 13 years ago by lvr@…

Just tried with top of tree (Revision: 27015) and I still get static, albeit less frequently, when I press pause/resume. NB I believe this may be a race condition as it doesn't appear to happen on an old AMD box but is very obvious on a recent Intel i5

Changed 13 years ago by anonymous

Attachment: mythmusic-pause-2.diff added

comment:13 Changed 13 years ago by lvr@…

This patch is even simpler and fixes the noise for me. Looks like it may have been a buffer alignment bug in PulseAudio?.

comment:14 Changed 13 years ago by JYA

If you had tried the latest trunk, writeaudio when using pulseaudio in pause mode does absolutely nothing and returns immediately...

So your *fix* is likely just a coincidence. Unless you tried 0.24-fixes

comment:15 Changed 13 years ago by lvr@…

My "patch" is totally reproducible - take it out and the problem returns, put it back and the hiss goes away. The code was a clean checkout by svn of top of tree (svn info gives rev 27015) but with your 27010 fix reverted. If 27010 is applied, with or without my fix, the hiss returns so it looks like it's tickling a bug in PulseAudio?, possibly to do with buffer alignment.

comment:16 Changed 13 years ago by JYA

Ae you using trunk or 0.24-fixes?

your patch doesn't change buffer alignment in anyway ; it just write zeros by chunk of 8ms...

As I wrote earlier, WriteAudio? in pause mode does nothing; so changing the size of the buffer written to writeaudio will not make a difference

comment:17 Changed 13 years ago by lvr@…

As I said before, I'm using trunk head. Here's the svn info output: Path: . URL: http://svn.mythtv.org/svn/trunk Repository Root: http://svn.mythtv.org/svn Repository UUID: 7dbf422c-18fa-0310-86e9-fd20926502f2 Revision: 27015 Node Kind: directory Schedule: normal Last Changed Author: markk Last Changed Rev: 27015 Last Changed Date: 2010-10-28 11:38:25 +0200 (Thu, 28 Oct 2010)

My patch changes the alignment of the _end_ of the buffer, and so apparently avoids tickling a bug in PulseAudio?. You can repeat your assertion about WriteAudio? as many times as you like, but the fact is that it has no effect on the hiss. This is _not_ a bug in MythTV but a workaround for a problem in PulseAudio?.

comment:18 Changed 13 years ago by databubble

The blast of static has gone away for me. However, I'm not sure whether it's the fix (running 0.24-fixes (revision 26996), or whether it's due to me changing the default sample rate in /etc/pulse/daemon.conf to 48KHz. (I have NOT set the extra audio configuration setting in myth to peg myth to 48K, however. Static went away without having to do that.)

BTW, these are the "non-default" settings I've been using in pulse for ages (i.e., I was using them with 0.23-fixes, using the pulse alsa interface... without any static):

realtime-scheduling = yes
realtime-priority = 5

default-sample-rate = 48000

resample-method = speex-float-1

rlimit-rtprio = 9
rlimit-rttime = 1000000

default-fragments = 15
default-fragment-size-msec = 20

If it's helpful, I can change the pulse sample rate back to 44.1KHz and re-test?

comment:19 Changed 13 years ago by JYA

There's no fix in 0.24-fixes ; what fixed it for you is changing the sampling rate in pulse as mentioned several times above.

Again, (and again...) there is no need to force resampling within myth ; it would only make things worse as pulse default sampling rate is 44.1kHz

Last edited 13 years ago by JYA (previous) (diff)

comment:20 Changed 13 years ago by JYA

Ticket locked: set

Locking the ticket, as no new information is provided ...

comment:21 Changed 13 years ago by stuartm

Milestone: 0.240.24.1

comment:22 Changed 13 years ago by JYA

Resolution: Invalid
Status: assignedclosed

Mark it as invalid as it's obviously related to pulse default resampler. Changing the default pulse server sampling rate from 44.1kHz to 48kHz prevent the issue from occurring.

Note: See TracTickets for help on using tickets.