summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2023-06-15 23:03:15 -0500
committerMichele Calgaro <michele.calgaro@yahoo.it>2023-06-17 14:08:46 +0900
commiteb439ea63b0aba3b77e15ba5bef54771f9d00584 (patch)
tree8997a186effa6128a95024e724d55ea4c0e87867
parentfc763a04fd135d51339e3d8cab9ac6043a365b30 (diff)
downloadarts-eb439ea63b0aba3b77e15ba5bef54771f9d00584.tar.gz
arts-eb439ea63b0aba3b77e15ba5bef54771f9d00584.zip
Update ALSA support to use 1.x API
Despite the comment in ConfigureChecks.cmake which claimed only ALSA 1.x was supported, the code requested and expected the 0.9 version of some PCM APIs. These old APIs were superceded in 2002. ALSA implements backwards compatibility with the old version of the API using symbol versioning, which is not supported on all platforms (e.g., musl does not support it). This fixes issue #5 Signed-off-by: Bobby Bingham <koorogi@koorogi.info> (cherry picked from commit c9092132fd7020cdb6f39aa7ed749f695fb98d26)
-rw-r--r--ConfigureChecks.cmake4
-rw-r--r--config.h.cmake2
-rw-r--r--flow/audioioalsa9.cpp13
3 files changed, 9 insertions, 10 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 5e3fb98..08fe29b 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -105,11 +105,7 @@ if( WITH_ALSA )
if( ALSA_FOUND )
- # there is support only for ALSA 1.x
-
set( HAVE_LIBASOUND2 1 )
- set( ALSA_PCM_OLD_SW_PARAMS_API 1 )
- set( ALSA_PCM_OLD_HW_PARAMS_API 1 )
check_include_file( "alsa/asoundlib.h" HAVE_ALSA_ASOUNDLIB_H )
if( NOT HAVE_ALSA_ASOUNDLIB_H )
diff --git a/config.h.cmake b/config.h.cmake
index 7c2f7c8..8527cdc 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -35,8 +35,6 @@
#cmakedefine HAVE_LIBASOUND2 1
#cmakedefine HAVE_ALSA_ASOUNDLIB_H 1
#cmakedefine HAVE_SND_PCM_RESUME 1
-#cmakedefine ALSA_PCM_OLD_SW_PARAMS_API 1
-#cmakedefine ALSA_PCM_OLD_HW_PARAMS_API 1
#cmakedefine HAVE_SYS_SOUNDCARD_H 1
#cmakedefine HAVE_LIBPTHREAD 1
diff --git a/flow/audioioalsa9.cpp b/flow/audioioalsa9.cpp
index 1c8b3a5..9162d41 100644
--- a/flow/audioioalsa9.cpp
+++ b/flow/audioioalsa9.cpp
@@ -73,7 +73,8 @@ protected:
snd_pcm_t *m_pcm_playback;
snd_pcm_t *m_pcm_capture;
snd_pcm_format_t m_format;
- int m_period_size, m_periods;
+ snd_pcm_uframes_t m_period_size;
+ unsigned m_periods;
void startIO();
int setPcmParams(snd_pcm_t *pcm);
@@ -540,7 +541,11 @@ int AudioIOALSA::setPcmParams(snd_pcm_t *pcm)
return 1;
}
- unsigned int rate = snd_pcm_hw_params_set_rate_near(pcm, hw, _samplingRate, 0);
+ unsigned rate = _samplingRate;
+ if (snd_pcm_hw_params_set_rate_near(pcm, hw, &rate, 0) < 0) {
+ _error = "Unable to set sampling rate!";
+ return 1;
+ }
const unsigned int tolerance = _samplingRate/10+1000;
if (abs((int)rate - (int)_samplingRate) > (int)tolerance) {
_error = "Can't set requested sampling rate!";
@@ -562,12 +567,12 @@ int AudioIOALSA::setPcmParams(snd_pcm_t *pcm)
m_period_size <<= 1;
if (_channels > 1)
m_period_size /= _channels;
- if ((m_period_size = snd_pcm_hw_params_set_period_size_near(pcm, hw, m_period_size, 0)) < 0) {
+ if (snd_pcm_hw_params_set_period_size_near(pcm, hw, &m_period_size, 0) < 0) {
_error = "Unable to set period size!";
return 1;
}
m_periods = _fragmentCount;
- if ((m_periods = snd_pcm_hw_params_set_periods_near(pcm, hw, m_periods, 0)) < 0) {
+ if (snd_pcm_hw_params_set_periods_near(pcm, hw, &m_periods, 0) < 0) {
_error = "Unable to set periods!";
return 1;
}