Fixed bug where AudioModel would never exit
This commit is contained in:
@@ -123,6 +123,8 @@ void AudioModel::startCapture()
|
|||||||
if(!m_instance)
|
if(!m_instance)
|
||||||
m_instance = new AudioModel();
|
m_instance = new AudioModel();
|
||||||
|
|
||||||
|
++m_clients;
|
||||||
|
|
||||||
if(m_thread->isRunning())
|
if(m_thread->isRunning())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -131,6 +133,12 @@ void AudioModel::startCapture()
|
|||||||
|
|
||||||
void AudioModel::stopCapture()
|
void AudioModel::stopCapture()
|
||||||
{
|
{
|
||||||
|
if(--m_clients > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(m_thread->isRunning())
|
||||||
|
m_thread->quit();
|
||||||
|
|
||||||
m_running = false;
|
m_running = false;
|
||||||
pw_main_loop_quit(m_impl_data.loop);
|
pw_main_loop_quit(m_impl_data.loop);
|
||||||
}
|
}
|
||||||
@@ -314,7 +322,7 @@ void AudioModel::on_process(void *userdata)
|
|||||||
|
|
||||||
painter.end();
|
painter.end();
|
||||||
|
|
||||||
if(m_mutex.tryLock(1))
|
if(m_mutex.tryLock(4))
|
||||||
{
|
{
|
||||||
m_instance->m_frame = audioTexture;
|
m_instance->m_frame = audioTexture;
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ private:
|
|||||||
inline static AudioModel *m_instance = nullptr;
|
inline static AudioModel *m_instance = nullptr;
|
||||||
inline static QThread *m_thread = nullptr;
|
inline static QThread *m_thread = nullptr;
|
||||||
inline static QMutex m_mutex;
|
inline static QMutex m_mutex;
|
||||||
|
inline static quint64 m_clients = 0; // used to track
|
||||||
|
|
||||||
QPixmap m_frame;
|
QPixmap m_frame;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user