Opened 14 years ago

Closed 14 years ago

#7784 closed defect (fixed)

WriteAudio: buffer underrun during playback of CD audio

Reported by: Paul <paul@…> Owned by: JYA
Priority: minor Milestone: unknown
Component: MythTV - Audio Output Version: 0.22-fixes
Severity: medium Keywords:
Cc: Ticket locked: yes

Description

When I select CD-Audio as input source for Mythmusic I can stop/start playback Mythfrontend logfile produces:

WriteAudio?: buffer underrun

MP3 playback ok and GNOME CD player works ok too Just seems to affect MythTV. I thought it might be related to my TV recording playback where I get same message.

Verbose log

2009-12-20 14:00:14.487 GetAudiotime? now=1261278014.487640, set=1261278014.482333, ret=5, audt=15568 sf=1 2009-12-20 14:00:14.487 AO: _AddSamples samples=512 bytes=2048, used=47105, free=1488895, timecode=-1 needsupmix 0 2009-12-20 14:00:14.487 GetAudiotime? now=1261278014.487739, set=1261278014.482333, ret=5, audt=15568 sf=1 2009-12-20 14:00:14.487 AO: _AddSamples samples=512 bytes=2048, used=49153, free=1486847, timecode=-1 needsupmix 0 2009-12-20 14:00:14.487 GetAudiotime? now=1261278014.487852, set=1261278014.482333, ret=5, audt=15568 sf=1 2009-12-20 14:00:14.487 AO: _AddSamples samples=512 bytes=2048, used=51201, free=1484799, timecode=-1 needsupmix 0 2009-12-20 14:00:14.487 GetAudiotime? now=1261278014.487952, set=1261278014.482333, ret=5, audt=15568 sf=1 2009-12-20 14:00:14.488 AO: _AddSamples samples=512 bytes=2048, used=53249, free=1482751, timecode=-1 needsupmix 0 2009-12-20 14:00:14.488 SetAudiotime? set=1261278014.488314, audt=15568 atc=15881 tb=55296 sb=0 eds=4410000 abps=4 sf=1 2009-12-20 14:00:14.488 GetAudiotime? now=1261278014.488391, set=1261278014.488314, ret=0, audt=15568 sf=1 2009-12-20 14:00:14.488 AO: Broadcasting free space avail 2009-12-20 14:00:14.488 WriteAudio?: Preparing 6144 bytes (1536 frames) 2009-12-20 14:00:14.488 WriteAudio?: buffer underrun 2009-12-20 14:00:14.488 SetAudiotime? set=1261278014.488702, audt=15568 atc=15881 tb=55268 sb=6116 eds=4410000 abps=4 sf=1 2009-12-20 14:00:14.488 GetAudiotime? now=1261278014.488774, set=1261278014.488702, ret=0, audt=15568 sf=1 2009-12-20 14:00:14.488 AO: Broadcasting free space avail 2009-12-20 14:00:14.488 WriteAudio?: Preparing 6144 bytes (1536 frames) 2009-12-20 14:00:14.489 SetAudiotime? set=1261278014.489126, audt=15569 atc=15881 tb=55208 sb=12200 eds=4410000 abps=4 sf=1 2009-12-20 14:00:14.489 GetAudiotime? now=1261278014.489182, set=1261278014.489126, ret=0, audt=15569 sf=1 2009-12-20 14:00:14.489 AO: Broadcasting free space avail 2009-12-20 14:00:14.489 WriteAudio?: Preparing 6144 bytes (1536 frames) 2009-12-20 14:00:14.489 SetAudiotime? set=1261278014.489425, audt=15569 atc=15881 tb=55148 sb=18284 eds=4410000 abps=4 sf=1 2009-12-20 14:00:14.489 GetAudiotime? now=1261278014.489481, set=1261278014.489425, ret=0, audt=15569 sf=1 2009-12-20 14:00:14.489 AO: Broadcasting free space avail

Note I can re-produce longer verbose recording logs if required.

Change History (24)

comment:1 Changed 14 years ago by stuartm

Component: Plugin - MythMusicMythTV - Audio Output
Owner: changed from stuartm to JYA
Status: newassigned

comment:2 Changed 14 years ago by Paul Wilson <paul@…>

audio settings: Device:ALSA:Default Mixer:ALSA:Defualt (output to SPDIF) DTS passthru to SPDIF I am using a on board 7.1 sound device optical output to my AMP receiver.

comment:3 Changed 14 years ago by Paul Wilson <paul@…>

I don't know if this related but when I get these during TV playback they occur every 60 sec exactly. eg 2010-01-04 12:35:01.084 WriteAudio?: buffer underrun 2010-01-04 12:36:01.077 WriteAudio?: buffer underrun 2010-01-04 12:37:01.078 WriteAudio?: buffer underrun 2010-01-04 12:38:01.081 WriteAudio?: buffer underrun 2010-01-04 12:39:01.068 WriteAudio?: buffer underrun 2010-01-04 12:40:01.068 WriteAudio?: buffer underrun 2010-01-04 12:41:01.070 WriteAudio?: buffer underrun

