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",
32 #define ALSA_NUM_FUNCS (sizeof(alsa_func_names) / sizeof(alsa_func_names[0]))
35 struct alsa_func alsa_func
;
36 static void * libasoundhandle
;
38 static void *hostlib_load_so(const char *sofile
, const char **names
, int nfuncs
,
45 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
46 D(bug("[ALSA] failed to open '%s': %s\n", sofile
, err
));
50 for (i
= 0; i
< nfuncs
; i
++) {
51 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
53 bug("[ALSA] failed to get symbol '%s' (%s)\n", names
[i
], err
);
54 HostLib_Close(handle
, NULL
);
62 BOOL
ALSA_HostLib_Init()
64 HostLibBase
= OpenResource("hostlib.resource");
69 libasoundhandle
= hostlib_load_so("libasound.so", alsa_func_names
,
70 ALSA_NUM_FUNCS
, (void **)&alsa_func
);
78 VOID
ALSA_HostLib_Cleanup()
80 HostLib_Close(libasoundhandle
, NULL
);