Bugs item #776924, was opened at 2003-07-24 05:52
Message generated for change (Comment added) made by nobody
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=111050&aid=776924&group_id=11050

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Sound problem due to not enough dropped frames(?)

Initial Comment:
Hi,    
    
I have the following problem using newer version of    
avifile (currently I'm using debian/latest sid    
package):    
I use a pretty slow computer K6/2-500 + G200 and   
hence I have some dropped frames using DIVX-Playback.   
Yet what is annoying that it seems that not enough   
video frames are dropped to ensure proper playback of   
the audio stream.    
When playing back the audio stream alone or when    
partially covering the video with another window, the    
sound plays perfectly (the computer seems to be able    
to keep the audio queue(?) filled).    
Yet when I play back audio and video together and    
make the computer do the work for the whole picture,    
it works for a few seconds (audio queue filled   
initially?) and then the audio quality is getting   
very poor with static clicks and unclean noises ...    
Previously I used an ancient version of avifile which   
dropped far more frames but which played the stream   
flawlessly.   
Hence my guess is that the audio queue somehow   
underflows. Note that even when the audio quality is   
poor, I do not necessarily have dropped frames.  
  
Best regards,  
Ralf 
 
P.S. I use OSS/Alsa audio playback and tried both 
MP3-decoders with the exact same result. 

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2003-08-01 17:13

Message:
Logged In: NO 

The following patch extremly improves the situation
(however: sometimes, especially directly after a seek the
sound fails nevertheless - in that case, an (additional)
seek makes the sound work again).
Maybe some additional intelligence (e.g. evaluation of
return code + errno (cf. my previous post)) could finally
resolve that matter.

--- deb/avifile-0.7.38.20030710/lib/aviplay/aviplayth.cpp
2003-05-26 10:03:41.000000000 +0200
+++ deb2/avifile-0.7.38.20030710/lib/aviplay/aviplayth.cpp
2003-08-02 01:38:11.000000000 +0200
@@ -557,6 +557,7 @@
             // is unable to extract new samples - wait for
a while
            m_ThreadCond[th].Wait(m_ThreadMut[th], 0.1);
        }
+       /*
        else if (m_pAudioRenderer->GetBufferTime() - buftime > 0.02)
        {
            // just a small trick - so the buffers will not be filled
@@ -564,6 +565,7 @@
            //AVM_WRITE("aviplay", "JO  %f  %f\n", buftime,
to_float(longcount(), m_lTimeStart));
            m_ThreadCond[th].Wait(m_ThreadMut[th], 0.01);
        }
+       */
     }
 
     AVM_WRITE("aviplay", 1, "Thread audio finished\n");

