mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-03-03 22:15:22 +00:00
apply button works again with a few leftover snags
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@874 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
@ -46,7 +46,7 @@
|
||||
pa_io_event * QPulseAudioThread::stdio_event = NULL;
|
||||
char * QPulseAudioThread::server = NULL;
|
||||
char * QPulseAudioThread::stream_name = NULL, *QPulseAudioThread::client_name = NULL, *QPulseAudioThread::device =0;
|
||||
QMutex QPulseAudioThread::s_audioMutex;
|
||||
QMutex * QPulseAudioThread::s_audioMutex;
|
||||
int QPulseAudioThread::verbose = 0;
|
||||
|
||||
pa_volume_t QPulseAudioThread::volume = PA_VOLUME_NORM;
|
||||
@ -60,10 +60,10 @@ QPulseAudioThread::SourceContainer::const_iterator QPulseAudioThread::s_sourcePo
|
||||
|
||||
QProjectM ** QPulseAudioThread::s_projectMPtr = 0;
|
||||
|
||||
QPulseAudioThread::QPulseAudioThread ( int _argc, char **_argv, QProjectM * _projectM, QObject * parent ) : QThread ( parent ), argc ( _argc ), argv ( _argv ), m_projectM ( _projectM )
|
||||
QPulseAudioThread::QPulseAudioThread ( int _argc, char **_argv, QProjectM * _projectM, QObject * parent, QMutex * audioMutex ) : QThread ( parent ), argc ( _argc ), argv ( _argv ), m_projectM ( _projectM )
|
||||
{
|
||||
s_projectMPtr = new QProjectM*;
|
||||
|
||||
s_audioMutex = audioMutex;
|
||||
*s_projectMPtr = m_projectM;
|
||||
}
|
||||
|
||||
@ -259,9 +259,7 @@ void QPulseAudioThread::pa_stream_success_callback(pa_stream *s, int success, vo
|
||||
if (pausedFlag)
|
||||
qDebug() << "pause";
|
||||
else {
|
||||
qDebug() << "play";
|
||||
s_audioMutex.unlock();
|
||||
qDebug() << "UNLOCK: success callback";
|
||||
qDebug() << "play";
|
||||
}
|
||||
|
||||
|
||||
@ -273,7 +271,7 @@ void QPulseAudioThread::pa_stream_success_callback(pa_stream *s, int success, vo
|
||||
|
||||
|
||||
QMutex * QPulseAudioThread::mutex() {
|
||||
return &s_audioMutex;
|
||||
return s_audioMutex;
|
||||
}
|
||||
|
||||
void QPulseAudioThread::cork()
|
||||
@ -456,7 +454,7 @@ void QPulseAudioThread::stdout_callback ( pa_mainloop_api*a, pa_io_event *e, int
|
||||
|
||||
//int * int_buf = (int *) buffer;
|
||||
//qDebug() << "LOCK: add pcm";
|
||||
s_audioMutex.lock();
|
||||
s_audioMutex->lock();
|
||||
QProjectM ** prjmPtr = static_cast<QProjectM **> ( userdata );
|
||||
QProjectM * prjm = *prjmPtr;
|
||||
|
||||
@ -466,7 +464,7 @@ void QPulseAudioThread::stdout_callback ( pa_mainloop_api*a, pa_io_event *e, int
|
||||
|
||||
prjm->pcm()->addPCMfloat
|
||||
( buffer+buffer_index, buffer_length / ( sizeof ( float ) ) );
|
||||
s_audioMutex.unlock();
|
||||
s_audioMutex->unlock();
|
||||
//qDebug() << "UNLOCK: add pcm";
|
||||
assert ( buffer_length );
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ class QPulseAudioThread : public QThread
|
||||
public:
|
||||
typedef QHash<int, QString> SourceContainer;
|
||||
QPulseAudioThread () {}
|
||||
QPulseAudioThread(int _argc, char **_argv, QProjectM * projectM, QObject *parent);
|
||||
QPulseAudioThread(int _argc, char **_argv, QProjectM * projectM, QObject *parent, QMutex * audioMutex);
|
||||
virtual ~QPulseAudioThread();
|
||||
void run();
|
||||
void cleanup();
|
||||
@ -45,10 +45,7 @@ class QPulseAudioThread : public QThread
|
||||
public slots:
|
||||
inline void projectM_New(QProjectM * projectM) {
|
||||
m_projectM = projectM;
|
||||
*s_projectMPtr = m_projectM;
|
||||
qDebug() << "CORKING";
|
||||
cork();
|
||||
|
||||
*s_projectMPtr = m_projectM;
|
||||
}
|
||||
|
||||
void cork();
|
||||
@ -89,7 +86,7 @@ class QPulseAudioThread : public QThread
|
||||
|
||||
static void pa_stream_success_callback(pa_stream *s, int success, void *userdata);
|
||||
|
||||
static QMutex s_audioMutex;
|
||||
static QMutex * s_audioMutex;
|
||||
static SourceContainer s_sourceList;
|
||||
static SourceContainer::const_iterator s_sourcePosition;
|
||||
int argc;
|
||||
|
||||
@ -93,7 +93,10 @@ int main ( int argc, char*argv[] )
|
||||
std::string config_file;
|
||||
config_file = read_config();
|
||||
|
||||
QProjectM_MainWindow * mainWindow = new QProjectM_MainWindow ( config_file, 0);
|
||||
|
||||
QMutex audioMutex;
|
||||
|
||||
QProjectM_MainWindow * mainWindow = new QProjectM_MainWindow ( config_file, &audioMutex);
|
||||
|
||||
QAction pulseAction("Pulse audio settings...", mainWindow);
|
||||
|
||||
@ -101,18 +104,14 @@ int main ( int argc, char*argv[] )
|
||||
mainWindow->registerSettingsAction(&pulseAction);
|
||||
mainWindow->show();
|
||||
|
||||
QPulseAudioThread * pulseThread = new QPulseAudioThread(argc, argv, mainWindow->qprojectM(), mainWindow);
|
||||
|
||||
mainWindow->qprojectMWidget()->setAudioMutex(pulseThread->mutex());
|
||||
|
||||
// First projectM_Initialized() has already happened, so manually start
|
||||
QPulseAudioThread * pulseThread = new QPulseAudioThread(argc, argv, mainWindow->qprojectM(), mainWindow, &audioMutex);
|
||||
|
||||
pulseThread->start();
|
||||
|
||||
QApplication::connect
|
||||
(mainWindow->qprojectMWidget(), SIGNAL(projectM_Initialized(QProjectM *)), pulseThread, SLOT(projectM_New(QProjectM*)));
|
||||
QApplication::connect
|
||||
(mainWindow->qprojectMWidget(), SIGNAL(projectM_BeforeDestroy()), pulseThread, SLOT(cork()), Qt::DirectConnection);
|
||||
|
||||
|
||||
QPulseAudioDeviceChooser devChooser(pulseThread, mainWindow);
|
||||
QApplication::connect(&pulseAction, SIGNAL(triggered()), &devChooser, SLOT(open()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user