Mercurial > hg > svcore
comparison data/fileio/MatrixFile.cpp @ 411:52303ec15cd2
* Permit holding Shift while dragging an instant or other edited thing,
to override the initial drag resistance (for #1928943 sticky time
instants)
* better handling of updates during progressive decode load
* ready() signal from model (used by vect)
author | Chris Cannam |
---|---|
date | Mon, 19 May 2008 17:23:11 +0000 |
parents | 115f60df1e4d |
children | 5e4238d08caa |
comparison
equal
deleted
inserted
replaced
410:9c7ebf2cd956 | 411:52303ec15cd2 |
---|---|
270 | 270 |
271 if (w > 0 && m_defaultCacheWidth > w) { | 271 if (w > 0 && m_defaultCacheWidth > w) { |
272 m_defaultCacheWidth = w; | 272 m_defaultCacheWidth = w; |
273 } | 273 } |
274 | 274 |
275 static size_t maxCacheMB = 16; | 275 //!!! static size_t maxCacheMB = 16; |
276 static size_t maxCacheMB = 4; | |
276 if (2 * m_defaultCacheWidth * h * m_cellSize > maxCacheMB * 1024 * 1024) { //!!! | 277 if (2 * m_defaultCacheWidth * h * m_cellSize > maxCacheMB * 1024 * 1024) { //!!! |
277 m_defaultCacheWidth = (maxCacheMB * 1024 * 1024) / (2 * h * m_cellSize); | 278 m_defaultCacheWidth = (maxCacheMB * 1024 * 1024) / (2 * h * m_cellSize); |
278 if (m_defaultCacheWidth < 16) m_defaultCacheWidth = 16; | 279 if (m_defaultCacheWidth < 16) m_defaultCacheWidth = 16; |
279 } | 280 } |
280 | 281 |
423 MatrixFile::setColumnAt(size_t x, const void *data) | 424 MatrixFile::setColumnAt(size_t x, const void *data) |
424 { | 425 { |
425 assert(m_mode == ReadWrite); | 426 assert(m_mode == ReadWrite); |
426 | 427 |
427 #ifdef DEBUG_MATRIX_FILE_READ_SET | 428 #ifdef DEBUG_MATRIX_FILE_READ_SET |
428 std::cerr << "MatrixFile::setColumnAt(" << x << ")" << std::endl; | 429 // std::cerr << "MatrixFile::setColumnAt(" << x << ")" << std::endl; |
430 std::cerr << "."; | |
429 #endif | 431 #endif |
430 | 432 |
431 ssize_t w = 0; | 433 ssize_t w = 0; |
432 bool seekFailed = false; | 434 bool seekFailed = false; |
433 | 435 |
515 } | 517 } |
516 | 518 |
517 std::cerr << "MatrixFile(" << this << ":" << m_fileName.toStdString() << ")::resume(): fd is " << m_fd << std::endl; | 519 std::cerr << "MatrixFile(" << this << ":" << m_fileName.toStdString() << ")::resume(): fd is " << m_fd << std::endl; |
518 } | 520 } |
519 | 521 |
522 static int alloc = 0; | |
523 | |
520 void | 524 void |
521 MatrixFile::primeCache(size_t x, bool goingLeft) | 525 MatrixFile::primeCache(size_t x, bool goingLeft) |
522 { | 526 { |
523 // Profiler profiler("MatrixFile::primeCache"); | 527 // Profiler profiler("MatrixFile::primeCache"); |
524 | 528 |
584 #ifdef DEBUG_MATRIX_FILE_READ_SET | 588 #ifdef DEBUG_MATRIX_FILE_READ_SET |
585 std::cerr << "received last request: actual size is: " << m_cache.x << ", " << m_cache.width << std::endl; | 589 std::cerr << "received last request: actual size is: " << m_cache.x << ", " << m_cache.width << std::endl; |
586 #endif | 590 #endif |
587 | 591 |
588 if (m_cache.data) { | 592 if (m_cache.data) { |
589 if (m_spareData) free(m_spareData); | 593 if (m_spareData) { |
594 std::cerr << this << ": Freeing spare data" << std::endl; | |
595 free(m_spareData); | |
596 } | |
597 std::cerr << this << ": Moving old cache data to spare" << std::endl; | |
590 m_spareData = m_cache.data; | 598 m_spareData = m_cache.data; |
591 } | 599 } |
600 std::cerr << this << ": Moving request data to cache" << std::endl; | |
592 m_cache.data = request.data; | 601 m_cache.data = request.data; |
593 | 602 |
594 m_readThread->done(m_requestToken); | 603 m_readThread->done(m_requestToken); |
595 m_requestToken = -1; | 604 m_requestToken = -1; |
596 } | 605 } |
609 | 618 |
610 #ifdef DEBUG_MATRIX_FILE_READ_SET | 619 #ifdef DEBUG_MATRIX_FILE_READ_SET |
611 std::cerr << "cancelled " << m_requestToken << std::endl; | 620 std::cerr << "cancelled " << m_requestToken << std::endl; |
612 #endif | 621 #endif |
613 | 622 |
614 if (m_spareData) free(m_spareData); | 623 if (m_spareData) { |
624 std::cerr << this << ": Freeing spare data" << std::endl; | |
625 free(m_spareData); | |
626 } | |
627 std::cerr << this << ": Moving request data to spare" << std::endl; | |
615 m_spareData = request.data; | 628 m_spareData = request.data; |
616 m_readThread->done(m_requestToken); | 629 m_readThread->done(m_requestToken); |
617 | 630 |
618 m_requestToken = -1; | 631 m_requestToken = -1; |
619 } | 632 } |
625 | 638 |
626 request.fd = m_fd; | 639 request.fd = m_fd; |
627 request.mutex = &m_fdMutex; | 640 request.mutex = &m_fdMutex; |
628 request.start = m_headerSize + rx * m_height * m_cellSize; | 641 request.start = m_headerSize + rx * m_height * m_cellSize; |
629 request.size = rw * m_height * m_cellSize; | 642 request.size = rw * m_height * m_cellSize; |
643 | |
644 std::cerr << this << ": Moving spare data to request, and resizing to " << rw * m_height * m_cellSize << std::endl; | |
645 | |
630 request.data = (char *)realloc(m_spareData, rw * m_height * m_cellSize); | 646 request.data = (char *)realloc(m_spareData, rw * m_height * m_cellSize); |
631 MUNLOCK(request.data, rw * m_height * m_cellSize); | 647 MUNLOCK(request.data, rw * m_height * m_cellSize); |
632 m_spareData = 0; | 648 m_spareData = 0; |
633 | 649 |
634 m_requestingX = rx; | 650 m_requestingX = rx; |