spAudio
Loading...
Searching...
No Matches
driver.c
/*
* driver.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sp/spBaseLib.h>
#include <sp/spAudioLib.h>
#include <sp/spMain.h>
static spBool help_flag;
static int debug_level = -1;
static char *plugin_search_path = NULL;
static spOptions options;
static spOption option[] = {
{"-path", NULL, "plugin search path", NULL,
SP_TYPE_STRING, &plugin_search_path, NULL},
{"-debug", NULL, "debug level", NULL,
SP_TYPE_INT, &debug_level, NULL},
{"-help", "-h", "display this message", NULL,
SP_TYPE_BOOLEAN, &help_flag, SP_FALSE_STRING},
};
static const char *filelabel[] = {
"",
};
int spMain(int argc, char *argv[])
{
int k, l;
int num_driver;
char *driver_name;
int num_device;
char *device_name;
spAudio audio;
spSetHelpMessage(&help_flag, "audio driver test");
options = spGetOptions(argc, argv, option, filelabel);
spGetOptionsValue(argc, argv, options);
spSetDebugLevel(debug_level);
/*spSetDebugLevel(100);*/
if (!spStrNone(plugin_search_path)) {
spDebug(10, "spMain", "plugin_search_path: %s\n", plugin_search_path);
spSetPluginSearchPath(plugin_search_path);
}
{
num_device = spGetNumAudioDriverDevice(NULL);
spMessage("number of driver device = %d\n", num_device);
for (l = 0; l < num_device; l++) {
if ((device_name = xspGetAudioDriverDeviceName(NULL, l)) != NULL) {
spMessage("driver device %d = %s\n", l, device_name);
xspFree(device_name);
}
}
}
num_driver = spGetNumAudioDriver();
for (k = 0; k < num_driver; k++) {
if ((driver_name = xspGetAudioDriverName(k)) != NULL) {
spMessage("driver %d = %s\n", k, driver_name);
if ((audio = spInitAudioDriver(driver_name)) != NULL) {
if (spGetNumAudioDevice(audio, &num_device) == SP_TRUE) {
spMessage("num_device = %d\n", num_device);
for (l = 0; l < num_device; l++) {
if ((device_name = xspGetAudioDeviceName(audio, l)) != NULL) {
spMessage("device %d = %s\n", l, device_name);
xspFree(device_name);
}
if (spSelectAudioDevice(audio, l) == SP_FALSE) {
spMessage("Can't select device: %d\n", l);
} else {
if (spOpenAudioDevice(audio, "w") == SP_FALSE) {
spMessage("Can't open device: %d\n", l);
} else {
spMessage("Device successfully opened: %d\n", l);
}
}
}
}
} else {
spMessage("Can't open audio driver: %s\n", driver_name);
}
xspFree(driver_name);
}
}
return 0;
}
A class to handle audio I/O.
#define spFreeAudioDriver(audio)
Definition spAudio.h:373
char * xspGetAudioDriverName(int index)
char * xspGetAudioDriverDeviceName(const char *driver_name, int index)
int spGetNumAudioDriver(void)
int spGetNumAudioDriverDevice(const char *driver_name)
void spSetDebugLevel(int level)
void spMessage(const char *format,...)
void spDebug(int level, const char *func_name, const char *format,...)
#define SP_FALSE_STRING
int spBool
#define spStrNone(string)
#define xspFree(p)
#define spGetOptions(argc, argv, option, file_label)
struct _spOptions * spOptions
void spGetOptionsValue(int argc, char **argv, spOptions options)
void spSetHelpMessage(spBool *flag, const char *format,...)
void spSetPluginSearchPath(const char *pathlist)
spAudio spInitAudioDriver(const char *driver_name)
spBool spGetNumAudioDevice(spAudio audio, int *num_device)
char * xspGetAudioDeviceName(spAudio audio, int device_index)
spBool spSelectAudioDevice(spAudio audio, int device_index)
spBool spOpenAudioDevice(spAudio audio, const char *mode)
spBool spCloseAudioDevice(spAudio audio)