CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-07-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Fri Jul 21 02:11:18 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Reorder for readability.

No functional change intended.

XXX pullup-10.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.12 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.13
--- src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.12	Thu Jul 20 12:33:27 2023
+++ src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c	Fri Jul 21 02:11:18 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sbc_encode.c,v 1.12 2023/07/20 12:33:27 nat Exp $ */
+/* $NetBSD: sbc_encode.c,v 1.13 2023/07/21 02:11:18 nat Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss 
@@ -952,8 +952,6 @@ stream(int in, int outfd, uint8_t mode, 
 	memcpy(whole + offset, frameData, (size_t)next_pkt);
 	free(frameData);
 
-	tries = 1;
-
 	/* Wait if necessary to avoid rapid playback. */
 	gettimeofday(, NULL);
 	timeNow = myTime.tv_sec * 100 + myTime.tv_usec;
@@ -967,6 +965,7 @@ stream(int in, int outfd, uint8_t mode, 
 	}
 	prevTime = timeNow;
 
+	tries = 1;
 send_again:
 	len = write(outfd, whole, totalSize);
 



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-07-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Fri Jul 21 02:11:18 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Reorder for readability.

No functional change intended.

XXX pullup-10.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-07-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Jul 20 13:31:31 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: bta2dpd.8

Log Message:
Fix formatting.

XXX pullup-10.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-07-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Jul 20 13:31:31 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: bta2dpd.8

Log Message:
Fix formatting.

XXX pullup-10.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8
diff -u src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.9 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.10
--- src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.9	Thu Jul 20 13:28:47 2023
+++ src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8	Thu Jul 20 13:31:31 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bta2dpd.8,v 1.9 2023/07/20 13:28:47 nat Exp $
+.\"	$NetBSD: bta2dpd.8,v 1.10 2023/07/20 13:31:31 nat Exp $
 .\"
 .\" Copyright (c) 2015 - 2016  Nathanial Sloss 
 .\" All rights reserved.
@@ -116,7 +116,7 @@ Local device address.
 May be given as BDADDR or device name.
 .It Fl I
 Initiate a Discover command.
- Useful when used as an audio sink as some devices need this to pair.
+Useful when used as an audio sink as some devices need this to pair.
 .It Fl K
 Allows registering as an audio sink receiving an incoming connection.
 .It Fl M Ar mtu



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-07-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Jul 20 13:28:48 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: bta2dpd.8

Log Message:
Add BUGS section to manual page.

This notes the problems with playback from file on certain devices.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-07-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Jul 20 13:28:48 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: bta2dpd.8

Log Message:
Add BUGS section to manual page.

This notes the problems with playback from file on certain devices.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8
diff -u src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.8 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.9
--- src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.8	Thu Jun 22 01:35:12 2023
+++ src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8	Thu Jul 20 13:28:47 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bta2dpd.8,v 1.8 2023/06/22 01:35:12 nat Exp $
+.\"	$NetBSD: bta2dpd.8,v 1.9 2023/07/20 13:28:47 nat Exp $
 .\"
 .\" Copyright (c) 2015 - 2016  Nathanial Sloss 
 .\" All rights reserved.
@@ -29,7 +29,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd June 20, 2023
+.Dd July 20, 2023
 .Dt BTA2DPD 8
 .Os
 .Sh NAME
@@ -289,3 +289,8 @@ and send to speakers.
 .Xr btconfig 8
 .Sh AUTHORS
 .An Nathanial Sloss
+.Sh BUGS
+For some devices playback from file results in rapid playback or playback with
+stutter.
+For best results use with
+.Xr pad 4 .



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-07-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Jul 20 12:33:28 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Add thottling when playing from file.

This avoids rapid playback when playing from file with affected devices.

Playback using pad(4) is still preferred ad gives a better result.
Playback from pad(4) is unaffected by this change.

