-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin with static linking #10
Comments
Yeah you can manipulate the static_drivers mechanism. Here is how to do:
#include <ao/ao.h>
#include <ao/plugin.h>
// declaration from include/ao/ao_private.h
struct ao_functions {
int (*test)(void);
ao_info* (*driver_info)(void);
int (*device_init)(ao_device *device);
int (*set_option)(ao_device *device, const char *key,
const char *value);
int (*open)(ao_device *device, ao_sample_format *format);
int (*play)(ao_device *device, const char *output_samples,
uint_32 num_bytes);
int (*close)(ao_device *device);
void (*device_clear)(ao_device *device);
const char* (*file_extension)(void);
};
// declare the plugin symbols. We will get them later when
// linking against the static plugin lib (i.e. libalsa.a)
ao_functions ao_generic_plugin = {
ao_plugin_test,
ao_plugin_driver_info,
ao_plugin_device_init,
ao_plugin_set_option,
ao_plugin_open,
ao_plugin_play,
ao_plugin_close,
ao_plugin_device_clear
//ao_plugin_file_extension
};
// gain access to the static_drivers array from libao.a,
// this is now possible because we removed the static in audio_out.c
extern ao_functions* static_drivers[];
int main(int argc, char** argv)
{
// override the null driver with the plugin (i.e. alsa) driver
static_drivers[0] = &ao_generic_plugin;
ao_initialize();
// ....
// do awesome stuff here
// ....
return 0;
}
Depending on your alsa setup this might or might not work. Here a fully working example (completely statically linked, including source code). You may need to tweak the alsa config files within the alsa_config directory to make it work on your device. Execute (I use https://github.com/nwrkbiz/static-build to build my dependencies (->3rdParty folder missing in the *.tar.gz archive), this already applies the 'remove static hack' on libao.) |
Hi! Is it possible to include a plugin like Alsa, as a built-in driver?
Thanks!
The text was updated successfully, but these errors were encountered: