traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src/core ReadSource.cpp


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src/core ReadSource.cpp
Date: Wed, 17 Oct 2007 08:22:30 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/10/17 08:22:30

Modified files:
        src/core       : ReadSource.cpp 

Log message:
        * do not substract one 'frame' from the fileposition in 
rb_seek_to_file_position() when filepostion < 0. 
        It was done to solve a sync bug, but it seems it was a wrong fix after 
all, and it now introduces sync issues. 
        * make rb_file_read() more robust when file_read() didn't return the 
amount of frames requested. 

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ReadSource.cpp?cvsroot=traverso&r1=1.75&r2=1.76

Patches:
Index: ReadSource.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ReadSource.cpp,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- ReadSource.cpp      15 Oct 2007 10:00:12 -0000      1.75
+++ ReadSource.cpp      17 Oct 2007 08:22:30 -0000      1.76
@@ -412,11 +412,14 @@
 int ReadSource::rb_file_read(DecodeBuffer* buffer, nframes_t cnt)
 {
        int readFrames = file_read(buffer, m_rbFileReadPos, cnt);
+       if (readFrames == cnt) {
+               m_rbFileReadPos.add_frames(readFrames, m_outputRate);
+       } else {
+               printf("ERROR in ReadSource::rb_file_read %s : \nreadFrames %d, 
requested %d, m_rbFileReadPos %d\n", QS_C(m_fileName), readFrames, cnt, 
m_rbRelativeFileReadPos.to_frame(get_rate()));
+               // DiskIO will be confused when cnt != readframes, so just for 
the sake of
+               // not looping in DiskIO::do_work(), fake that the file_read() 
did work out correctly!
        m_rbFileReadPos.add_frames(cnt, m_outputRate);
-       // FIXME it should work with the line like below, but it sometimes 
confuses DiskIO::do_work()
-       // it starts looping!
-//     m_rbFileReadPos.add_frames(readFrames, m_outputRate);
-//     printf("file %s: readFrames, cnt: %d, %d\n", QS_C(m_fileName), 
readFrames, cnt);
+       }
 
        return readFrames;
 }
@@ -431,6 +434,7 @@
        // calculate position relative to the file!
        TimeRef fileposition = position - m_clip->get_track_start_location() - 
m_clip->get_source_start_location();
        
+       // Do nothing if we are allready at the seek position
        if (m_rbFileReadPos == fileposition) {
 //             printf("ringbuffer allready at position %d\n", position);
                return;
@@ -441,19 +445,16 @@
        // will come into play.
        if (fileposition < 0) {
 //             printf("not seeking to %ld, but too %d\n\n", 
fileposition,m_clip->get_source_start_location()); 
-               // Song's start from 0, this makes a period start from
-               // 0 - 1023 for example, the nframes is 1024!
-               // Setting a songs new position is on 1024, and NOT 
-               // 1023.. Hmm, something isn't correct here, but at least 
substract 1
-               // to make this thing work!
-               // TODO check if this is still needed!
-               fileposition = m_clip->get_source_start_location() - TimeRef(1, 
m_outputRate);
+               fileposition = m_clip->get_source_start_location();
        }
        
 //     printf("rb_seek_to_file_position:: seeking to relative pos: %d\n", 
fileposition);
+       
+       // The content of our buffers is no longer valid, so we empty them
        for (int i=0; i<m_buffers.size(); ++i) {
                m_buffers.at(i)->reset();
        }
+       
        m_rbFileReadPos = fileposition;
        m_rbRelativeFileReadPos = fileposition;
 }
@@ -504,9 +505,11 @@
        nframes_t toWrite = rb_file_read(buffer, toRead);
        
        // and write it to the ringbuffer
+       if (toWrite) {
        for (int i=m_buffers.size()-1; i>=0; --i) {
                m_buffers.at(i)->write(buffer->destination[i], toWrite);
        }
+       }
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]