Reformat using clang-format.

This commit is contained in:
Mke Brady
2015-06-01 23:16:50 +01:00
parent 04e27cfe4f
commit 87a0475c16
25 changed files with 4987 additions and 5001 deletions
+72 -79
View File
@@ -24,7 +24,6 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <unistd.h>
#include <memory.h>
@@ -35,102 +34,96 @@
ao_device *dev = NULL;
static void help(void) {
printf(" -d driver set the output driver\n"
" -o name=value set an arbitrary ao option\n"
" -i id shorthand for -o id=<id>\n"
" -n name shorthand for -o dev=<name> -o dsp=<name>\n"
);
printf(" -d driver set the output driver\n"
" -o name=value set an arbitrary ao option\n"
" -i id shorthand for -o id=<id>\n"
" -n name shorthand for -o dev=<name> -o dsp=<name>\n");
}
static int init(int argc, char **argv) {
ao_initialize();
int driver = ao_default_driver_id();
ao_option *ao_opts = NULL;
ao_initialize();
int driver = ao_default_driver_id();
ao_option *ao_opts = NULL;
optind = 1; // optind=0 is equivalent to optind=1 plus special behaviour
argv--; // so we shift the arguments to satisfy getopt()
argc++;
config.audio_backend_buffer_desired_length = 44100; // one second.
config.audio_backend_latency_offset = 0;
optind = 1; // optind=0 is equivalent to optind=1 plus special behaviour
argv--; // so we shift the arguments to satisfy getopt()
argc++;
// some platforms apparently require optreset = 1; - which?
int opt;
char *mid;
while ((opt = getopt(argc, argv, "d:i:n:o:")) > 0) {
switch (opt) {
case 'd':
driver = ao_driver_id(optarg);
if (driver < 0)
die("could not find ao driver %s", optarg);
break;
case 'i':
ao_append_option(&ao_opts, "id", optarg);
break;
case 'n':
ao_append_option(&ao_opts, "dev", optarg);
// Old libao versions (for example, 0.8.8) only support
// "dsp" instead of "dev".
ao_append_option(&ao_opts, "dsp", optarg);
break;
case 'o':
mid = strchr(optarg, '=');
if (!mid)
die("Expected an = in audio option %s", optarg);
*mid = 0;
ao_append_option(&ao_opts, optarg, mid+1);
break;
default:
help();
die("Invalid audio option -%c specified", opt);
}
config.audio_backend_buffer_desired_length = 44100; // one second.
config.audio_backend_latency_offset = 0;
// some platforms apparently require optreset = 1; - which?
int opt;
char *mid;
while ((opt = getopt(argc, argv, "d:i:n:o:")) > 0) {
switch (opt) {
case 'd':
driver = ao_driver_id(optarg);
if (driver < 0)
die("could not find ao driver %s", optarg);
break;
case 'i':
ao_append_option(&ao_opts, "id", optarg);
break;
case 'n':
ao_append_option(&ao_opts, "dev", optarg);
// Old libao versions (for example, 0.8.8) only support
// "dsp" instead of "dev".
ao_append_option(&ao_opts, "dsp", optarg);
break;
case 'o':
mid = strchr(optarg, '=');
if (!mid)
die("Expected an = in audio option %s", optarg);
*mid = 0;
ao_append_option(&ao_opts, optarg, mid + 1);
break;
default:
help();
die("Invalid audio option -%c specified", opt);
}
}
if (optind < argc)
die("Invalid audio argument: %s", argv[optind]);
if (optind < argc)
die("Invalid audio argument: %s", argv[optind]);
ao_sample_format fmt;
memset(&fmt, 0, sizeof(fmt));
ao_sample_format fmt;
memset(&fmt, 0, sizeof(fmt));
fmt.bits = 16;
fmt.rate = 44100;
fmt.channels = 2;
fmt.byte_format = AO_FMT_NATIVE;
fmt.bits = 16;
fmt.rate = 44100;
fmt.channels = 2;
fmt.byte_format = AO_FMT_NATIVE;
dev = ao_open_live(driver, &fmt, ao_opts);
dev = ao_open_live(driver, &fmt, ao_opts);
return dev ? 0 : 1;
return dev ? 0 : 1;
}
static void deinit(void) {
if (dev)
ao_close(dev);
dev = NULL;
ao_shutdown();
if (dev)
ao_close(dev);
dev = NULL;
ao_shutdown();
}
static void start(int sample_rate) {
if (sample_rate != 44100)
die("unexpected sample rate!");
if (sample_rate != 44100)
die("unexpected sample rate!");
}
static void play(short buf[], int samples) {
ao_play(dev, (char*)buf, samples*4);
}
static void play(short buf[], int samples) { ao_play(dev, (char *)buf, samples * 4); }
static void stop(void) {
}
static void stop(void) {}
audio_output audio_ao = {
.name = "ao",
.help = &help,
.init = &init,
.deinit = &deinit,
.start = &start,
.stop = &stop,
.flush = NULL,
.delay = NULL,
.play = &play,
.volume = NULL,
.parameters = NULL
};
audio_output audio_ao = {.name = "ao",
.help = &help,
.init = &init,
.deinit = &deinit,
.start = &start,
.stop = &stop,
.flush = NULL,
.delay = NULL,
.play = &play,
.volume = NULL,
.parameters = NULL};