mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 00:34:03 +02:00
Use snd_pcm_hw/sw_params_alloca() instead of *malloc()
This commit is contained in:
@@ -1791,10 +1791,7 @@ mal_result mal_device_init__alsa(mal_device* pDevice, mal_device_type type, mal_
|
|||||||
}
|
}
|
||||||
|
|
||||||
snd_pcm_hw_params_t* pHWParams = NULL;
|
snd_pcm_hw_params_t* pHWParams = NULL;
|
||||||
if (snd_pcm_hw_params_malloc(&pHWParams) < 0) {
|
snd_pcm_hw_params_alloca(&pHWParams);
|
||||||
mal_device_uninit__alsa(pDevice);
|
|
||||||
return mal_post_error(pDevice, "[ALSA] Failed to allocate snd_pcm_hw_params_t.", MAL_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snd_pcm_hw_params_any((snd_pcm_t*)pDevice->alsa.pPCM, pHWParams) < 0) {
|
if (snd_pcm_hw_params_any((snd_pcm_t*)pDevice->alsa.pPCM, pHWParams) < 0) {
|
||||||
snd_pcm_hw_params_free(pHWParams);
|
snd_pcm_hw_params_free(pHWParams);
|
||||||
@@ -1856,15 +1853,10 @@ mal_result mal_device_init__alsa(mal_device* pDevice, mal_device_type type, mal_
|
|||||||
return mal_post_error(pDevice, "[ALSA] Failed to set hardware parameters. snd_pcm_hw_params() failed.", MAL_ALSA_FAILED_TO_SET_SW_PARAMS);
|
return mal_post_error(pDevice, "[ALSA] Failed to set hardware parameters. snd_pcm_hw_params() failed.", MAL_ALSA_FAILED_TO_SET_SW_PARAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
snd_pcm_hw_params_free(pHWParams);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
snd_pcm_sw_params_t* pSWParams = NULL;
|
snd_pcm_sw_params_t* pSWParams = NULL;
|
||||||
if (snd_pcm_sw_params_malloc(&pSWParams) < 0) {
|
snd_pcm_sw_params_alloca(&pSWParams);
|
||||||
mal_device_uninit__alsa(pDevice);
|
|
||||||
return mal_post_error(pDevice, "[ALSA] Failed to allocate software parameters. snd_pcm_dw_params_malloc() failed.", MAL_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snd_pcm_sw_params_current((snd_pcm_t*)pDevice->alsa.pPCM, pSWParams) != 0) {
|
if (snd_pcm_sw_params_current((snd_pcm_t*)pDevice->alsa.pPCM, pSWParams) != 0) {
|
||||||
snd_pcm_sw_params_free(pSWParams);
|
snd_pcm_sw_params_free(pSWParams);
|
||||||
@@ -1892,8 +1884,6 @@ mal_result mal_device_init__alsa(mal_device* pDevice, mal_device_type type, mal_
|
|||||||
return mal_post_error(pDevice, "[ALSA] Failed to set software parameters. snd_pcm_sw_params() failed.", MAL_ALSA_FAILED_TO_SET_SW_PARAMS);
|
return mal_post_error(pDevice, "[ALSA] Failed to set software parameters. snd_pcm_sw_params() failed.", MAL_ALSA_FAILED_TO_SET_SW_PARAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
snd_pcm_sw_params_free(pSWParams);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// If we're _not_ using mmap we need to use an intermediary buffer.
|
// If we're _not_ using mmap we need to use an intermediary buffer.
|
||||||
|
|||||||
Reference in New Issue
Block a user