Esempio n. 1
0
void esd_audio_close()
{
    /*
     * I guess this chunk of code is meant to make sure that
     * everything that was sent to the output got written
     * - let's leave that in for now, but it could cause a
     * delay when the user hits stop
     * -KDT
     */
    if (esd_audio_fd >= 0) {
	fd_set write_fds;
	FD_ZERO(&write_fds);
	FD_SET(esd_audio_fd, &write_fds);	
    
	ALsetfillpoint(outaudioport, ESD_BUF_SIZE * 2);
	select(esd_audio_fd + 1, NULL, &write_fds, NULL, NULL);
    }
    
    if (outaudioport != (ALport) 0) {
      ALcloseport(outaudioport);
      outaudioport = (ALport) 0;
    }
    if (inaudioport != (ALport) 0) {
      ALcloseport(inaudioport);
      inaudioport = (ALport) 0;
    }
}
Esempio n. 2
0
/* Close the audio device */
void
sgi_audio_close(audio_desc_t ad)
{
        UNUSED(ad);
	ALcloseport(rp);
	ALcloseport(wp);
        audio_fd = -1;
}
Esempio n. 3
0
/** 
 * Stop recording.
 * 
 * @return TRUE on success, FALSE on failure.
 */
boolean
adin_mic_end()
{
  /* close audio port */
  ALcloseport(aport);
  return(TRUE);
}
Esempio n. 4
0
/*
 * Initialize the audio hardware.
 */
int sfxInit(char *audioDir, int numPorts) {
	int idx;
	char *str;

	if (audioDir != NULL) {
		str = strdup(audioDir);
		if (str)
			sfxAudioDir = str;
	}
	if (numPorts < 1)
		return SFX_ERR_NO_PORTS_AVAIL;

	if (numPorts > MAX_AUDIO_PORTS)
		numPorts = MAX_AUDIO_PORTS;

	(void) ALseterrorhandler(sfxSoundErrFunc);

	nAudioPorts = sfxOpenAudioPorts(audioPort, numPorts);

	if (nAudioPorts == 0)
		return SFX_ERR_NO_PORTS_AVAIL;

	if (nAudioPorts < 0)
		return SFX_ERR_NO_AUDIO_HW;

	(void) signal(SIGCHLD, sfxSoundDied);

	if (pipe(spigot) < 0 || (soundChild = sproc(sfxSoundHandler, PR_SADDR, audioPort)) < 0) {
		for (idx=0; idx < nAudioPorts; idx++)
			ALcloseport(audioPort[idx]);

		return SFX_ERR_NO_SPROC;
	}
	return nAudioPorts;
}
Esempio n. 5
0
SoundCardPMO::~SoundCardPMO()
{

   m_bExit = true;
   m_pSleepSem->Signal();
   m_pPauseSem->Signal();

   if (m_pBufferThread)
   {
      m_pBufferThread->Join();
      delete m_pBufferThread;
   }

   Reset(true);
   if (outaudioport != (ALport) 0) {
       ALcloseport(outaudioport);
       outaudioport = (ALport)0;
   }

   if (myInfo)
   {
      delete    myInfo;

      myInfo = NULL;
   }
}
Esempio n. 6
0
Error SoundCardPMO::Reset(bool user_stop)
{
   int a;

   if (audio_fd <= 0)
      return kError_NoErr;

   if (user_stop)
   {
      ALcloseport(outaudioport);
      outaudioport = (ALport)0;
      Init(NULL);
   }
   else
   {
      //PORTING: DSP_SYNC blocks until the soundcard is done playing and
      //         then returns
      if (audio_fd >= 0) {
          fd_set write_fds;
          FD_ZERO(&write_fds);
          FD_SET(audio_fd, &write_fds);
 
          select(audio_fd + 1, NULL, &write_fds, NULL, NULL);
      }
  }
   return kError_NoErr;
}
Esempio n. 7
0
void Audio_Irix::close ()
{
    if (_audio != NULL)
    {
        ALcloseport(_audio);
        ALfreeconfig(_config);
        _audio  = NULL;
        _config = NULL;
        outOfOrder ();
    }
}
Esempio n. 8
0
/*
 * Clean up sound routines.
 */
void sfxEnd(int waitForSounds) {
	int idx;

	endingOnPurpose = 1;

	if (waitForSounds) {		/* wait for sounds to complete */
		for (idx=0; idx < nAudioPorts; idx++) {
			while (ALgetfilled(audioPort[idx]) > 0)
				sginap(1);

			ALcloseport(audioPort[idx]);
		}
	} else if (soundChild > 0)	/* kill childs playing sounds */
		kill(soundChild, SIGKILL);

	if (nAudioPorts > 0)		/* reset audio subsystem */
		sfxResetAudioHw();
}
Esempio n. 9
0
void MainLoop(ALport alp, FileDescriptor dacfd, FileDescriptor sockfd, SynthState *v1, SynthState *v2) {
/*    int hwm = 300, lwm = 256; */
    int hwm = 1000, lwm = 800;
    fd_set read_fds, write_fds;

    /* largest file descriptor to search for */    
    int	nfds = BIGGER_OF(dacfd, sockfd) + 1;

    printf("MainLoop: dacfd %d, sockfd %d, nfds %d\n", dacfd, sockfd, nfds);

    time_to_quit = 0;
    sigset(SIGINT, catch_sigint);       /* set sig handler       */

    while(!time_to_quit) {

	/* compute sine wave samples while the sound output buffer is below
	   the high water mark */

	while (ALgetfilled(alp) < hwm) {
	    Synthesize(alp, v1, v2);
	}

	/* Figure out the time tag corresponding to the time in the future that we haven't
	   computed any samples for yet. */
	OSCInvokeAllMessagesThatAreReady(OSCTT_PlusSeconds(OSCTT_CurrentTime(), 
							   ALgetfilled(alp) / the_sample_rate));

	/* set the low water mark, i.e. when we want control from select(2) */
	ALsetfillpoint(alp, OUTPUTQUEUESIZE - lwm);

	/* set up select */
	FD_ZERO(&read_fds);	/* clear read_fds */
	FD_ZERO(&write_fds);	/* clear write_fds */
	FD_SET(dacfd, &write_fds);
	FD_SET(sockfd, &read_fds); 

	FD_SET(0, &read_fds);	/* stdin */

	/* give control back to OS scheduler to put us to sleep until the DAC
	   queue drains and/or a character is available from standard input */

	if (select(nfds, &read_fds, &write_fds, (fd_set * )0, (struct timeval *)0) < 0) {
	    /* select reported an error */
	    perror("bad select"); 
	    goto quit;
	}

	if(FD_ISSET(sockfd, &read_fds)) {
	    ReceivePacket(sockfd);
	}

	/* is there a character in the queue? */
	if (FD_ISSET(0, &read_fds)) {
	    /* this will never block */
	    char c = getchar();

	    if (c == 'q') {
		/* quit */
		break;
	    } else if ((c <= '9') && (c >= '0')) {
		/* tweak frequency */
		v1->f = 440.0 + 100.0 * (c - '0');
	    }
	}
    }
quit:
    ALcloseport(alp);
    closeudp(sockfd);
}
Esempio n. 10
0
void sound_uninit()
{
  ALfreeconfig(audioconfig);
  ALcloseport(audioport);
}
Esempio n. 11
0
static void shutdown(struct xmp_context *ctx)
{
	xmp_smix_off(ctx);
	ALcloseport(audio_port);
}