kwave  18.07.70
StreamObject.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  StreamObject.cpp - base class with a generic sample source/sink
3  -------------------
4  begin : Thu Nov 10 2007
5  copyright : (C) 2007 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <QString>
21 #include <QVariant>
22 
24 
27 
28 //***************************************************************************
30  :QObject(Q_NULLPTR /*parent*/), m_lock_set_attribute(QMutex::Recursive)
31 {
32  Q_UNUSED(parent);
33 }
34 
35 //***************************************************************************
37 {
38 }
39 
40 //***************************************************************************
41 void Kwave::StreamObject::setAttribute(const char *attribute,
42  const QVariant &value)
43 {
44  QMutexLocker lock(&m_lock_set_attribute);
45 
46  for (unsigned int track = 0; track < tracks(); track++) {
47  Kwave::StreamObject *obj = (*this)[track];
48  if (!obj) continue;
49 
50  // temporary establish a signal->slot connection
51  QObject::connect(this, SIGNAL(attributeChanged(QVariant)),
52  obj, attribute,
53  Qt::DirectConnection);
54 
55  // emit the new value through our own signal
56  emit attributeChanged(value);
57 
58  // remove the temporary signal->slot connection
59  QObject::disconnect(this, SIGNAL(attributeChanged(QVariant)),
60  obj, attribute);
61  }
62 }
63 
64 //***************************************************************************
65 unsigned int Kwave::StreamObject::blockSize() const
66 {
67  return (m_interactive) ? 8*1024 : 512*1024;
68 }
69 
70 //***************************************************************************
72 {
73  m_interactive = interactive;
74 }
75 
76 //***************************************************************************
77 //***************************************************************************
StreamObject(QObject *parent=Q_NULLPTR)
virtual unsigned int tracks() const
Definition: StreamObject.h:50
static void setInteractive(bool interactive)
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
virtual unsigned int blockSize() const
void attributeChanged(const QVariant value)
static bool m_interactive
Definition: StreamObject.h:127
void setAttribute(const char *attribute, const QVariant &value)