diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-06-05 12:45:49 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-06-05 12:45:49 +0000 |
commit | 50086f252a707f0e817c106badb17f2aa7814784 (patch) | |
tree | a48fa80af77d6afc73ca6ec798570993bed27d9d /usr.bin/aucat | |
parent | 34efc00b4042f87181ec69432f8164115bae2208 (diff) |
Don't send the initial position as a clock tick with a negative delta.
Add a new ``initial position'' message which is simpler. No bahaviour
change, except effects of the protocol version crank.
Diffstat (limited to 'usr.bin/aucat')
-rw-r--r-- | usr.bin/aucat/amsg.h | 15 | ||||
-rw-r--r-- | usr.bin/aucat/aucat.c | 4 | ||||
-rw-r--r-- | usr.bin/aucat/sock.c | 37 | ||||
-rw-r--r-- | usr.bin/aucat/sock.h | 3 |
4 files changed, 41 insertions, 18 deletions
diff --git a/usr.bin/aucat/amsg.h b/usr.bin/aucat/amsg.h index f5dd3030e1f..552afa7f8d8 100644 --- a/usr.bin/aucat/amsg.h +++ b/usr.bin/aucat/amsg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: amsg.h,v 1.16 2010/04/06 20:19:42 ratchov Exp $ */ +/* $OpenBSD: amsg.h,v 1.17 2010/06/05 12:45:48 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -35,11 +35,12 @@ struct amsg { #define AMSG_START 3 /* request the server to start the stream */ #define AMSG_STOP 4 /* request the server to stop the stream */ #define AMSG_DATA 5 /* data block */ -#define AMSG_MOVE 6 /* position changed */ -#define AMSG_GETCAP 7 /* get capabilities */ -#define AMSG_SETVOL 8 /* set volume */ -#define AMSG_HELLO 9 /* say hello, check versions and so ... */ -#define AMSG_BYE 10 /* ask server to drop connection */ +#define AMSG_POS 6 /* initial position */ +#define AMSG_MOVE 7 /* position changed */ +#define AMSG_GETCAP 8 /* get capabilities */ +#define AMSG_SETVOL 9 /* set volume */ +#define AMSG_HELLO 10 /* say hello, check versions and so ... */ +#define AMSG_BYE 11 /* ask server to drop connection */ uint32_t cmd; uint32_t __pad; union { @@ -90,7 +91,7 @@ struct amsg { #define AMSG_MON 0x10 /* audio monitoring */ #define AMSG_RECMASK (AMSG_REC | AMSG_MON) /* can record ? */ uint16_t proto; /* protocol type */ -#define AMSG_VERSION 2 +#define AMSG_VERSION 3 uint8_t version; /* protocol version */ uint8_t reserved1[5]; /* for future use */ char opt[12]; /* profile name */ diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index 97933ab5993..daa3d727d2c 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.92 2010/06/04 06:15:28 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.93 2010/06/05 12:45:48 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -242,7 +242,7 @@ struct cfdev { struct cfmidlist mids; /* midi ports to subscribe */ struct aparams ipar; /* input (read) parameters */ struct aparams opar; /* output (write) parameters */ - unsigned hold; /* open immediately */ + unsigned hold; /* open immediately */ unsigned bufsz; /* par.bufsz for sio device */ unsigned round; /* par.round for sio device */ unsigned mode; /* bitmap of MODE_XXX */ diff --git a/usr.bin/aucat/sock.c b/usr.bin/aucat/sock.c index 6cf05b8bdd0..624b1ecd5ea 100644 --- a/usr.bin/aucat/sock.c +++ b/usr.bin/aucat/sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sock.c,v 1.48 2010/06/04 06:15:28 ratchov Exp $ */ +/* $OpenBSD: sock.c,v 1.49 2010/06/05 12:45:48 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -354,6 +354,7 @@ sock_new(struct fileops *ops, int fd) f->xrun = AMSG_IGNORE; f->delta = 0; f->tickpending = 0; + f->startpos = 0; f->startpending = 0; f->vol = f->lastvol = MIDI_MAXCTL; f->slot = -1; @@ -422,6 +423,7 @@ sock_allocbuf(struct sock *f) f->walign = f->round; } f->delta = 0; + f->startpos = 0; f->wmax = 0; f->rmax = f->bufsz; f->tickpending = 0; @@ -563,14 +565,14 @@ sock_attach(struct sock *f, int force) * get the current position, the origin is when * the first sample is played/recorded */ - f->delta = dev_getpos(f->dev) * (int)f->round / (int)f->dev->round; + f->startpos = dev_getpos(f->dev) * (int)f->round / (int)f->dev->round; f->startpending = 1; f->pstate = SOCK_RUN; #ifdef DEBUG if (debug_level >= 3) { sock_dbg(f); dbg_puts(": attaching at "); - dbg_puti(f->delta); + dbg_puti(f->startpos); dbg_puts("\n"); } #endif @@ -1492,20 +1494,40 @@ sock_buildmsg(struct sock *f) } /* + * Send initial position + */ + if (f->startpending) { +#ifdef DEBUG + if (debug_level >= 4) { + sock_dbg(f); + dbg_puts(": building POS message, pos = "); + dbg_puti(f->startpos); + dbg_puts("\n"); + } +#endif + AMSG_INIT(&f->wmsg); + f->wmsg.cmd = AMSG_POS; + f->wmsg.u.ts.delta = f->startpos; + f->wtodo = sizeof(struct amsg); + f->wstate = SOCK_WMSG; + f->startpending = 0; + return 1; + } + + /* * If pos changed, build a MOVE message. */ - if ((f->tickpending && f->delta > 0) || f->startpending) { + if (f->tickpending) { #ifdef DEBUG if (debug_level >= 4) { sock_dbg(f); - dbg_puts(": building POS message, delta = "); + dbg_puts(": building MOVE message, delta = "); dbg_puti(f->delta); dbg_puts("\n"); } #endif f->wmax += f->delta; - if (f->delta > 0) - f->rmax += f->delta; + f->rmax += f->delta; AMSG_INIT(&f->wmsg); f->wmsg.cmd = AMSG_MOVE; f->wmsg.u.ts.delta = f->delta; @@ -1513,7 +1535,6 @@ sock_buildmsg(struct sock *f) f->wstate = SOCK_WMSG; f->delta = 0; f->tickpending = 0; - f->startpending = 0; return 1; } diff --git a/usr.bin/aucat/sock.h b/usr.bin/aucat/sock.h index 5ef793afec5..190b4a847cf 100644 --- a/usr.bin/aucat/sock.h +++ b/usr.bin/aucat/sock.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sock.h,v 1.16 2010/06/04 06:15:28 ratchov Exp $ */ +/* $OpenBSD: sock.h,v 1.17 2010/06/05 12:45:48 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -54,6 +54,7 @@ struct sock { struct aparams rpar; /* read (ie play) parameters */ struct aparams wpar; /* write (ie rec) parameters */ int delta; /* pos. change to send */ + int startpos; /* initial pos. to send */ int tickpending; /* delta waiting to be transmitted */ int startpending; /* initial delta waiting to be transmitted */ unsigned walign; /* align data packets to this */ |