2 Copyright © 2015-2018, The AROS Development Team. All rights reserved.
6 #include "alsa_hostlib.h"
7 #include <proto/hostlib.h>
9 #include <aros/debug.h>
11 #define LIBASOUND_SOFILE "libasound.so.2"
13 static const char *alsa_func_names
[] =
17 "snd_pcm_hw_params_malloc",
18 "snd_pcm_hw_params_free",
19 "snd_pcm_hw_params_any",
20 "snd_pcm_hw_params_set_access",
21 "snd_pcm_hw_params_set_format",
22 "snd_pcm_hw_params_set_rate_near",
23 "snd_pcm_hw_params_set_channels",
27 "snd_pcm_avail_update",
28 "snd_pcm_hw_params_get_buffer_size",
29 "snd_pcm_hw_params_set_buffer_size",
36 "snd_mixer_find_selem",
37 "snd_mixer_selem_register",
38 "snd_mixer_selem_id_malloc",
39 "snd_mixer_selem_id_free",
40 "snd_mixer_selem_id_set_index",
41 "snd_mixer_selem_id_set_name",
42 "snd_mixer_selem_get_playback_volume_range",
43 "snd_mixer_selem_get_playback_volume",
44 "snd_mixer_selem_set_playback_volume_all",
47 #define ALSA_NUM_FUNCS (sizeof(alsa_func_names) / sizeof(alsa_func_names[0]))
50 struct alsa_func alsa_func
;
51 static void *libasoundhandle
;
53 static void *hostlib_load_so(const char *sofile
, const char **names
, int nfuncs
,
60 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
61 D(bug("[ALSA] failed to open '%s': %s\n", sofile
, err
));
65 for (i
= 0; i
< nfuncs
; i
++) {
66 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
68 bug("[ALSA] failed to get symbol '%s' (%s)\n", names
[i
], err
);
69 HostLib_Close(handle
, NULL
);
77 BOOL
ALSA_HostLib_Init()
79 HostLibBase
= OpenResource("hostlib.resource");
83 D(bug("[ALSA] failed to open hostlib.resource\n"));
87 libasoundhandle
= hostlib_load_so(LIBASOUND_SOFILE
, alsa_func_names
,
88 ALSA_NUM_FUNCS
, (void **)&alsa_func
);
92 bug("[ALSA] failed to open "LIBASOUND_SOFILE
"\n");
99 VOID
ALSA_HostLib_Cleanup()
101 if (libasoundhandle
!= NULL
)
102 HostLib_Close(libasoundhandle
, NULL
);