ao: no CamelCase
Renamed functions and variables.
This commit is contained in:
@@ -24,24 +24,17 @@
|
|||||||
#undef G_LOG_DOMAIN
|
#undef G_LOG_DOMAIN
|
||||||
#define G_LOG_DOMAIN "ao"
|
#define G_LOG_DOMAIN "ao"
|
||||||
|
|
||||||
static int driverInitCount;
|
static unsigned ao_output_ref;
|
||||||
|
|
||||||
typedef struct _AoData {
|
struct ao_data {
|
||||||
size_t writeSize;
|
size_t write_size;
|
||||||
int driverId;
|
int driver;
|
||||||
ao_option *options;
|
ao_option *options;
|
||||||
ao_device *device;
|
ao_device *device;
|
||||||
} AoData;
|
} AoData;
|
||||||
|
|
||||||
static AoData *newAoData(void)
|
static void
|
||||||
{
|
ao_output_error(const char *msg)
|
||||||
AoData *ret = g_malloc(sizeof(AoData));
|
|
||||||
ret->options = NULL;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void audioOutputAo_error(const char *msg)
|
|
||||||
{
|
{
|
||||||
const char *error;
|
const char *error;
|
||||||
|
|
||||||
@@ -74,28 +67,30 @@ static void audioOutputAo_error(const char *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
audioOutputAo_initDriver(G_GNUC_UNUSED const struct audio_format *audio_format,
|
ao_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||||
const struct config_param *param)
|
const struct config_param *param)
|
||||||
{
|
{
|
||||||
|
struct ao_data *ad = g_new(struct ao_data, 1);
|
||||||
ao_info *ai;
|
ao_info *ai;
|
||||||
AoData *ad = newAoData();
|
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
ad->writeSize = config_get_block_unsigned(param, "write_size", 1024);
|
ad->options = NULL;
|
||||||
|
|
||||||
if (driverInitCount == 0) {
|
ad->write_size = config_get_block_unsigned(param, "write_size", 1024);
|
||||||
|
|
||||||
|
if (ao_output_ref == 0) {
|
||||||
ao_initialize();
|
ao_initialize();
|
||||||
}
|
}
|
||||||
driverInitCount++;
|
ao_output_ref++;
|
||||||
|
|
||||||
value = config_get_block_string(param, "driver", "default");
|
value = config_get_block_string(param, "driver", "default");
|
||||||
if (0 == strcmp(value, "default")) {
|
if (0 == strcmp(value, "default")) {
|
||||||
ad->driverId = ao_default_driver_id();
|
ad->driver = ao_default_driver_id();
|
||||||
} else if ((ad->driverId = ao_driver_id(value)) < 0)
|
} else if ((ad->driver = ao_driver_id(value)) < 0)
|
||||||
g_error("\"%s\" is not a valid ao driver at line %i\n",
|
g_error("\"%s\" is not a valid ao driver at line %i\n",
|
||||||
value, param->line);
|
value, param->line);
|
||||||
|
|
||||||
if ((ai = ao_driver_info(ad->driverId)) == NULL) {
|
if ((ai = ao_driver_info(ad->driver)) == NULL) {
|
||||||
g_error("problems getting driver info for device defined at line %i\n"
|
g_error("problems getting driver info for device defined at line %i\n"
|
||||||
"you may not have permission to the audio device\n", param->line);
|
"you may not have permission to the audio device\n", param->line);
|
||||||
}
|
}
|
||||||
@@ -126,35 +121,33 @@ audioOutputAo_initDriver(G_GNUC_UNUSED const struct audio_format *audio_format,
|
|||||||
return ad;
|
return ad;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void freeAoData(AoData * ad)
|
static void
|
||||||
|
ao_output_finish(void *data)
|
||||||
{
|
{
|
||||||
|
struct ao_data *ad = (struct ao_data *)data;
|
||||||
|
|
||||||
ao_free_options(ad->options);
|
ao_free_options(ad->options);
|
||||||
g_free(ad);
|
g_free(ad);
|
||||||
}
|
|
||||||
|
|
||||||
static void audioOutputAo_finishDriver(void *data)
|
ao_output_ref--;
|
||||||
{
|
|
||||||
AoData *ad = (AoData *)data;
|
|
||||||
freeAoData(ad);
|
|
||||||
|
|
||||||
driverInitCount--;
|
if (ao_output_ref == 0)
|
||||||
|
|
||||||
if (driverInitCount == 0)
|
|
||||||
ao_shutdown();
|
ao_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void audioOutputAo_closeDevice(void *data)
|
static void
|
||||||
|
ao_output_close(void *data)
|
||||||
{
|
{
|
||||||
AoData *ad = (AoData *)data;
|
struct ao_data *ad = (struct ao_data *)data;
|
||||||
|
|
||||||
ao_close(ad->device);
|
ao_close(ad->device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
audioOutputAo_openDevice(void *data, struct audio_format *audio_format)
|
ao_output_open(void *data, struct audio_format *audio_format)
|
||||||
{
|
{
|
||||||
ao_sample_format format;
|
ao_sample_format format;
|
||||||
AoData *ad = (AoData *)data;
|
struct ao_data *ad = (struct ao_data *)data;
|
||||||
|
|
||||||
/* support for 24 bit samples in libao is currently dubious,
|
/* support for 24 bit samples in libao is currently dubious,
|
||||||
and until we have sorted that out, resample everything to
|
and until we have sorted that out, resample everything to
|
||||||
@@ -167,10 +160,10 @@ audioOutputAo_openDevice(void *data, struct audio_format *audio_format)
|
|||||||
format.byte_format = AO_FMT_NATIVE;
|
format.byte_format = AO_FMT_NATIVE;
|
||||||
format.channels = audio_format->channels;
|
format.channels = audio_format->channels;
|
||||||
|
|
||||||
ad->device = ao_open_live(ad->driverId, &format, ad->options);
|
ad->device = ao_open_live(ad->driver, &format, ad->options);
|
||||||
|
|
||||||
if (ad->device == NULL) {
|
if (ad->device == NULL) {
|
||||||
audioOutputAo_error("Failed to open libao");
|
ao_output_error("Failed to open libao");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,26 +188,26 @@ static int ao_play_deconst(ao_device *device, const void *output_samples,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
audioOutputAo_play(void *data, const void *chunk, size_t size)
|
ao_output_play(void *data, const void *chunk, size_t size)
|
||||||
{
|
{
|
||||||
AoData *ad = (AoData *)data;
|
struct ao_data *ad = (struct ao_data *)data;
|
||||||
|
|
||||||
if (size > ad->writeSize)
|
if (size > ad->write_size)
|
||||||
size = ad->writeSize;
|
size = ad->write_size;
|
||||||
|
|
||||||
if (ao_play_deconst(ad->device, chunk, size) == 0) {
|
if (ao_play_deconst(ad->device, chunk, size) == 0) {
|
||||||
audioOutputAo_error("Closing libao device due to play error");
|
ao_output_error("Closing libao device due to play error");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct audio_output_plugin aoPlugin = {
|
const struct audio_output_plugin ao_output_plugin = {
|
||||||
.name = "ao",
|
.name = "ao",
|
||||||
.init = audioOutputAo_initDriver,
|
.init = ao_output_init,
|
||||||
.finish = audioOutputAo_finishDriver,
|
.finish = ao_output_finish,
|
||||||
.open = audioOutputAo_openDevice,
|
.open = ao_output_open,
|
||||||
.play = audioOutputAo_play,
|
.close = ao_output_close,
|
||||||
.close = audioOutputAo_closeDevice,
|
.play = ao_output_play,
|
||||||
};
|
};
|
||||||
|
@@ -24,7 +24,7 @@ extern const struct audio_output_plugin shoutPlugin;
|
|||||||
extern const struct audio_output_plugin null_output_plugin;
|
extern const struct audio_output_plugin null_output_plugin;
|
||||||
extern const struct audio_output_plugin fifoPlugin;
|
extern const struct audio_output_plugin fifoPlugin;
|
||||||
extern const struct audio_output_plugin alsaPlugin;
|
extern const struct audio_output_plugin alsaPlugin;
|
||||||
extern const struct audio_output_plugin aoPlugin;
|
extern const struct audio_output_plugin ao_output_plugin;
|
||||||
extern const struct audio_output_plugin ossPlugin;
|
extern const struct audio_output_plugin ossPlugin;
|
||||||
extern const struct audio_output_plugin osxPlugin;
|
extern const struct audio_output_plugin osxPlugin;
|
||||||
extern const struct audio_output_plugin pulse_plugin;
|
extern const struct audio_output_plugin pulse_plugin;
|
||||||
@@ -43,7 +43,7 @@ const struct audio_output_plugin *audio_output_plugins[] = {
|
|||||||
&alsaPlugin,
|
&alsaPlugin,
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_AO
|
#ifdef HAVE_AO
|
||||||
&aoPlugin,
|
&ao_output_plugin,
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_OSS
|
#ifdef HAVE_OSS
|
||||||
&ossPlugin,
|
&ossPlugin,
|
||||||
|
Reference in New Issue
Block a user