Lines Matching defs:handle
454 static int set_hwparams(snd_pcm_t *handle, snd_pcm_hw_params_t *params, snd_pcm_access_t access) {
463 err = snd_pcm_hw_params_any(handle, params);
470 err = snd_pcm_hw_params_set_access(handle, params, access);
477 err = snd_pcm_hw_params_set_format(handle, params, format);
484 err = snd_pcm_hw_params_set_channels(handle, params, channels);
492 err = snd_pcm_hw_params_set_rate(handle, params, rate, 0);
517 err = snd_pcm_hw_params_set_period_time_near(handle, params, &tmp, NULL);
526 err = snd_pcm_hw_params_set_buffer_time_near(handle, params, &buffer_time, NULL);
538 err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &buffer_size);
547 err = snd_pcm_hw_params_set_periods_near(handle, params, &nperiods, NULL);
556 err = snd_pcm_hw_params(handle, params);
574 static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams) {
578 err = snd_pcm_sw_params_current(handle, swparams);
585 err = snd_pcm_sw_params_set_start_threshold(handle, swparams, buffer_size);
592 err = snd_pcm_sw_params_set_avail_min(handle, swparams, period_size);
599 err = snd_pcm_sw_params(handle, swparams);
609 static int config_chmap(snd_pcm_t *handle, const char *mapstr)
619 err = snd_pcm_set_chmap(handle, channel_map);
628 channel_map = snd_pcm_get_chmap(handle);
642 static int xrun_recovery(snd_pcm_t *handle, int err) {
644 err = snd_pcm_prepare(handle);
651 while ((err = snd_pcm_resume(handle)) == -EAGAIN)
655 err = snd_pcm_prepare(handle);
854 static int write_buffer(snd_pcm_t *handle, uint8_t *ptr, int cptr)
860 err = snd_pcm_writei(handle, ptr, cptr);
867 if ((err = xrun_recovery(handle, err)) < 0) {
874 ptr += snd_pcm_frames_to_bytes(handle, err);
903 static int write_loop(snd_pcm_t *handle, int channel, int periods, uint8_t *frames)
911 int bufsize = snd_pcm_frames_to_bytes(handle, period_size);
915 if ((err = write_buffer(handle, frames,
916 snd_pcm_bytes_to_frames(handle, err * channels))) < 0)
920 snd_pcm_drain(handle);
921 snd_pcm_prepare(handle);
943 if ((err = write_buffer(handle, frames, period_size)) < 0)
947 snd_pcm_drain(handle);
948 snd_pcm_prepare(handle);
1012 snd_pcm_t *handle;
1225 if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
1229 pcm_handle = handle;
1231 if ((err = set_hwparams(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
1235 if ((err = set_swparams(handle, swparams)) < 0) {
1241 err = config_chmap(handle, chmap);
1250 snd_pcm_dump(handle, log);
1255 frames = malloc(snd_pcm_frames_to_bytes(handle, period_size));
1279 err = write_loop(handle, channel, ((rate*3)/period_size), frames);
1301 err = write_loop(handle, chn, ((rate*5)/period_size), frames);
1308 snd_pcm_drain(handle);