Opened 12 years ago

Closed 11 years ago

#5313 closed patch (fixed)

Tracking ticket for audio fixes to backport to 0.21

Reported by: danielk Owned by: danielk
Priority: minor Milestone: 0.21.1
Component: mythtv Version: head
Severity: medium Keywords:
Cc: Ticket locked: no

Description


Attachments (3)

5313-v1.patch (4.6 KB) - added by danielk 11 years ago.
untested backport of the referenced trunk patches.
5313-v2.patch (4.6 KB) - added by danielk 11 years ago.
still completely untested, but this version compiles
gdb.txt (68.8 KB) - added by anonymous 11 years ago.
output from gdb

Download all attachments as: .zip

Change History (21)

comment:1 Changed 12 years ago by danielk

(In [17251]) Fixes #4764. Refs #5313. Fixes ALSA output buffer sizing problem.

comment:2 Changed 12 years ago by danielk

(In [17252]) Fixes #5043. Refs #5313. Make sure we always modulo kAudioRingBufferSize when setting the audio ring buffer pointer.

comment:3 Changed 12 years ago by danielk

(In [17253]) Fixes #5283. Refs #5313. Fixes for default audio timestretch != 1.0.

Changed 11 years ago by danielk

Attachment: 5313-v1.patch added

untested backport of the referenced trunk patches.

comment:4 Changed 11 years ago by danielk

Type: taskpatch

I've just attached a patch to this ticket backporting the fixes for #4764, #5043, and #5283. It's completely untested but if someone has audio problems with 0.21-fixes and a little time on their hands...

comment:5 Changed 11 years ago by anonymous

Patch does not compile for me against head of .21-fixes (r18548). Fixing lines 706 and 775 were trivial. The issue at 681 is beyond me.

audiooutputbase.cpp: In member function ‘virtual int AudioOutputBase::GetAudioBufferedTime?() const’: audiooutputbase.cpp:681: error: passing ‘const AudioOutputBase?’ as ‘this’ argument of ‘virtual int AudioOutputBase::GetAudiotime?()’ discards qualifiers audiooutputbase.cpp: In member function ‘virtual bool AudioOutputBase::AddSamples?(char, int, long long int)’: audiooutputbase.cpp:706: error: expected `)' before ‘{’ token audiooutputbase.cpp:749: warning: no return statement in function returning non-void audiooutputbase.cpp: In member function ‘virtual bool AudioOutputBase::AddSamples?(char*, int, long long int)’: audiooutputbase.cpp:775: error: expected `)' before ‘{’ token audiooutputbase.cpp:812: warning: no return statement in function returning non-void

comment:6 Changed 11 years ago by elkin@…

strange, I got it to apply to 0.21.0+fixes18528 ...

but I get the following build error:

ccache g++ -c -pipe -march=k8 -fomit-frame-pointer -O3 -DNDEBUG -g -Wall -Wno-switch -Wpointer-arith -Wredundant-decls -
Wno-non-virtual-dtor -D__STDC_CONSTANT_MACROS -I/usr/include/kde/artsc -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-
2.0/include -D_REENTRANT -DPIC -fPIC  -DMMX -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DRUNPREFIX=\"/usr\" -DLIBDIRNAME=\"lib
\" -DUSING_OSS -DUSE_ALSA -DUSE_JOYSTICK_MENU -DUSE_LIRC -DUSE_ARTS -DUSE_JACK -DUSING_X11 -DUSING_XRANDR -DQT_THREAD_SU
PPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I/usr/include -I/usr/include -I../libmythsam
plerate -I../libmythsoundtouch -I../libmythfreesurround -I../libavcodec -I../libavutil -I../.. -I.. -I. -I/usr/include/q
t3 -o audiooutputbase.o audiooutputbase.cpp                                                                             
audiooutputbase.cpp: In member function â??virtual int AudioOutputBase::GetAudioBufferedTime() constâ??:                
audiooutputbase.cpp:681: error: passing â??const AudioOutputBaseâ?? as â??thisâ?? argument of â??virtual int AudioOutput
Base::GetAudiotime()â?? discards qualifiers                                                                             
audiooutputbase.cpp: In member function â??virtual bool AudioOutputBase::AddSamples(char**, int, long long int)â??:     
audiooutputbase.cpp:706: error: expected `)' before â??{â?? token                                                       
audiooutputbase.cpp:749: warning: no return statement in function returning non-void                                    
audiooutputbase.cpp: In member function â??virtual bool AudioOutputBase::AddSamples(char*, int, long long int)â??:      
audiooutputbase.cpp:775: error: expected `)' before â??{â?? token                                                       
audiooutputbase.cpp:812: warning: no return statement in function returning non-void  

