Esempio n. 1
0
RESULT eDVBTSRecorder::stop()
{
	int state=3;

	for (std::map<int,int>::iterator i(m_pids.begin()); i != m_pids.end(); ++i)
		stopPID(i->first);

	if (!m_running)
		return -1;

#if HAVE_DVB_API_VERSION >= 5
	/* workaround for record thread stop */
	if (::ioctl(m_source_fd, DMX_STOP) < 0)
		perror("DMX_STOP");
	else
		state &= ~1;

	if (::close(m_source_fd) < 0)
		perror("close");
	else
		state &= ~2;
#endif

	m_thread->stop();

	if (state & 3)
		::close(m_source_fd);

	m_running = 0;
	m_source_fd = -1;

	m_thread->stopSaveMetaInformation();
	return 0;
}
Esempio n. 2
0
RESULT eDVBTSRecorder::removePID(int pid)
{
	if (m_pids.find(pid) == m_pids.end())
		return -1;

	if (m_running)
		stopPID(pid);

	m_pids.erase(pid);
	return 0;
}
Esempio n. 3
0
RESULT eDVBTSRecorder::stop()
{
	int state=3;

	for (std::map<int,int>::iterator i(m_pids.begin()); i != m_pids.end(); ++i)
		stopPID(i->first);

	if (!m_running)
		return -1;

	/* workaround for record thread stop */
	if (m_source_fd >= 0)
	{
		if (::ioctl(m_source_fd, DMX_STOP) < 0)
			eWarning("[eDVBTSRecorder] DMX_STOP: %m");
		else
			state &= ~1;

		if (::close(m_source_fd) < 0)
			eWarning("[eDVBTSRecorder] close: %m");
		else
			state &= ~2;
		m_source_fd = -1;
	}

	m_thread->stop();

	if (state & 3)
	{
		if (m_source_fd >= 0)
		{
			::close(m_source_fd);
			m_source_fd = -1;
		}
	}

	m_running = 0;

	m_thread->stopSaveMetaInformation();
	return 0;
}