static void play_file_av(int filefd, int vfd, int afd)
{
	unsigned char buf[BUFFY];
	int count;

	audioSetMute(afd, 1);
	videoBlank(vfd, 1);
	if (audio && !black) {
		audioStop(afd);
		deviceClear(afd, -1);
		audioSetAVSync(afd, 0);
		audioSelectSource(afd, AUDIO_SOURCE_MEMORY);
		audioPlay(afd);
		videoBlank(vfd, 0);
	} else if (audio && black) {
		deviceClear(afd, vfd);
		videoBlank(vfd, 1);
		audioSetAVSync(afd, 0);
		audioSelectSource(afd, AUDIO_SOURCE_MEMORY);
		videoSelectSource(vfd, VIDEO_SOURCE_MEMORY);
		audioPlay(afd);
		videoPlay(vfd);
	} else {
		deviceClear(afd, vfd);
		audioSetAVSync(afd, 1);
		audioSelectSource(afd, AUDIO_SOURCE_MEMORY);
		videoSelectSource(vfd, VIDEO_SOURCE_MEMORY);
		audioPlay(afd);
		videoPlay(vfd);
		videoBlank(vfd, 0);
	}

	if (dolby) {
		audioSetVolume(afd, 0);
		volset = 0;
	} else {
		audioSetVolume(afd, 255);
		volset = 1;
	}

#ifndef __stub_posix_fadvise
	posix_fadvise(filefd, 0, 0, POSIX_FADV_SEQUENTIAL);
#endif

	while ((count = read(filefd,buf,BUFFY)) > 0)
		scan_file_av(vfd,afd,buf,count);
}
Exemple #2
0
void Weapon::doShot(list<Shot*>* shotlist)
{
	if (cooling || loading)
		return;

	if (getShotsRemaining()) {
		clip--;

		cooling = true;
		coolTime = cooldownDuration.value();

		for (int i = 0; i < shots; i++) {
			Shot* shot = new Shot(ammo, wielder, inaccuracy);
			shotlist->push_back(shot);
		}
	}

	else {
		if (!loadSnd.isEmpty())
			audioPlay(loadSnd);
		loading = true;
		loadTime = loadDuration.value();
	}
}
static void copy_to_dvb(int vfd, int afd, int cfd, const uint8_t* ptr, const unsigned short len)
{
	struct pollfd pfd[NFD];
	unsigned short pos = 0;
	int stopped = 0;

	pfd[0].fd = STDIN_FILENO;
	pfd[0].events = POLLIN;

	pfd[1].fd = vfd;
	pfd[1].events = POLLOUT;

	pfd[2].fd = afd;
	pfd[2].events = POLLOUT;

	while (pos < len) {
		int ret;
		if ((ret = poll(pfd,NFD,1)) > 0) {
			if (pfd[1].revents & POLLOUT) {
				int cnt = write(cfd, ptr + pos, len - pos);
				if (cnt > 0)
					pos += cnt;
				else if (cnt < 0) {
					if (errno != EAGAIN && errno != EINTR) {
						perror("Write:");
						exit(-1);
					}
					if (errno == EAGAIN)
						usleep(1000);
					continue;
				}
			}
			if (pfd[0].revents & POLLIN) {
				int c = getchar();
				switch(c) {
				case 'z':
					if (audio && !black) {
						audioSetMute(afd, 1);
					} else {
						videoFreeze(vfd);
					}
					deviceClear(afd, -1);
					printf("playback frozen\n");
					stopped = 1;
					break;

				case 's':
					if (audio) {
						audioStop(afd);
						deviceClear(afd, -1);
					} else {
						videoStop(vfd);
						deviceClear(afd, vfd);
					}
					printf("playback stopped\n");
					stopped = 1;
					break;

				case 'c':
					if (audio && !black) {
						audioSetAVSync(afd, 0);
						deviceClear(afd, -1);
						audioSetMute(afd, 0);
					} else {
						audioSetAVSync(afd, 1);
						deviceClear(afd, vfd);
						videoContinue(vfd);
					}
					printf("playback continued\n");
					stopped = 0;
					break;

				case 'p':
					if (audio) {
						deviceClear(afd, -1);
						audioSetAVSync(afd, 0);
						audioPlay(afd);
					} else {
						deviceClear(afd, vfd);
						audioSetAVSync(afd, 1);
						audioPlay(afd);
						videoPlay(vfd);
					}
					audioSetMute(afd, 0);
					printf("playback started\n");
					stopped = 0;
					break;

				case 'f':
					audioSetAVSync(afd, 0);
					if (!audio) {
						audioSetMute(afd, 1);
						videoFastForward(vfd,0);
					}
					printf("fastforward\n");
					stopped = 0;
					break;

				case 'm':
					audioSetAVSync(afd, 0);
					audioSetMute(afd, 1);
					printf("mute\n");
					stopped = 0;
					break;

				case 'u':
					audioSetAVSync(afd, 1);
					audioSetMute(afd, 0);
					printf("unmute\n");
					stopped = 0;
					break;

				case 'd':
					if (dolby)
						dolby = 0;
					else
						dolby++;
					break;

				case 'l':
					audioSetAVSync(afd, 0);
					if (!audio) {
						audioSetMute(afd, 1);
						videoSlowMotion(vfd,2);
					}
					printf("slowmotion\n");
					stopped = 0;
					break;

				case 'q':
					videoContinue(vfd);
					exit(0);
					break;

				default:
					break;
				}
			}
		} else if (ret < 0) {
			if (errno != EAGAIN && errno != EINTR) {
				perror("Write:");
				exit(-1);
			}
			if (errno == EAGAIN)
				usleep(1000);
		}
	}
}