Simplify init function, add defaults for latency offset and buffer size. Remove redundant timer stuff from audio_dummy.c.
This commit is contained in:
+3
-17
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user