Changed 11 years ago by danielk

Attachment: 5313-v2.patch added

still completely untested, but this version compiles

comment:7 Changed 11 years ago by danielk

note: I attached a new version of the patch a couple days ago, just commenting because trac doesn't notify when an attachment is added.

comment:8 in reply to:  7 Changed 11 years ago by anonymous

Replying to danielk:

note: I attached a new version of the patch a couple days ago, just commenting because trac doesn't notify when an attachment is added.

thanks, patch applies, builds and I am testing it right now

comment:9 Changed 11 years ago by elkin@…

Tested it for a few hours yesterday and its stable. Thanks!

comment:10 Changed 11 years ago by anonymous

My preliminary testing of this seems to have resolved ticket 5750 for me. I still get a few instances of "AddAudioData?():p1: Audio buffer overflow, audio data lost!", but it's not continual as before. With the patch, the audio now sounds fluid and the video chopiness is gone. I'll try to test this some more tomorrow. Thanks!

comment:11 Changed 11 years ago by anonymous

I've played several types of media with this today and it has worked well under normal conditions. If, however, I attempt to use Time Stretch on a video with AC3 audio and AC3 pass through enabled, the Frontend crashes. It does not crash if the video either does not contain AC3 audio or if pass through is disabled.

I applied the patch on top of r18670. I won't have time until next weekend to check if I have the same problem without the patch or to get any diagnostic information.

comment:12 in reply to:  11 Changed 11 years ago by anonymous

Replying to anonymous:

Reverting the patch back to r18670, I no longer get the Segmentation Fault when doing time stretch on AC3 pass through. It looks like this patch breaks time stretch with pass through enabled.

comment:13 Changed 11 years ago by danielk

Can you create a backtrace for the the segfault? Here are the directions:

http://www.mythtv.org/docs/mythtv-HOWTO-22.html#ss22.2

With that in hand I should be able to fix this pretty quickly by comparing the relevant code to the code in head.

comment:14 in reply to:  13 ; Changed 11 years ago by anonymous

Replying to danielk:

Can you create a backtrace for the the segfault?

Yeah, I'll get that for you. Likely won't be until next weekend though.

comment:15 in reply to:  14 ; Changed 11 years ago by anonymous

Replying to anonymous:

Turns out a sleepless baby means time to do this tonight...

Anyhow, it does not appear gdb resulted in anything useful. Once I activate time stretch, mythfrontend just locks up where it would typically seg fault. As far as I can tell, the gdb.txt file ends with the button presses. Ctl-C in gdb does not produce a backtrace as suggested. Neither does killing mythfrontend or the gdb process.

For what it's worth, this seems really easy to reproduce. I'm seeing it on both a Gentoo and an Ubuntu box. One is AMD, the other Intel. They're both running 64-bit. I'm not sure if spdif out is required or not (both my boxes have it although only one has it hooked up)

I will be attaching the gdb.txt file. Additionally, I attempted to get more info as follows:


