static int irix_dsp_get_freespace(struct sysdep_dsp_struct *dsp) { struct irix_dsp_priv_data *priv = dsp->_priv; return alGetFillable(priv->devAudio);; }
// return: how many bytes can be played without blocking static int get_space(void) { // printf("ao_sgi, get_space: (ao_outburst %d)\n", ao_data.outburst); // printf("ao_sgi, get_space: alGetFillable [%d] \n", alGetFillable(ao_port)); return alGetFillable(ao_port) * bytes_per_frame; }
void static AL_WaitAudio(_THIS) { Sint32 timeleft; timeleft = this->spec.samples - alGetFillable(audio_port); if ( timeleft > 0 ) { timeleft /= (this->spec.freq/1000); SDL_Delay((Uint32)timeleft); } }
void static IRIXAUDIO_WaitDevice(_THIS) { Sint32 timeleft; timeleft = this->spec.samples - alGetFillable(this->hidden->audio_port); if (timeleft > 0) { timeleft /= (this->spec.freq / 1000); SDL_Delay((Uint32) timeleft); } }
int audriv_write(char *buff, int n) /* audio に buff を n バイト分流し込みます. * audriv_set_noblock_write() で非ブロック・モードが設定された * 場合は,この関数の呼び出しは即座に処理が返ります. * 返り値は実際に流し込まれたバイト数であり,非ブロック・モードが設定 * されている場合は,引数 n より少ない場合があります. * 失敗すると -1 を返し,成功すると,実際に流し込まれたバイト数を返します. */ { n /= play_frame_width; if(audio_write_noblocking) { int size; size = alGetFillable(out); if(size < n) n = size; } add_sample_counter(n); if(play_encoding != AENC_G711_ULAW) { alWriteFrames(out, buff, n); return n * play_frame_width; } else { /* AENC_G711_ULAW */ int i, m, ret; short samps[BUFSIZ]; n *= play_frame_width; ret = n; while(n > 0) { m = n; if(m > BUFSIZ) m = BUFSIZ; for(i = 0; i < m; i++) samps[i] = AUDIO_U2S(buff[i]); alWriteFrames(out, samps, m / play_frame_width); buff += m; n -= m; } return ret; } }
static int irix_dsp_write(struct sysdep_dsp_struct *dsp, unsigned char *data, int count) { struct irix_dsp_priv_data *priv = dsp->_priv; int playcnt; int maxsize; /* * We write as many samples as possible (up to count) without blocking */ maxsize = alGetFillable(priv->devAudio); playcnt = (count <= maxsize) ? count : maxsize; alWriteFrames(priv->devAudio, data, playcnt); return playcnt; }
void SNDDMA_Submit(void) { int nFillable, nFilled, nPos; int nFrames, nFramesLeft; unsigned endtime; if (!sgisnd_aport) return; nFillable = alGetFillable( sgisnd_aport ); nFilled = QSND_BUFFER_FRAMES - nFillable; nFrames = dma.samples >> (dma.channels - 1); if (paintedtime - soundtime < nFrames) nFrames = paintedtime - soundtime; if (nFrames <= QSND_SKID) return; nPos = UST_TO_BUFFPOS( sgisnd_startframe ); // dump re-written contents of the buffer if (sgisnd_lastframewritten > sgisnd_startframe) { alDiscardFrames( sgisnd_aport, sgisnd_lastframewritten - sgisnd_startframe ); } else if ((int)(sgisnd_startframe - sgisnd_lastframewritten) >= QSND_BUFFER_FRAMES) { // blow away everything if we've underflowed alDiscardFrames( sgisnd_aport, QSND_BUFFER_FRAMES ); } // don't block if (nFrames > nFillable) nFrames = nFillable; // account for stereo nFramesLeft = nFrames; if (nPos + nFrames * dma.channels > QSND_BUFFER_SIZE) { int nFramesAtEnd = (QSND_BUFFER_SIZE - nPos) >> (dma.channels - 1); alWriteFrames( sgisnd_aport, &dma_buffer[nPos], nFramesAtEnd ); nPos = 0; nFramesLeft -= nFramesAtEnd; }
BOOL wave_out_set_format(WAVEFORMATEX * pwfx) { int channels; int frameSize, channelCount; ALpv params; #if (defined(IRIX_DEBUG)) fprintf(stderr, "wave_out_set_format: init...\n"); #endif g_swapaudio = False; if (pwfx->wBitsPerSample == 8) width = AL_SAMPLE_8; else if (pwfx->wBitsPerSample == 16) { width = AL_SAMPLE_16; /* Do we need to swap the 16bit values? (Are we BigEndian) */ #if (defined(B_ENDIAN)) g_swapaudio = 1; #else g_swapaudio = 0; #endif } /* Limited support to configure an opened audio port in IRIX. The number of channels is a static setting and can not be changed after a port is opened. So if the number of channels remains the same, we can configure other settings; otherwise we have to reopen the audio port, using same config. */ channels = pwfx->nChannels; g_snd_rate = pwfx->nSamplesPerSec; alSetSampFmt(audioconfig, AL_SAMPFMT_TWOSCOMP); alSetWidth(audioconfig, width); if (channels != alGetChannels(audioconfig)) { alClosePort(output_port); alSetChannels(audioconfig, channels); output_port = alOpenPort("rdpsnd", "w", audioconfig); if (output_port == (ALport) 0) { fprintf(stderr, "wave_out_set_format: alOpenPort failed: %s\n", alGetErrorString(oserror())); return False; } } resource = alGetResource(output_port); maxFillable = alGetFillable(output_port); channelCount = alGetChannels(audioconfig); frameSize = alGetWidth(audioconfig); if (frameSize == 0 || channelCount == 0) { fprintf(stderr, "wave_out_set_format: bad frameSize or channelCount\n"); return False; } combinedFrameSize = frameSize * channelCount; params.param = AL_RATE; params.value.ll = (long long) g_snd_rate << 32; if (alSetParams(resource, ¶ms, 1) < 0) { fprintf(stderr, "wave_set_format: alSetParams failed: %s\n", alGetErrorString(oserror())); return False; } if (params.sizeOut < 0) { fprintf(stderr, "wave_set_format: invalid rate %d\n", g_snd_rate); return False; } #if (defined(IRIX_DEBUG)) fprintf(stderr, "wave_out_set_format: returning...\n"); #endif return True; }