Mercurial > hg > svapp
comparison audioio/AudioCallbackPlaySource.cpp @ 220:0b1886cee2cf templating
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 27 Apr 2011 11:33:48 +0100 |
parents | fe83e6e68683 |
children | 8c13e8219903 |
comparison
equal
deleted
inserted
replaced
210:143e1b56e81b | 220:0b1886cee2cf |
---|---|
104 std::cerr << "AudioCallbackPlaySource::~AudioCallbackPlaySource entering" << std::endl; | 104 std::cerr << "AudioCallbackPlaySource::~AudioCallbackPlaySource entering" << std::endl; |
105 #endif | 105 #endif |
106 m_exiting = true; | 106 m_exiting = true; |
107 | 107 |
108 if (m_fillThread) { | 108 if (m_fillThread) { |
109 m_condition.wakeAll(); | 109 #ifdef DEBUG_AUDIO_PLAY_SOURCE |
110 std::cout << "AudioCallbackPlaySource dtor: awakening thread" << std::endl; | |
111 #endif | |
112 m_condition.wakeAll(); | |
110 m_fillThread->wait(); | 113 m_fillThread->wait(); |
111 delete m_fillThread; | 114 delete m_fillThread; |
112 } | 115 } |
113 | 116 |
114 clearModels(); | 117 clearModels(); |
250 } | 253 } |
251 | 254 |
252 connect(model, SIGNAL(modelChanged(size_t, size_t)), | 255 connect(model, SIGNAL(modelChanged(size_t, size_t)), |
253 this, SLOT(modelChanged(size_t, size_t))); | 256 this, SLOT(modelChanged(size_t, size_t))); |
254 | 257 |
258 #ifdef DEBUG_AUDIO_PLAY_SOURCE | |
259 std::cout << "AudioCallbackPlaySource::addModel: awakening thread" << std::endl; | |
260 #endif | |
261 | |
255 m_condition.wakeAll(); | 262 m_condition.wakeAll(); |
256 } | 263 } |
257 | 264 |
258 void | 265 void |
259 AudioCallbackPlaySource::modelChanged(size_t startFrame, size_t endFrame) | 266 AudioCallbackPlaySource::modelChanged(size_t startFrame, size_t endFrame) |
302 std::cout << "(done, lastEnd now " << lastEnd << ")" << std::endl; | 309 std::cout << "(done, lastEnd now " << lastEnd << ")" << std::endl; |
303 #endif | 310 #endif |
304 } | 311 } |
305 m_lastModelEndFrame = lastEnd; | 312 m_lastModelEndFrame = lastEnd; |
306 | 313 |
314 m_audioGenerator->removeModel(model); | |
315 | |
307 m_mutex.unlock(); | 316 m_mutex.unlock(); |
308 | |
309 m_audioGenerator->removeModel(model); | |
310 | 317 |
311 clearRingBuffers(); | 318 clearRingBuffers(); |
312 } | 319 } |
313 | 320 |
314 void | 321 void |
439 | 446 |
440 bool changed = !m_playing; | 447 bool changed = !m_playing; |
441 m_lastRetrievalTimestamp = 0; | 448 m_lastRetrievalTimestamp = 0; |
442 m_lastCurrentFrame = 0; | 449 m_lastCurrentFrame = 0; |
443 m_playing = true; | 450 m_playing = true; |
451 | |
452 #ifdef DEBUG_AUDIO_PLAY_SOURCE | |
453 std::cout << "AudioCallbackPlaySource::play: awakening thread" << std::endl; | |
454 #endif | |
455 | |
444 m_condition.wakeAll(); | 456 m_condition.wakeAll(); |
445 if (changed) { | 457 if (changed) { |
446 emit playStatusChanged(m_playing); | 458 emit playStatusChanged(m_playing); |
447 emit activity(tr("Play from %1").arg | 459 emit activity(tr("Play from %1").arg |
448 (RealTime::frame2RealTime | 460 (RealTime::frame2RealTime |
451 } | 463 } |
452 | 464 |
453 void | 465 void |
454 AudioCallbackPlaySource::stop() | 466 AudioCallbackPlaySource::stop() |
455 { | 467 { |
468 #ifdef DEBUG_AUDIO_PLAY_SOURCE | |
469 std::cerr << "AudioCallbackPlaySource::stop()" << std::endl; | |
470 #endif | |
456 bool changed = m_playing; | 471 bool changed = m_playing; |
457 m_playing = false; | 472 m_playing = false; |
473 | |
474 #ifdef DEBUG_AUDIO_PLAY_SOURCE | |
475 std::cout << "AudioCallbackPlaySource::stop: awakening thread" << std::endl; | |
476 #endif | |
477 | |
458 m_condition.wakeAll(); | 478 m_condition.wakeAll(); |
459 m_lastRetrievalTimestamp = 0; | 479 m_lastRetrievalTimestamp = 0; |
460 if (changed) { | 480 if (changed) { |
461 emit playStatusChanged(m_playing); | 481 emit playStatusChanged(m_playing); |
462 emit activity(tr("Stop at %1").arg | 482 emit activity(tr("Stop at %1").arg |
1056 } | 1076 } |
1057 } | 1077 } |
1058 return 0; | 1078 return 0; |
1059 } | 1079 } |
1060 | 1080 |
1081 #ifdef DEBUG_AUDIO_PLAY_SOURCE_PLAYING | |
1082 std::cerr << "AudioCallbackPlaySource::getSourceSamples: Playing" << std::endl; | |
1083 #endif | |
1084 | |
1061 // Ensure that all buffers have at least the amount of data we | 1085 // Ensure that all buffers have at least the amount of data we |
1062 // need -- else reduce the size of our requests correspondingly | 1086 // need -- else reduce the size of our requests correspondingly |
1063 | 1087 |
1064 for (size_t ch = 0; ch < getTargetChannelCount(); ++ch) { | 1088 for (size_t ch = 0; ch < getTargetChannelCount(); ++ch) { |
1065 | 1089 |
1148 } | 1172 } |
1149 } | 1173 } |
1150 } | 1174 } |
1151 | 1175 |
1152 applyAuditioningEffect(count, buffer); | 1176 applyAuditioningEffect(count, buffer); |
1177 | |
1178 #ifdef DEBUG_AUDIO_PLAY_SOURCE | |
1179 std::cout << "AudioCallbackPlaySource::getSamples: awakening thread" << std::endl; | |
1180 #endif | |
1153 | 1181 |
1154 m_condition.wakeAll(); | 1182 m_condition.wakeAll(); |
1155 | 1183 |
1156 return got; | 1184 return got; |
1157 } | 1185 } |
1237 } | 1265 } |
1238 } | 1266 } |
1239 | 1267 |
1240 applyAuditioningEffect(count, buffer); | 1268 applyAuditioningEffect(count, buffer); |
1241 | 1269 |
1270 #ifdef DEBUG_AUDIO_PLAY_SOURCE | |
1271 std::cout << "AudioCallbackPlaySource::getSamples [stretched]: awakening thread" << std::endl; | |
1272 #endif | |
1273 | |
1242 m_condition.wakeAll(); | 1274 m_condition.wakeAll(); |
1243 | 1275 |
1244 return count; | 1276 return count; |
1245 } | 1277 } |
1246 | 1278 |