(gdb) bt
#0  0x00007fe4da12d718 in ?? () from /usr/lib/libqt-mt.so.3
#1  0x00007fe4da12e129 in operator< () from /usr/lib/libqt-mt.so.3
#2  0x00007fe4de809077 in QMapPrivate<QString, OSDSet*>::find (this=0x290df40, k=@0x44310ad0) at /usr/include/qt3/qmap.h:506
#3  0x00007fe4de809135 in QMap<QString, OSDSet*>::find (this=0x5f04a98, k=@0x44310ad0) at /usr/include/qt3/qmap.h:701
#4  0x00007fe4de809170 in QMap<QString, OSDSet*>::contains (this=0x5f04a98, k=@0x44310ad0) at /usr/include/qt3/qmap.h:706
#5  0x00007fe4de7e67e2 in OSD::GetSet (this=0x5f049d0, text=@0x44310ad0) at osd.cpp:2639
#6  0x00007fe4de7e913f in OSD::DialogShowing (this=0x5f049d0, name=@0x44310ad0) at osd.cpp:2276
#7  0x00007fe4de6ebd79 in TV::UpdateOSDTimeoutMessage (this=0x7fe4d0002fc0) at tv_play.cpp:5475
#8  0x00007fe4de7196b2 in TV::RunTV (this=0x7fe4d0002fc0) at tv_play.cpp:2125
#9  0x00007fe4de71baf9 in TV::EventThread (param=0x7fe4d0002fc0) at tv_play.cpp:2079
#10 0x00007fe4d8cce3ea in start_thread () from /lib/libpthread.so.0
#11 0x00007fe4d8291c6d in clone () from /lib/libc.so.6
#12 0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x00007fe4da12e129 in operator< () from /usr/lib/libqt-mt.so.3
(gdb) return
Make selected stack frame return now? (y or n) u
Please answer y or n.
Make selected stack frame return now? (y or n) y
#0  0x00007fe4de809077 in QMapPrivate<QString, OSDSet*>::find (this=0x290df40, k=@0x44310ad0) at /usr/include/qt3/qmap.h:506
506		if ( !( key(x) < k ) ) {
(gdb) return
Make QMapPrivate<QString, OSDSet*>::find(QString const&) const return now? (y or n) y
#0  0x00007fe4de809135 in QMap<QString, OSDSet*>::find (this=0x5f04a98, k=@0x44310ad0) at /usr/include/qt3/qmap.h:701
701	    const_iterator find ( const Key& k ) const {	return sh->find( k ); }
(gdb) return
Make QMap<QString, OSDSet*>::find(QString const&) const return now? (y or n) y
#0  0x00007fe4de809170 in QMap<QString, OSDSet*>::contains (this=0x5f04a98, k=@0x44310ad0) at /usr/include/qt3/qmap.h:706
706		{ return find( k ) != end(); }
(gdb) return
Make QMap<QString, OSDSet*>::contains(QString const&) const return now? (y or n) y
#0  0x00007fe4de7e67e2 in OSD::GetSet (this=0x5f049d0, text=@0x44310ad0) at osd.cpp:2639
2639	    if (setMap.contains(text))
(gdb) return
Make OSD::GetSet(QString const&) return now? (y or n) y
#0  0x00007fe4de7e913f in OSD::DialogShowing (this=0x5f049d0, name=@0x44310ad0) at osd.cpp:2276
2276	    bool ret = (GetSet(name) != NULL);
(gdb) return
Make OSD::DialogShowing(QString const&) return now? (y or n) y
#0  0x00007fe4de6ebd79 in TV::UpdateOSDTimeoutMessage (this=0x7fe4d0002fc0) at tv_play.cpp:5475
5475	        if (osd->DialogShowing(dlg_name))
(gdb) return
Make TV::UpdateOSDTimeoutMessage() return now? (y or n) y
#0  TV::RunTV (this=0x7fe4d0002fc0) at tv_play.cpp:2127
2127	            if (!tvchainUpdate.isEmpty())
(gdb) return
Make TV::RunTV() return now? (y or n) y
#0  TV::EventThread (param=0x7fe4d0002fc0) at tv_play.cpp:2081
2081	    return NULL;
(gdb) return
Make TV::EventThread(void*) return now? (y or n) y
#0  0x00007fe4d8cce3ea in start_thread () from /lib/libpthread.so.0
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x00007fe4d8291c6d in clone () from /lib/libc.so.6
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()
(gdb) return
Make selected stack frame return now? (y or n) y
#0  0x0000000000000000 in ?? ()

Changed 11 years ago by anonymous

Attachment: gdb.txt added

output from gdb

comment:16 in reply to:  15 Changed 11 years ago by anonymous

Replying to anonymous:

Here is the frontend verbose output (important,playback,audio) from where time stretch was enabled:

2008-10-27 00:26:42.580 Set video sync frame interval to 15888
2008-10-27 00:26:42.580 NVP: Stretch Factor 1.05, disable passthru 
2008-10-27 00:26:42.580 AFD: Disabling pass through
2008-10-27 00:26:42.581 AFD: Initializing audio parms from audio track #1
2008-10-27 00:26:42.581 AFD: Audio format changed digital passthrough id( AC3) 48000Hz  2ch  16bps   
			from id( AC3) 48000Hz  6ch  16bps pt ; id( AC3) 48000Hz  2ch  16bps pt
			to   id( AC3) 48000Hz  2ch  16bps    ; id( AC3) 48000Hz  2ch  16bps   
2008-10-27 00:26:42.581 AO: SetEffDsp: 4800000
2008-10-27 00:26:42.581 AO: Killing AudioOutputDSP
2008-10-27 00:26:42.581 AO: OutputAudioLoop: Stop Event
2008-10-27 00:26:42.581 AO: kickoffOutputAudioLoop exiting
2008-10-27 00:26:42.615 in SetParameters(format=2, channels=2, rate=48000, buffer_time=400000, period_time=25000)
2008-10-27 00:26:42.615 get_buffer_size returned 19200
2008-10-27 00:26:42.615 set_period_time_near returned 25000
2008-10-27 00:26:42.615 get_period_size returned 1200
2008-10-27 00:26:42.627 Opening mixer default
2008-10-27 00:26:42.655 Setting Master volume to 70
2008-10-27 00:26:42.665 Volume range is 0 to 65536, mult=0.00152588
2008-10-27 00:26:42.665 channel 0 vol set to 45875
2008-10-27 00:26:42.665 Mixer unable to find control PCM
2008-10-27 00:26:42.665 Mixer unable to find control PCM
2008-10-27 00:26:42.665 ALSA: channel 0 playback switch set to 1
2008-10-27 00:26:42.665 Setting Master volume to 70
2008-10-27 00:26:42.665 Volume range is 0 to 65536, mult=0.00152588
2008-10-27 00:26:42.665 channel 1 vol set to 45875
2008-10-27 00:26:42.665 Mixer unable to find control PCM
2008-10-27 00:26:42.665 Mixer unable to find control PCM
2008-10-27 00:26:42.665 ALSA: channel 1 playback switch set to 1
2008-10-27 00:26:42.665 Setting PCM volume to 96
2008-10-27 00:26:42.665 Mixer unable to find control PCM
2008-10-27 00:26:42.665 Setting PCM volume to 96
2008-10-27 00:26:42.665 Mixer unable to find control PCM
2008-10-27 00:26:42.665 Mixer unable to find control PCM
2008-10-27 00:26:42.665 AO: Audio fragment size: 6144
2008-10-27 00:26:42.665 AO: Audio Stretch Factor: 1
2008-10-27 00:26:42.665 Audio Codec Used: AC3
2008-10-27 00:26:42.672 AO: Ending reconfigure
2008-10-27 00:26:42.677 AO: Creating Encoder for codec 86020 origfs 1536
2008-10-27 00:26:42.677 DEnc: Init codecid=AC3, br=384000, sr=48000, ch=2
2008-10-27 00:26:42.677 DigitalEncoder::Init fs=1536, bpf=4 ofb=6144
2008-10-27 00:26:42.672 AO: kickoffOutputAudioLoop: pid = 20268
2008-10-27 00:26:42.679 AO: OutputAudioLoop: Play Event
2008-10-27 00:26:42.686 NVP: Video is 30 frames ahead of audio,
			doubling video frame interval to slow down.
'video_output' mean = '18924.09', std. dev. = '11491.31', fps = '52.84'
2008-10-27 00:26:42.970 NVP: Video is 5.161 frames ahead of audio,
			doubling video frame interval to slow down.
2008-10-27 00:26:42.979 NVP: Video is 16.8994 frames ahead of audio,
			doubling video frame interval to slow down.
2008-10-27 00:26:43.000 NVP: Video is 25.8134 frames ahead of audio,
			doubling video frame interval to slow down.
2008-10-27 00:26:43.019 NVP: Video is 30 frames ahead of audio,
			doubling video frame interval to slow down.
2008-10-27 00:26:43.033 NVP: Video is 30 frames ahead of audio,
			doubling video frame interval to slow down.
2008-10-27 00:26:43.067 NVP: Video is 30 frames ahead of audio,
			doubling video frame interval to slow down.
2008-10-27 00:26:43.079 NVP: Video is 30 frames ahead of audio,
			doubling video frame interval to slow down.
2008-10-27 00:26:43.108 NVP: Video is 30 frames ahead of audio,
			doubling video frame interval to slow down.

comment:17 Changed 11 years ago by Dibblah

Status: newassigned

comment:18 Changed 11 years ago by danielk

Resolution: fixed
Status: assignedclosed

No point in trying to backport this now since it causes problems and the next release is getting closer.. Marking as fixed for the already applied backports.

Note: See TracTickets for help on using tickets.