Mercurial > hg > svapp
comparison audioio/AudioCallbackPlaySource.cpp @ 103:2485f822dc54
* Fix bug that was causing decoded audio files (mp3s, oggs) to come up some of
the time with zero sample rate
author | Chris Cannam |
---|---|
date | Sat, 01 Mar 2008 16:17:44 +0000 |
parents | 8591a0a3d57e |
children | 907e44e4ecf0 |
comparison
equal
deleted
inserted
replaced
102:8591a0a3d57e | 103:2485f822dc54 |
---|---|
148 if (modelChannels > m_sourceChannelCount) { | 148 if (modelChannels > m_sourceChannelCount) { |
149 m_sourceChannelCount = modelChannels; | 149 m_sourceChannelCount = modelChannels; |
150 } | 150 } |
151 | 151 |
152 #ifdef DEBUG_AUDIO_PLAY_SOURCE | 152 #ifdef DEBUG_AUDIO_PLAY_SOURCE |
153 std::cout << "Adding model with " << modelChannels << " channels " << std::endl; | 153 std::cout << "Adding model with " << modelChannels << " channels at rate " << model->getSampleRate() << std::endl; |
154 #endif | 154 #endif |
155 | 155 |
156 if (m_sourceSampleRate == 0) { | 156 if (m_sourceSampleRate == 0) { |
157 | 157 |
158 m_sourceSampleRate = model->getSampleRate(); | 158 m_sourceSampleRate = model->getSampleRate(); |
1192 size_t spaceHere = wb->getWriteSpace(); | 1192 size_t spaceHere = wb->getWriteSpace(); |
1193 if (c == 0 || spaceHere < space) space = spaceHere; | 1193 if (c == 0 || spaceHere < space) space = spaceHere; |
1194 } | 1194 } |
1195 } | 1195 } |
1196 | 1196 |
1197 if (space == 0) return false; | 1197 if (space == 0) { |
1198 #ifdef DEBUG_AUDIO_PLAY_SOURCE | |
1199 std::cout << "AudioCallbackPlaySourceFillThread: no space to fill" << std::endl; | |
1200 #endif | |
1201 return false; | |
1202 } | |
1198 | 1203 |
1199 size_t f = m_writeBufferFill; | 1204 size_t f = m_writeBufferFill; |
1200 | 1205 |
1201 bool readWriteEqual = (m_readBuffers == m_writeBuffers); | 1206 bool readWriteEqual = (m_readBuffers == m_writeBuffers); |
1202 | 1207 |
1663 std::cout << "AudioCallbackPlaySourceFillThread: awoken" << std::endl; | 1668 std::cout << "AudioCallbackPlaySourceFillThread: awoken" << std::endl; |
1664 #endif | 1669 #endif |
1665 | 1670 |
1666 work = false; | 1671 work = false; |
1667 | 1672 |
1668 if (!s.getSourceSampleRate()) continue; | 1673 if (!s.getSourceSampleRate()) { |
1674 #ifdef DEBUG_AUDIO_PLAY_SOURCE | |
1675 std::cout << "AudioCallbackPlaySourceFillThread: source sample rate is zero" << std::endl; | |
1676 #endif | |
1677 continue; | |
1678 } | |
1669 | 1679 |
1670 bool playing = s.m_playing; | 1680 bool playing = s.m_playing; |
1671 | 1681 |
1672 if (playing && !previouslyPlaying) { | 1682 if (playing && !previouslyPlaying) { |
1673 #ifdef DEBUG_AUDIO_PLAY_SOURCE | 1683 #ifdef DEBUG_AUDIO_PLAY_SOURCE |