Or uuencoded:
begin 644 solve_audio_problems_in_most_cases_patch
M+2TM(&1E8B]A=FEF:6QE+3`N-RXS."XR,#`S,#<Q,"]L:6(O879I<&QA>2]A
M=FEP;&%Y=&@N8W!P"3(P,#,M,#4M,C8@,3`Z,#,Z-#$N,#`P,#`P,#`P("LP
M,C`P"BLK*R!D96(R+V%V:69I;&4M,"XW+C,X+C(P,#,P-S$P+VQI8B]A=FEP
M;&%Y+V%V:7!L87ET:"YC<'`),C`P,RTP."TP,B`P,3HS.#HQ,2XP,#`P,#`P
M,[EMAIL PROTECTED],[EMAIL PROTECTED]("LU-3<L-R!`0`H@("`@("`@("`@("[EMAIL PROTECTED]@
M:7,@=6YA8FQE('1O(&5X=')A8W0@;F5W('-A;7!L97,@+2!W86ET(&9O<B!A
M('=H:6QE"B`)("`@(&U?5&AR96%D0V]N9%MT:%TN5V%I="AM7U1H<F5A9$UU
M=%MT:%TL(#`N,2D["B`)?0HK"2\J"B`)96QS92!I9B`H;5]P075D:6]296YD
M97)E<BT^1V5T0G5F9F5R5&[EMAIL PROTECTED]("[EMAIL PROTECTED]&EM92`^(#`N,#(I"B`)>PH@
M"2`@("`O+R!J=7-T(&$@<VUA;&[EMAIL PROTECTED]')[EMAIL PROTECTED];R!T:&[EMAIL 
PROTECTED]<R!W
M:6QL(&YO="!B92!F:[EMAIL PROTECTED]"PV("LU-C4L-R!`0`H@"2`@("`O
[EMAIL PROTECTED]<&QA>2(L(")*3R`@)68@("5F7&XB+"!B=69T:6UE
M+"!T;U]F;&]A="AL;VYG8V]U;G0H*2P@;5]L5&EM95-T87)T*2D["B`)("`@
M(&U?5&AR96%D0V]N9%MT:%TN5V%I="AM7U1H<F5A9$UU=%MT:%TL(#`N,#$I
M.PH@"7T**PDJ+PH@("`@('T*(`H@("`@([EMAIL PROTECTED]<&QA>2(L
@(#$L(")4:')[EMAIL PROTECTED]:[EMAIL PROTECTED]:7-H961<;B(I.PH`
`
end

I also have minor patch for AudioQueue which is unrelated to
my problem (it is a neglectable speed up):
--- deb/avifile-0.7.38.20030710/lib/aviplay/AudioQueue.cpp
2003-05-25 00:47:27.000000000 +0200
+++ deb2/avifile-0.7.38.20030710/lib/aviplay/AudioQueue.cpp
2003-08-02 01:34:02.000000000 +0200
@@ -197,15 +197,17 @@
 {
     //AVM_WRITE("aviplay", 2, "AudioQueue::Write(%d) %d\n",
count, m_uiBufSize);
 
-    uint_t new_count = count * m_Owf.nSamplesPerSec /
m_Iwf.nSamplesPerSec + 16;
-
     chunk newch;
 
-    newch.mem = data;
-    newch.size = count;
-
-    if (m_Iwf.nSamplesPerSec != m_Owf.nSamplesPerSec)
+    if (m_Iwf.nSamplesPerSec == m_Owf.nSamplesPerSec)
     {
+       newch.mem = data;
+       newch.size = count;
+    }
+    else
+    {
+       uint_t new_count = count * m_Owf.nSamplesPerSec /
m_Iwf.nSamplesPerSec + 16;
+
        newch.mem = new char[new_count];
        newch.size = Resample(newch.mem, data, count);
        delete[] data;

Or uuencoded:
begin 644 tiny_speed_up_patch
M+2TM(&1E8B]A=FEF:6QE+3`N-RXS."XR,#`S,#<Q,"]L:6(O879I<&QA>2]!
M=61I;U%U975E+F-P<`DR,#`S+3`U+3(U(#`P.C0W.C(W+C`P,#`P,#`P,"`K
M,#(P,[EMAIL PROTECTED]&5B,B]A=FEF:6QE+3`N-RXS."XR,#`S,#<Q,"]L:6(O879I
M<&QA>2]!=61I;U%U975E+F-P<`DR,#`S+3`X+3`R(#`Q.C,T.C`R+C`P,#`P
M,#`P,"`K,#(P,`I`0"`M,3DW+#$U("LQ.3<L,3<@0$`*('L*("`@("`O+T%6
[EMAIL PROTECTED]<&QA>2(L(#(L(")!=61I;U%U975E.CI7<[EMAIL PROTECTED]"D@
M)61<;B(L(&-O=6YT+"!M7W5I0G5F4VEZ92D["B`*+2`@("!U:6YT7W0@;F5W
M7V-O=6YT([EMAIL PROTECTED];[EMAIL PROTECTED]<&QE<U!E<E-E8R`O(&U?27=F
M+FY386UP;&5S4&5R4V5C("L@,38["BT*("`@("!C:'5N:R!N97=C:#L*(`HM
M("`@(&YE=V-H+FUE;2`](&1A=&$["BT@("`@;[EMAIL PROTECTED]<VEZ92`](&-O=6YT
M.PHM"BT@("`@:[EMAIL PROTECTED]&U?27=F+FY386UP;&5S4&5R4V5C("$](&U?3W=F+FY3
M86UP;&5S4&5R4V5C*0HK("`@(&EF("AM7TEW9BYN4V%M<&QE<U!E<E-E8R`]
M/2!M7T]W9BYN4V%M<&QE<U!E<E-E8RD*("`@("!["BL);[EMAIL PROTECTED];65M(#T@
M9&%T83L**PEN97=C:"YS:7IE([EMAIL PROTECTED];G0["BL@("[EMAIL PROTECTED]("`@(&5L<V4*
M*R`@("!["BL)=6EN=%]T(&YE=U]C;W5N="`](&-O=6YT("H@;5]/=V8N;E-A
M;7!L97-097)396,@+R!M7TEW9BYN4V%M<&QE<U!E<E-E8R`K(#$V.PHK"B`)
M;[EMAIL PROTECTED];65M(#T@;F5W(&-H87);;F5W7V-O=6YT73L*(`EN97=C:"YS:7IE
M([EMAIL PROTECTED];&4H;[EMAIL PROTECTED];65M+"!D871A+"!C;W5N="D["B`)9&5L971E
)[EMAIL PROTECTED]&%T83L*
`
end

Best regards,
Ralf

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2003-07-31 15:01

Message:
Logged In: NO 

So after enabling some debug stuff, I figured out that when
the trouble starts, the audio queue is indeed nearly empty
(< a.m_uiWriteSize) and hence the oss buffer is empty, too.
The function doAudioOut is unable to deliver the data to the
oss buffer in time, because it becomes available too slowly.

I just installed alsa 0.9.6 (previously 0.9.5) and now I
have the problem shows itself in a different fashion:
instead of the clicks and stuff like the, the sound
completely stops.
The reason seems to be a different behavior of alsa - the call 
ioctl(a.m_iAudioFd, SNDCTL_DSP_GETOSPACE, &zz);
in the function
void* OssAudioRenderer::doAudioOut(void* arg)
returns -1 and errno is 32 (EPIPE), when the oss buffer
underflows and zz is not updated. Hence no further data is
delivered to the oss buffer (it might also have to be
reseted after the underflow (?)).

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2003-07-30 10:08

Message:
Logged In: NO 

Additional observation:
I uncommented line 40 in lib/aviplay/OssAudioRenderer.cpp
(int ds = open("/tmp/wav", O_WRONLY | O_CREAT | O_APPEND,
0666); write(ds, src, n); close(ds);).
The resulting /tmp/wav contains perfectly clear sound while
at the same time the real time playback has the deficiencies
mentioned in the bug report.
It really seems like the data is just not there in time.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2003-07-25 05:04

Message:
Logged In: NO 

Okay, I played just a little bit around and it seems like  
SDL audio playback is working perfectly.  
Hence it seems to be an OSS (OssAudioRenderer?) problem 
only.  

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=111050&aid=776924&group_id=11050

_______________________________________________
Avifile mailing list
[EMAIL PROTECTED]
http://prak.org/mailman/listinfo/avifile

Reply via email to