comment:4 Changed 14 years ago by JYA

Resolution: worksforme
Status: assignedclosed

According to a post of yours in another forum: "I didn't change anything other than goto the general settings again and save them, but the "buffer underrun" msg and the video pausing has gone. woot!!."

And as this more than likely a local issue at your end (I/O or CPU starvation) ..

Check: http://www.mythtv.org/wiki/Troubleshooting:Prebuffering_pause

comment:5 Changed 14 years ago by paul@…

please reopen as CD playback still a problem

comment:6 Changed 14 years ago by otto at kolsi dot fi

I'm seeing something similar here. Hasn't bothered me since I'm not listening CDs, but I've noticed that the issue exists.

[20820] shortened audio buffering in MythMusic. As a very quick test, I bumped the CD buffering from 500ms -> 2000ms and this fixed the issue for me. Of course the 2sec buffer might be too much but maybe 500ms is too short also for some.

With the one machine I tested this, listening 1 minute of CD resulted 6-10 short pauses and buffer underruns. With the increased buffering the playback is fine.

Paul, if you are able to test patches, you could try something like this:

Index: mythmusic/mythmusic/cddecoder.cpp
===================================================================
--- mythmusic/mythmusic/cddecoder.cpp   (revision 23071)
+++ mythmusic/mythmusic/cddecoder.cpp   (working copy)
@@ -85,7 +85,7 @@
             // Never buffer more than 500ms of audio since this slows down
             // actions such as seeking or track changes made after decoding is
             // complete but audio remains in the buffer
