2 Copyright © 2015, The AROS Development Team. All rights reserved.
6 #include <proto/exec.h>
7 #include <proto/hostlib.h>
8 #include "alsa_hostlib.h"
10 #include <aros/debug.h>
12 #define LIBASOUND_SOFILE "libasound.so.2"
14 static const char *alsa_func_names
[] =
18 "snd_pcm_hw_params_malloc",
19 "snd_pcm_hw_params_free",
20 "snd_pcm_hw_params_any",
21 "snd_pcm_hw_params_set_access",
22 "snd_pcm_hw_params_set_format",
23 "snd_pcm_hw_params_set_rate_near",
24 "snd_pcm_hw_params_set_channels",
28 "snd_pcm_avail_update",
29 "snd_pcm_hw_params_get_buffer_size",
30 "snd_pcm_hw_params_set_buffer_size",
34 #define ALSA_NUM_FUNCS (sizeof(alsa_func_names) / sizeof(alsa_func_names[0]))
37 struct alsa_func alsa_func
;
38 static void * libasoundhandle
;
40 static void *hostlib_load_so(const char *sofile
, const char **names
, int nfuncs
,
47 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
48 D(bug("[ALSA] failed to open '%s': %s\n", sofile
, err
));
52 for (i
= 0; i
< nfuncs
; i
++) {
53 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
55 bug("[ALSA] failed to get symbol '%s' (%s)\n", names
[i
], err
);
56 HostLib_Close(handle
, NULL
);
64 BOOL
ALSA_HostLib_Init()
66 HostLibBase
= OpenResource("hostlib.resource");
71 libasoundhandle
= hostlib_load_so(LIBASOUND_SOFILE
, alsa_func_names
,
72 ALSA_NUM_FUNCS
, (void **)&alsa_func
);
80 VOID
ALSA_HostLib_Cleanup()
82 HostLib_Close(libasoundhandle
, NULL
);