comparison audio/AudioCallbackPlaySource.cpp @ 473:c6094bca34f4 bqaudioio

Avoid playing repeated buffer while re-seeking
author Chris Cannam
date Wed, 05 Aug 2015 09:42:25 +0100
parents 56acd9368532
children 6ec35c1690c0
comparison
equal deleted inserted replaced
468:56acd9368532 473:c6094bca34f4
1109 } 1109 }
1110 1110
1111 emit activity(tr("Change time-stretch factor to %1").arg(factor)); 1111 emit activity(tr("Change time-stretch factor to %1").arg(factor));
1112 } 1112 }
1113 1113
1114 void 1114 int
1115 AudioCallbackPlaySource::getSourceSamples(int count, float **buffer) 1115 AudioCallbackPlaySource::getSourceSamples(int count, float **buffer)
1116 { 1116 {
1117 if (!m_playing) { 1117 if (!m_playing) {
1118 #ifdef DEBUG_AUDIO_PLAY_SOURCE_PLAYING 1118 #ifdef DEBUG_AUDIO_PLAY_SOURCE_PLAYING
1119 SVDEBUG << "AudioCallbackPlaySource::getSourceSamples: Not playing" << endl; 1119 SVDEBUG << "AudioCallbackPlaySource::getSourceSamples: Not playing" << endl;
1121 for (int ch = 0; ch < getTargetChannelCount(); ++ch) { 1121 for (int ch = 0; ch < getTargetChannelCount(); ++ch) {
1122 for (int i = 0; i < count; ++i) { 1122 for (int i = 0; i < count; ++i) {
1123 buffer[ch][i] = 0.0; 1123 buffer[ch][i] = 0.0;
1124 } 1124 }
1125 } 1125 }
1126 return; 1126 return 0;
1127 } 1127 }
1128 1128
1129 #ifdef DEBUG_AUDIO_PLAY_SOURCE_PLAYING 1129 #ifdef DEBUG_AUDIO_PLAY_SOURCE_PLAYING
1130 SVDEBUG << "AudioCallbackPlaySource::getSourceSamples: Playing" << endl; 1130 SVDEBUG << "AudioCallbackPlaySource::getSourceSamples: Playing" << endl;
1131 #endif 1131 #endif
1157 #endif 1157 #endif
1158 count = rs; 1158 count = rs;
1159 } 1159 }
1160 } 1160 }
1161 1161
1162 if (count == 0) return; 1162 if (count == 0) return 0;
1163 1163
1164 RubberBandStretcher *ts = m_timeStretcher; 1164 RubberBandStretcher *ts = m_timeStretcher;
1165 RubberBandStretcher *ms = m_monoStretcher; 1165 RubberBandStretcher *ms = m_monoStretcher;
1166 1166
1167 double ratio = ts ? ts->getTimeRatio() : 1.0; 1167 double ratio = ts ? ts->getTimeRatio() : 1.0;
1227 cout << "AudioCallbackPlaySource::getSamples: awakening thread" << endl; 1227 cout << "AudioCallbackPlaySource::getSamples: awakening thread" << endl;
1228 #endif 1228 #endif
1229 1229
1230 m_condition.wakeAll(); 1230 m_condition.wakeAll();
1231 1231
1232 return; 1232 return got;
1233 } 1233 }
1234 1234
1235 int channels = getTargetChannelCount(); 1235 int channels = getTargetChannelCount();
1236 sv_frame_t available; 1236 sv_frame_t available;
1237 sv_frame_t fedToStretcher = 0; 1237 sv_frame_t fedToStretcher = 0;
1319 cout << "AudioCallbackPlaySource::getSamples [stretched]: awakening thread" << endl; 1319 cout << "AudioCallbackPlaySource::getSamples [stretched]: awakening thread" << endl;
1320 #endif 1320 #endif
1321 1321
1322 m_condition.wakeAll(); 1322 m_condition.wakeAll();
1323 1323
1324 return; 1324 return count;
1325 } 1325 }
1326 1326
1327 void 1327 void
1328 AudioCallbackPlaySource::applyAuditioningEffect(sv_frame_t count, float **buffers) 1328 AudioCallbackPlaySource::applyAuditioningEffect(sv_frame_t count, float **buffers)
1329 { 1329 {