-            bool ok = (output()->GetAudioBufferedTime() <= 500);
+            bool ok = (output()->GetAudioBufferedTime() <= 2000);
             if (ok) ok = output()->AddSamples(output_buf, samples, -1);
             if (ok)
             {

comment:7 Changed 14 years ago by paul@…

thanks, I'd like to test it but I'm currently using a binary package (atrpms on Fedora 12), is it possible I could download a binary to test?

Note another question would this related to TV recording playback too?

comment:8 in reply to:  7 Changed 14 years ago by otto at kolsi dot fi

Replying to paul@…:

thanks, I'd like to test it but I'm currently using a binary package (atrpms on Fedora 12), is it possible I could download a binary to test?

Unfortunately not possible.

Note another question would this related to TV recording playback too?

No, this is strictly related to MythMusic and in there, only for CD playback. Like jyavenard said, if you have issues with TV playback and music, you probably have some local issues with your setup.

jyavenard and others, I think this ticket should still be re-opened since there definitely is an issue with CD playback with a system that otherwise functions well.

I have two frontends, both on Fedora 11. One uses Pulseaudio and analog audio out and with that, 2000ms CD buffering seems to be enough. The other one does not use Pulseaudio and has S/PDIF optical out. With that one, 2500ms is not enough, but 5000ms is.

While testing, I noticed that in the latter maching DVD drive is only accessed ~15sec, then 15-20sec pause, and then access again. If the reading of disk is such, it may very well cause those buffering issues.

comment:9 Changed 14 years ago by arizonamythtv@…

I'm seeing the same issue as well running 0.22 release fixes on MB 9.04 64 Bit. I compile so I was able to make the changes above. They didn't help so I increased to 5000ms and this didn't solve the problem either.

comment:10 Changed 14 years ago by anonymous

Yes, could you please re-open this? I am experiencing the same issue on MB 9.10. It's very bad for the WAF. Nearly terminal... :)

comment:11 Changed 14 years ago by JYA

Ticket locked: set

This has been improved in trunk. And is closed until someone find that trunk doesn't behave properly.

comment:12 Changed 14 years ago by cpinkham

Ticket locked: unset

comment:13 Changed 14 years ago by Britney Fransen <britney.fransen@…>

Running trunk 23562 I am seeing these buffer underruns and pauses during CD playback. I tried increasing the buffer time in cddecoder.cpp to 10 seconds and that did significantly reduce the underruns but there were still 3 over a 5 minute song.

comment:14 Changed 14 years ago by mhulsman@…

The fix in trunk did not work for me either. Reverting the changes made in http://svn.mythtv.org/trac/changeset/20820 to cddecoder.cpp however did solve the problem.

comment:15 Changed 14 years ago by stuartm

Resolution: worksforme
Status: closednew

Could you please attach a frontend log using -v media.

comment:16 Changed 14 years ago by psylencer <d.herlihy@…>

Stuart,

Thanks for having a look at this, although I think you've closed the ticket prematurly.

I have fully read and understood and impliemnted changes above.

I've done some more testing of this problem and reverted back to version .22.

To clarify, (refer to bug #8181) and for the benefit of everyone here, the reason I was not receiving buffer underrun messages in mythfrontend log was because I was not using ALSA as my audio device, I was using dev/dsp (which does not return buffer errors to mythfrontend log). Changing to ALSA revealed the dreaded buffer underrun messages. While running .22, both the LG drive and the Pioneer drive displayed exactly the same 15 second buffer issues.

I upgraded to .23 using Mythbuntu Auto Daily Builds and when i did, the pioneer drive played back fine and the LG drive continued to display the buffer messages.

Thinking this was something to do with the LG drive, I installed a brand new Asus drive which displayed exactly the same problem and error messages as did the LG.

Basically, the 2 year old Pioneer Drive woks fine with the .23 and the brand new LG and Asus drives exibit buffer underrun messages. :

Here is the log from mythfrontend for the Asus drive (not working) and then the Pioneer Drive (Working).

ASUS BRW-24B1LT-16

2010-03-16 16:20:03.949 CD status has changed.
2010-03-16 16:20:22.823 AO: Using resampler. From: 44100 to 48000
2010-03-16 16:20:22.824 Opening audio device 'default'. ch 2(2) sr 48000 (reenc 0)
2010-03-16 16:20:22.824 Opening ALSA audio device 'default'.
2010-03-16 16:20:23.967 AO: Using resampler. From: 44100 to 48000
2010-03-16 16:20:23.968 Opening audio device 'default'. ch 2(2) sr 48000 (reenc 0)
2010-03-16 16:20:23.968 Opening ALSA audio device 'default'.
2010-03-16 16:20:24.035 MythCDROMLinux::setSpeed() - Limiting CD/DVD Speed to 354KB/s
2010-03-16 16:20:24.044 MythCDROMLinux::setSpeed() - CD/DVD Speed Set Successful
2010-03-16 16:20:24.044 MediaMonitor::setSpeed(%1) - Cannot find/create CDROM?/dev/sr0
2010-03-16 16:20:52.431 WriteAudio: buffer underrun
2010-03-16 16:20:52.655 WriteAudio: buffer underrun
2010-03-16 16:21:11.821 WriteAudio: buffer underrun
2010-03-16 16:21:31.161 WriteAudio: buffer underrun

And this from the Pioneer DVR-215BK(Working).

2010-03-16 16:43:37.237 CD status has changed.
2010-03-16 16:43:47.539 AO: Using resampler. From: 44100 to 48000
2010-03-16 16:43:47.540 Opening audio device 'default'. ch 2(2) sr 48000 (reenc 0)
2010-03-16 16:43:47.541 Opening ALSA audio device 'default'.
2010-03-16 16:43:47.598 MythCDROMLinux::setSpeed() - Limiting CD/DVD Speed to 354KB/s
2010-03-16 16:43:47.601 MythCDROMLinux::setSpeed() - CD/DVD Speed Set Successful
2010-03-16 16:43:47.601 MediaMonitor::setSpeed(%1) - Cannot find/create CDROM?/dev/sr0

All I did was unplug one and plug in the other.

Hope this helps

comment:17 Changed 14 years ago by roland-s@…

I have the same issue. MB 9.10 and a new LG. ppa is activated. No solution at all. VLC plays Audio fine ...

comment:18 Changed 14 years ago by anonymous

Just an update on what I have tested.

OS's (None work) Mythbuntu (latest release V.22 amd32Bit). Mythbuntu (latest release V.22 amd64Bit).

Mythtv Version .23 (Does not work)

New DVD Burners (none of which work): LG, ASUS, Liteon, HP

Older Burner (Works but is very noisy) 2YO Pioneer Sata Drive.

Setup (None of which work) ASUS M4A785G- HTPC Mobo, AMD Athlon X$ 630, 2G DDR3 1066. ASUS P5P41TLE Mobo, Intel Q9600, 4GB DD4 1333

Although a 2 Year old Pioneer SATA drive does not exhibit the problem, Im am not convinced this is purely a Hardware problem. All components used (Bar the Pioner Burner) were brand new straight out of the box.

Can anyone please advise of a setup which DOES work - preferably with new, easy to find components?

comment:19 Changed 14 years ago by anonymous

By the way can someone please upgrade the status of this? Also this is NOT unique to version .22 as mentioned above .23 exhibits exactly the same problem.

comment:20 Changed 14 years ago by robertm

The ticket is open, there is no status to "upgrade." The milestone is set to unknown, which means it has no specific due date, but that it will be dealt with when someone capable and interested looks at it. If you would like to converse about the ticket, please take it to the developers list so that it is not necessary to lock the ticket.

comment:21 Changed 14 years ago by d.herlihy@…

One would have thought the ability for MythTV to Play CDs was not "Minor".

comment:22 Changed 14 years ago by robertm

Ticket locked: set

comment:23 Changed 14 years ago by robertm

See #8362 for proposed patch.

comment:24 Changed 14 years ago by JYA

Resolution: fixed
Status: newclosed

buffer handling was rewritten in the hdaudio branch and now merged in trunk...

If you do notice issues, please submit a new ticket

Note: See TracTickets for help on using tickets.