XXX pullup-10.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.11 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.12
--- src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.11	Sun May 28 07:59:17 2023
+++ src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c	Thu Jul 20 12:33:27 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sbc_encode.c,v 1.11 2023/05/28 07:59:17 mlelstv Exp $ */
+/* $NetBSD: sbc_encode.c,v 1.12 2023/07/20 12:33:27 nat Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss 
@@ -32,6 +32,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -841,6 +842,7 @@ stream(int in, int outfd, uint8_t mode, 
 blocks, uint8_t alloc_method, uint8_t bitpool, size_t mtu, int volume)
 {
 	struct rtpHeader myHeader;
+	struct timeval myTime;
 	uint8_t *whole, *frameData;
 	int16_t music[2048];
 	ssize_t len, mySize[16], offset, next_pkt;
@@ -849,6 +851,7 @@ stream(int in, int outfd, uint8_t mode, 
 	size_t frequency;
 	static size_t ts = 0;
 	static uint16_t seqnumber = 0;
+	static time_t prevTime, readTime, sleepTime, timeNow;
 	int numpkts, tries;
 
 	global_mode = mode;
@@ -912,9 +915,11 @@ stream(int in, int outfd, uint8_t mode, 
 	next_pkt = 0;
 	len = 0;
 	pkt_len = 80;
+	readTime = 0;
 	while (totalSize + ((size_t)pkt_len * 2) <= mtu) {
 
 		len = readloop(in, music, readsize);
+		readTime += (time_t)readsize;
 		if (len < (int)readsize)
 			break;
 
@@ -934,6 +939,8 @@ stream(int in, int outfd, uint8_t mode, 
 		return -1;
 	}
 
+	readTime = readTime * 100 / 2 / global_chan / (time_t)frequency;
+
 	myHeader.numFrames = (uint8_t)numpkts;
 	whole = malloc(totalSize);
 	if (whole == NULL)
@@ -946,6 +953,20 @@ stream(int in, int outfd, uint8_t mode, 
 	free(frameData);
 
 	tries = 1;
+
+	/* Wait if necessary to avoid rapid playback. */
+	gettimeofday(, NULL);
+	timeNow = myTime.tv_sec * 100 + myTime.tv_usec;
+	if (prevTime == 0)
+		prevTime = timeNow;
+	else
+		sleepTime += readTime - (timeNow - prevTime);
+	if (sleepTime >= 1000) {
+		usleep(500);
+		sleepTime -= 1000;
+	}
+	prevTime = timeNow;
+
 send_again:
 	len = write(outfd, whole, totalSize);
 



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-07-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Jul 20 12:33:28 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Add thottling when playing from file.

This avoids rapid playback when playing from file with affected devices.

Playback using pad(4) is still preferred ad gives a better result.
Playback from pad(4) is unaffected by this change.

XXX pullup-10.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-06-21 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Jun 22 01:35:12 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: bta2dpd.8

Log Message:
Bump date for previous commit.

XXX pullup-10.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-06-21 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Jun 22 01:35:12 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: bta2dpd.8

Log Message:
Bump date for previous commit.

XXX pullup-10.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8
diff -u src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.7 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.8
--- src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.7	Tue Jun 20 03:24:08 2023
+++ src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8	Thu Jun 22 01:35:12 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bta2dpd.8,v 1.7 2023/06/20 03:24:08 nat Exp $
+.\"	$NetBSD: bta2dpd.8,v 1.8 2023/06/22 01:35:12 nat Exp $
 .\"
 .\" Copyright (c) 2015 - 2016  Nathanial Sloss 
 .\" All rights reserved.
@@ -29,7 +29,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd July 27, 2019
+.Dd June 20, 2023
 .Dt BTA2DPD 8
 .Os
 .Sh NAME



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-06-19 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue Jun 20 03:24:08 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: bta2dpd.8

Log Message:
Manual page fixups.

Fix EXAMPLES section.

Use correct flags when used with pad(4).
Use correct encoding format (sinear_le).

