stream.h 1.83 KB
Newer Older
jcaceres's avatar
jcaceres committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef _STREAM_H
#define _STREAM_H

#include "circularbuffer.h"
#include "input_plugin.h"
#include "output_plugin.h"
#include "process_plugin.h"
#include "audioInfo.h"
#include "networkInfo.h"
#include "qthread.h"
#include "qptrvector.h"

/**
 * @brief Connects an InputPlugin to an OutputPlugin with
 * optional ProcessPlugins processing the signal.
 */
/**
 * Stream uses a CircularBuffer (a queue of audio buffers) under the hood. \n
 * <img src="stream.jpg">
 */
class Stream 
{
    long lastPluckTime;
    bool harp;
        
  protected:
 //  Vector inputs;
 	  QPtrVector < InputPlugin > ins;
  //  Vector outputs;
 	  QPtrVector < OutputPlugin > outs;
  //   Vector processes;
 	  QPtrVector < ProcessPlugin > procs;
  //   Vector circularBuffers;
	  QPtrVector < CircularBuffer > bufs;
 //    Vector outputLocks;     
 	  QPtrVector < QSemaphore >locks;
  	int insCount;
	int procsCount;
	int outsCount;
	int locksCount;
	int bufsCount;
	int processesPerChan;

  /** @brief Controls read access.  No output is allowed
                                to read until the master output has read (set with
                                synchronizeOutputsTo.
                            */
    int outputSynchKey;
    
    AudioInfoT audioInfo;
        
    void addCircularBuffer();
        
  public:
    

    Stream(AudioInfo * info, NetworkInfo * netInfo, int numBuffers, bool block);
    ~Stream();
    void addInput(InputPlugin *newin);
    void addOutput(OutputPlugin *newout);
    void synchronizeOutputsTo(OutputPlugin *synchControlOutput);
    void addProcess(ProcessPlugin *newproc);
    int read(void *buf, int key);
    int tapRead(void *buf);
    
    int write(const void *buf, int key);
 int
writeRedundant (const void *buf, int key, int z, int seq);
  void clear();
    void startThreads();
     void stopThreads();
  bool threadsRunning;
};

#endif