Example #1
0
  void
  ALAudioDevice::update() {
    ADR_GUARD("ALAudioDevice::update");

    // how much data can we write?
    const int filled = alGetFilled(m_port);
    int can_write = 5000 - filled;  // empty portion of the buffer

    // write 1024 frames at a time
    static const int BUFFER_SIZE = 1024;
    u8 buffer[BUFFER_SIZE * 4];
    while (can_write > 0) {
      int transfer_count = std::min(can_write, BUFFER_SIZE);

      ADR_LOG("reading");

      read(transfer_count, buffer);

      ADR_LOG("writing");

      alWriteFrames(m_port, buffer, transfer_count);
      can_write -= transfer_count;
    }

    usleep(50000);  // 50 milliseconds
  }
Example #2
0
long audriv_get_filled(void)
/* オーディオバッファ内のバイト数を返します。
 * エラーの場合は -1 を返します。
 */
{
    if(out == NULL)
	return 0;
    return (long)play_frame_width * alGetFilled(out);
}
Example #3
0
void audriv_wait_play(void)
/* CPU パワーを浪費しないようにするために,一時的に停止します.*/
{
    double spare;

    spare = (double)alGetFilled(out) / (double)play_sample_rate;
    if(spare < 0.1)
	return;
    usleep((unsigned long)(spare * 500000.0));
}
Example #4
0
int32 ad_read (ad_rec_t *r, int16 *buf, int32 max)
{
  int32 length = alGetFilled(r->audio);
  
  if (length > max) {
    alReadFrames(r->audio, buf, max);
    return max; 
  } else {
    alReadFrames(r->audio, buf, length); 
    return length;
  }
}
// close audio device
static void uninit(int immed) {

  /* TODO: samplerate should be set back to the value before mplayer was started! */

  mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Uninit);

  if (ao_config) {
    alFreeConfig(ao_config);
    ao_config = NULL;
  }

  if (ao_port) {
    if (!immed)
    while(alGetFilled(ao_port) > 0) sginap(1);
    alClosePort(ao_port);
    ao_port = NULL;
  }

}
Example #6
0
void
sgi_play(void)
{
	struct audio_packet *packet;
	ssize_t len;
	unsigned int i;
	STREAM out;
	int gf;

	while (1)
	{
		if (rdpsnd_queue_empty())
			return;

		packet = rdpsnd_queue_current_packet();
		out = &packet->s;

		len = out->end - out->p;

		alWriteFrames(output_port, out->p, len / combinedFrameSize);

		out->p += len;
		if (out->p == out->end)
		{
			gf = alGetFilled(output_port);
			if (gf < (4 * maxFillable / 10))
			{
				rdpsnd_queue_next(0);
			}
			else
			{
#if (defined(IRIX_DEBUG))
/*  				fprintf(stderr,"Busy playing...\n"); */
#endif
				usleep(10);
				return;
			}
		}
	}
}
Example #7
0
void
wave_out_play(void)
{
	struct audio_packet *packet;
	ssize_t len;
	unsigned int i;
	uint8 swap;
	STREAM out;
	static BOOL swapped = False;
	int gf;

	while (1)
	{
		if (queue_lo == queue_hi)
		{
			This->dsp_bu = False;
			return;
		}

		packet = &packet_queue[queue_lo];
		out = &packet->s;

		/* Swap the current packet, but only once */
		if (g_swapaudio && !swapped)
		{
			for (i = 0; i < out->end - out->p; i += 2)
			{
				swap = *(out->p + i);
				*(out->p + i) = *(out->p + i + 1);
				*(out->p + i + 1) = swap;
			}
			swapped = True;
		}

		len = out->end - out->p;

		alWriteFrames(output_port, out->p, len / combinedFrameSize);

		out->p += len;
		if (out->p == out->end)
		{
			gf = alGetFilled(output_port);
			if (gf < (4 * maxFillable / 10))
			{
				rdpsnd_send_completion(packet->tick, packet->index);
				free(out->data);
				queue_lo = (queue_lo + 1) % MAX_QUEUE;
				swapped = False;
			}
			else
			{
#if (defined(IRIX_DEBUG))
/*  				fprintf(stderr,"Busy playing...\n"); */
#endif
				This->dsp_bu = True;
				usleep(10);
				return;
			}
		}
	}
}
Example #8
0
/*
	Wait until the audio port has no more samples to play.
*/
void waitport (ALport port)
{
	while (alGetFilled(port) > 0)
		sginap(1);
}
Example #9
0
int audriv_play_active(void)
/* 演奏中なら 1,演奏中でないなら 0, エラーなら -1 を返します.
 */
{
    return out && alGetFilled(out) > 0;
}