Пример #1
0
static void
NAS_flush (GstNasSink * sink)
{
    AuEvent ev;

    AuNextEvent (sink->audio, AuTrue, &ev);
    AuDispatchEvent (sink->audio, &ev);
}
Пример #2
0
/* This function waits until it is possible to write a full sound buffer */
static void NAS_WaitAudio(_THIS)
{
	while ( this->hidden->buf_free < this->hidden->mixlen ) {
		AuEvent ev;
		AuNextEvent(this->hidden->aud, AuTrue, &ev);
		AuDispatchEvent(this->hidden->aud, &ev);
	}
}
Пример #3
0
static void flush_nas(out123_handle *ao)
{
    AuEvent         ev;
    
    while ((!info.data_sent) && (!info.finished)) {
        AuNextEvent(info.aud, AuTrue, &ev);
        AuDispatchEvent(info.aud, &ev);
    }
    info.data_sent = AuFalse;
}
Пример #4
0
static void nas_flush()
{
	AuEvent ev;

	_D(_D_INFO "flush");

	while (!info.data_sent && !info.finished) {
		AuNextEvent(info.aud, AuTrue, &ev);
		AuDispatchEvent(info.aud, &ev);
	}
	info.data_sent = AuFalse;
}
Пример #5
0
static int nas_close(WINE_WAVEOUT* wwo)
{
  AuEvent ev;

  nas_free(wwo);

  AuStopFlow(wwo->AuServ, wwo->AuFlow, NULL);
  AuDestroyFlow(wwo->AuServ, wwo->AuFlow, NULL);
  AuFlush(wwo->AuServ);
  AuNextEvent(wwo->AuServ, AuTrue, &ev);
  AuDispatchEvent(wwo->AuServ, &ev);

  wwo->AuFlow = 0;
  wwo->open = 0;
  wwo->BufferUsed = 0;
  wwo->freeBytes = 0;
  wwo->SoundBuffer = NULL;
  return 1;
}
Пример #6
0
void
audio_play(int n,short *data)
{
 int endian = 1;
#define little_endian ((*((char *)&endian) == 1))
 int priv = 0;
 AuEvent ev;
 Sound s = SoundCreate(SoundFileFormatNone, little_endian ?
                       AuFormatLinearSigned16LSB : AuFormatLinearSigned16MSB,
                       1, samp_rate, n, "Chit chat");
 if (aud)
  {
#ifdef USE_ALL_ARGS
   AuStatus ret_status;
   AuFlowID flow = 0;
   int monitor = 0;
   int multiplier = 0;
   if (!AuSoundPlayFromData(aud, s, data, AuNone,
                            AuFixedPointFromFraction(volume, 100),
                            done, &priv,
                            &flow, &multiplier,
                            &monitor, &ret_status))
#else
   if (!AuSoundPlayFromData(aud, s, data, AuNone,
                            AuFixedPointFromFraction(volume, 100),
                            done, &priv,
                            NULL, NULL, NULL, NULL))
#endif
    perror("problems playing data");
   else
    {
     while (1)
      {
       AuNextEvent(aud, AuTrue, &ev);
       AuDispatchEvent(aud, &ev);
       if (priv)
        break;
      }
    }
  }
 SoundDestroy(s);
}
Пример #7
0
static void NAS_PlayAudio(_THIS)
{
	while (this->hidden->mixlen > this->hidden->buf_free) { /* We think the buffer is full? Yikes! Ask the server for events,
				    in the hope that some of them is LowWater events telling us more
				    of the buffer is free now than what we think. */
		AuEvent ev;
		AuNextEvent(this->hidden->aud, AuTrue, &ev);
		AuDispatchEvent(this->hidden->aud, &ev);
	}
	this->hidden->buf_free -= this->hidden->mixlen;

	/* Write the audio data */
	AuWriteElement(this->hidden->aud, this->hidden->flow, 0, this->hidden->mixlen, this->hidden->mixbuf, AuFalse, NULL);

	this->hidden->written += this->hidden->mixlen;
	
#ifdef DEBUG_AUDIO
	fprintf(stderr, "Wrote %d bytes of audio data\n", this->hidden->mixlen);
#endif
}
Пример #8
0
int ao_plugin_play(ao_device *device, const char* output_samples,
                   uint_32 num_bytes)
{
    ao_nas_internal *internal = (ao_nas_internal *) device->internal;

    while (num_bytes > 0) {
        /* Wait for room in buffer */
        while (internal->buf_free == 0) {
            AuEvent ev;
            AuNextEvent(internal->aud, AuTrue, &ev);
            if (ev.type == AuEventTypeElementNotify) {
                AuElementNotifyEvent* event = (AuElementNotifyEvent*)(&ev);
                if (event->kind == AuElementNotifyKindLowWater)
                    internal->buf_free = event->num_bytes;
                else if ((event->kind == AuElementNotifyKindState) &&
                         (event->cur_state == AuStatePause) &&
                         (event->reason != AuReasonUser))
                    internal->buf_free = event->num_bytes;
            }
        }

        /* Partial transfer */
        if (num_bytes > internal->buf_free) {
            AuWriteElement(internal->aud, internal->flow, 0, internal->buf_free,
                           (AuPointer)output_samples, AuFalse, 0);
            num_bytes -= internal->buf_free;
            output_samples += internal->buf_free;
            internal->buf_free = 0;
        }

        /* Final transfer */
        else {
            AuWriteElement(internal->aud, internal->flow, 0, num_bytes,
                           (AuPointer)output_samples, AuFalse, 0);
            internal->buf_free -= num_bytes;
            break;
        }
    }

    return 1;
}
/* Process audio events from the NAS server.  The same routine is used
   whether we are recording or playing back */