XXX pullup-10.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8
diff -u src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.6 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.7
--- src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.6	Thu Dec  2 21:59:22 2021
+++ src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8	Tue Jun 20 03:24:08 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bta2dpd.8,v 1.6 2021/12/02 21:59:22 andvar Exp $
+.\"	$NetBSD: bta2dpd.8,v 1.7 2023/06/20 03:24:08 nat Exp $
 .\"
 .\" Copyright (c) 2015 - 2016  Nathanial Sloss 
 .\" All rights reserved.
@@ -267,7 +267,7 @@ Encode and send audio
 to address
 .Sq spkr .
 .Pp
-.Dl bta2dpd -a spkr /dev/pad
+.Dl bta2dpd -n -a spkr /dev/pad
 Encode and send audio from
 .Xr pad 4
 to address
@@ -278,7 +278,7 @@ Decode stream from any connected address
 and write it to
 .Pa out.pcm .
 .Pp
-.Dl bta2dpd -K -a phone | audioplay -f -e linear -P 16 -s 44100 -c 2 --
+.Dl bta2dpd -K -a phone | audioplay -f -e slinear_le -P 16 -s 44100 -c 2 --
 Decode stream from address
 .Sq phone
 and send to speakers.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-06-19 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue Jun 20 03:24:08 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: bta2dpd.8

Log Message:
Manual page fixups.

Fix EXAMPLES section.

Use correct flags when used with pad(4).
Use correct encoding format (sinear_le).

XXX pullup-10.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-05-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun May 28 07:59:17 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
With the latest changes, pad(4) will return partial reads to allow a
more fine grained pacing of audio data. But this broke bta2dpd which
relied on full buffers returned (like reading from a file).

Replace the single read() in bta2dpd with a loop that fetches a full
buffer. This restores the old behaviour but loops in userland instead
of the kernel at the cost of a few extra system calls.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2023-05-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun May 28 07:59:17 UTC 2023

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
With the latest changes, pad(4) will return partial reads to allow a
more fine grained pacing of audio data. But this broke bta2dpd which
relied on full buffers returned (like reading from a file).

