jacksonlcrews / darkice

Automatically exported from code.google.com/p/darkice
0 stars 0 forks source link

Buffering problem with fix, long standing bug in BufferedSink.cpp #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. always ticks with mp3 file after a few seconds
2. breaks aacp stream sync in my player
3.

What is the expected output? What do you see instead?
Some buffer is written twice, causing corruption of datastream

What version of the product are you using? On what operating system?
0.20.1

Please provide any additional information below.

In BufferedSink.cpp some logic is not OK
starting on line 331

// if the buffer is empty then inp==outp 

  // the internal buffer is empty, try to write the fresh data
    soFar = 0;
    if (/* inp != outp*/ inp == outp ) { /* Edwin van den Oetelaar bug fix
26/4/2010 has been here for 10 years !! */
        while ( soFar < len && sink->canWrite( 0, 0) ) {
            try {
            soFar += sink->write( b + soFar, len - soFar);
            } catch (Exception &e) {
                fprintf(stderr,"Exception caught in BufferedSink :: write3\n");
                throw; /* up a level */
        }
            }
    }
    length = soFar;

Original issue reported on code.google.com by oetelaar.automatisering on 25 Apr 2010 at 11:34

GoogleCodeExporter commented 9 years ago
Where is the patch with the fix?
I'll be glad to apply it.

Original comment by rafael2k...@gmail.com on 6 May 2010 at 7:18

GoogleCodeExporter commented 9 years ago
I just realized this bug is present in the stream I'm testing right now.

Original comment by rafael2k...@gmail.com on 6 May 2010 at 7:29

GoogleCodeExporter commented 9 years ago
This lines you posted are the fix?

Original comment by rafael2k...@gmail.com on 6 May 2010 at 7:31

GoogleCodeExporter commented 9 years ago
Index: src/BufferedSink.cpp
===================================================================
--- src/BufferedSink.cpp        (revision 467)
+++ src/BufferedSink.cpp        (working copy)
@@ -330,10 +330,15 @@

     // the internal buffer is empty, try to write the fresh data
     soFar = 0;
-    if ( inp != outp ) {
+    if ( inp == outp ) { /* Edwin van den Oetelaar bug fix 26/4/2010 */
         while ( soFar < len && sink->canWrite( 0, 0) ) {
-            soFar += sink->write( b + soFar, len - soFar);
-        }
+           try {
+               soFar += sink->write( b + soFar, len - soFar);
+           } catch (Exception &e) {
+               reportEvent(3,"Exception caught in BufferedSink :: write3\n");
+               throw; /* up a level */
+           }
+       }
     }
     length = soFar;

Original comment by rafael2k...@gmail.com on 6 May 2010 at 7:45

GoogleCodeExporter commented 9 years ago
Any more comments about this bug?
I'll apply the patch.

Original comment by rafael2k...@gmail.com on 6 May 2010 at 8:10

GoogleCodeExporter commented 9 years ago
applied in 468.

Original comment by rafael2k...@gmail.com on 6 May 2010 at 8:20