bool PulseHandler::SuspendInternal(bool suspend) { // set everything up... if (!Init()) return false; // just in case it all goes pete tong if (!is_current_thread(m_thread)) LOG(VB_AUDIO, LOG_WARNING, LOC + "PulseHandler called from a different thread"); QString action = suspend ? "suspend" : "resume"; // don't bother to suspend a networked server if (!pa_context_is_local(m_ctx)) { LOG(VB_GENERAL, LOG_ERR, LOC + "PulseAudio server is remote. No need to " + action); return false; } // create and dispatch 2 operations to suspend or resume all current sinks // and all current sources m_pending_operations = 2; pa_operation *operation_sink = pa_context_suspend_sink_by_index( m_ctx, PA_INVALID_INDEX, suspend, OperationCallback, this); pa_operation_unref(operation_sink); pa_operation *operation_source = pa_context_suspend_source_by_index( m_ctx, PA_INVALID_INDEX, suspend, OperationCallback, this); pa_operation_unref(operation_source); // run the loop manually and wait for the callbacks int count = 0; int ret = 0; while (m_pending_operations && count++ < 100) { pa_mainloop_iterate(m_loop, 0, &ret); usleep(10000); } // a failure isn't necessarily disastrous if (m_pending_operations) { m_pending_operations = 0; LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to " + action); return false; } // rejoice LOG(VB_GENERAL, LOG_INFO, LOC + "PulseAudio " + action + " OK"); return true; }
void BDRingBuffer::ProgressUpdate(void) { // This thread check is probably unnecessary as processEvents should // only handle events in the calling thread - and not all threads if (!is_current_thread(m_mainThread)) return; qApp->postEvent(GetMythMainWindow(), new MythEvent(MythEvent::kUpdateTvProgressEventType)); qApp->processEvents(QEventLoop::ExcludeUserInputEvents); }
void MythSignalingTimer::stop(void) { if (is_current_thread(this)) { dorun = false; return; } QMutexLocker locker(&startStopLock); if (running) { dorun = false; timerWait.wakeAll(); locker.unlock(); wait(); } }