diff options
-rw-r--r-- | audio_ao.c | 6 | ||||
-rw-r--r-- | audio_dummy.c | 20 | ||||
-rw-r--r-- | audio_pipe.c | 8 | ||||
-rw-r--r-- | audio_pulse.c | 6 | ||||
-rw-r--r-- | audio_sndio.c | 5 |
5 files changed, 22 insertions, 23 deletions
@@ -42,7 +42,7 @@ static void help(void) { ); } -static int init(int argc, char **argv, config_t *cfgp) { +static int init(int argc, char **argv) { ao_initialize(); int driver = ao_default_driver_id(); ao_option *ao_opts = NULL; @@ -50,6 +50,10 @@ static int init(int argc, char **argv, config_t *cfgp) { 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; + // some platforms apparently require optreset = 1; - which? int opt; char *mid; diff --git a/audio_dummy.c b/audio_dummy.c index d7531a0..2fd8ebf 100644 --- a/audio_dummy.c +++ b/audio_dummy.c @@ -32,7 +32,7 @@ int Fs; long long starttime, samples_played; -static int init(int argc, char **argv, config_t *cfgp) { +static int init(int argc, char **argv) { return 0; } @@ -43,28 +43,14 @@ static void start(int sample_rate) { Fs = sample_rate; starttime = 0; samples_played = 0; - printf("dummy audio output started at Fs=%d Hz\n", sample_rate); + debug(1,"dummy audio output started at Fs=%d Hz\n", sample_rate); } static void play(short buf[], int samples) { - struct timeval tv; - - // this is all a bit expensive but it's long-term stable. - gettimeofday(&tv, NULL); - - long long nowtime = tv.tv_usec + 1e6*tv.tv_sec; - - if (!starttime) - starttime = nowtime; - - samples_played += samples; - - long long finishtime = starttime + samples_played * 1e6 / Fs; - usleep(finishtime - nowtime); } static void stop(void) { - printf("dummy audio stopped\n"); + debug(1,"dummy audio stopped\n"); } static void help(void) { diff --git a/audio_pipe.c b/audio_pipe.c index b218d78..00921e8 100644 --- a/audio_pipe.c +++ b/audio_pipe.c @@ -54,12 +54,14 @@ static void stop(void) { close(fd); } -static int init(int argc, char **argv, config_t *cfgp) { +static int init(int argc, char **argv) { + config.audio_backend_buffer_desired_length = 44100; // one second. + config.audio_backend_latency_offset = 0; - if (cfgp!=NULL) { + if (config.cfg!=NULL) { /* Get the Output Pipename. */ const char *str; - if(config_lookup_string(cfgp, "pipe.name", &str)) { + if(config_lookup_string(config.cfg, "pipe.name", &str)) { pipename = (char*)str; } } diff --git a/audio_pulse.c b/audio_pulse.c index 93b0fb0..d76c1de 100644 --- a/audio_pulse.c +++ b/audio_pulse.c @@ -58,8 +58,12 @@ static void help(void) { ); } -static int init(int argc, char **argv, config_t *cfgp) { +static int init(int argc, char **argv) { + pulse_options.apname = config.apname; + + 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() diff --git a/audio_sndio.c b/audio_sndio.c index 2ece843..65a4277 100644 --- a/audio_sndio.c +++ b/audio_sndio.c @@ -23,7 +23,7 @@ static struct sio_hdl *sio; static struct sio_par par; -static int init(int argc, char **argv, config_t *cfgp) { +static int init(int argc, char **argv) { sio = sio_open(SIO_DEVANY, SIO_PLAY, 0); if (!sio) die("sndio: cannot connect to sound server"); @@ -40,6 +40,9 @@ static int init(int argc, char **argv, config_t *cfgp) { die("sndio: failed to set audio parameters"); if (!sio_getpar(sio, &par)) die("sndio: failed to get audio parameters"); + + config.audio_backend_buffer_desired_length = 44100; // one second. + config.audio_backend_latency_offset = 0; return 0; } |