Replace the single read() in bta2dpd with a loop that fetches a full
buffer. This restores the old behaviour but loops in userland instead
of the kernel at the cost of a few extra system calls.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.10 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.11
--- src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.10	Sat Sep 21 00:01:33 2019
+++ src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c	Sun May 28 07:59:17 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sbc_encode.c,v 1.10 2019/09/21 00:01:33 nat Exp $ */
+/* $NetBSD: sbc_encode.c,v 1.11 2023/05/28 07:59:17 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss 
@@ -813,6 +813,29 @@ make_frame(uint8_t *frame, int16_t *inpu
 	return frame - frameStart;
 }
 
+static ssize_t
+readloop(int fd, void *buf, size_t nbytes)
+{
+	size_t count;
+	ssize_t ret;
+
+	count = 0;
+	while (nbytes > 0) {
+		ret = read(fd, ((char *)buf) + count, nbytes);
+		if (ret < 0) {
+			if (count == 0)
+return ret;
+			break;
+		}
+		if (ret == 0)
+			break;
+		count += (size_t)ret;
+		nbytes -= (size_t)ret;
+	}
+
+	return (ssize_t) count;
+}
+
 ssize_t
 stream(int in, int outfd, uint8_t mode, uint8_t freq, uint8_t bands, uint8_t
 blocks, uint8_t alloc_method, uint8_t bitpool, size_t mtu, int volume)
@@ -891,7 +914,7 @@ stream(int in, int outfd, uint8_t mode, 
 	pkt_len = 80;
 	while (totalSize + ((size_t)pkt_len * 2) <= mtu) {
 
-		len = read(in, music, readsize);
+		len = readloop(in, music, readsize);
 		if (len < (int)readsize)
 			break;
 



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2021-12-02 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Dec  2 21:59:22 UTC 2021

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: bta2dpd.8

Log Message:
bta2dpd(8): s/conection/connection/


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8
diff -u src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.5 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.6
--- src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.5	Sun Mar  7 13:09:43 2021
+++ src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8	Thu Dec  2 21:59:22 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bta2dpd.8,v 1.5 2021/03/07 13:09:43 nat Exp $
+.\"	$NetBSD: bta2dpd.8,v 1.6 2021/12/02 21:59:22 andvar Exp $
 .\"
 .\" Copyright (c) 2015 - 2016  Nathanial Sloss 
 .\" All rights reserved.
@@ -108,7 +108,7 @@ option and the maximum bitpool for your 
 .It Fl D
 Run in the background.
 .It Fl n
-Do not close conection on end of file (EOF).
+Do not close connection on end of file (EOF).
 Useful for
 .Xr pad 4 .
 .It Fl d Ar device



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2021-12-02 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Dec  2 21:59:22 UTC 2021

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: bta2dpd.8

Log Message:
bta2dpd(8): s/conection/connection/


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2021-09-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 14 20:45:19 UTC 2021

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: Makefile

Log Message:
bta2dpd: fix lint build


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/bta2dpd/bta2dpd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/Makefile
diff -u src/usr.sbin/bta2dpd/bta2dpd/Makefile:1.3 src/usr.sbin/bta2dpd/bta2dpd/Makefile:1.4
--- src/usr.sbin/bta2dpd/bta2dpd/Makefile:1.3	Sat Jul 27 20:10:29 2019
+++ src/usr.sbin/bta2dpd/bta2dpd/Makefile	Tue Sep 14 20:45:19 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2019/07/27 20:10:29 nakayama Exp $
+# $NetBSD: Makefile,v 1.4 2021/09/14 20:45:19 rillig Exp $
 
 .include 
 
@@ -8,7 +8,7 @@ PROG=		bta2dpd
 SRCS=		bta2dpd.c avdtp.c sbc_encode.c
 MAN=		bta2dpd.8
 
-CFLAGS+=	-I.
+CPPFLAGS+=	-I.
 DPADD+=		${LIBBLUETOOTH} ${LIBEVENT} ${LIBUTIL}
 LDADD+=		-lbluetooth -levent -lutil
 CLEANFILES+=	sbc_crc.h sbc_coeffs.h



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2021-09-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 14 20:45:19 UTC 2021

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: Makefile

Log Message:
bta2dpd: fix lint build


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/bta2dpd/bta2dpd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2021-03-16 Thread nia
On Sun, Mar 07, 2021 at 01:09:43PM +, Nathanial Sloss wrote:
> This is to compenstate for the behaviour in NetBSD current that pad(4) will
> no longer output 0's when its corresponding audio(4) device is not active.
> 
> I believe that this new pad(4) behaviour is not present in -9 and -8.

I also noticed this, it makes things very strange when you're using
a single pad(4) with multiple applications writing to its audio device.

Does anyone know when/how this behaviour was introduced?


CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-09-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sat Sep 21 00:01:33 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Fix off by one in sbc encoder.  Test mode transmission and reception
works again.

XXX pullup -8 and -9.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-09-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sat Sep 21 00:01:33 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Fix off by one in sbc encoder.  Test mode transmission and reception
works again.

XXX pullup -8 and -9.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.9 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.10
--- src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.9	Mon Aug  5 13:50:58 2019
+++ src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c	Sat Sep 21 00:01:33 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sbc_encode.c,v 1.9 2019/08/05 13:50:58 maya Exp $ */
+/* $NetBSD: sbc_encode.c,v 1.10 2019/09/21 00:01:33 nat Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss 
@@ -902,7 +902,7 @@ stream(int in, int outfd, uint8_t mode, 
 		totalSize += (size_t)mySize[numpkts];
 		numpkts++;
 
-		if (numpkts > 13)
+		if (numpkts > 12)
 			break;
 	}
 



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-08-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug  5 13:50:58 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Consistent indentation / whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.8 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.9
--- src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.8	Mon Aug  5 13:49:10 2019
+++ src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c	Mon Aug  5 13:50:58 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sbc_encode.c,v 1.8 2019/08/05 13:49:10 maya Exp $ */
+/* $NetBSD: sbc_encode.c,v 1.9 2019/08/05 13:50:58 maya Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss 
@@ -983,7 +983,6 @@ recvstream(int in, int outfd)
 		return -1;
 	}
 
-
 	myFrame = frameData + sizeof(myHeader);
 	next_pkt = 0;
 	pkt_len = 0;
@@ -1002,7 +1001,7 @@ recvstream(int in, int outfd)
 	res = (ssize_t)(sizeof(myHeader)) + next_pkt;
 		readlen -= res;
 	if (readlen > 0)
-			memcpy(frameData, frameData + res, (size_t)readlen);
+		memcpy(frameData, frameData + res, (size_t)readlen);
 
 send_again:
 	len = write(outfd, music, totalSize);



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-08-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug  5 13:50:58 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Consistent indentation / whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-08-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug  5 13:49:10 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
KNF for loops


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.7 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.8
--- src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.7	Mon Aug  5 13:45:01 2019
+++ src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c	Mon Aug  5 13:49:10 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sbc_encode.c,v 1.7 2019/08/05 13:45:01 maya Exp $ */
+/* $NetBSD: sbc_encode.c,v 1.8 2019/08/05 13:49:10 maya Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss 
@@ -162,7 +162,7 @@ calc_scalefactors_joint(int32_t sb_sampl
 	unsigned int joint;
 
 	joint = 0;
-	for (sb = 0;sb < global_bands - 1;sb++) {
+	for (sb = 0; sb < global_bands - 1; sb++) {
 		for (block = 0; block < global_blocks; block++) {
 			sb_j[block][0] = (sb_sample[block][0][sb]) +
 			(sb_sample[block][1][sb]);
@@ -254,8 +254,8 @@ next_chan:
 	slicecount=0;
 
 	if (global_alloc == ALLOC_SNR) {
-		for (ch = start_chan;ch < global_chan;ch++) {
-			for (sb = 0;sb < global_bands;sb++) {
+		for (ch = start_chan; ch < global_chan; ch++) {
+			for (sb = 0; sb < global_bands; sb++) {
 bitneed[ch][sb] = (int32_t)scalefactor[ch][sb];
 
 if (bitneed[ch][sb] > max_bitneed)
@@ -263,8 +263,8 @@ next_chan:
 			}
 		}
 	} else {
-		for (ch = start_chan;ch < global_chan;ch++) {
-			for (sb = 0;sb < global_bands;sb++) {
+		for (ch = start_chan; ch < global_chan; ch++) {
+			for (sb = 0; sb < global_bands; sb++) {
 if (scalefactor[ch][sb] == 0)
 	bitneed[ch][sb] = -5;
 else {
@@ -296,8 +296,8 @@ next_chan:
 		bitslice--;
 		bitcount += slicecount;
 		slicecount = 0;
-		for (ch = start_chan;ch < global_chan;ch++) {
-			for (sb = 0;sb < global_bands;sb++) {
+		for (ch = start_chan; ch < global_chan; ch++) {
+			for (sb = 0; sb < global_bands; sb++) {
 if((bitneed[ch][sb] > bitslice + 1)&&
 (bitneed[ch][sb] < bitslice + 16))
 	slicecount++;
@@ -311,8 +311,8 @@ next_chan:
 		bitslice--;
 	}
 
-	for (ch = start_chan;ch < global_chan;ch++) {
-		for (sb = 0;sb < global_bands;sb++) {
+	for (ch = start_chan; ch < global_chan; ch++) {
+		for (sb = 0; sb < global_bands; sb++) {
 			if (bitneed[ch][sb] < bitslice + 2)
 bits[ch][sb] = 0;
 			else {
@@ -555,8 +555,8 @@ sbc_encode(int16_t *input, int32_t *samp
 
 	calc_bitneed();
 
-	for(chan = 0;chan < global_chan;chan++) {
-		for (sb = 0; sb < global_bands;sb++) {
+	for(chan = 0; chan < global_chan; chan++) {
+		for (sb = 0; sb < global_bands; sb++) {
 			levels[chan][sb] = ((1 << bits[chan][sb]) - 1) <<
 (15 - scalefactor[chan][sb]);
 			delta[chan][sb] = 1 << (scalefactor[chan][sb] + 16);
@@ -592,8 +592,8 @@ sbc_decode(int32_t *samples, int16_t *pc
 	int chan, block, sb, position, i, k;
 	size_t numsamples;
 
-	for(chan = 0;chan < global_chan;chan++) {
-		for (sb = 0; sb < global_bands;sb++) {
+	for(chan = 0; chan < global_chan; chan++) {
+		for (sb = 0; sb < global_bands; sb++) {
 			levels[chan][sb] = (1 << bits[chan][sb]) - 1;
 			delta[chan][sb] = 1 << (scalefactor[chan][sb] + 1);
 		}
@@ -620,7 +620,7 @@ sbc_decode(int32_t *samples, int16_t *pc
 	if (global_mode == MODE_JOINT) {
 		k = 0;
 		while (k < (global_blocks * global_bands * global_chan)) {
-			for (sb = 0; sb < global_bands;sb++) {
+			for (sb = 0; sb < global_bands; sb++) {
 if (join & 1 << (global_bands - sb - 1)) {
 	audioout = samples[k];
 	samples[k] = (2 * samples[k]) + (2 *
@@ -639,7 +639,7 @@ sbc_decode(int32_t *samples, int16_t *pc
 
 
 	position = 0;
-	for (block = 0;block < global_blocks; block++) {
+	for (block = 0; block < global_blocks; block++) {
 		for (chan = 0; chan < global_chan; chan++) {
 			if (chan == 0)
 X = L;



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-08-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug  5 13:49:10 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
KNF for loops


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-08-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug  5 13:45:01 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Remove duplicate check for curpkt > 13

We already guarantee this above:
if (numpkts < 1 || numpkts > 13) {
return -1;


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-08-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug  5 13:45:01 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Remove duplicate check for curpkt > 13

We already guarantee this above:
if (numpkts < 1 || numpkts > 13) {
return -1;


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.6 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.7
--- src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.6	Sat Jul 27 23:33:09 2019
+++ src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c	Mon Aug  5 13:45:01 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sbc_encode.c,v 1.6 2019/07/27 23:33:09 maya Exp $ */
+/* $NetBSD: sbc_encode.c,v 1.7 2019/08/05 13:45:01 maya Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss 
@@ -997,9 +997,6 @@ recvstream(int in, int outfd)
 		totalSize += 2 * decsize;
 		offset += decsize;
 		cur_pkt++;
-
-		if (cur_pkt > 13)
-			break;
 	}
 
 	res = (ssize_t)(sizeof(myHeader)) + next_pkt;



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-08-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug  5 13:39:19 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: avdtp.c

Log Message:
Avoid read overflows


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/bta2dpd/bta2dpd/avdtp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/avdtp.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/avdtp.c:1.2 src/usr.sbin/bta2dpd/bta2dpd/avdtp.c:1.3
--- src/usr.sbin/bta2dpd/bta2dpd/avdtp.c:1.2	Wed Jul 25 19:03:50 2018
+++ src/usr.sbin/bta2dpd/bta2dpd/avdtp.c	Mon Aug  5 13:39:18 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: avdtp.c,v 1.2 2018/07/25 19:03:50 kamil Exp $ */
+/* $NetBSD: avdtp.c,v 1.3 2019/08/05 13:39:18 maya Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss 
@@ -210,7 +210,7 @@ avdtpDiscover(uint8_t *buffer, size_t re
 	bool isSink;
 
 	if (recvsize >= 2) {
-		for (offset = 0;offset < recvsize;offset += 2) {
+		for (offset = 0; offset < recvsize - 1; offset += 2) {
 			sepInfo->sep = buffer[offset] >> 2;
 			sepInfo->media_Type = buffer[offset+1] >> 4;
 			isSink = (buffer[offset+1] >> 3) & 1;
@@ -313,7 +313,7 @@ avdtpAutoConfigSBC(int fd, int recvfd, u
 	uint8_t supBitpoolMin, supBitpoolMax, tmp_mask;
 	size_t i;
 
-	for (i = 0; i < cap_len; i++) {
+	for (i = 0; i < cap_len - 5; i++) {
 		if (capabilities[i] == mediaTransport &&
 		capabilities[i + 1] == 0 &&
 		capabilities[i + 2] == mediaCodec &&
@@ -321,7 +321,7 @@ avdtpAutoConfigSBC(int fd, int recvfd, u
 		capabilities[i + 5] == SBC_CODEC_ID)
 			break;
 	}
-	if (i >= cap_len)
+	if (i >= cap_len - 9)
 		goto auto_config_failed;
 
 	availFreqMode = capabilities[i + 6];



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-08-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug  5 13:39:19 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: avdtp.c

Log Message:
Avoid read overflows


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/bta2dpd/bta2dpd/avdtp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-07-27 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Jul 27 23:33:09 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-07-27 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Jul 27 23:33:09 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: sbc_encode.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.5 src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.6
--- src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c:1.5	Sun Mar 31 11:44:11 2019
+++ src/usr.sbin/bta2dpd/bta2dpd/sbc_encode.c	Sat Jul 27 23:33:09 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sbc_encode.c,v 1.5 2019/03/31 11:44:11 nat Exp $ */
+/* $NetBSD: sbc_encode.c,v 1.6 2019/07/27 23:33:09 maya Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss 
@@ -707,7 +707,8 @@ sbc_decode(int32_t *samples, int16_t *pc
 			pcm[i++] = (int16_t)R[k];
 		k++;
 	}
-return numsamples;
+
+	return numsamples;
 }
 
 uint8_t



CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-07-27 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Sat Jul 27 20:10:29 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: Makefile bta2dpd.8 bta2dpd.c

Log Message:
Add option -D to run in the background using daemon(3).
Also changed the message output to using syslog(3).


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/bta2dpd/bta2dpd/Makefile
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/Makefile
diff -u src/usr.sbin/bta2dpd/bta2dpd/Makefile:1.2 src/usr.sbin/bta2dpd/bta2dpd/Makefile:1.3
--- src/usr.sbin/bta2dpd/bta2dpd/Makefile:1.2	Sat Jan 28 23:19:20 2017
+++ src/usr.sbin/bta2dpd/bta2dpd/Makefile	Sat Jul 27 20:10:29 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2017/01/28 23:19:20 christos Exp $
+# $NetBSD: Makefile,v 1.3 2019/07/27 20:10:29 nakayama Exp $
 
 .include 
 
@@ -9,8 +9,8 @@ SRCS=		bta2dpd.c avdtp.c sbc_encode.c
 MAN=		bta2dpd.8
 
 CFLAGS+=	-I.
-DPADD+=		${LIBBLUETOOTH} ${LIBEVENT}
-LDADD+=		-lbluetooth -levent
+DPADD+=		${LIBBLUETOOTH} ${LIBEVENT} ${LIBUTIL}
+LDADD+=		-lbluetooth -levent -lutil
 CLEANFILES+=	sbc_crc.h sbc_coeffs.h
 
 sbc_encode.c:	sbc_coeffs.h sbc_crc.h

Index: src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8
diff -u src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.3 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.4
--- src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8:1.3	Tue May 15 04:25:25 2018
+++ src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8	Sat Jul 27 20:10:29 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bta2dpd.8,v 1.3 2018/05/15 04:25:25 nat Exp $
+.\"	$NetBSD: bta2dpd.8,v 1.4 2019/07/27 20:10:29 nakayama Exp $
 .\"
 .\" Copyright (c) 2015 - 2016  Nathanial Sloss 
 .\" All rights reserved.
@@ -29,7 +29,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd March 2, 2016
+.Dd July 27, 2019
 .Dt BTA2DPD 8
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd Bluetooth Advanced Audio Distribution Profile daemon
 .Sh SYNOPSIS
 .Nm
-.Op Fl v
+.Op Fl \
 .Op Fl A Ar bitpool_allocation
 .Op Fl B Ar bitpool
 .Op Fl b Ar blocks
@@ -52,7 +52,7 @@
 .Ar files ...
 .Nm
 .Fl K
-.Op Fl Iv
+.Op Fl DIv
 .Op Fl A Ar bitpool_allocation
 .Op Fl B Ar bitpool
 .Op Fl b Ar blocks
@@ -105,6 +105,8 @@ Use
 with only the
 .Fl v
 option and the maximum bitpool for your device will be printed to stdout.
+.It Fl D
+Run in the background.
 .It Fl d Ar device
 Local device address.
 May be given as BDADDR or device name.

Index: src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.c:1.5 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.c:1.6
--- src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.c:1.5	Sat Jan 13 10:20:45 2018
+++ src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.c	Sat Jul 27 20:10:29 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: bta2dpd.c,v 1.5 2018/01/13 10:20:45 nat Exp $ */
+/* $NetBSD: bta2dpd.c,v 1.6 2019/07/27 20:10:29 nakayama Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss 
@@ -82,7 +82,9 @@ __RCSID("$NetBSD");
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include "avdtp_signal.h"
@@ -216,6 +218,7 @@ static struct event recv_ev;			/* audio 
 static struct event ctl_ev;			/* avdtp ctl event */
 
 struct l2cap_info	info;
