Exemple #1
0
int dvbsub_close()
{
	if(threadReader) 
	{
		dvbsub_pause();
		reader_running = false;
		dvbsub_stopped = 1;

		pthread_mutex_lock(&readerMutex);
		pthread_cond_broadcast(&readerCond);
		pthread_mutex_unlock(&readerMutex);

		pthread_join(threadReader, NULL);
		threadReader = 0;
	}
	
	if(threadDvbsub) 
	{
		dvbsub_running = false;

		pthread_mutex_lock(&packetMutex);
		pthread_cond_broadcast(&packetCond);
		pthread_mutex_unlock(&packetMutex);

		pthread_join(threadDvbsub, NULL);
		threadDvbsub = 0;
	}
	printf("[dvb-sub] stopped\n");

	return 0;
}
Exemple #2
0
int dvbsub_stop()
{
	dvbsub_pid = 0;
	if(reader_running) {
		dvbsub_stopped = 1;
		dvbsub_pause();
		pid_change_req = 1;
	}

	return 0;
}
int dvbsub_stop()
{
	dvbsub_pid = 0;
	if(reader_running) {
		dvbsub_stopped = 1;
		dvbsub_pause();
		pid_change_req = 1;
		write(flagFd, "", 1);
	}

	return 0;
}
int dvbsub_start(int pid)
#endif
{
#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
	isEplayer = _isEplayer;
	if (isEplayer && !dvbsub_paused)
		return 0;
#endif
	if(!dvbsub_paused && !pid)
		return 0;

	if(pid && (pid != dvbsub_pid)) {
		dvbsub_pause();
		if(dvbSubtitleConverter)
			dvbSubtitleConverter->Reset();
		dvbsub_pid = pid;
		pid_change_req = 1;
	}
printf("[dvb-sub] start, stopped %d pid %x\n", dvbsub_stopped, dvbsub_pid);
	if(dvbsub_pid) {
#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
		if (isEplayer) {
			OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(ass_mutex);
			std::map<int,ASS_Track*>::iterator it = ass_map.find(dvbsub_pid);
			if (it != ass_map.end())
				ass_track = it->second;
			else
				ass_track = NULL; //FIXME
		}
#endif
		dvbsub_stopped = 0;
		dvbsub_paused = false;
		if(dvbSubtitleConverter)
			dvbSubtitleConverter->Pause(false);
		pthread_mutex_lock(&readerMutex);
		pthread_cond_broadcast(&readerCond);
		pthread_mutex_unlock(&readerMutex);
		printf("[dvb-sub] started with pid 0x%x\n", dvbsub_pid);
	}

	return 1;
}
int dvbsub_close()
{
	if(threadReader) {
		dvbsub_pause();
		reader_running = false;
		dvbsub_stopped = 1;
		write(flagFd, "", 1);

		pthread_mutex_lock(&readerMutex);
		pthread_cond_broadcast(&readerCond);
		pthread_mutex_unlock(&readerMutex);

// dvbsub_close() is called at shutdown time only. Instead of waiting for
// the threads to terminate just detach. --martii
		pthread_detach(threadReader);
		threadReader = 0;
	}
	if(threadDvbsub) {
		dvbsub_running = false;

		pthread_mutex_lock(&packetMutex);
		pthread_cond_broadcast(&packetCond);
		pthread_mutex_unlock(&packetMutex);

		pthread_detach(threadDvbsub);
		threadDvbsub = 0;
	}
#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
	if (ass_reader_running) {
		ass_reader_running = false;
		sem_post(&ass_sem);
	}
#endif
	printf("[dvb-sub] stopped\n");

	return 0;
}
Exemple #6
0
int dvbsub_start(int pid)
{
	if(!dvbsub_paused && (pid == 0)) 
	{
		return 0;
	}

	if(pid) 
	{
		if(pid != dvbsub_pid) 
		{
			dvbsub_pause();
			if(dvbSubtitleConverter)
				dvbSubtitleConverter->Reset();
			dvbsub_pid = pid;
			pid_change_req = 1;
		}
	}
	printf("[dvb-sub] start, stopped %d pid %x\n", dvbsub_stopped, dvbsub_pid);
#if 0
	while(!dvbsub_stopped)
		usleep(10);
#endif
	if(dvbsub_pid > 0) 
	{
		dvbsub_stopped = 0;
		dvbsub_paused = false;
		if(dvbSubtitleConverter)
			dvbSubtitleConverter->Pause(false);
		pthread_mutex_lock(&readerMutex);
		pthread_cond_broadcast(&readerCond);
		pthread_mutex_unlock(&readerMutex);
		printf("[dvb-sub] started with pid 0x%x\n", pid);
	}

	return 1;
}
int CSubtitleChangeExec::exec(CMenuTarget* /*parent*/, const std::string & actionKey)
{
printf("CSubtitleChangeExec::exec: action %s\n", actionKey.c_str());

	CMoviePlayerGui *mp = &CMoviePlayerGui::getInstance();
	bool is_mp = mp->Playing();

	if(actionKey == "off") {
		tuxtx_stop_subtitle();
		if (!is_mp && dvbsub_getpid() > 0)
			dvbsub_stop();
		if (is_mp && playback) {
			playback->SetSubtitlePid(0);
			playback->SetTeletextPid(0);
			mp->setCurrentTTXSub("");
		}
		return menu_return::RETURN_EXIT;
	}
	if(!strncmp(actionKey.c_str(), "DVB", 3)) {
		char const * pidptr = strchr(actionKey.c_str(), ':');
		int pid = atoi(pidptr+1);
		tuxtx_stop_subtitle();
		dvbsub_pause();
		dvbsub_start(pid);
	} else if (!strncmp(actionKey.c_str(), "TTX", 3)) {
		char const * ptr = strchr(actionKey.c_str(), ':');
		ptr++;
		int pid = atoi(ptr);
		ptr = strchr(ptr, ':');
		ptr++;
		int page = strtol(ptr, NULL, 16);
		ptr = strchr(ptr, ':');
		ptr++;
printf("CSubtitleChangeExec::exec: TTX, pid %x page %x lang %s\n", pid, page, ptr);
		tuxtx_stop_subtitle();
		tuxtx_set_pid(pid, page, ptr);
		dvbsub_stop();
		if (is_mp) {
			playback->SetSubtitlePid(0);
			playback->SetTeletextPid(pid);
			tuxtx_set_pid(pid, page, ptr);
#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
			tuxtx_main(pid, page, 0, true);
#else
			tuxtx_main(pid, page, 0);
#endif
			mp->setCurrentTTXSub(actionKey.c_str());
		} else {
			tuxtx_set_pid(pid, page, ptr);
			tuxtx_main(pid, page);
		}
	} else if (is_mp && !strncmp(actionKey.c_str(), "SUB", 3)) {
		tuxtx_stop_subtitle();
		dvbsub_stop();
		playback->SetSubtitlePid(0);
		playback->SetTeletextPid(0);
		mp->setCurrentTTXSub("");
		char const * pidptr = strchr(actionKey.c_str(), ':');
		int pid = atoi(pidptr+1);
		playback->SetSubtitlePid(pid);
	}
        return menu_return::RETURN_EXIT;
}