Mercurial > hg > svcore
comparison data/fileio/WavFileReader.cpp @ 1162:1dd98a5432cf
Work around libsndfile-1.0.26 bug that reports all files as non-seekable
author | Chris Cannam |
---|---|
date | Wed, 24 Feb 2016 11:35:51 +0000 |
parents | 5b463c7727e5 |
children | 6877f4200912 |
comparison
equal
deleted
inserted
replaced
1161:5b463c7727e5 | 1162:1dd98a5432cf |
---|---|
58 m_channelCount = m_fileInfo.channels; | 58 m_channelCount = m_fileInfo.channels; |
59 m_sampleRate = m_fileInfo.samplerate; | 59 m_sampleRate = m_fileInfo.samplerate; |
60 | 60 |
61 m_seekable = (m_fileInfo.seekable != 0); | 61 m_seekable = (m_fileInfo.seekable != 0); |
62 | 62 |
63 // Our m_seekable reports whether a file is rapidly seekable, | |
64 // so things like Ogg don't qualify. We cautiously report | |
65 // every file type of "at least" the historical period of Ogg | |
66 // or FLAC as non-seekable. | |
67 int type = m_fileInfo.format & SF_FORMAT_TYPEMASK; | 63 int type = m_fileInfo.format & SF_FORMAT_TYPEMASK; |
68 // cerr << "WavFileReader: format type is " << type << " (flac, ogg are " << SF_FORMAT_FLAC << ", " << SF_FORMAT_OGG << ")" << endl; | 64 int subtype = m_fileInfo.format & SF_FORMAT_SUBMASK; |
65 | |
69 if (type >= SF_FORMAT_FLAC || type >= SF_FORMAT_OGG) { | 66 if (type >= SF_FORMAT_FLAC || type >= SF_FORMAT_OGG) { |
70 // cerr << "WavFileReader: Recording as non-seekable" << endl; | 67 // Our m_seekable reports whether a file is rapidly |
68 // seekable, so things like Ogg don't qualify. We | |
69 // cautiously report every file type of "at least" the | |
70 // historical period of Ogg or FLAC as non-seekable. | |
71 m_seekable = false; | 71 m_seekable = false; |
72 } else if (type == SF_FORMAT_WAV && subtype <= SF_FORMAT_DOUBLE) { | |
73 // libsndfile 1.0.26 has a bug (subsequently fixed in the | |
74 // repo) that causes all files to be reported as | |
75 // non-seekable. We know that certain common file types | |
76 // are definitely seekable so, again cautiously, identify | |
77 // and mark those (basically only non-adaptive WAVs). | |
78 m_seekable = true; | |
72 } | 79 } |
73 } | 80 } |
74 | 81 |
75 // cerr << "WavFileReader: Filename " << m_path << ", frame count " << m_frameCount << ", channel count " << m_channelCount << ", sample rate " << m_sampleRate << ", format " << m_fileInfo.format << ", seekable " << m_seekable << endl; | 82 // cerr << "WavFileReader: Filename " << m_path << ", frame count " << m_frameCount << ", channel count " << m_channelCount << ", sample rate " << m_sampleRate << ", format " << m_fileInfo.format << ", seekable " << m_fileInfo.seekable << " adjusted to " << m_seekable << endl; |
76 | |
77 } | 83 } |
78 | 84 |
79 WavFileReader::~WavFileReader() | 85 WavFileReader::~WavFileReader() |
80 { | 86 { |
81 if (m_file) sf_close(m_file); | 87 if (m_file) sf_close(m_file); |