+static bool		runasDaemon;
 static bool		asSpeaker;
 static bool		initDiscover;	/* initiate avdtp discover */
 static bool 		verbose;	/* copy to stdout */
@@ -250,10 +253,11 @@ static void do_interrupt(int, short, voi
 static void do_recv(int, short, void *);
 static void do_ctlreq(int, short, void *);
 
-#define log_err(x, ...)		if (verbose) { fprintf (stderr, x "\n",\
-		__VA_ARGS__); }
-#define log_info(x, ...)	if (verbose) { fprintf (stderr, x "\n",\
-		__VA_ARGS__); }
+#define log_err(st, fmt, args...)	\
+	do { syslog(LOG_ERR, fmt, ##args); exit(st); } while (0)
+#define log_warn(fmt, args...)	syslog(LOG_WARNING, fmt, ##args)
+#define log_info(fmt, args...)	syslog(LOG_INFO, fmt, ##args)
+#define log_debug(fmt, args...)	syslog(LOG_DEBUG, fmt, ##args)
 
 int
 main(int ac, char *av[])
@@ -263,7 +267,7 @@ main(int ac, char *av[])
 	bdaddr_copy(, BDADDR_ANY);
 
 	sc = hc = -1;
-	verbose = asSpeaker = test_mode = initDiscover = false;
+	verbose = asSpeaker = test_mode = initDiscover = runasDaemon = false;
 	n = m = l = i = j = o = 0;
 	freqs[0] = frequency;
 	channel_config[0] = channel_mode;
@@ -272,7 +276,7 @@ main(int ac, char *av[])
 	alloc_config[0] = alloc_method;
 	channel_config[0] = channel_mode;
 
-	while ((ch = getopt(ac, av, "A:a:B:b:d:e:f:IKM:m:p:r:tV:v")) != EOF) {
+	while ((ch = getopt(ac, av, "A:a:B:b:Dd:e:f:IKM:m:p:r:tV:v")) != EOF) {
 		switch (ch) {
 		case 'A':
 			for (k = 0; k < (int)strlen(optarg); k++) {
@@ -331,6 +335,9 @@ main(int ac, char *av[])
 usage();
 			}
 			break;
+		case 'D':
+			

CVS commit: src/usr.sbin/bta2dpd/bta2dpd

2019-07-27 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Sat Jul 27 20:10:29 UTC 2019

Modified Files:
src/usr.sbin/bta2dpd/bta2dpd: Makefile bta2dpd.8 bta2dpd.c

Log Message:
Add option -D to run in the background using daemon(3).
Also changed the message output to using syslog(3).


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/bta2dpd/bta2dpd/Makefile
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/bta2dpd/bta2dpd/bta2dpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.