Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 738:48001ed9143b audio-source-refactor
Introduce TimeStretchWrapper; some work towards making the AudioCallbackPlaySource not actually try to be an ApplicationPlaybackSource itself but only return one that is constructed from wrappers that it controls the lifespan of
author | Chris Cannam |
---|---|
date | Wed, 18 Mar 2020 12:51:41 +0000 |
parents | 4b58b8f44be7 |
children | 771ec060c1d2 |
comparison
equal
deleted
inserted
replaced
737:497d80d3b9c4 | 738:48001ed9143b |
---|---|
80 #include "system/System.h" | 80 #include "system/System.h" |
81 | 81 |
82 #include <bqaudioio/SystemPlaybackTarget.h> | 82 #include <bqaudioio/SystemPlaybackTarget.h> |
83 #include <bqaudioio/SystemAudioIO.h> | 83 #include <bqaudioio/SystemAudioIO.h> |
84 #include <bqaudioio/AudioFactory.h> | 84 #include <bqaudioio/AudioFactory.h> |
85 #include <bqaudioio/ResamplerWrapper.h> | |
86 | 85 |
87 #include <QApplication> | 86 #include <QApplication> |
88 #include <QMessageBox> | 87 #include <QMessageBox> |
89 #include <QGridLayout> | 88 #include <QGridLayout> |
90 #include <QLabel> | 89 #include <QLabel> |
149 m_timeRulerLayer(nullptr), | 148 m_timeRulerLayer(nullptr), |
150 m_audioMode(audioMode), | 149 m_audioMode(audioMode), |
151 m_midiMode(midiMode), | 150 m_midiMode(midiMode), |
152 m_playSource(nullptr), | 151 m_playSource(nullptr), |
153 m_recordTarget(nullptr), | 152 m_recordTarget(nullptr), |
154 m_resamplerWrapper(nullptr), | |
155 m_playTarget(nullptr), | 153 m_playTarget(nullptr), |
156 m_audioIO(nullptr), | 154 m_audioIO(nullptr), |
157 m_oscQueue(nullptr), | 155 m_oscQueue(nullptr), |
158 m_oscQueueStarter(nullptr), | 156 m_oscQueueStarter(nullptr), |
159 m_oscScript(nullptr), | 157 m_oscScript(nullptr), |
2566 SVCERR << "createAudioIO: Preferred playback device = \"" | 2564 SVCERR << "createAudioIO: Preferred playback device = \"" |
2567 << preference.playbackDevice << "\"" << endl; | 2565 << preference.playbackDevice << "\"" << endl; |
2568 SVCERR << "createAudioIO: Preferred record device = \"" | 2566 SVCERR << "createAudioIO: Preferred record device = \"" |
2569 << preference.recordDevice << "\"" << endl; | 2567 << preference.recordDevice << "\"" << endl; |
2570 | 2568 |
2571 if (!m_resamplerWrapper) { | 2569 breakfastquay::ApplicationPlaybackSource *source = |
2572 m_resamplerWrapper = new breakfastquay::ResamplerWrapper(m_playSource); | 2570 m_playSource->getApplicationPlaybackSource(); |
2573 m_playSource->setResamplerWrapper(m_resamplerWrapper); | |
2574 } | |
2575 | 2571 |
2576 std::string errorString; | 2572 std::string errorString; |
2577 | 2573 |
2578 if (m_audioMode == AUDIO_PLAYBACK_AND_RECORD) { | 2574 if (m_audioMode == AUDIO_PLAYBACK_AND_RECORD) { |
2579 m_audioIO = breakfastquay::AudioFactory:: | 2575 m_audioIO = breakfastquay::AudioFactory:: |
2580 createCallbackIO(m_recordTarget, m_resamplerWrapper, | 2576 createCallbackIO(m_recordTarget, source, preference, errorString); |
2581 preference, errorString); | |
2582 if (m_audioIO) { | 2577 if (m_audioIO) { |
2583 SVCERR << "MainWindowBase::createAudioIO: Suspending on creation" << endl; | 2578 SVCERR << "MainWindowBase::createAudioIO: Suspending on creation" << endl; |
2584 m_audioIO->suspend(); // start in suspended state | 2579 m_audioIO->suspend(); // start in suspended state |
2585 m_playSource->setSystemPlaybackTarget(m_audioIO); | 2580 m_playSource->setSystemPlaybackTarget(m_audioIO); |
2586 } else { | 2581 } else { |
2591 } | 2586 } |
2592 } | 2587 } |
2593 | 2588 |
2594 if (!m_audioIO) { | 2589 if (!m_audioIO) { |
2595 m_playTarget = breakfastquay::AudioFactory:: | 2590 m_playTarget = breakfastquay::AudioFactory:: |
2596 createCallbackPlayTarget(m_resamplerWrapper, | 2591 createCallbackPlayTarget(source, preference, errorString); |
2597 preference, errorString); | |
2598 if (m_playTarget) { | 2592 if (m_playTarget) { |
2599 SVCERR << "MainWindowBase::createAudioIO: Suspending on creation" << endl; | 2593 SVCERR << "MainWindowBase::createAudioIO: Suspending on creation" << endl; |
2600 m_playTarget->suspend(); // start in suspended state | 2594 m_playTarget->suspend(); // start in suspended state |
2601 m_playSource->setSystemPlaybackTarget(m_playTarget); | 2595 m_playSource->setSystemPlaybackTarget(m_playTarget); |
2602 } | 2596 } |
2646 MainWindowBase::deleteAudioIO() | 2640 MainWindowBase::deleteAudioIO() |
2647 { | 2641 { |
2648 // First prevent this trying to call target. | 2642 // First prevent this trying to call target. |
2649 if (m_playSource) { | 2643 if (m_playSource) { |
2650 m_playSource->setSystemPlaybackTarget(nullptr); | 2644 m_playSource->setSystemPlaybackTarget(nullptr); |
2651 m_playSource->setResamplerWrapper(nullptr); | |
2652 } | 2645 } |
2653 | 2646 |
2654 // Then delete the breakfastquay::System object. | 2647 // Then delete the breakfastquay::System object. |
2655 // Only one of these two exists! | 2648 // Only one of these two exists! |
2656 delete m_audioIO; | 2649 delete m_audioIO; |
2657 delete m_playTarget; | 2650 delete m_playTarget; |
2658 | 2651 |
2659 // And the breakfastquay resampler wrapper. We need to | |
2660 // delete/recreate this if the channel count changes, which is one | |
2661 // of the use cases for recreateAudioIO() calling this | |
2662 delete m_resamplerWrapper; | |
2663 | |
2664 m_audioIO = nullptr; | 2652 m_audioIO = nullptr; |
2665 m_playTarget = nullptr; | 2653 m_playTarget = nullptr; |
2666 m_resamplerWrapper = nullptr; | |
2667 } | 2654 } |
2668 | 2655 |
2669 void | 2656 void |
2670 MainWindowBase::recreateAudioIO() | 2657 MainWindowBase::recreateAudioIO() |
2671 { | 2658 { |