comparison data/fileio/WavFileReader.cpp @ 1053:48e4ffa9fb48 cxx11

Minor simplification; could use more
author Chris Cannam
date Wed, 11 Mar 2015 11:52:05 +0000
parents 843f67be0ed9
children 4d9816ba0ebe 1517d4c60e88
comparison
equal deleted inserted replaced
1052:e603b44510c3 1053:48e4ffa9fb48
138 138
139 if (start + count > m_fileInfo.frames) { 139 if (start + count > m_fileInfo.frames) {
140 count = m_fileInfo.frames - start; 140 count = m_fileInfo.frames - start;
141 } 141 }
142 142
143 sf_count_t readCount = 0;
144
145 if (start != m_lastStart || count != m_lastCount) { 143 if (start != m_lastStart || count != m_lastCount) {
146 144
147 if (sf_seek(m_file, start, SEEK_SET) < 0) { 145 if (sf_seek(m_file, start, SEEK_SET) < 0) {
148 return SampleBlock(); 146 return SampleBlock();
149 } 147 }
150 148
151 sv_frame_t n = count * m_fileInfo.channels; 149 sv_frame_t n = count * m_fileInfo.channels;
152 m_buffer.resize(n); 150 m_buffer.resize(n);
153 151
152 sf_count_t readCount = 0;
153
154 if ((readCount = sf_readf_float(m_file, m_buffer.data(), count)) < 0) { 154 if ((readCount = sf_readf_float(m_file, m_buffer.data(), count)) < 0) {
155 return SampleBlock(); 155 return SampleBlock();
156 } 156 }
157 157
158 m_buffer.resize(readCount * m_fileInfo.channels);
159
158 m_lastStart = start; 160 m_lastStart = start;
159 m_lastCount = readCount; 161 m_lastCount = readCount;
160 } 162 }
161 163
162 return m_buffer; 164 return m_buffer;