mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2026-02-05 04:06:31 -05:00
Handle alsa-lib 1.2.15 logging change
This commit is contained in:
parent
b096704c0d
commit
bbbe3462b4
1 changed files with 31 additions and 1 deletions
|
|
@ -49,6 +49,11 @@
|
|||
#include <modules/udev-util.h>
|
||||
#endif
|
||||
|
||||
// alsa-lib < 1.2.5 does not have SND_LIB_VER() version macro
|
||||
#if !defined(SND_LIB_VER)
|
||||
#define SND_LIB_VER(X,Y,Z) (((X)<<16)|((Y)<<8)|(Z))
|
||||
#endif
|
||||
|
||||
static int set_format(snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, pa_sample_format_t *f) {
|
||||
|
||||
static const snd_pcm_format_t format_trans[] = {
|
||||
|
|
@ -892,6 +897,20 @@ finish:
|
|||
snd_output_close(out);
|
||||
}
|
||||
|
||||
#if SND_LIB_VERSION >= SND_LIB_VER(1, 2, 15)
|
||||
static void alsa_log_handler(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg) {
|
||||
char *alsa_file;
|
||||
|
||||
if (!snd_lib_log_filter(prio, interface, NULL))
|
||||
return;
|
||||
|
||||
alsa_file = pa_sprintf_malloc("(alsa-lib) %s", file);
|
||||
|
||||
pa_log_levelv_meta(PA_LOG_INFO, alsa_file, line, function, fmt, arg);
|
||||
|
||||
pa_xfree(alsa_file);
|
||||
}
|
||||
#else
|
||||
static void alsa_error_handler(const char *file, int line, const char *function, int err, const char *fmt,...) {
|
||||
va_list ap;
|
||||
char *alsa_file;
|
||||
|
|
@ -906,14 +925,21 @@ static void alsa_error_handler(const char *file, int line, const char *function,
|
|||
|
||||
pa_xfree(alsa_file);
|
||||
}
|
||||
#endif
|
||||
|
||||
static pa_atomic_t n_error_handler_installed = PA_ATOMIC_INIT(0);
|
||||
|
||||
void pa_alsa_refcnt_inc(void) {
|
||||
/* This is not really thread safe, but we do our best */
|
||||
|
||||
if (pa_atomic_inc(&n_error_handler_installed) == 0)
|
||||
if (pa_atomic_inc(&n_error_handler_installed) == 0) {
|
||||
/* alsa-lib messages are printed to stderr by default, intercept them */
|
||||
#if SND_LIB_VERSION >= SND_LIB_VER(1, 2, 15)
|
||||
snd_lib_log_set_handler(alsa_log_handler);
|
||||
#else
|
||||
snd_lib_error_set_handler(alsa_error_handler);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void pa_alsa_refcnt_dec(void) {
|
||||
|
|
@ -922,7 +948,11 @@ void pa_alsa_refcnt_dec(void) {
|
|||
pa_assert_se((r = pa_atomic_dec(&n_error_handler_installed)) >= 1);
|
||||
|
||||
if (r == 1) {
|
||||
#if SND_LIB_VERSION >= SND_LIB_VER(1, 2, 15)
|
||||
snd_lib_log_set_handler(NULL);
|
||||
#else
|
||||
snd_lib_error_set_handler(NULL);
|
||||
#endif
|
||||
snd_config_update_free_global();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue