]> git.sesse.net Git - mlt/commitdiff
Fix audio glitch on seek (3362840).
authorDan Dennedy <dan@dennedy.org>
Fri, 15 Jul 2011 05:35:45 +0000 (22:35 -0700)
committerDan Dennedy <dan@dennedy.org>
Fri, 15 Jul 2011 05:35:45 +0000 (22:35 -0700)
src/modules/avformat/producer_avformat.c

index 038e3f1a80e20569728e273a27e4a9e8f67e1995..929b08cb5807f79a5328e20b3861d659b1906b51 100644 (file)
@@ -2055,10 +2055,10 @@ static int decode_audio( producer_avformat self, int *ignore, AVPacket pkt, int
                        }
 
                        // Handle ignore
-                       while ( *ignore && audio_used > samples )
+                       while ( *ignore && audio_used )
                        {
                                *ignore -= 1;
-                               audio_used -= samples;
+                               audio_used -= audio_used > samples ? samples : audio_used;
                                memmove( audio_buffer, &audio_buffer[ samples * (resample? channels : codec_context->channels) * sizeof_sample ],
                                                 audio_used * sizeof_sample );
                        }
@@ -2076,9 +2076,10 @@ static int decode_audio( producer_avformat self, int *ignore, AVPacket pkt, int
 
                if ( *ignore == 0 )
                {
+                       fprintf(stderr, "int_pos %lld req_pos %lld\n", int_position, req_position);
                        if ( int_position < req_position )
                                // We are behind, so skip some
-                               *ignore = 1;
+                               *ignore = req_position - int_position;
 
                        // We use nb_streams in this test because the tolerance is dependent
                        // on the interleaving of all streams esp. when there is more than