static void handleAudioEvents(int fd, void *data, int flags)
{
  if(!server) {
    DPRINTF( "handleAudioEvents called while unconnected!\n");
    return;
  }

  /* read events once */
  AuEventsQueued(server, AuEventsQueuedAfterReading);

  /* then loop through the read queue */
  while(AuEventsQueued(server, AuEventsQueuedAlready)) {
    AuEvent event;
    AuNextEvent(server, AuTrue, &event);
    DPRINTF("event of type %d\n", event.type);
    
    switch(event.type) {
    case 0:
      {
	AuErrorEvent *errEvent = (AuErrorEvent *) &event;
	char errdesc[1000];
      
	AuGetErrorText(server, errEvent->error_code, errdesc, sizeof(errdesc));
	fprintf(stderr, "audio error: %s\n", errdesc);
	sound_Stop();
	return;  /* return, not break, so that we don't
		    process the now-closed server any longer! */
      }
    

    case AuEventTypeElementNotify:
      {
	AuElementNotifyEvent *enEvent = (AuElementNotifyEvent *)&event;

	switch(enEvent->kind) {
	case AuElementNotifyKindLowWater:
	  DPRINTF("low water event\n");
	  bytesAvail += enEvent->num_bytes;
	  break;
	case AuElementNotifyKindHighWater:
	  DPRINTF("high water event\n");
	  bytesAvail += enEvent->num_bytes;
	  break;
	case AuElementNotifyKindState:
	  DPRINTF("state change (%d->%d)\n",
		  enEvent->prev_state,
		  enEvent->cur_state);
	  bytesAvail += enEvent->num_bytes;
	  if(enEvent->cur_state == AuStatePause) {
	       /* if the flow has stopped, then arrange for it to get started again */
	       /* XXX there is probably a more intelligent place to do
                  this, in case there is a real reason it has paused */
	       DPRINTF("unpausing\n");
	       AuStartFlow(server, flow, NULL);
	       AuFlush(server);
	  }

	  break;
	}
      }
    }
  }

  if(bytesAvail > 0) {
    DPRINTF("bytesAvail: %d\n", bytesAvail);
    signalSemaphoreWithIndex(semaIndex);
  }

  aioHandle(fd, handleAudioEvents, flags & AIO_RW);
}