int32 ad_close (ad_rec_t *r) { if (r->audio) alClosePort(r->audio); free(r); return 0; }
void ClosePlay(void *port){ struct Sgiplay *sgiplay=(struct Sgiplay *)port; type j; j = alClosePort(sgiplay->out_port); j = alFreeConfig(sgiplay->out_c); free(sgiplay); }
static void AL_CloseAudio(_THIS) { if ( mixbuf != NULL ) { SDL_FreeAudioMem(mixbuf); mixbuf = NULL; } if ( audio_port != NULL ) { alClosePort(audio_port); audio_port = NULL; } }
void audriv_play_close(void) /* 演奏用にオープンされた audio を閉じます.すでに閉じている * 場合はなにも行いません. */ { if(!out) return; while(audriv_play_active() == 1) audriv_wait_play(); alClosePort(out); out = NULL; }
static void IRIXAUDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { if (this->hidden->mixbuf != NULL) { SDL_FreeAudioMem(this->hidden->mixbuf); this->hidden->mixbuf = NULL; } if (this->hidden->audio_port != NULL) { alClosePort(this->hidden->audio_port); this->hidden->audio_port = NULL; } SDL_free(this->hidden); this->hidden = NULL; } }
long audriv_play_stop(void) /* 演奏を即座に停止し,停止直前のサンプル数を返します. * audriv_play_stop() の呼び出しによって,audio は閉じます. * audio が既に閉じている場合に audriv_play_stop() を呼び出した場合は 0 を * 返します. * エラーの場合は -1 を返します. */ { long samp; if(!out) return 0; samp = audriv_play_samples(); alClosePort(out); reset_samples = play_counter = 0; out = NULL; return samp; }
static void irix_dsp_destroy(struct sysdep_dsp_struct *dsp) { struct irix_dsp_priv_data *priv = dsp->_priv; #ifdef IRIX_DEBUG fprintf(stderr, "Destroying sound channel.\n"); #endif if (priv) { if (priv->port_status >= 0) alClosePort(priv->devAudio); free(priv); } free(dsp); }
void audriv_free_audio(void) /* audio の後処理を行います. */ { if(!out_config) return; if(out != NULL) { alClosePort(out); out = NULL; } alFreeConfig(out_config); out_config = NULL; if(out_config != NULL) alFreeConfig(out_config); out_config = NULL; }
// 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; } }
void sgi_close(void) { /* Ack all remaining packets */ #if (defined(IRIX_DEBUG)) fprintf(stderr, "sgi_close: begin\n"); #endif while (!rdpsnd_queue_empty()) rdpsnd_queue_next(0); alDiscardFrames(output_port, 0); alClosePort(output_port); output_port = (ALport) 0; alFreeConfig(audioconfig); #if (defined(IRIX_DEBUG)) fprintf(stderr, "sgi_close: returning\n"); #endif }
void wave_out_close(void) { /* Ack all remaining packets */ #if (defined(IRIX_DEBUG)) fprintf(stderr, "wave_out_close: begin\n"); #endif while (queue_lo != queue_hi) { rdpsnd_send_completion(packet_queue[queue_lo].tick, packet_queue[queue_lo].index); free(packet_queue[queue_lo].s.data); queue_lo = (queue_lo + 1) % MAX_QUEUE; } alDiscardFrames(output_port, 0); alClosePort(output_port); alFreeConfig(audioconfig); #if (defined(IRIX_DEBUG)) fprintf(stderr, "wave_out_close: returning\n"); #endif }
Bool audriv_play_open(void) /* audio を演奏用に開き,いつでも audriv_write() により演奏可能な * 状態にします.既に開いている場合はなにも行いません. * 成功した場合は True を,失敗した場合は False を返します. */ { if(out) return True; if(audriv_al_set_width(out_config, play_encoding) < 0) { audriv_err(ALERROR); return False; } alSetChannels(out_config, play_nchannels); out = alOpenPort("audriv", "w", out_config); if(!out) { audriv_err(ALERROR); return False; } if(audriv_al_set_rate(out, play_sample_rate) == False) { audriv_err(ALERROR); alClosePort(out); out = NULL; return False; } alSetConfig(out, out_config); reset_samples = 0; play_counter = 0; return True; }
main (int argc, char **argv) { AFfilehandle file; AFframecount count, frameCount; int channelCount, sampleFormat, sampleWidth; float frameSize; void *buffer; double sampleRate; ALport outport; ALconfig outportconfig; if (argc < 2) usage(); file = afOpenFile(argv[1], "r", NULL); if (file == AF_NULL_FILEHANDLE) { fprintf(stderr, "Could not open file %s.\n", argv[1]); exit(EXIT_FAILURE); } frameCount = afGetFrameCount(file, AF_DEFAULT_TRACK); frameSize = afGetVirtualFrameSize(file, AF_DEFAULT_TRACK, 1); channelCount = afGetVirtualChannels(file, AF_DEFAULT_TRACK); sampleRate = afGetRate(file, AF_DEFAULT_TRACK); afGetVirtualSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); if (sampleFormat == AF_SAMPFMT_UNSIGNED) { afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, sampleWidth); } printf("frame count: %lld\n", frameCount); printf("frame size: %d bytes\n", (int) frameSize); printf("channel count: %d\n", channelCount); printf("sample rate: %.2f Hz\n", sampleRate); buffer = malloc(BUFFERED_FRAME_COUNT * frameSize); outportconfig = alNewConfig(); setwidth(outportconfig, sampleWidth); setsampleformat(outportconfig, sampleFormat); alSetChannels(outportconfig, channelCount); count = afReadFrames(file, AF_DEFAULT_TRACK, buffer, BUFFERED_FRAME_COUNT); outport = alOpenPort("irixread", "w", outportconfig); setrate(outport, sampleRate); do { printf("count = %lld\n", count); alWriteFrames(outport, buffer, count); count = afReadFrames(file, AF_DEFAULT_TRACK, buffer, BUFFERED_FRAME_COUNT); } while (count > 0); waitport(outport); alClosePort(outport); alFreeConfig(outportconfig); afCloseFile(file); }
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; }
/* ============== SNDDMA_Shutdown Reset the sound device for exiting =============== */ void SNDDMA_Shutdown(void) { if (sgisnd_aport) alClosePort( sgisnd_aport ), sgisnd_aport = NULL; return; }
static void al_close (ao_instance_t * _instance) { al_instance_t * instance = (al_instance_t *) _instance; alClosePort (instance->port); }
ALAudioDevice::~ALAudioDevice() { ADR_GUARD("ALAudioDevice::~ALAudioDevice"); alClosePort(m_port); }