aboutsummaryrefslogtreecommitdiff
path: root/lib/output.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2007-10-31 18:04:24 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2007-10-31 18:04:24 +0000
commit86aac72c6547ae976059c1aee91059687ea65b8b (patch)
treee9cacce658ec4dad6c235ee6f354232280fa4dd7 /lib/output.cpp
parent342ada45af81cba245abd9a2fb4a19b4974e93e4 (diff)
downloadqmmp-86aac72c6547ae976059c1aee91059687ea65b8b.tar.gz
qmmp-86aac72c6547ae976059c1aee91059687ea65b8b.tar.bz2
qmmp-86aac72c6547ae976059c1aee91059687ea65b8b.zip
added visual plugin support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@171 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'lib/output.cpp')
-rw-r--r--lib/output.cpp95
1 files changed, 75 insertions, 20 deletions
diff --git a/lib/output.cpp b/lib/output.cpp
index fbbe1c0e4..94b68aa36 100644
--- a/lib/output.cpp
+++ b/lib/output.cpp
@@ -62,7 +62,7 @@ Output *Output::create ( QObject *parent )
Output *output = 0;
checkFactories();
- if ( factories->isEmpty () )
+ if (factories->isEmpty ())
{
qDebug("Output: unable to find output plugins");
return output;
@@ -76,28 +76,28 @@ Output *Output::create ( QObject *parent )
if (files.at(i).section('/',-1) == pluginFileName)
j = i;
}
- OutputFactory *fact = factories->at ( j );
+ OutputFactory *fact = factories->at (j);
if ( fact )
{
- output = fact->create ( parent );
+ output = fact->create (parent);
}
switch ((int) output->volumeControl())
{
case Output::Standard:
- {
- break;
- }
+ {
+ break;
+ }
case Output::Custom:
- {
- timer = new QTimer(output);
- connect(timer, SIGNAL(timeout()), output, SLOT(checkVolume()));
- timer->start(125);
- break;
- }
+ {
+ timer = new QTimer(output);
+ connect(timer, SIGNAL(timeout()), output, SLOT(checkVolume()));
+ timer->start(125);
+ break;
+ }
case Output::Disabled:
- {
- break;
- }
+ {
+ break;
+ }
}
return output;
}
@@ -122,7 +122,15 @@ Output::Output ( QObject* parent, VolumeType vt) : QThread (parent), r (stackSiz
Output::~Output()
-{}
+{
+ qDebug("Output::~Output()");
+ Visual *visual = 0;
+ foreach(visual, m_vis_map.values ())
+ {
+ visual->close();
+ }
+ //m_vis_map.clear();
+}
void Output::error ( const QString &e )
{
@@ -135,6 +143,8 @@ void Output::addVisual ( Visual *v )
if (visuals.indexOf (v) == -1)
{
visuals.append (v);
+ v->setOutput(this);
+ qDebug("Output: added external visualization");
}
}
@@ -142,6 +152,39 @@ void Output::addVisual ( Visual *v )
void Output::removeVisual (Visual *v)
{
visuals.removeAll (v);
+ if (m_vis_map.key(v))
+ {
+ VisualFactory *factory = m_vis_map.key(v);
+ m_vis_map.remove(factory);
+ //Visual::setEnabled(factory, FALSE);
+ }
+}
+
+void Output::addVisual(VisualFactory *factory, QWidget *parent)
+{
+ if (m_vis_map.value(factory))
+ return;
+ Visual::setEnabled(factory, TRUE);
+ Visual* visual = factory->create(parent);
+ visual->setWindowFlags(Qt::Window);
+ if (visual)
+ {
+ visual->setOutput(this);
+ qDebug("Output: added visual factory: %s",
+ qPrintable(factory->properties().name));
+ m_vis_map.insert (factory, visual);
+ visual->show();
+ }
+}
+
+void Output::removeVisual(VisualFactory *factory)
+{
+ if (m_vis_map.value(factory))
+ {
+ m_vis_map.value(factory)->close();
+ m_vis_map.remove (factory);
+ }
+ Visual::setEnabled(factory, FALSE);
}
void Output::dispatchVisual ( Buffer *buffer, unsigned long written,
@@ -150,7 +193,13 @@ void Output::dispatchVisual ( Buffer *buffer, unsigned long written,
if ( ! buffer || !visuals.size())
return;
Visual* visual = 0;
- foreach (visual , visuals);
+ foreach (visual , visuals) //external
+ {
+ visual->mutex()->lock ();
+ visual->add ( buffer, written, chan, prec );
+ visual->mutex()->unlock();
+ }
+ foreach (visual , m_vis_map.values ()) //internal
{
visual->mutex()->lock ();
visual->add ( buffer, written, chan, prec );
@@ -162,7 +211,13 @@ void Output::dispatchVisual ( Buffer *buffer, unsigned long written,
void Output::clearVisuals()
{
Visual *visual = 0;
- foreach (visual, visuals );
+ foreach (visual, visuals )
+ {
+ visual->mutex()->lock ();
+ visual->clear();
+ visual->mutex()->unlock();
+ }
+ foreach(visual, m_vis_map.values ())
{
visual->mutex()->lock ();
visual->clear();
@@ -172,7 +227,7 @@ void Output::clearVisuals()
void Output::dispatch(OutputState::Type st)
{
- if(st == OutputState::Stopped)
+ if (st == OutputState::Stopped)
clearVisuals();
emit stateChanged ( OutputState(st) );
}
@@ -184,7 +239,7 @@ void Output::dispatch(long s, unsigned long w, int b, int f, int p, int c)
void Output::dispatch ( const OutputState &st )
{
- if(st.type() == OutputState::Stopped)
+ if (st.type() == OutputState::Stopped)
clearVisuals();
emit stateChanged ( st );
}