[Summary] Added possibility to identify IO thread which does not have required resources initialized during process callback handling
Conflicts: libs/ardour/ardour/audioengine.h libs/backends/wavesaudio/waves_audiobackend.cc libs/pbd/pbd/pool.h
This commit is contained in:
parent
017e580c9f
commit
ef59fbffa1
|
@ -209,6 +209,9 @@ class LIBARDOUR_API AudioEngine : public SessionHandlePtr, public PortManager
|
|||
void latency_callback (bool for_playback);
|
||||
void halted_callback (const char* reason);
|
||||
|
||||
/* checks if current thread is properly set up for audio processing */
|
||||
static bool thread_initialised_for_audio_processing ();
|
||||
|
||||
/* sets up the process callback thread */
|
||||
static void thread_init_callback (void *);
|
||||
|
||||
|
|
|
@ -134,6 +134,7 @@ public:
|
|||
|
||||
static const framepos_t Immediate = -1;
|
||||
|
||||
static bool has_per_thread_pool ();
|
||||
static void create_per_thread_pool (const std::string& n, uint32_t nitems);
|
||||
static void init_event_pool ();
|
||||
|
||||
|
|
|
@ -1151,6 +1151,12 @@ AudioEngine::set_systemic_output_latency (uint32_t ol)
|
|||
return _backend->set_systemic_output_latency (ol);
|
||||
}
|
||||
|
||||
bool
|
||||
AudioEngine::thread_initialised_for_audio_processing ()
|
||||
{
|
||||
return SessionEvent::has_per_thread_pool () && AsyncMIDIPort::is_process_thread();
|
||||
}
|
||||
|
||||
/* END OF BACKEND PROXY API */
|
||||
|
||||
void
|
||||
|
|
|
@ -42,6 +42,12 @@ SessionEvent::init_event_pool ()
|
|||
pool = new PerThreadPool;
|
||||
}
|
||||
|
||||
bool
|
||||
SessionEvent::has_per_thread_pool ()
|
||||
{
|
||||
return pool->has_per_thread_pool ();
|
||||
}
|
||||
|
||||
void
|
||||
SessionEvent::create_per_thread_pool (const std::string& name, uint32_t nitems)
|
||||
{
|
||||
|
|
|
@ -758,6 +758,17 @@ WavesAudioBackend::_audio_device_callback (const float* input_buffer,
|
|||
AudioEngine::thread_init_callback (this);
|
||||
}
|
||||
|
||||
if ( !engine.thread_initialised_for_audio_processing () ) {
|
||||
std::cerr << "\tWavesAudioBackend::_audio_device_callback (): It's an attempt to call process callback from the thread which didn't initialize it " << std::endl;
|
||||
|
||||
if (process_id != pthread_self() ) {
|
||||
std::cerr << "Process thread ID has changed. Expected thread: " << process_id << " current thread: " << pthread_self() << std::dec << " !" << std::endl;
|
||||
process_id = pthread_self();
|
||||
}
|
||||
|
||||
AudioEngine::thread_init_callback (this);
|
||||
}
|
||||
|
||||
engine.process_callback (nframes);
|
||||
|
||||
_write_audio_data_to_device (output_buffer, nframes);
|
||||
|
|
|
@ -129,7 +129,7 @@ class LIBPBD_API PerThreadPool
|
|||
|
||||
void create_per_thread_pool (std::string name, unsigned long item_size, unsigned long nitems);
|
||||
CrossThreadPool* per_thread_pool (bool must_exist = true);
|
||||
|
||||
bool has_per_thread_pool ();
|
||||
void set_trash (RingBuffer<CrossThreadPool*>* t);
|
||||
void add_to_trash (CrossThreadPool *);
|
||||
|
||||
|
|
|
@ -175,6 +175,20 @@ PerThreadPool::create_per_thread_pool (string n, unsigned long isize, unsigned l
|
|||
_key.set (new CrossThreadPool (n, isize, nitems, this));
|
||||
}
|
||||
|
||||
/** @return True if CrossThreadPool for the current thread exists,
|
||||
* False otherwise
|
||||
*/
|
||||
bool
|
||||
PerThreadPool::has_per_thread_pool ()
|
||||
{
|
||||
CrossThreadPool* p = _key.get();
|
||||
if (p) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** @return CrossThreadPool for the current thread, which must previously have been created by
|
||||
* calling create_per_thread_pool in the current thread.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user