Пример #1
0
void disableVideoOutput(bool disable)
{
	int arg=disable?1:0;
	int fd;
	printf("[controld] videoOutput %s\n", disable?"off":"on");

	if((fd = open(SAA7126_DEVICE,O_RDWR|O_NONBLOCK)) < 0)
	{
		perror("[controld] SAA DEVICE: ");
		return;
	}

	if ( (ioctl(fd,SAAIOSPOWERSAVE,&arg) < 0))
	{
		perror("[controld] IOCTL: ");
		close(fd);
		return;
	}
	close(fd);
	/*
		arg=disable?0:0xf;
		if((fd = open("/dev/dbox/fp0",O_RDWR|O_NONBLOCK)) < 0)
		{
			perror("[controld] FP DEVICE: ");
			return;
		}

		if ( (ioctl(fd,FP_IOCTL_LCD_DIMM,&arg) < 0))
		{
			perror("[controld] IOCTL: ");
			close(fd);
			return;
		}
		close(fd);
	*/
	if(!disable)
	{
		zapit.startPlayBack();
		setvideooutput(settings.videooutput, false);
		setVideoFormat(settings.videoformat, false);
	}
	else
	{
		setvideooutput(0, false);
		setVideoFormat(-1, false);
		zapit.stopPlayBack();
	}
}
Пример #2
0
void disableVideoOutput(bool disable)
{
	settings.videoOutputDisabled = disable;
	printf("[controld] videoOutput %s\n", disable?"off":"on");

#ifdef HAVE_DBOX_HARDWARE
	int arg=disable?1:0;
	int fd;
	if ((fd = open(SAA7126_DEVICE,O_RDWR|O_NONBLOCK)) < 0)
		perror("[controld] " SAA7126_DEVICE);

	else 
	{
		if ((ioctl(fd,SAAIOSPOWERSAVE,&arg) < 0))
			perror("[controld] SAAIOSPOWERSAVE");

		close(fd);
	}
#endif
	/*
	  arg=disable?0:0xf;
	  if((fd = open("/dev/dbox/fp0",O_RDWR|O_NONBLOCK)) < 0)
	  {
	  perror("[controld] FP DEVICE: ");
	  return;
	  }

	  if ( (ioctl(fd,FP_IOCTL_LCD_DIMM,&arg) < 0))
	  {
	  perror("[controld] IOCTL: ");
	  close(fd);
	  return;
	  }
	  close(fd);
	*/

	if (!disable)
	{
		//zapit.setStandby(false);
		if (!settings.mute)
			audioDecoder->unmute();
#if defined HAVE_DREAMBOX_HARDWARE || defined HAVE_IPBOX_HARDWARE
		startPlayBack(cc);
#endif
		setvideooutput(settings.videooutput, false);
		videoDecoder->setVideoFormat(settings.videoformat);
	}
	else
	{
#ifdef HAVE_TRIPLEDRAGON
		if (videoDecoder)
			videoDecoder->setVideoOutput(VID_OUTFMT_DISABLE_DACS);
#else
		setvideooutput(CControld::FORMAT_CVBS, false);
#endif
		videoDecoder->setVideoFormat(-1);
		//zapit.setStandby(true);
		audioDecoder->mute();
#if defined HAVE_DREAMBOX_HARDWARE || defined HAVE_IPBOX_HARDWARE
		stopPlayBack();
#endif
	}
}
Пример #3
0
int main(int argc, char **argv)
{
	int listenfd, connfd;
	printf("Controld  $Id: controld.cpp,v 1.76.2.1 2002/10/24 20:34:32 thegoodguy Exp $\n\n");
	
	switch (fork())
	{
	case -1:
		perror("[controld] fork");
		return -1;
	case 0:
		break;
	default:
		return 0;
	}
	
	if (setsid() == -1)
	{
		perror("[controld] setsid");
		return -1;
	}

	eventServer = new CEventServer;

	struct sockaddr_un servaddr;
	int clilen;
	memset(&servaddr, 0, sizeof(struct sockaddr_un));
	servaddr.sun_family = AF_UNIX;
	strcpy(servaddr.sun_path, CONTROLD_UDS_NAME);
	clilen = sizeof(servaddr.sun_family) + strlen(servaddr.sun_path);
	unlink(CONTROLD_UDS_NAME);

	//network-setup
	if ((listenfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
	{
		perror("socket");
	}

	if ( bind(listenfd, (struct sockaddr*) &servaddr, clilen) <0 )
	{
		perror("[controld] bind failed...\n");
		exit(-1);
	}


	if (listen(listenfd, 5) !=0)
	{
		perror("[controld] listen failed...\n");
		exit( -1 );
	}

	//busyBox
	signal(SIGHUP,sig_catch);
	signal(SIGINT,sig_catch);
	signal(SIGQUIT,sig_catch);
	signal(SIGTERM,sig_catch);

	/* load configuration */
	config = new CConfigFile(',');

	if (!config->loadConfig(CONF_FILE))
	{
		/* set defaults if no configuration file exists */
		printf("[controld] %s not found\n", CONF_FILE);
	}


	settings.volume      = config->getInt32("volume", 100);
	settings.volume_avs  = config->getInt32("volume_avs", 100);
	settings.mute        = config->getBool("mute", false);
	settings.mute_avs    = config->getBool("mute_avs", false);
	settings.videooutput = config->getInt32("videooutput", 1); // fblk1 - rgb
	settings.videoformat = config->getInt32("videoformat", 2); // fnc2 - 4:3

	setBoxType(); // dummy set - liest den aktuellen Wert aus!

	watchDog = new CEventWatchDog();
	aspectRatioNotifier = new CControldAspectRatioNotifier();
	watchDog->registerNotifier(WDE_VIDEOMODE, aspectRatioNotifier);

	//init
	audioControl::setVolume(map_volume(settings.volume_avs, true));
	zapit.setVolume(map_volume(settings.volume, false), map_volume(settings.volume, false));
	lcdd.setVolume(settings.volume_avs);    // we could also display settings.volume at startup

	audioControl::setMute(settings.mute_avs);
	zapit.muteAudio(settings.mute);
	lcdd.setMute(settings.mute || settings.mute_avs);

	setvideooutput(settings.videooutput);
	setVideoFormat(settings.videoformat, false);


	try
	{
		struct CControld::Header rmessage;
		while(true)
		{
			connfd = accept(listenfd, (struct sockaddr*) &servaddr, (socklen_t*) &clilen);
			memset(&rmessage, 0, sizeof(rmessage));
			read(connfd,&rmessage,sizeof(rmessage));

			parse_command(connfd, &rmessage);
			close(connfd);
		}
	}
	catch (std::exception& e)
	{
		printf("[controld] caught std-exception in main-thread %s!\n", e.what());
	}
	catch (...)
	{
	    printf("[controld] caught exception in main-thread!\n");
  	}
}
Пример #4
0
void parse_command(int connfd, CControld::Header * rmessage)
{
	
	if(rmessage->version != CControld::ACTVERSION)
	{
		perror("[controld] wrong version\n");
		return;
	}

	switch (rmessage->cmd)
	{
	case CControld::CMD_SHUTDOWN:
		shutdownBox();
		break;

	case CControld::CMD_SAVECONFIG:
		saveSettings();
		break;

	case CControld::CMD_SETVOLUME:
	case CControld::CMD_SETVOLUME_AVS:
		CControld::commandVolume msg_commandVolume;
		read(connfd, &msg_commandVolume, sizeof(msg_commandVolume));

		if (rmessage->cmd == CControld::CMD_SETVOLUME)
		{
			settings.volume = msg_commandVolume.volume;
			config->setInt32("volume", settings.volume);
			zapit.setVolume(map_volume(msg_commandVolume.volume, false), map_volume(msg_commandVolume.volume, false));
		}
		else
		{
			settings.volume_avs = msg_commandVolume.volume;
			config->setInt32("volume_avs", settings.volume_avs);
			audioControl::setVolume(map_volume(msg_commandVolume.volume, true));
		}
		lcdd.setVolume(msg_commandVolume.volume);
		eventServer->sendEvent(CControldClient::EVT_VOLUMECHANGED, CEventServer::INITID_CONTROLD, &msg_commandVolume.volume, sizeof(msg_commandVolume.volume));
		break;

	case CControld::CMD_MUTE:
		settings.mute = true;
		config->setBool("mute", settings.mute);
		zapit.muteAudio(true);
		lcdd.setMute(true);
		eventServer->sendEvent(CControldClient::EVT_MUTECHANGED, CEventServer::INITID_CONTROLD, &settings.mute, sizeof(settings.mute));
		break;
	case CControld::CMD_MUTE_AVS:
		settings.mute_avs = true;
		config->setBool("mute_avs", settings.mute_avs);
		audioControl::setMute(true);
		lcdd.setMute(true);
		eventServer->sendEvent(CControldClient::EVT_MUTECHANGED, CEventServer::INITID_CONTROLD, &settings.mute_avs, sizeof(settings.mute_avs));
		break;
	case CControld::CMD_UNMUTE:
		settings.mute = false;
		config->setBool("mute", settings.mute);
		zapit.muteAudio(false);
		lcdd.setMute(settings.mute_avs);
		eventServer->sendEvent(CControldClient::EVT_MUTECHANGED, CEventServer::INITID_CONTROLD, &settings.mute_avs, sizeof(settings.mute_avs));
		break;
	case CControld::CMD_UNMUTE_AVS:
		settings.mute_avs = false;
		config->setBool("mute_avs", settings.mute_avs);
		audioControl::setMute(false);
		lcdd.setMute(settings.mute);
		eventServer->sendEvent(CControldClient::EVT_MUTECHANGED, CEventServer::INITID_CONTROLD, &settings.mute, sizeof(settings.mute));
		break;

		case CControld::CMD_SETANALOGMODE:
			CControld::commandAnalogMode msgmd;
			read(connfd, &msgmd, sizeof(msgmd));
			zapit.setAudioMode(msgmd.mode);
			break;
		case CControld::CMD_SETVIDEOFORMAT:
			//printf("[controld] set videoformat\n");
			CControld::commandVideoFormat msg2;
			read(connfd, &msg2, sizeof(msg2));
			setVideoFormat(msg2.format);
			break;
		case CControld::CMD_SETVIDEOOUTPUT:
			//printf("[controld] set videooutput\n");
			CControld::commandVideoOutput msg3;
			read(connfd, &msg3, sizeof(msg3));
			setvideooutput(msg3.output);
			break;
		case CControld::CMD_SETBOXTYPE:
			//printf("[controld] set boxtype\n");    //-------------------dummy!!!!!!!!!!
			CControld::commandBoxType msg4;
			read(connfd, &msg4, sizeof(msg4));
			setBoxType();
			break;
		case CControld::CMD_SETSCARTMODE:
			//printf("[controld] set scartmode\n");
			CControld::commandScartMode msg5;
			read(connfd, &msg5, sizeof(msg5));
			setScartMode(msg5.mode);
			break;
		case CControld::CMD_SETVIDEOPOWERDOWN:
			//printf("[controld] set scartmode\n");
			CControld::commandVideoPowerSave msg10;
			read(connfd, &msg10, sizeof(msg10));
			disableVideoOutput(msg10.powerdown);
			break;

	case CControld::CMD_GETVOLUME:
	case CControld::CMD_GETVOLUME_AVS:
		CControld::responseVolume msg_responseVolume;
		msg_responseVolume.volume = (rmessage->cmd == CControld::CMD_GETVOLUME) ? settings.volume : settings.volume_avs;
		write(connfd, &msg_responseVolume, sizeof(msg_responseVolume));
		break;

	case CControld::CMD_GETMUTESTATUS:
	case CControld::CMD_GETMUTESTATUS_AVS:
		CControld::responseMute msg_responseMute;
		msg_responseMute.mute = (rmessage->cmd == CControld::CMD_GETMUTESTATUS) ? settings.mute : settings.mute_avs;
		write(connfd, &msg_responseMute, sizeof(msg_responseMute));
		break;

		case CControld::CMD_GETVIDEOFORMAT:
			//printf("[controld] get videoformat (fnc)\n");
			CControld::responseVideoFormat msg8;
			msg8.format = settings.videoformat;
			write(connfd,&msg8,sizeof(msg8));
			break;
		case CControld::CMD_GETASPECTRATIO:
			//printf("[controld] get videoformat (fnc)\n");
			CControld::responseAspectRatio msga;
			msga.aspectRatio = aspectRatio;
			write(connfd,&msga,sizeof(msga));
			break;
		case CControld::CMD_GETVIDEOOUTPUT:
			//printf("[controld] get videooutput (fblk)\n");
			CControld::responseVideoOutput msg9;
			msg9.output = settings.videooutput;
			write(connfd,&msg9,sizeof(msg9));
			break;
		case CControld::CMD_GETBOXTYPE:
			//printf("[controld] get boxtype\n");
			CControld::responseBoxType msg0;
			msg0.boxtype = settings.boxtype;
			write(connfd,&msg0,sizeof(msg0));
			break;

		case CControld::CMD_REGISTEREVENT:
			eventServer->registerEvent(connfd);
			break;
		case CControld::CMD_UNREGISTEREVENT:
			eventServer->unRegisterEvent(connfd);
			break;

		default:
			printf("[controld] unknown command\n");
	}
}