Created
April 28, 2024 16:29
-
-
Save jdarge/17656309b7a42a8a37b78f1623e1f6c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
taken from: | |
MOC (music on console), alsa.c | |
*/ | |
static snd_pcm_hw_params_t *alsa_open_device (const char *device) | |
{ | |
int rc; | |
snd_pcm_hw_params_t *result; | |
assert (!handle); | |
rc = snd_pcm_open (&handle, device, SND_PCM_STREAM_PLAYBACK, | |
SND_PCM_NONBLOCK); | |
if (rc < 0) { | |
error_errno ("Can't open audio", rc); | |
goto err1; | |
} | |
rc = snd_pcm_hw_params_malloc (&result); | |
if (rc < 0) { | |
error_errno ("Can't allocate hardware parameters structure", rc); | |
goto err2; | |
} | |
rc = snd_pcm_hw_params_any (handle, result); | |
if (rc < 0) { | |
error_errno ("Can't initialize hardware parameters structure", rc); | |
goto err3; | |
} | |
if (0) { | |
err3: | |
snd_pcm_hw_params_free (result); | |
err2: | |
snd_pcm_close (handle); | |
err1: | |
result = NULL; | |
handle = NULL; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment