Mercurial > hg > svcore
diff data/fileio/OggVorbisFileReader.cpp @ 265:e08f486e8d8c
* Enable threaded decoding for Ogg and MP3 files.
Needs some work on reducing updates to the overview widget
author | Chris Cannam |
---|---|
date | Wed, 06 Jun 2007 16:24:55 +0000 |
parents | 71dfc6ab3b54 |
children | 822bd7fd526c |
line wrap: on
line diff
--- a/data/fileio/OggVorbisFileReader.cpp Fri Jun 01 13:56:35 2007 +0000 +++ b/data/fileio/OggVorbisFileReader.cpp Wed Jun 06 16:24:55 2007 +0000 @@ -41,6 +41,7 @@ m_fileSize(0), m_bytesRead(0), m_cancelled(false), + m_completion(0), m_decodeThread(0) { m_frameCount = 0; @@ -102,6 +103,7 @@ { std::cerr << "OggVorbisFileReader::~OggVorbisFileReader(" << m_path.toLocal8Bit().data() << "): now have " << (--instances) << " instances" << std::endl; if (m_decodeThread) { + m_cancelled = true; m_decodeThread->wait(); delete m_decodeThread; } @@ -118,6 +120,7 @@ m_reader->m_oggz = 0; if (m_reader->isDecodeCacheInitialised()) m_reader->finishDecodeCache(); + m_reader->m_completion = 100; } int @@ -130,13 +133,15 @@ fish_sound_decode(fs, packet->packet, packet->bytes); reader->m_bytesRead += packet->bytes; + + // The number of bytes read by this function is smaller than + // the file size because of the packet headers + int progress = lrint(double(reader->m_bytesRead) * 114 / + double(reader->m_fileSize)); + if (progress > 99) progress = 99; + reader->m_completion = progress; if (reader->m_fileSize > 0 && reader->m_progress) { - // The number of bytes read by this function is smaller than - // the file size because of the packet headers - int progress = lrint(double(reader->m_bytesRead) * 114 / - double(reader->m_fileSize)); - if (progress > 99) progress = 99; if (progress > reader->m_progress->value()) { reader->m_progress->setValue(progress); reader->m_progress->show(); @@ -146,7 +151,7 @@ reader->m_cancelled = true; } } - } + } if (reader->m_cancelled) return 1; return 0;