summaryrefslogtreecommitdiff
path: root/libs/backends/wavesaudio/waves_dataport.h
blob: fd8dd8090bf219b9e131ea1b3473cbacd51df344 (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
    Copyright (C) 2014 Waves Audio Ltd.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#ifndef __libardour_waves_dataport_h__
#define __libardour_waves_dataport_h__

#include "ardour/types.h"
#include "memory.h"
        
namespace ARDOUR {

class WavesDataPort {
public:

    virtual ~WavesDataPort ();

    inline const std::string& name () const
    {
        return _name;
    }
    
    int set_name (const std::string &name)
    {
        _name = name;
        return 0;
    }

    virtual DataType type () const = 0;

    inline PortFlags flags () const
    {
        return _flags;
    }

    inline bool is_input () { return flags () & IsInput; }
    inline bool is_output () { return flags () & IsOutput; }
    inline bool is_physical () { return flags () & IsPhysical; }
    inline bool is_terminal () { return flags () & IsTerminal; }
    inline operator void* () { return (void*)this; }

    inline const LatencyRange& latency_range (bool for_playback) const
    {
        return for_playback ? _playback_latency_range : _capture_latency_range;
    }

    inline void set_latency_range (const LatencyRange &latency_range, bool for_playback)
    {
        if (for_playback)
        {
            _playback_latency_range = latency_range;
        }
        else
        {
            _capture_latency_range = latency_range;
        }
    }

    int connect (WavesDataPort *port);
    
    int disconnect (WavesDataPort *port);
    
    void disconnect_all ();

    bool inline is_connected (const WavesDataPort *port) const
    {
        return std::find (_connections.begin (), _connections.end (), port) != _connections.end ();
    }

    bool inline is_connected () const
    {
        return _connections.size () != 0;
    }

    bool is_physically_connected () const;

    inline const std::vector<WavesDataPort *>& get_connections () const { return _connections; }

    virtual void* get_buffer (pframes_t nframes) = 0;

protected:
    WavesDataPort (const std::string& inport_name, PortFlags inflags);
	virtual void _wipe_buffer() = 0;

private:

    std::string _name;
    const PortFlags _flags;
    LatencyRange _capture_latency_range;
    LatencyRange  _playback_latency_range;
    std::vector<WavesDataPort*> _connections;

    void _connect (WavesDataPort* port, bool api_call);
    void _disconnect (WavesDataPort* port, bool api_call);
};

} // namespace

#endif /* __libardour_waves_dataport_h__ */