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 static const char *alsa_func_names
[] =
16 "snd_pcm_hw_params_malloc",
17 "snd_pcm_hw_params_free",
18 "snd_pcm_hw_params_any",
19 "snd_pcm_hw_params_set_access",
20 "snd_pcm_hw_params_set_format",
21 "snd_pcm_hw_params_set_rate_near",
22 "snd_pcm_hw_params_set_channels",
26 "snd_pcm_avail_update",
27 "snd_pcm_hw_params_get_buffer_size",
28 "snd_pcm_hw_params_set_buffer_size"
31 #define ALSA_NUM_FUNCS (sizeof(alsa_func_names) / sizeof(alsa_func_names[0]))
34 struct alsa_func alsa_func
;
35 static void * libasoundhandle
;
37 static void *hostlib_load_so(const char *sofile
, const char **names
, int nfuncs
,
44 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
45 D(bug("[ALSA] failed to open '%s': %s\n", sofile
, err
));
49 for (i
= 0; i
< nfuncs
; i
++) {
50 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
52 bug("[ALSA] failed to get symbol '%s' (%s)\n", names
[i
], err
);
53 HostLib_Close(handle
, NULL
);
61 BOOL
ALSA_HostLib_Init()
63 HostLibBase
= OpenResource("hostlib.resource");
68 libasoundhandle
= hostlib_load_so("libasound.so", alsa_func_names
,
69 ALSA_NUM_FUNCS
, (void **)&alsa_func
);
77 VOID
ALSA_HostLib_Cleanup()
79 HostLib_Close(libasoundhandle
, NULL
);