示例#1
0
文件: Player.cpp 项目: dkulp/fpp
void Player::SendBlankingData(void)
{
	usleep(100000); // FIXME, figure out a way to not need this delay
	                // possibly by just starting thread up once more

	bzero(m_seqData, FPPD_MAX_CHANNELS);

	if (getFPPmode() == MASTER_MODE)
		SendBlankingDataPacket();

	ProcessChannelData();
	SendChannelData(m_seqData);
}
示例#2
0
static void DoAudioState()
{
	char t = (char)dataState;
	if (t==1)
	{
		PORTD &= ~_BV(PD6); //LED off
		ReadUSB_SendChannelData();
	}
	else if (t==2)
	{
		PORTD &= ~_BV(PD6); //LED off
		SendChannelData();
	}
	else
		PORTD |= _BV(PD6); //LED on
}
示例#3
0
文件: Sequence.cpp 项目: jcochran/fpp
void Sequence::SendSequenceData(void) {
	SendChannelData(m_seqData);
}
示例#4
0
文件: Player.cpp 项目: dkulp/fpp
/*
 * Main loop in channel output thread
 */
void Player::RunChannelOutputThread(void)
{
	static long long lastStatTime = 0;
	long long startTime;
	long long sendTime;
	long long readTime;
	int onceMore = 0;
	struct timespec ts;
	int syncFrameCounter = 0;

	LogDebug(VB_PLAYER | VB_CHANNELOUT, "RunChannelOutputThread() starting\n");

	m_outputThreadIsRunning = 1;

	if ((getFPPmode() == REMOTE_MODE) &&
		(!IsEffectRunning()) &&
		(!UsingMemoryMapInput()) &&
		(!channelTester->Testing()) &&
		(!getAlwaysTransmit()))
	{
		// Sleep about 2 seconds waiting for the master
		int loops = 0;
		while ((m_masterFramesPlayed < 0) && (loops < 200))
		{
			usleep(10000);
			loops++;
		}

		// Stop playback if the master hasn't sent any sync packets yet
		if (m_masterFramesPlayed < 0)
			m_runOutputThread = 0;
	}

	StartOutputThreads();

	while (m_runOutputThread)
	{
		startTime = GetTime();

		pthread_mutex_lock(&m_sequenceLock);
		int runningSequences = m_sequence.size();

		if ((getFPPmode() == MASTER_MODE) && (runningSequences))
		{
			if (syncFrameCounter & 0x10)
			{
				// Send sync every 16 frames (use 16 to make the check simpler)
				syncFrameCounter = 1;

				for (int i = 0; i < m_sequence.size(); i++)
					SendSeqSyncPacket( m_sequence[i]->m_seqFilename,
						channelOutputFrame, mediaElapsedSeconds);
			}
			else
			{
				syncFrameCounter++;
			}
		}

		if (m_outputFrames)
		{
			if (getFPPmode() == BRIDGE_MODE)
			{
				memcpy(m_seqData, e131Data, FPPD_MAX_CHANNELS);
			}
			else
			{
				for (int i = 0; i < m_sequence.size(); i++)
					m_sequence[i]->OverlayNextFrame(m_seqData);
			}

			SendChannelData(m_seqData);
		}

		sendTime = GetTime();

		if ((getFPPmode() != BRIDGE_MODE) &&
			(runningSequences))
		{
			// Close any sequences that aren't open anymore
			for (int i = m_sequence.size() - 1; i >= 0; i--)
			{
				if (!m_sequence[i]->SequenceFileOpen())
				{
					Sequence *seq = m_sequence[i];
					m_sequence.erase(m_sequence.begin() + i);
					delete seq;
				}
			}

			runningSequences = m_sequence.size();

			// Loop through sequences pre-reading next frame of data
			for (int i = 0; i < m_sequence.size(); i++)
			{
				m_sequence[i]->ReadSequenceData();
			}
		}

		ProcessChannelData();

		readTime = GetTime();

		pthread_mutex_unlock(&m_sequenceLock);

		if ((runningSequences) ||
			(IsEffectRunning()) ||
			(UsingMemoryMapInput()) ||
			(channelTester->Testing()) ||
			(getAlwaysTransmit()) ||
			(getFPPmode() == BRIDGE_MODE))
		{
			onceMore = 1;

			if (startTime > (lastStatTime + 1000000)) {
				int sleepTime = m_lightDelay - (GetTime() - startTime);
				if (sleepTime < 0)
					sleepTime = 0;
				lastStatTime = startTime;
				LogDebug(VB_PLAYER | VB_CHANNELOUT,
					"Output Thread: Loop: %dus, Send: %lldus, Read: %lldus, Sleep: %dus, FrameNum: %ld\n",
					m_lightDelay, sendTime - startTime,
					readTime - sendTime, sleepTime, channelOutputFrame);
			}
		}
		else
		{
			m_lightDelay = m_defaultLightDelay;

			if (onceMore)
				onceMore = 0;
			else
				m_runOutputThread = 0;
		}

		// Calculate how long we need to nanosleep()
		ts.tv_sec = 0;
		ts.tv_nsec = (m_lightDelay - (GetTime() - startTime)) * 1000;
		nanosleep(&ts, NULL);
	}

	StopOutputThreads();

	m_outputThreadIsRunning = 0;

	LogDebug(VB_PLAYER | VB_CHANNELOUT, "RunChannelOutputThread() completed\n");

	pthread_exit(NULL);
}
示例#5
0
文件: Player.cpp 项目: dkulp/fpp
void Player::SendData(void)
{
	SendChannelData(m_seqData);
}