This file is indexed.

/usr/include/CLAM/NetworkPlayer.hxx is in libclam-dev 1.4.0-5build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
 * Copyright (c) 2001-2007 MUSIC TECHNOLOGY GROUP (MTG)
 *                         UNIVERSITAT POMPEU FABRA
 *
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef NetworkPlayer_hxx
#define NetworkPlayer_hxx

#include "Network.hxx"
#include "AudioSource.hxx"
#include "AudioSink.hxx"

namespace CLAM
{

/**
 * A NetworkPlayer is an object that controls the playback of a
 * Network providing a high level transport like interface.
 * This class is an abstract class.
 * Subclasses contextualizes the network inside a given execution
 * context dealing with threading, callback calling and device mapping
 * on concrete architectures such as Alsa, PortAudio, Jack, VST, Ladspa...
 */
class NetworkPlayer
{
protected:
	enum Status { Playing=0, Stopped=1, Paused=2 };

public:
	NetworkPlayer()
		: _network(NULL)
		, _status(Stopped)
	{
	}

	virtual ~NetworkPlayer()
	{
	}

	/// Should return true when the backend is able to run the network
	virtual bool IsWorking() = 0;

	/// Whenever the backend is not working, this method returns the reason
	virtual std::string NonWorkingReason() = 0;

	/// Redefine to add any initialization after being attached to a network
	/// TODO: Consider removing it as just Jack backend uses it but it is redundant
	virtual void Init() {}

	/// Redefine to make the backend ready to process and start the network.
	/// If IsPlaying() should do nothing.
	/// If it IsPaused() you should consider just call BePlaying()
	/// without starting the processings.
	virtual void Start()=0; // { if (not IsPlaying()) BePlaying(); }

	/// Redefine it to deactivate the backend.
	virtual void Stop()=0; // { if (not IsStopped()) BeStopped(); }

	virtual void Pause() { if (IsPlaying()) BePaused(); }

	void SetNetworkBackLink( Network& net )
	{
		_network=&net;
	}

	void BePaused() { _status=Paused; }
	void BeStopped() { _status=Stopped; }
	void BePlaying() { _status=Playing; }
	bool IsPaused() const { return _status==Paused; }
	bool IsStopped() const { return _status==Stopped; }
	bool IsPlaying() const { return _status==Playing; }
	virtual bool IsRealTime() const = 0;

	virtual unsigned BackendBufferSize()
	{
		return 512;
	}

	virtual unsigned BackendSampleRate()
	{
		return 44100;
	}

	std::string SourcesAndSinksToString();

protected:
	Network& GetNetwork()
	{
		CLAM_ASSERT( (_network!=NULL), "NetworkPlayer::GetNetwork() : NetworkPlayer does not have any Network");
		return *_network;
	}
protected:
	unsigned GetNSinks() const { return _exportedSinks.size(); }                   
	unsigned GetNSources() const { return _exportedSources.size(); }               
	void CacheSourcesAndSinks()
	{
		_exportedSources.clear();
		Network::Processings sources = GetSources();
		for (Network::Processings::const_iterator it = sources.begin(); it != sources.end(); ++it)
		{
			Processing * processing = *it;
			std::string processingName = _network->GetNetworkId(processing);
			unsigned nPorts = processing->GetNOutPorts();
			for (unsigned i=0; i<nPorts; i++)
			{
				std::ostringstream portName;
				portName << processingName;
				if (nPorts > 1)
					portName << "_" << processing->GetOutPort(i).GetName();
				_exportedSources.push_back(ExportedPort(processing,i, portName.str()));
			}
		}
		_exportedSinks.clear();
		Network::Processings sinks = GetSinks();
		for (Network::Processings::const_iterator it = sinks.begin(); it != sinks.end(); ++it)
		{
			Processing * processing = *it;
			std::string processingName = _network->GetNetworkId(processing);
			unsigned nPorts = processing->GetNInPorts();
			for (unsigned i=0; i<nPorts; i++)
			{
				std::ostringstream portName;
				portName << processingName;
				if (nPorts > 1)
					portName << "_" << processing->GetInPort(i).GetName();
				_exportedSinks.push_back(ExportedPort(processing,i, portName.str()));
			}
		}
	}
	const std::string & SourceName(unsigned source) const
	{
		return _exportedSources[source].name;
	}
	const std::string & SinkName(unsigned sink) const
	{
		return _exportedSinks[sink].name;
	}
	void SetSourceBuffer(unsigned source, const float * data, unsigned nframes);
	void SetSinkBuffer(unsigned sink, float * data, unsigned nframes);
	void SetSinkFrameSize(unsigned sink, unsigned frameSize);
	void SetSourceFrameSize(unsigned source, unsigned frameSize);
private:
	Network::Processings GetSources()
	{
		return GetNetwork().getOrderedProcessingsByAttribute("port_source_type");
	}

	Network::Processings GetSinks()
	{
		return GetNetwork().getOrderedProcessingsByAttribute("port_sink_type");
	}
	template <typename ProcessingType>
	void SetFrameAndHopSizeIf(Processing * proc, unsigned bufferSize, unsigned port)
	{
		if(typeid(*proc)!=typeid(ProcessingType)) return;
		((ProcessingType*)proc)->SetFrameAndHopSize(bufferSize, port);
		
	}
	template <typename ProcessingType>
	void SetExternalBuffer(Processing * proc, const float * data, unsigned nframes, unsigned port)
	{
		if(typeid(*proc)!=typeid(ProcessingType)) return;
		((ProcessingType*)proc)->SetExternalBuffer(data, nframes, port);
	}
	template <typename ProcessingType>
	void SetExternalBuffer(Processing * proc, float * data, unsigned nframes, unsigned port)
	{
		if(typeid(*proc)!=typeid(ProcessingType)) return;
		((ProcessingType*)proc)->SetExternalBuffer(data, nframes, port);
	}

private:
	struct ExportedPort
	{
		ExportedPort(Processing * aProcesing, unsigned aPort, const std::string & aName)
			: processing(aProcesing)
			, port(aPort)
			, name(aName)
		{
		}
		Processing * processing;
		unsigned port;
		std::string name;
	};
	typedef std::vector <ExportedPort> ExportedPorts;
	ExportedPorts _exportedSources;
	ExportedPorts _exportedSinks;
	Network *_network;
	volatile Status _status;
};

} //namespace CLAM

#endif // NetworkPlayer_hxx