Exemplo n.º 1
0
const BufferData MLConnection::peekElements(uint elements)
{
#ifdef EDEBUG
	if (!theReader)
	{	qWarning("*** WARNING: peekElements() cannot be called on an MLConnection object after\n"
				 "             killReader() has been called. Ignoring this call.\n");
		return BufferData();
	}
#endif

	while (1)
	{	BufferData ret = theReader->readElements(elements, false);
		theSink->checkExit();
		if (!ret.plunger())
		{
			if (type().isA<Mark>())
				if (!Mark::isEndOfTime(ret))
					m_latestTime = Mark::timestamp(ret);
				else{}
			else
				m_latestPeeked = m_samplesRead + elements / theType->size();
			return ret;
		}
		m_samplesRead = 0;
		m_latestPeeked = 0;
		m_latestTime = 0.0;
		theReader->haveRead(ret);
		theSink->plunged(theSinkIndex);
	}
}
Exemplo n.º 2
0
bool MLConnection::plungeSync(uint samples) const
{
#ifdef EDEBUG
	if (!theReader)
	{	qWarning("*** WARNING: plungeSync() cannot be called on an MLConnection object after\n"
				 "             killReader() has been called. Ignoring this call.\n");
		return false;
	}
#endif

	BufferData ret = theReader->readElements(theType->size() * samples, false);
	theSink->checkExit();
	if (ret.plunger())
	{
		m_samplesRead = 0;
		m_latestPeeked = 0;
		m_latestTime = 0.0;
		theReader->haveRead(ret);
		theSink->plunged(theSinkIndex);
		return false;
	}
	return true;
}
Exemplo n.º 3
0
const BufferData MLConnection::readElements(uint _elements)
{
#ifdef EDEBUG
	if (!theReader)
	{	qWarning("*** WARNING: readElements() cannot be called on an MLConnection object after\n"
				 "             killReader() has been called. Ignoring this call.\n");
		return BufferData();
	}
#endif

	while (1)
	{	BufferData ret = theReader->readElements(_elements, true);
		theSink->checkExit();
		if (!ret.plunger())
		{
			if (type().isA<Mark>())
				if (!Mark::isEndOfTime(ret))
					m_latestTime = Mark::timestamp(ret);
				else{}
			else
			{
				m_samplesRead += _elements / theType->size();
				m_latestPeeked = max(m_latestPeeked, m_samplesRead);
			}
			return ret;
		}
		m_samplesRead = 0;
		m_latestPeeked = 0;
		m_latestTime = 0.0;
		// This is a workaround for a buggy gcc (3.2.2).
		// If it wasn't here stuff wouldn't get freed up in the buffer.
		// As it is, there are deallocation problems, since the last instance of ret
		// will never get destroyed.
		ret.nullify();
		theSink->plunged(theSinkIndex);
	}
}