Lines Matching refs:this
256 const snd_pcm_sframes_t needed = (snd_pcm_sframes_t) this->spec.samples; in ALSA_WaitDevice()
257 while (SDL_AtomicGet(&this->enabled)) { in ALSA_WaitDevice()
258 const snd_pcm_sframes_t rc = ALSA_snd_pcm_avail(this->hidden->pcm_handle); in ALSA_WaitDevice()
263 SDL_OpenedAudioDeviceDisconnected(this); in ALSA_WaitDevice()
266 const Uint32 delay = ((needed - (SDL_max(rc, 0))) * 1000) / this->spec.freq; in ALSA_WaitDevice()
325 if (this->spec.channels == 6) { in swizzle_alsa_channels()
326 switch (SDL_AUDIO_BITSIZE(this->spec.format)) { in swizzle_alsa_channels()
350 const Uint8 *sample_buf = (const Uint8 *) this->hidden->mixbuf; in ALSA_PlayDevice()
351 const int frame_size = ((SDL_AUDIO_BITSIZE(this->spec.format)) / 8) * in ALSA_PlayDevice()
352 this->spec.channels; in ALSA_PlayDevice()
353 snd_pcm_uframes_t frames_left = ((snd_pcm_uframes_t) this->spec.samples); in ALSA_PlayDevice()
355 this->hidden->swizzle_func(this, this->hidden->mixbuf, frames_left); in ALSA_PlayDevice()
357 while ( frames_left > 0 && SDL_AtomicGet(&this->enabled) ) { in ALSA_PlayDevice()
358 int status = ALSA_snd_pcm_writei(this->hidden->pcm_handle, in ALSA_PlayDevice()
368 status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0); in ALSA_PlayDevice()
373 SDL_OpenedAudioDeviceDisconnected(this); in ALSA_PlayDevice()
381 Uint32 delay = (frames_left / 2 * 1000) / this->spec.freq; in ALSA_PlayDevice()
393 return (this->hidden->mixbuf); in ALSA_GetDeviceBuf()
400 const int frame_size = ((SDL_AUDIO_BITSIZE(this->spec.format)) / 8) * in ALSA_CaptureFromDevice()
401 this->spec.channels; in ALSA_CaptureFromDevice()
408 while ( frames_left > 0 && SDL_AtomicGet(&this->enabled) ) { in ALSA_CaptureFromDevice()
411 status = ALSA_snd_pcm_readi(this->hidden->pcm_handle, in ALSA_CaptureFromDevice()
415 ALSA_snd_pcm_wait(this->hidden->pcm_handle, wait_time); in ALSA_CaptureFromDevice()
420 status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0); in ALSA_CaptureFromDevice()
435 this->hidden->swizzle_func(this, buffer, total_frames - frames_left); in ALSA_CaptureFromDevice()
443 ALSA_snd_pcm_reset(this->hidden->pcm_handle); in ALSA_FlushCapture()
449 if (this->hidden->pcm_handle) { in ALSA_CloseDevice()
453 Uint32 delay = ((this->spec.samples * 1000) / this->spec.freq) * 2; in ALSA_CloseDevice()
456 ALSA_snd_pcm_close(this->hidden->pcm_handle); in ALSA_CloseDevice()
458 SDL_free(this->hidden->mixbuf); in ALSA_CloseDevice()
459 SDL_free(this->hidden); in ALSA_CloseDevice()
475 persize = this->spec.samples; in ALSA_set_buffer_size()
477 this->hidden->pcm_handle, hwparams, &persize, NULL); in ALSA_set_buffer_size()
485 this->hidden->pcm_handle, hwparams, &periods, NULL); in ALSA_set_buffer_size()
491 this->hidden->pcm_handle, hwparams, &periods, NULL); in ALSA_set_buffer_size()
497 status = ALSA_snd_pcm_hw_params(this->hidden->pcm_handle, hwparams); in ALSA_set_buffer_size()
502 this->spec.samples = persize; in ALSA_set_buffer_size()
535 this->hidden = (struct SDL_PrivateAudioData *) in ALSA_OpenDevice()
536 SDL_malloc((sizeof *this->hidden)); in ALSA_OpenDevice()
537 if (this->hidden == NULL) { in ALSA_OpenDevice()
540 SDL_zerop(this->hidden); in ALSA_OpenDevice()
545 get_audio_device(handle, this->spec.channels), in ALSA_OpenDevice()
554 this->hidden->pcm_handle = pcm_handle; in ALSA_OpenDevice()
574 for (test_format = SDL_FirstAudioFormat(this->spec.format); in ALSA_OpenDevice()
623 this->spec.format = test_format; in ALSA_OpenDevice()
628 this->hidden->swizzle_func = swizzle_alsa_channels; in ALSA_OpenDevice()
635 this->hidden->swizzle_func = no_swizzle; in ALSA_OpenDevice()
643 this->spec.channels); in ALSA_OpenDevice()
644 channels = this->spec.channels; in ALSA_OpenDevice()
650 this->spec.channels = channels; in ALSA_OpenDevice()
654 rate = this->spec.freq; in ALSA_OpenDevice()
661 this->spec.freq = rate; in ALSA_OpenDevice()
664 status = ALSA_set_buffer_size(this, hwparams); in ALSA_OpenDevice()
676 status = ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, this->spec.samples); in ALSA_OpenDevice()
694 SDL_CalculateAudioSpec(&this->spec); in ALSA_OpenDevice()
698 this->hidden->mixlen = this->spec.size; in ALSA_OpenDevice()
699 this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); in ALSA_OpenDevice()
700 if (this->hidden->mixbuf == NULL) { in ALSA_OpenDevice()
703 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen); in ALSA_OpenDevice()