File: proc_event.C

package info (click to toggle)
gmod 3.1-2
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 1,348 kB
  • ctags: 808
  • sloc: cpp: 7,755; makefile: 82
file content (72 lines) | stat: -rw-r--r-- 1,356 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// -*-C++-*-
// This file is part of the gmod package
// Copyright (C) 1997 by Andrew J. Robinson

#ifndef USE_X

#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

#include "defines.h"
#include "structs.h"
#include "globals.h"
#include "protos.h"

#include "Sequencer.h"

void
NoXProcessEvent ()
{
  fd_set readFds, writeFds;
  static int songFinished = 0;
  static int writeEnabled = 1;
  extern Sequencer *seq;
  SEQ_DECLAREBUF();

  FD_ZERO (&readFds);
  FD_ZERO (&writeFds);
  FD_SET (0, &readFds);	/* standard input */
  FD_SET (seq->seqFd(), &readFds);

  if (writeEnabled)
    FD_SET (seq->seqFd(), &writeFds);

  select (seq->seqFd() + 1, &readFds, &writeFds, NULL, NULL);
  
  if (FD_ISSET (seq->seqFd(), &writeFds))
    {
      if (stopFlag)
	songFinished = 1;

      do
	{
	  while ((seq->bufferSize() < 1) && (!songFinished))
	    if ((songFinished = playNextPosition()))
	      {
		syncTime();
		SEQ_ECHO_BACK(ECHO_END);
		seq->dump();
	      }
	}
      while ((seq->bufferSize() > 0) && (seq->write() != -1));

      if ((seq->bufferSize() == 0) && (songFinished))
	writeEnabled = 0;
   }
  
  if (FD_ISSET (seq->seqFd(), &readFds))
    {
      seqInput = procInput ();
      
      if (seqInput == ECHO_END)
	{
	  songFinished = 0;
	  writeEnabled = 1;
	}
    }

  if (FD_ISSET (0, &readFds))
    timerHandler (-1);
}
#endif