Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/bta2dpd/bta2dpd Intoduce "-n" switch.
details: https://anonhg.NetBSD.org/src/rev/79af3689a55b
branches: trunk
changeset: 953369:79af3689a55b
user: nat <nat%NetBSD.org@localhost>
date: Sun Mar 07 13:09:43 2021 +0000
description:
Intoduce "-n" switch.
Running btat2dpd with "-n" especially for use with pad(4) will stop bta2dpd
from exiting upon a read error from pad(4) devices.
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.
While here I've improved its function as a daemon and it should reconnect to
bluetooth speakers when they are disconnected/reconnected.
Reported and tested by reinoud@ and maya@
diffstat:
usr.sbin/bta2dpd/bta2dpd/bta2dpd.8 | 8 ++++-
usr.sbin/bta2dpd/bta2dpd/bta2dpd.c | 46 ++++++++++++++++++++++++++-----------
2 files changed, 38 insertions(+), 16 deletions(-)
diffs (165 lines):
diff -r 917c1551496d -r 79af3689a55b usr.sbin/bta2dpd/bta2dpd/bta2dpd.8
--- a/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8 Sun Mar 07 12:30:03 2021 +0000
+++ b/usr.sbin/bta2dpd/bta2dpd/bta2dpd.8 Sun Mar 07 13:09:43 2021 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: bta2dpd.8,v 1.4 2019/07/27 20:10:29 nakayama Exp $
+.\" $NetBSD: bta2dpd.8,v 1.5 2021/03/07 13:09:43 nat Exp $
.\"
.\" Copyright (c) 2015 - 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
.\" All rights reserved.
@@ -37,7 +37,7 @@
.Nd Bluetooth Advanced Audio Distribution Profile daemon
.Sh SYNOPSIS
.Nm
-.Op Fl \&Dv
+.Op Fl \&Dnv
.Op Fl A Ar bitpool_allocation
.Op Fl B Ar bitpool
.Op Fl b Ar blocks
@@ -107,6 +107,10 @@
option and the maximum bitpool for your device will be printed to stdout.
.It Fl D
Run in the background.
+.It Fl n
+Do not close conection on end of file (EOF).
+Useful for
+.Xr pad 4 .
.It Fl d Ar device
Local device address.
May be given as BDADDR or device name.
diff -r 917c1551496d -r 79af3689a55b usr.sbin/bta2dpd/bta2dpd/bta2dpd.c
--- a/usr.sbin/bta2dpd/bta2dpd/bta2dpd.c Sun Mar 07 12:30:03 2021 +0000
+++ b/usr.sbin/bta2dpd/bta2dpd/bta2dpd.c Sun Mar 07 13:09:43 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bta2dpd.c,v 1.7 2020/05/31 06:17:23 nat Exp $ */
+/* $NetBSD: bta2dpd.c,v 1.8 2021/03/07 13:09:43 nat Exp $ */
/*-
* Copyright (c) 2015 - 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -220,12 +220,14 @@
struct l2cap_info info;
static bool runasDaemon;
static bool asSpeaker;
+static bool dontStop;
static bool initDiscover; /* initiate avdtp discover */
static bool verbose; /* copy to stdout */
static bool test_mode; /* copy to stdout */
static uint8_t channel_mode = MODE_STEREO;
static uint8_t alloc_method = ALLOC_LOUDNESS;
static uint8_t frequency = FREQ_44_1K;
+static int freqnum = 44100;
static uint8_t freqs[4];
static uint8_t blocks_config[4];
static uint8_t channel_config[4];
@@ -252,6 +254,7 @@
static void do_interrupt(int, short, void *);
static void do_recv(int, short, void *);
static void do_ctlreq(int, short, void *);
+static void bt_exit(int fd);
#define log_err(st, fmt, args...) \
do { syslog(LOG_ERR, fmt, ##args); exit(st); } while (0)
@@ -262,12 +265,13 @@
int
main(int ac, char *av[])
{
- int enc, i, n, m, l, j, k, o, ch, freqnum, blocksnum;
+ int enc, i, n, m, l, j, k, o, ch, blocksnum;
u_int tmpbitpool;
bdaddr_copy(&info.laddr, BDADDR_ANY);
sc = hc = -1;
verbose = asSpeaker = test_mode = initDiscover = runasDaemon = false;
+ dontStop = false;
n = m = l = i = j = o = 0;
freqs[0] = frequency;
channel_config[0] = channel_mode;
@@ -276,7 +280,8 @@
alloc_config[0] = alloc_method;
channel_config[0] = channel_mode;
- while ((ch = getopt(ac, av, "A:a:B:b:Dd:e:f:IKM:m:p:r:tV:v")) != EOF) {
+ while ((ch = getopt(ac, av, "A:a:B:b:Dd:e:f:IKnM:m:p:r:tV:v")) !=
+ EOF) {
switch (ch) {
case 'A':
for (k = 0; k < (int)strlen(optarg); k++) {
@@ -405,6 +410,9 @@
errx(EXIT_FAILURE, "%s: unknown mode", optarg);
break;
+ case 'n':
+ dontStop = true;
+ break;
case 'p':
l2cap_psm = (uint16_t)atoi(optarg);
break;
@@ -556,7 +564,7 @@
audfile = -1;
}
- if (asSpeaker)
+ if (runasDaemon)
goto again;
return EXIT_SUCCESS;
@@ -566,9 +574,9 @@
usage(void)
{
fprintf(stderr,
- "usage:\t%s [-v] [-D] [-d device] [-m mode] [-r rate] [-M mtu]\n"
- "\t\t[-V volume] [-f mode] [-b blocks] [-e bands] [-A alloc]\n"
- "\t\t[-B bitpool] -a address files...\n"
+ "usage:\t%s [-v] [-D] [-n] [-d device] [-m mode] [-r rate]\n"
+ "\t\t[-M mtu] [-V volume] [-f mode] [-b blocks] [-e bands]\n"
+ "\t\t[-A alloc] [-B bitpool] -a address files...\n"
"\t%s [-v] [-D] [-d device] [-m mode] [-p psm] [-B bitpool]\n"
"\t\t[-a address] [-M mtu] [-r rate] [-I] -K file\n"
"\t%s -t [-v] [-K] [-r rate] [-M mtu] [-V volume] [-f mode]\n"
@@ -626,6 +634,17 @@
}
static void
+bt_exit(int fd)
+{
+ if (!runasDaemon) {
+ close(fd);
+ fd = -1;
+ exit(1);
+ }
+ /* Not reached */
+}
+
+static void
do_ctlreq(int fd, short ev, void *arg)
{
bool isCommand;
@@ -825,9 +844,7 @@
if (len < 0) {
event_del(&recv_ev);
- close(fd);
- fd = -1;
- exit(1);
+ bt_exit(fd);
}
}
@@ -844,12 +861,13 @@
len = stream(fd, sc, channel_mode, frequency, bands, blocks,
alloc_method, bitpool, mtu, volume);
+
next_file:
- if (len == -1 && currentFileInd >= numfiles -1) {
+ if (dontStop && len == -1)
+ usleep(1);
+ else if (len == -1 && currentFileInd >= numfiles -1) {
event_del(&interrupt_ev);
- close(fd);
- fd = -1;
- exit(1);
+ bt_exit(fd);
} else if (len == -1) {
close(fd);
currentFileInd++;
Home |
Main Index |
Thread Index |
Old Index