* [PATCH BlueZ] android: Fix const to non-const issue on android-tester
From: Anderson Lizardo @ 2014-01-18 14:54 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
According to definition from hardware/bluetooth.h, the "val" field does
not have const modifier.
Fix clang errors like:
android/android-tester.c:760:14: error: initializing 'void *' with an
expression of type 'const char (*)[18]' discards qualifiers
[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
---
android/android-tester.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 6f0e962..0e44bc8 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -897,7 +897,7 @@ static void remote_device_properties_cb(bt_status_t status,
}
static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
-static const char enable_done_bdname_val[] = "BlueZ for Android";
+static char enable_done_bdname_val[] = "BlueZ for Android";
static bt_uuid_t enable_done_uuids_val = {
.uu = { 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb},
@@ -1344,7 +1344,7 @@ static const struct generic_data bluetooth_discovery_device_found_test = {
.expected_adapter_status = BT_STATUS_NOT_EXPECTED,
};
-static const char remote_get_properties_bdname_val[] = "00:AA:01:01:00:00";
+static char remote_get_properties_bdname_val[] = "00:AA:01:01:00:00";
static uint32_t remote_get_properties_cod_val = 0;
static bt_device_type_t remote_get_properties_tod_val = BT_DEVICE_DEVTYPE_BREDR;
static int32_t remote_get_properties_rssi_val = -60;
@@ -1400,7 +1400,7 @@ static const struct generic_data bt_dev_getprops_success_test = {
.expected_adapter_status = BT_STATUS_NOT_EXPECTED,
};
-static const char remote_getprop_bdname_val[] = "00:AA:01:01:00:00";
+static char remote_getprop_bdname_val[] = "00:AA:01:01:00:00";
static struct priority_property remote_getprop_bdname_props[] = {
{
@@ -1675,7 +1675,7 @@ static const struct generic_data bt_dev_getprop_fname_fail_test = {
.expected_adapter_status = BT_STATUS_FAIL,
};
-static const char remote_setprop_fname_val[] = "set_fname_test";
+static char remote_setprop_fname_val[] = "set_fname_test";
static struct priority_property remote_setprop_fname_props[] = {
{
@@ -1702,7 +1702,7 @@ static const struct generic_data bt_dev_setprop_fname_success_test = {
.expected_adapter_status = BT_STATUS_SUCCESS,
};
-static const char remote_setprop_bdname_val[] = "setprop_bdname_fail";
+static char remote_setprop_bdname_val[] = "setprop_bdname_fail";
static struct priority_property remote_setprop_bdname_props[] = {
{
--
1.8.3.2
^ permalink raw reply related
* Re: [PATCH 1/2] agent: Remove not used enum value
From: Johan Hedberg @ 2014-01-18 13:20 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1390049485-23503-1-git-send-email-szymon.janc@gmail.com>
Hi Szymon,
On Sat, Jan 18, 2014, Szymon Janc wrote:
> Only user of AGENT_REQUEST_CONFIRM_MODE is already removed.
> ---
> src/agent.c | 1 -
> 1 file changed, 1 deletion(-)
Both patches have been applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/2] neard: Set device UUIDs from EIR
From: Johan Hedberg @ 2014-01-18 13:20 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1390048980-16670-1-git-send-email-szymon.janc@gmail.com>
Hi Szymon,
On Sat, Jan 18, 2014, Szymon Janc wrote:
> Handle UUIDs received in EIR from neard in same way as UUIDs received
> on device discovery.
> ---
> plugins/neard.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Both patches have been applied. Thanks.
Johan
^ permalink raw reply
* [PATCH 2/2] device: Remove addr from struct probe_data
From: Szymon Janc @ 2014-01-18 12:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1390049485-23503-1-git-send-email-szymon.janc@gmail.com>
It is not used anywhere.
---
src/device.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/device.c b/src/device.c
index aa663f7..bcc5561 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2504,7 +2504,6 @@ static bool device_match_profile(struct btd_device *device,
struct probe_data {
struct btd_device *dev;
GSList *uuids;
- char addr[18];
};
static void dev_probe(struct btd_profile *p, void *user_data)
@@ -2579,15 +2578,16 @@ void device_probe_profiles(struct btd_device *device, GSList *uuids)
{
struct probe_data d = { device, uuids };
GSList *l;
+ char addr[18];
- ba2str(&device->bdaddr, d.addr);
+ ba2str(&device->bdaddr, addr);
if (device->blocked) {
- DBG("Skipping profiles for blocked device %s", d.addr);
+ DBG("Skipping profiles for blocked device %s", addr);
goto add_uuids;
}
- DBG("Probing profiles for device %s", d.addr);
+ DBG("Probing profiles for device %s", addr);
btd_profile_foreach(dev_probe, &d);
--
1.8.5.3
^ permalink raw reply related
* [PATCH 1/2] agent: Remove not used enum value
From: Szymon Janc @ 2014-01-18 12:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Only user of AGENT_REQUEST_CONFIRM_MODE is already removed.
---
src/agent.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/agent.c b/src/agent.c
index 4c63cb9..6887bc1 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -66,7 +66,6 @@ typedef enum {
AGENT_REQUEST_AUTHORIZATION,
AGENT_REQUEST_PINCODE,
AGENT_REQUEST_AUTHORIZE_SERVICE,
- AGENT_REQUEST_CONFIRM_MODE,
AGENT_REQUEST_DISPLAY_PINCODE,
} agent_request_type_t;
--
1.8.5.3
^ permalink raw reply related
* [PATCH 2/2] neard: Refactor request_oob function
From: Szymon Janc @ 2014-01-18 12:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1390048980-16670-1-git-send-email-szymon.janc@gmail.com>
This makes function flow easier to follow.
---
plugins/neard.c | 43 ++++++++++++++++++++-----------------------
1 file changed, 20 insertions(+), 23 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index da6e37c..b546750 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -768,42 +768,39 @@ static DBusMessage *request_oob(DBusConnection *conn, DBusMessage *msg,
if (err < 0)
return error_reply(msg, -err);
- if (bacmp(&remote.address, BDADDR_ANY) == 0)
- goto read_local;
-
- device = btd_adapter_get_device(adapter, &remote.address,
- BDADDR_BREDR);
+ if (bacmp(&remote.address, BDADDR_ANY) == 0) {
+ if (btd_adapter_get_powered(adapter))
+ goto read_local;
- err = check_device(device);
- if (err < 0) {
- free_oob_params(&remote);
+ goto done;
+ }
- if (err == -EALREADY)
- return create_request_oob_reply(adapter, NULL, NULL,
- msg);
+ device = btd_adapter_get_device(adapter, &remote.address, BDADDR_BREDR);
- return error_reply(msg, -err);
- }
+ err = check_device(device);
+ if (err < 0)
+ goto done;
if (!btd_adapter_get_pairable(adapter)) {
- free_oob_params(&remote);
-
- return error_reply(msg, ENONET);
+ err = -ENONET;
+ goto done;
}
store_params(adapter, device, &remote);
- if (!remote.hash || !btd_adapter_get_powered(adapter)) {
- free_oob_params(&remote);
- return create_request_oob_reply(adapter, NULL, NULL, msg);
- }
+ if (remote.hash && btd_adapter_get_powered(adapter))
+ goto read_local;
+done:
+ free_oob_params(&remote);
+
+ if (err < 0 && err != -EALREADY)
+ return error_reply(msg, -err);
+
+ return create_request_oob_reply(adapter, NULL, NULL, msg);
read_local:
free_oob_params(&remote);
- if (!btd_adapter_get_powered(adapter))
- return create_request_oob_reply(adapter, NULL, NULL, msg);
-
err = btd_adapter_read_local_oob_data(adapter);
if (err < 0)
return error_reply(msg, -err);
--
1.8.5.3
^ permalink raw reply related
* [PATCH 1/2] neard: Set device UUIDs from EIR
From: Szymon Janc @ 2014-01-18 12:42 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Handle UUIDs received in EIR from neard in same way as UUIDs received
on device discovery.
---
plugins/neard.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 35fdaeb..da6e37c 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -643,7 +643,8 @@ static void store_params(struct btd_adapter *adapter, struct btd_device *device,
btd_device_device_set_name(device, params->name);
}
- /* TODO handle UUIDs? */
+ if (params->services)
+ device_add_eir_uuids(device, params->services);
if (params->hash) {
btd_adapter_add_remote_oob_data(adapter, ¶ms->address,
--
1.8.5.3
^ permalink raw reply related
* Re: Status of BlueZ GATT APIs
From: Marcel Holtmann @ 2014-01-18 8:42 UTC (permalink / raw)
To: Arman Uguray; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <CAHrH25SjO5Bgdjnu6YjwKSQEiwvP+p8bfqcjJO9WEMDvG1A3PQ@mail.gmail.com>
Hi Arman,
> I was wondering what the current plans are for the GATT D-Bus API in
> BlueZ. Can anyone give a rough estimate of when these APIs will be
> available in BlueZ upstream and approximately when they could make to
> into a release?
I think the best person to answer this is Claudio. INdT has been working on these patches and we have discussed the APIs during the Plumbers Conf.
Maybe they just need to re-submit a new version and we could include them. I honestly don’t know until I see an updated set of the patches.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH] test: Python import cleanup
From: Marcel Holtmann @ 2014-01-18 8:39 UTC (permalink / raw)
To: Petri Gynther; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <20140118014507.85FAE10065C@puck.mtv.corp.google.com>
Hi Petri,
> Some test scripts use "from gi.repository import GObject" whereas others
> use "import gobject". gi.repository is not always available on embedded
> systems, so convert all instances to this format:
>
> try:
> from gi.repository import GObject
> except ImportError:
> import gobject as GObject
>
> Also, sort the imports in this order: system, dbus, gobject, bluezutils
I am not a Python expert, but the changes look all good to. So I went ahead and applied the patch.
Regards
Marcel
^ permalink raw reply
* [PATCH] test: Python import cleanup
From: Petri Gynther @ 2014-01-18 1:45 UTC (permalink / raw)
To: linux-bluetooth
Some test scripts use "from gi.repository import GObject" whereas others
use "import gobject". gi.repository is not always available on embedded
systems, so convert all instances to this format:
try:
from gi.repository import GObject
except ImportError:
import gobject as GObject
Also, sort the imports in this order: system, dbus, gobject, bluezutils
---
test/ftp-client | 12 +++++++-----
test/map-client | 15 ++++++++-------
test/monitor-bluetooth | 8 +++++---
test/opp-client | 11 +++++++----
test/pbap-client | 10 ++++++----
test/simple-agent | 8 +++++---
test/simple-endpoint | 7 +++++--
test/simple-obex-agent | 8 +++++---
test/simple-player | 10 +++++++---
test/test-adapter | 4 ++--
test/test-alert | 15 ++++++++++-----
test/test-cyclingspeed | 10 ++++++----
test/test-device | 10 ++++++----
test/test-discovery | 8 +++++---
test/test-health | 11 +++++++----
test/test-health-sink | 9 ++++++---
test/test-heartrate | 10 ++++++----
test/test-hfp | 12 +++++++-----
test/test-manager | 6 ++++--
test/test-nap | 2 +-
test/test-network | 2 +-
test/test-profile | 8 +++++---
test/test-proximity | 10 ++++++----
test/test-thermometer | 10 ++++++----
24 files changed, 133 insertions(+), 83 deletions(-)
diff --git a/test/ftp-client b/test/ftp-client
index ae3cbcb..78c32b3 100755
--- a/test/ftp-client
+++ b/test/ftp-client
@@ -2,14 +2,16 @@
from __future__ import absolute_import, print_function, unicode_literals
-import gobject
-
+from optparse import OptionParser
+import os.path
import sys
import dbus
import dbus.service
import dbus.mainloop.glib
-import os.path
-from optparse import OptionParser
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
BUS_NAME='org.bluez.obex'
PATH = '/org/bluez/obex'
@@ -142,7 +144,7 @@ if __name__ == '__main__':
sys.exit(0)
bus = dbus.SessionBus()
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
client = dbus.Interface(bus.get_object(BUS_NAME, PATH,),
CLIENT_INTERFACE)
diff --git a/test/map-client b/test/map-client
index f3c657f..b9695da 100755
--- a/test/map-client
+++ b/test/map-client
@@ -2,15 +2,16 @@
from __future__ import absolute_import, print_function, unicode_literals
-import gobject
-
-import sys
+from optparse import OptionParser
import os
+from pprint import pformat
+import sys
import dbus
import dbus.mainloop.glib
-from optparse import OptionParser
-
-from pprint import pformat
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
BUS_NAME='org.bluez.obex'
PATH = '/org/bluez/obex'
@@ -185,7 +186,7 @@ if __name__ == '__main__':
exit(0)
bus = dbus.SessionBus()
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
client = dbus.Interface(bus.get_object(BUS_NAME, PATH),
CLIENT_INTERFACE)
diff --git a/test/monitor-bluetooth b/test/monitor-bluetooth
index bc5ddaf..d9b5472 100755
--- a/test/monitor-bluetooth
+++ b/test/monitor-bluetooth
@@ -2,10 +2,12 @@
from __future__ import absolute_import, print_function, unicode_literals
-import gobject
-
import dbus
import dbus.mainloop.glib
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
relevant_ifaces = [ "org.bluez.Adapter1", "org.bluez.Device1" ]
@@ -48,5 +50,5 @@ if __name__ == '__main__':
dbus_interface="org.freedesktop.DBus.ObjectManager",
signal_name="InterfacesRemoved")
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
mainloop.run()
diff --git a/test/opp-client b/test/opp-client
index 878c263..62d5b84 100755
--- a/test/opp-client
+++ b/test/opp-client
@@ -2,12 +2,15 @@
from __future__ import absolute_import, print_function, unicode_literals
+from optparse import OptionParser
+import os.path
import sys
import dbus
-import gobject
import dbus.mainloop.glib
-import os.path
-from optparse import OptionParser
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
BUS_NAME='org.bluez.obex'
PATH = '/org/bluez/obex'
@@ -97,7 +100,7 @@ if __name__ == '__main__':
sys.exit(0)
bus = dbus.SessionBus()
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
client = dbus.Interface(bus.get_object(BUS_NAME, PATH),
CLIENT_INTERFACE)
diff --git a/test/pbap-client b/test/pbap-client
index c02833b..51e26eb 100755
--- a/test/pbap-client
+++ b/test/pbap-client
@@ -2,13 +2,15 @@
from __future__ import absolute_import, print_function, unicode_literals
-import gobject
-
-import sys
import os
+import sys
import dbus
import dbus.service
import dbus.mainloop.glib
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
BUS_NAME='org.bluez.obex'
PATH = '/org/bluez/obex'
@@ -113,7 +115,7 @@ if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
client = dbus.Interface(bus.get_object(BUS_NAME, PATH),
CLIENT_INTERFACE)
diff --git a/test/simple-agent b/test/simple-agent
index 854e1af..a69299a 100755
--- a/test/simple-agent
+++ b/test/simple-agent
@@ -2,13 +2,15 @@
from __future__ import absolute_import, print_function, unicode_literals
-from gi.repository import GObject
-
+from optparse import OptionParser
import sys
import dbus
import dbus.service
import dbus.mainloop.glib
-from optparse import OptionParser
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
import bluezutils
BUS_NAME = 'org.bluez'
diff --git a/test/simple-endpoint b/test/simple-endpoint
index 590f83a..0164cff 100755
--- a/test/simple-endpoint
+++ b/test/simple-endpoint
@@ -6,7 +6,10 @@ import sys
import dbus
import dbus.service
import dbus.mainloop.glib
-import gobject
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
import bluezutils
A2DP_SOURCE_UUID = "0000110A-0000-1000-8000-00805F9B34FB"
@@ -94,7 +97,7 @@ if __name__ == '__main__':
path = "/test/endpoint"
endpoint = Endpoint(bus, path)
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
properties = dbus.Dictionary({ "UUID" : A2DP_SOURCE_UUID,
"Codec" : SBC_CODEC,
diff --git a/test/simple-obex-agent b/test/simple-obex-agent
index f15e9d1..05ec4ed 100755
--- a/test/simple-obex-agent
+++ b/test/simple-obex-agent
@@ -2,12 +2,14 @@
from __future__ import absolute_import, print_function, unicode_literals
-import gobject
-
import sys
import dbus
import dbus.service
import dbus.mainloop.glib
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
BUS_NAME = 'org.bluez.obex'
PATH = '/org/bluez/obex'
@@ -63,7 +65,7 @@ if __name__ == '__main__':
path = "/test/agent"
agent = Agent(bus, path)
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
manager.RegisterAgent(path)
print("Agent registered")
diff --git a/test/simple-player b/test/simple-player
index 01bec06..23e78ad 100755
--- a/test/simple-player
+++ b/test/simple-player
@@ -1,12 +1,16 @@
#!/usr/bin/python
from __future__ import print_function
+
import os
import sys
import dbus
import dbus.service
import dbus.mainloop.glib
-import gobject
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
import bluezutils
class Player(dbus.service.Object):
@@ -56,7 +60,7 @@ class Player(dbus.service.Object):
signature="sv")
handler = InputHandler(self)
- gobject.io_add_watch(sys.stdin, gobject.IO_IN,
+ GObject.io_add_watch(sys.stdin, GObject.IO_IN,
handler.handle)
@dbus.service.method("org.freedesktop.DBus.Properties",
@@ -136,7 +140,7 @@ if __name__ == '__main__':
path = "/test/player"
player = Player(bus, path)
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
if len(sys.argv) > 2:
player.set_object(sys.argv[2])
diff --git a/test/test-adapter b/test/test-adapter
index 5deeda4..959a437 100755
--- a/test/test-adapter
+++ b/test/test-adapter
@@ -2,10 +2,10 @@
from __future__ import absolute_import, print_function, unicode_literals
+from optparse import OptionParser, make_option
import sys
-import dbus
import time
-from optparse import OptionParser, make_option
+import dbus
import bluezutils
bus = dbus.SystemBus()
diff --git a/test/test-alert b/test/test-alert
index 066e537..43b3cf3 100755
--- a/test/test-alert
+++ b/test/test-alert
@@ -1,12 +1,17 @@
#!/usr/bin/python
+
from __future__ import absolute_import, print_function, unicode_literals
+
+import optparse
+import os
+import sys
import dbus
import dbus.service
import dbus.mainloop.glib
-import gobject
-import optparse
-import sys
-import os
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
BUS_NAME = 'org.bluez'
ALERT_INTERFACE = 'org.bluez.Alert1'
@@ -149,7 +154,7 @@ parser.disable_interspersed_args()
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
-mainloop = gobject.MainLoop()
+mainloop = GObject.MainLoop()
alert = dbus.Interface(bus.get_object(BUS_NAME, BLUEZ_OBJECT_PATH),
ALERT_INTERFACE)
alert_agent = AlertAgent(bus, TEST_OBJECT_PATH, alert, mainloop)
diff --git a/test/test-cyclingspeed b/test/test-cyclingspeed
index 75bd7d7..d49041f 100755
--- a/test/test-cyclingspeed
+++ b/test/test-cyclingspeed
@@ -6,13 +6,15 @@ from __future__ import absolute_import, print_function, unicode_literals
Cycling Speed and Cadence test script
'''
-import gobject
-
+from optparse import OptionParser, make_option
import sys
import dbus
import dbus.service
import dbus.mainloop.glib
-from optparse import OptionParser, make_option
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
BUS_NAME = 'org.bluez'
CYCLINGSPEED_MANAGER_INTERFACE = 'org.bluez.CyclingSpeedManager1'
@@ -190,5 +192,5 @@ if __name__ == "__main__":
print("Unknown command")
sys.exit(1)
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
mainloop.run()
diff --git a/test/test-device b/test/test-device
index 3d7b852..b490d53 100755
--- a/test/test-device
+++ b/test/test-device
@@ -2,13 +2,15 @@
from __future__ import absolute_import, print_function, unicode_literals
-from gi.repository import GObject
-
+from optparse import OptionParser, make_option
+import re
import sys
import dbus
import dbus.mainloop.glib
-import re
-from optparse import OptionParser, make_option
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
import bluezutils
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
diff --git a/test/test-discovery b/test/test-discovery
index c13bfac..73b8161 100755
--- a/test/test-discovery
+++ b/test/test-discovery
@@ -2,11 +2,13 @@
from __future__ import absolute_import, print_function, unicode_literals
-from gi.repository import GObject
-
+from optparse import OptionParser, make_option
import dbus
import dbus.mainloop.glib
-from optparse import OptionParser, make_option
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
import bluezutils
compact = False
diff --git a/test/test-health b/test/test-health
index 052a602..343f29c 100755
--- a/test/test-health
+++ b/test/test-health
@@ -3,11 +3,14 @@
from __future__ import absolute_import, print_function, unicode_literals
# -*- coding: utf-8 -*-
+import sys
import dbus
import dbus.service
-import gobject
from dbus.mainloop.glib import DBusGMainLoop
-import sys
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
BUS_NAME = 'org.bluez'
PATH = '/org/bluez'
@@ -16,7 +19,7 @@ HEALTH_MANAGER_INTERFACE = 'org.bluez.HealthManager1'
HEALTH_DEVICE_INTERFACE = 'org.bluez.HealthDevice1'
DBusGMainLoop(set_as_default=True)
-loop = gobject.MainLoop()
+loop = GObject.MainLoop()
bus = dbus.SystemBus()
@@ -48,7 +51,7 @@ def enter_mainloop():
try:
print("Entering main lopp, push Ctrl+C for finish")
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
mainloop.run()
except KeyboardInterrupt:
pass
diff --git a/test/test-health-sink b/test/test-health-sink
index 32afd71..52be535 100755
--- a/test/test-health-sink
+++ b/test/test-health-sink
@@ -3,11 +3,14 @@
from __future__ import absolute_import, print_function, unicode_literals
# -*- coding: utf-8 -*-
+import sys
import dbus
import dbus.service
-import gobject
from dbus.mainloop.glib import DBusGMainLoop
-import sys
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
BUS_NAME = 'org.bluez'
PATH = '/org/bluez'
@@ -16,7 +19,7 @@ HEALTH_MANAGER_INTERFACE = 'org.bluez.HealthManager1'
HEALTH_DEVICE_INTERFACE = 'org.bluez.HealthDevice1'
DBusGMainLoop(set_as_default=True)
-loop = gobject.MainLoop()
+loop = GObject.MainLoop()
bus = dbus.SystemBus()
diff --git a/test/test-heartrate b/test/test-heartrate
index f26b3db..5e4e7e5 100755
--- a/test/test-heartrate
+++ b/test/test-heartrate
@@ -6,13 +6,15 @@ from __future__ import absolute_import, print_function, unicode_literals
Heart Rate Monitor test script
'''
-import gobject
-
+from optparse import OptionParser, make_option
import sys
import dbus
import dbus.service
import dbus.mainloop.glib
-from optparse import OptionParser, make_option
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
import bluezutils
BUS_NAME = 'org.bluez'
@@ -102,5 +104,5 @@ if __name__ == "__main__":
print("unknown command")
sys.exit(1)
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
mainloop.run()
diff --git a/test/test-hfp b/test/test-hfp
index 873de0a..a806043 100755
--- a/test/test-hfp
+++ b/test/test-hfp
@@ -2,16 +2,18 @@
from __future__ import absolute_import, print_function, unicode_literals
-from gi.repository import GObject
-
+from optparse import OptionParser, make_option
import os
+from socket import SOCK_SEQPACKET, socket
import sys
import dbus
-import glib
import dbus.service
import dbus.mainloop.glib
-from optparse import OptionParser, make_option
-from socket import SOCK_SEQPACKET, socket
+import glib
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
mainloop = None
audio_supported = True
diff --git a/test/test-manager b/test/test-manager
index 1e3882f..4f5994f 100755
--- a/test/test-manager
+++ b/test/test-manager
@@ -2,10 +2,12 @@
from __future__ import absolute_import, print_function, unicode_literals
-from gi.repository import GObject
-
import dbus
import dbus.mainloop.glib
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
import bluezutils
def interfaces_added(path, interfaces):
diff --git a/test/test-nap b/test/test-nap
index 197e3c2..00a2585 100755
--- a/test/test-nap
+++ b/test/test-nap
@@ -2,10 +2,10 @@
from __future__ import absolute_import, print_function, unicode_literals
+from optparse import OptionParser, make_option
import sys
import time
import dbus
-from optparse import OptionParser, make_option
import bluezutils
bus = dbus.SystemBus()
diff --git a/test/test-network b/test/test-network
index 3e8713f..6f09486 100755
--- a/test/test-network
+++ b/test/test-network
@@ -2,10 +2,10 @@
from __future__ import absolute_import, print_function, unicode_literals
+from optparse import OptionParser, make_option
import sys
import time
import dbus
-from optparse import OptionParser, make_option
import bluezutils
bus = dbus.SystemBus()
diff --git a/test/test-profile b/test/test-profile
index b78d00c..2791580 100755
--- a/test/test-profile
+++ b/test/test-profile
@@ -2,15 +2,17 @@
from __future__ import absolute_import, print_function, unicode_literals
-from gi.repository import GObject
-
+from optparse import OptionParser, make_option
import os
import sys
import uuid
import dbus
import dbus.service
import dbus.mainloop.glib
-from optparse import OptionParser, make_option
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
class Profile(dbus.service.Object):
fd = -1
diff --git a/test/test-proximity b/test/test-proximity
index 2f47824..66b7bc2 100755
--- a/test/test-proximity
+++ b/test/test-proximity
@@ -6,12 +6,14 @@ from __future__ import absolute_import, print_function, unicode_literals
Proximity Monitor test script
'''
-import gobject
-
+from optparse import OptionParser, make_option
import sys
import dbus
import dbus.mainloop.glib
-from optparse import OptionParser, make_option
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
import bluezutils
BUS_NAME = 'org.bluez'
@@ -64,5 +66,5 @@ if __name__ == "__main__":
print("Proximity SetProperty('%s', '%s')" % (args[0], args[1]))
device_prop.Set(PROXIMITY_MONITOR_INTERFACE, args[0], args[1])
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
mainloop.run()
diff --git a/test/test-thermometer b/test/test-thermometer
index 6c143be..7e67c23 100755
--- a/test/test-thermometer
+++ b/test/test-thermometer
@@ -6,13 +6,15 @@ from __future__ import absolute_import, print_function, unicode_literals
Thermometer test script
'''
-import gobject
-
+from optparse import OptionParser, make_option
import sys
import dbus
import dbus.service
import dbus.mainloop.glib
-from optparse import OptionParser, make_option
+try:
+ from gi.repository import GObject
+except ImportError:
+ import gobject as GObject
import bluezutils
BUS_NAME = 'org.bluez'
@@ -93,5 +95,5 @@ if __name__ == "__main__":
print("unknown command")
sys.exit(1)
- mainloop = gobject.MainLoop()
+ mainloop = GObject.MainLoop()
mainloop.run()
--
1.8.5.3
^ permalink raw reply related
* Status of BlueZ GATT APIs
From: Arman Uguray @ 2014-01-17 21:47 UTC (permalink / raw)
To: linux-bluetooth
Hi all,
I was wondering what the current plans are for the GATT D-Bus API in
BlueZ. Can anyone give a rough estimate of when these APIs will be
available in BlueZ upstream and approximately when they could make to
into a release?
Thanks!
Arman Uguray
^ permalink raw reply
* Re: Compilation using clang
From: Donald Carr @ 2014-01-17 21:26 UTC (permalink / raw)
To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <20140110200624.GA25318@molly.amr.corp.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2753 bytes --]
Hola,
Thanks for the rapid response :)
I am simply attaching a patch, probably in complete defiance of some
standardized announcement/submission pattern.
Yours sincerely,
Donald
On Fri, Jan 10, 2014 at 12:06 PM, Vinicius Costa Gomes
<vcgomes@gmail.com> wrote:
> Hi Donald,
>
> On 09:57 Fri 10 Jan, Donald Carr wrote:
>> Top of the morning,
>>
>> qtconnectivity currently contains a kludge which is required due to
>> the use of the GCC typeof extension in bluetooth.h which is breaking
>> with Clang compilation against the cxx11 spec.
>
> Another kludge that I have seen is putting a
> "#define typeof(x) __tupeof__(x)" before including bluetooth.h.
>
>>
>> The kludge in question involves molesting the standard (eg -std=cxx11)
>> specified to the compiler (explicitly away from cxx11 toward g++0x)
>> and hence I am hoping to be able to murder its intrusive self. I am
>> not entirely clear on the nuances though:
>>
>> This is the offending section:
>>
>> #define bt_get_unaligned(ptr) \
>> ({ \
>> struct __attribute__((packed)) { \
>> typeof(*(ptr)) __v; \
>> } *__p = (typeof(__p)) (ptr); \
>> __p->__v; \
>> })
>>
>> #define bt_put_unaligned(val, ptr) \
>> do { \
>> struct __attribute__((packed)) { \
>> typeof(*(ptr)) __v; \
>> } *__p = (typeof(__p)) (ptr); \
>> __p->__v = (val); \
>> } while(0)
>>
>> and changing typeof to __typeof__ has been verified to succeed in the
>> stated circumstance. I don't know whether this is the ideal solution,
>> or whether decltype or so other designator would be a closer/better
>> match.
>
> I would vote for changing it to __typeof__.
>
>>
>> Any feedback would be greatly appreciated, I am using this change
>> locally and I think it could be of broader use to people.
>
> Please send a patch and let's see what others think.
>
>>
>> Yours sincerely,
>> Donald Carr
>>
>>
>> --
>> -------------------------------
>> °v° Donald Carr
>> /(_)\ Vaguely Professional Penguin lover
>> ^ ^
>>
>> Cave canem, te necet lingendo
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
> Cheers,
> --
> Vinicius
--
-------------------------------
°v° Donald Carr
/(_)\ Vaguely Professional Penguin lover
^ ^
Cave canem, te necet lingendo
[-- Attachment #2: 0001-Bluez-Move-off-gcc-typeof-extension.patch --]
[-- Type: text/x-patch, Size: 1026 bytes --]
From 846b84143ee4240258b2aee6aad3cd95565caefb Mon Sep 17 00:00:00 2001
From: Donald Carr <sirspudd@gmail.com>
Date: Fri, 17 Jan 2014 13:20:39 -0800
Subject: [PATCH] Bluez: Move off gcc typeof extension
Change-Id: I63c70c9b43af6a29aa69ed11a720c45c1085dce9
---
bluetooth/bluetooth.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/bluetooth/bluetooth.h b/bluetooth/bluetooth.h
index 61c1f9a..bc9b35e 100644
--- a/bluetooth/bluetooth.h
+++ b/bluetooth/bluetooth.h
@@ -158,16 +158,16 @@ enum {
#define bt_get_unaligned(ptr) \
({ \
struct __attribute__((packed)) { \
- typeof(*(ptr)) __v; \
- } *__p = (typeof(__p)) (ptr); \
+ __typeof__(*(ptr)) __v; \
+ } *__p = (__typeof__(__p)) (ptr); \
__p->__v; \
})
#define bt_put_unaligned(val, ptr) \
do { \
struct __attribute__((packed)) { \
- typeof(*(ptr)) __v; \
- } *__p = (typeof(__p)) (ptr); \
+ __typeof__(*(ptr)) __v; \
+ } *__p = (__typeof__(__p)) (ptr); \
__p->__v = (val); \
} while(0)
--
1.8.5.3
^ permalink raw reply related
* Re: [PATCH 3/3] android/ipc: Add PTS test results document for AVCTP
From: Szymon Janc @ 2014-01-17 20:34 UTC (permalink / raw)
To: Jakub Tyszkowski; +Cc: linux-bluetooth
In-Reply-To: <1389866462-7993-3-git-send-email-jakub.tyszkowski@tieto.com>
Hi Jakub,
On Thursday 16 January 2014 11:01:02 Jakub Tyszkowski wrote:
> This will allow for better tracking of current state of implementation.
> ---
> android/Makefile.am | 1 +
> android/pts-avctp.txt | 41 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 42 insertions(+)
> create mode 100644 android/pts-avctp.txt
>
Please fix commit title prefix android/ipc -> android/pts
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 95ed7a7..f030bd4 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -149,5 +149,6 @@ EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt
> android/README \ android/pics-a2dp.txt android/pixit-a2dp.txt \
> android/pics-avctp.txt android/pixit-avctp.txt \
> android/pts-a2dp.txt android/pts-avrcp.txt \
> + android/pts-avctp.txt \
>
> android/pts-l2cap.txt
> diff --git a/android/pts-avctp.txt b/android/pts-avctp.txt
> new file mode 100644
> index 0000000..c057a10
> --- /dev/null
> +++ b/android/pts-avctp.txt
> @@ -0,0 +1,41 @@
> +PTS test results for AVCTP
> +
> +PTS version: 5.0
> +Tested: --not yet tested--
> +
> +Results:
> +PASS test passed
> +FAIL test failed
> +INC test is inconclusive
> +N/A test is disabled due to PICS setup
> +
> + Controller (CT)
> +---------------------------------------------------------------------------
> ---- +Test Name Result Notes
> +---------------------------------------------------------------------------
> ---- +TC_CT_CCM_BV_01_C N/A
> +TC_CT_CCM_BV_02_C N/A
> +TC_CT_CCM_BV_03_C N/A
> +TC_CT_CCM_BV_04_C N/A
> +TC_CT_CCM_BI_01_C N/A
> +TC_CT_NFR_BV_01_C N/A
> +TC_CT_NFR_BV_04_C N/A
> +TC_CT_FRA_BV_01_C N/A
> +TC_CT_FRA_BV_04_C N/A
> +---------------------------------------------------------------------------
> ---- +
> +
> + Target (TG)
> +---------------------------------------------------------------------------
> ---- +Test Name Result Notes
> +---------------------------------------------------------------------------
> ---- +TC_TG_CCM_BV_01_C INC
> +TC_TG_CCM_BV_02_C INC
> +TC_TG_CCM_BV_03_C INC
> +TC_TG_CCM_BV_04_C INC
> +TC_TG_NFR_BV_02_C INC
> +TC_TG_NFR_BV_03_C INC
> +TC_TG_NFR_BI_01_C INC
> +TC_TG_FRA_BV_02_C INC
> +TC_TG_FRA_BV_03_C INC
> +---------------------------------------------------------------------------
> ----
--
Szymon K. Janc
szymon.janc@gmail.com
^ permalink raw reply
* Re: [PATCH 1/3] android/pts: Add PTS test results document for A2DP
From: Szymon Janc @ 2014-01-17 20:31 UTC (permalink / raw)
To: Jakub Tyszkowski; +Cc: linux-bluetooth
In-Reply-To: <1389866462-7993-1-git-send-email-jakub.tyszkowski@tieto.com>
Hi Jakub,
On Thursday 16 January 2014 11:01:00 Jakub Tyszkowski wrote:
> This will allow for better tracking of current state of implementation.
> ---
> android/Makefile.am | 2 ++
> android/pts-a2dp.txt | 57
> ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59
> insertions(+)
> create mode 100644 android/pts-a2dp.txt
>
> diff --git a/android/Makefile.am b/android/Makefile.am
> index cd4a526..0ce0188 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -148,4 +148,6 @@ EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt
> android/README \ android/pics-avrcp.txt android/pixit-avrcp.txt \
> android/pics-a2dp.txt android/pixit-a2dp.txt \
> android/pics-avctp.txt android/pixit-avctp.txt \
> + android/pts-a2dp.txt \
> +
This extra empty line is not needed.
> android/pts-l2cap.txt
> diff --git a/android/pts-a2dp.txt b/android/pts-a2dp.txt
> new file mode 100644
> index 0000000..a269ec1
> --- /dev/null
> +++ b/android/pts-a2dp.txt
> @@ -0,0 +1,57 @@
> +PTS test results for A2DP
> +
> +PTS version: 5.0
> +Tested: --not yet tested--
> +
> +Results:
> +PASS test passed
> +FAIL test failed
> +INC test is inconclusive
> +N/A test is disabled due to PICS setup
> +
> + Source (SRC)
> +---------------------------------------------------------------------------
> ---- +Test Name Result Notes
> +---------------------------------------------------------------------------
> ---- +TC_SRC_CC_BV_09_I INC
> +TC_SRC_CC_BV_10_I N/A
> +TC_SRC_REL_BV_01_I INC
> +TC_SRC_REL_BV_02_I INC
> +TC_SRC_SET_BV_01_I INC
> +TC_SRC_SET_BV_02_I INC
> +TC_SRC_SET_BV_03_I INC
> +TC_SRC_SET_BV_04_I INC
> +TC_SRC_SET_BV_05_I INC
> +TC_SRC_SET_BV_06_I INC
> +TC_SRC_SUS_BV_01_I INC
> +TC_SRC_SUS_BV_02_I INC
> +TC_SRC_SDP_BV_01_I INC
> +TC_SRC_AS_BV_01_I INC
> +---------------------------------------------------------------------------
> ---- +
> +
> + Sink (SNK)
> +---------------------------------------------------------------------------
> ---- +Test Name Result Notes
> +---------------------------------------------------------------------------
> ---- +TC_SNK_CC_BV_01_I N/A
> +TC_SNK_CC_BV_02_I N/A
> +TC_SNK_CC_BV_03_I N/A
> +TC_SNK_CC_BV_04_I N/A
> +TC_SNK_CC_BV_05_I N/A
> +TC_SNK_CC_BV_06_I N/A
> +TC_SNK_CC_BV_07_I N/A
> +TC_SNK_CC_BV_08_I N/A
> +TC_SNK_REL_BV_01_I N/A
> +TC_SNK_REL_BV_02_I N/A
> +TC_SNK_SET_BV_01_I N/A
> +TC_SNK_SET_BV_02_I N/A
> +TC_SNK_SET_BV_03_I N/A
> +TC_SNK_SET_BV_04_I N/A
> +TC_SNK_SET_BV_05_I N/A
> +TC_SNK_SET_BV_06_I N/A
> +TC_SNK_SUS_BV_01_I N/A
> +TC_SNK_SUS_BV_02_I N/A
> +TC_SNK_SDP_BV_02_I N/A
> +TC_SNK_AS_BV_01_I N/A
> +---------------------------------------------------------------------------
> ----
--
Szymon K. Janc
szymon.janc@gmail.com
^ permalink raw reply
* Re: [PATCH 5/9] android/hal-audio: Calculate SBC stream parameters
From: Marcel Holtmann @ 2014-01-17 20:25 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Andrzej Kaczmarek, linux-bluetooth@vger.kernel.org development
In-Reply-To: <CABBYNZ+iMPo091X2CpX6G6kQqb3j9eXO1s+Z-L8FPQ2gRupsRA@mail.gmail.com>
Hi Luiz,
>>>> This patch adds necessary calculations for SBC stream parameters.
>>>>
>>>> Both input and output buffers are expected to have exact amount of
>>>> data to fill single media packet (based on transport channel MTU).
>>>>
>>>> Frame duration will be used to synchronize input and output streams.
>>>> ---
>>>> android/hal-audio.c | 50 ++++++++++++++++++++++++++++++-----
>>>> android/rtp.h | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>> 2 files changed, 120 insertions(+), 6 deletions(-)
>>>> create mode 100644 android/rtp.h
>>>>
>>>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>>>> index e5c646c..3f53295 100644
>>>> --- a/android/hal-audio.c
>>>> +++ b/android/hal-audio.c
>>>> @@ -33,6 +33,7 @@
>>>> #include "hal-msg.h"
>>>> #include "../profiles/audio/a2dp-codecs.h"
>>>> #include <sbc/sbc.h>
>>>> +#include "rtp.h"
>>>>
>>>> static const uint8_t a2dp_src_uuid[] = {
>>>> 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x10, 0x00,
>>>> @@ -46,6 +47,12 @@ static pthread_t ipc_th = 0;
>>>> static pthread_mutex_t close_mutex = PTHREAD_MUTEX_INITIALIZER;
>>>> static pthread_mutex_t sk_mutex = PTHREAD_MUTEX_INITIALIZER;
>>>>
>>>> +struct media_packet {
>>>> + struct rtp_header hdr;
>>>> + struct rtp_payload payload;
>>>> + uint8_t data[0];
>>>> +};
>>>> +
>>>> struct audio_input_config {
>>>> uint32_t rate;
>>>> uint32_t channels;
>>>> @@ -56,10 +63,19 @@ struct sbc_data {
>>>> a2dp_sbc_t sbc;
>>>>
>>>> sbc_t enc;
>>>> +
>>>> + size_t in_frame_len;
>>>> + size_t in_buf_size;
>>>> +
>>>> + size_t out_buf_size;
>>>> + uint8_t *out_buf;
>>>> +
>>>> + unsigned frame_duration;
>>>> };
>>>>
>>>> static int sbc_get_presets(struct audio_preset *preset, size_t *len);
>>>> -static int sbc_codec_init(struct audio_preset *preset, void **codec_data);
>>>> +static int sbc_codec_init(struct audio_preset *preset, uint16_t mtu,
>>>> + void **codec_data);
>>>> static int sbc_cleanup(void *codec_data);
>>>> static int sbc_get_config(void *codec_data,
>>>> struct audio_input_config *config);
>>>> @@ -69,7 +85,8 @@ struct audio_codec {
>>>>
>>>> int (*get_presets) (struct audio_preset *preset, size_t *len);
>>>>
>>>> - int (*init) (struct audio_preset *preset, void **codec_data);
>>>> + int (*init) (struct audio_preset *preset, uint16_t mtu,
>>>> + void **codec_data);
>>>> int (*cleanup) (void *codec_data);
>>>> int (*get_config) (void *codec_data,
>>>> struct audio_input_config *config);
>>>> @@ -251,9 +268,14 @@ static void sbc_init_encoder(struct sbc_data *sbc_data)
>>>> }
>>>> }
>>>>
>>>> -static int sbc_codec_init(struct audio_preset *preset, void **codec_data)
>>>> +static int sbc_codec_init(struct audio_preset *preset, uint16_t mtu,
>>>> + void **codec_data)
>>>> {
>>>> struct sbc_data *sbc_data;
>>>> + size_t hdr_len = sizeof(struct media_packet);
>>>> + size_t in_frame_len;
>>>> + size_t out_frame_len;
>>>> + size_t num_frames;
>>>>
>>>> DBG("");
>>>>
>>>> @@ -268,6 +290,18 @@ static int sbc_codec_init(struct audio_preset *preset, void **codec_data)
>>>>
>>>> sbc_init_encoder(sbc_data);
>>>>
>>>> + in_frame_len = sbc_get_codesize(&sbc_data->enc);
>>>> + out_frame_len = sbc_get_frame_length(&sbc_data->enc);
>>>> + num_frames = (mtu - hdr_len) / out_frame_len;
>>>> +
>>>> + sbc_data->in_frame_len = in_frame_len;
>>>> + sbc_data->in_buf_size = num_frames * in_frame_len;
>>>> +
>>>> + sbc_data->out_buf_size = hdr_len + num_frames * out_frame_len;
>>>> + sbc_data->out_buf = calloc(1, sbc_data->out_buf_size);
>>>> +
>>>> + sbc_data->frame_duration = sbc_get_frame_duration(&sbc_data->enc);
>>>> +
>>>> *codec_data = sbc_data;
>>>>
>>>> return AUDIO_STATUS_SUCCESS;
>>>> @@ -280,6 +314,7 @@ static int sbc_cleanup(void *codec_data)
>>>> DBG("");
>>>>
>>>> sbc_finish(&sbc_data->enc);
>>>> + free(sbc_data->out_buf);
>>>> free(codec_data);
>>>>
>>>> return AUDIO_STATUS_SUCCESS;
>>>> @@ -511,7 +546,7 @@ static int ipc_close_cmd(uint8_t endpoint_id)
>>>> return result;
>>>> }
>>>>
>>>> -static int ipc_open_stream_cmd(uint8_t endpoint_id,
>>>> +static int ipc_open_stream_cmd(uint8_t endpoint_id, uint16_t *mtu,
>>>> struct audio_preset **caps)
>>>> {
>>>> char buf[BLUEZ_AUDIO_MTU];
>>>> @@ -534,6 +569,7 @@ static int ipc_open_stream_cmd(uint8_t endpoint_id,
>>>> if (result == AUDIO_STATUS_SUCCESS) {
>>>> size_t buf_len = sizeof(struct audio_preset) +
>>>> rsp->preset[0].len;
>>>> + *mtu = rsp->mtu;
>>>> *caps = malloc(buf_len);
>>>> memcpy(*caps, &rsp->preset, buf_len);
>>>> } else {
>>>> @@ -919,6 +955,7 @@ static int audio_open_output_stream(struct audio_hw_device *dev,
>>>> struct a2dp_stream_out *out;
>>>> struct audio_preset *preset;
>>>> const struct audio_codec *codec;
>>>> + uint16_t mtu;
>>>>
>>>> out = calloc(1, sizeof(struct a2dp_stream_out));
>>>> if (!out)
>>>> @@ -946,7 +983,8 @@ static int audio_open_output_stream(struct audio_hw_device *dev,
>>>> /* TODO: for now we always use endpoint 0 */
>>>> out->ep = &audio_endpoints[0];
>>>>
>>>> - if (ipc_open_stream_cmd(out->ep->id, &preset) != AUDIO_STATUS_SUCCESS)
>>>> + if (ipc_open_stream_cmd(out->ep->id, &mtu, &preset) !=
>>>> + AUDIO_STATUS_SUCCESS)
>>>> goto fail;
>>>>
>>>> if (!preset)
>>>> @@ -954,7 +992,7 @@ static int audio_open_output_stream(struct audio_hw_device *dev,
>>>>
>>>> codec = out->ep->codec;
>>>>
>>>> - codec->init(preset, &out->ep->codec_data);
>>>> + codec->init(preset, mtu, &out->ep->codec_data);
>>>> codec->get_config(out->ep->codec_data, &out->cfg);
>>>>
>>>> DBG("rate=%d channels=%d format=%d", out->cfg.rate,
>>>> diff --git a/android/rtp.h b/android/rtp.h
>>>> new file mode 100644
>>>> index 0000000..45fddcf
>>>> --- /dev/null
>>>> +++ b/android/rtp.h
>>>> @@ -0,0 +1,76 @@
>>>> +/*
>>>> + *
>>>> + * BlueZ - Bluetooth protocol stack for Linux
>>>> + *
>>>> + * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
>>>> + *
>>>> + *
>>>> + * This library is free software; you can redistribute it and/or
>>>> + * modify it under the terms of the GNU Lesser General Public
>>>> + * License as published by the Free Software Foundation; either
>>>> + * version 2.1 of the License, or (at your option) any later version.
>>>> + *
>>>> + * This library is distributed in the hope that it will be useful,
>>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>>>> + * Lesser General Public License for more details.
>>>> + *
>>>> + * You should have received a copy of the GNU Lesser General Public
>>>> + * License along with this library; if not, write to the Free Software
>>>> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
>>>> + *
>>>> + */
>>>
>>> where is this file coming from? Why do we need a copy of it?
>>
>> From BlueZ but it was removed (was used in pcm_bluetooth.c) so I just
>> added it again since we need RTP header structures. Or should these
>> just be added inline to hal-audio.c?
>
> I would just add these to hal-audio.c, nothing else should need it.
can we try to add it to libsbc and see how it works out. I like to see options.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 4/9] android/hal-audio: Initialize SBC encoder
From: Marcel Holtmann @ 2014-01-17 20:24 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Andrzej Kaczmarek, linux-bluetooth@vger.kernel.org development
In-Reply-To: <CABBYNZ+_CXL5EsTt27ERRjCFEZK69HopAJigNusSG6ELGaPwLA@mail.gmail.com>
Hi Luiz,
>>>>> ---
>>>>> android/hal-audio.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>> 1 file changed, 72 insertions(+)
>>>>>
>>>>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>>>>> index f53dba0..e5c646c 100644
>>>>> --- a/android/hal-audio.c
>>>>> +++ b/android/hal-audio.c
>>>>> @@ -32,6 +32,7 @@
>>>>> #include "hal-log.h"
>>>>> #include "hal-msg.h"
>>>>> #include "../profiles/audio/a2dp-codecs.h"
>>>>> +#include <sbc/sbc.h>
>>>>>
>>>>> static const uint8_t a2dp_src_uuid[] = {
>>>>> 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x10, 0x00,
>>>>> @@ -53,6 +54,8 @@ struct audio_input_config {
>>>>>
>>>>> struct sbc_data {
>>>>> a2dp_sbc_t sbc;
>>>>> +
>>>>> + sbc_t enc;
>>>>> };
>>>>>
>>>>> static int sbc_get_presets(struct audio_preset *preset, size_t *len);
>>>>> @@ -184,6 +187,70 @@ static int sbc_get_presets(struct audio_preset *preset, size_t *len)
>>>>> return i;
>>>>> }
>>>>>
>>>>> +static void sbc_init_encoder(struct sbc_data *sbc_data)
>>>>> +{
>>>>> + a2dp_sbc_t *in = &sbc_data->sbc;
>>>>> + sbc_t *out = &sbc_data->enc;
>>>>> +
>>>>> + DBG("");
>>>>> +
>>>>> + sbc_init(out, 0L);
>>>>> +
>>>>> + switch (in->frequency) {
>>>>> + case SBC_SAMPLING_FREQ_16000:
>>>>> + out->frequency = SBC_FREQ_16000;
>>>>> + break;
>>>>> + case SBC_SAMPLING_FREQ_32000:
>>>>> + out->frequency = SBC_FREQ_32000;
>>>>> + break;
>>>>> + case SBC_SAMPLING_FREQ_44100:
>>>>> + out->frequency = SBC_FREQ_44100;
>>>>> + break;
>>>>> + case SBC_SAMPLING_FREQ_48000:
>>>>> + out->frequency = SBC_FREQ_48000;
>>>>> + break;
>>>>> + }
>>>>> +
>>>>> + out->subbands = in->subbands == SBC_SUBBANDS_4 ? SBC_SB_4 : SBC_SB_8;
>>>>> +
>>>>> + switch (in->channel_mode) {
>>>>> + case SBC_CHANNEL_MODE_MONO:
>>>>> + out->mode = SBC_MODE_MONO;
>>>>> + break;
>>>>> + case SBC_CHANNEL_MODE_DUAL_CHANNEL:
>>>>> + out->mode = SBC_MODE_DUAL_CHANNEL;
>>>>> + break;
>>>>> + case SBC_CHANNEL_MODE_JOINT_STEREO:
>>>>> + out->mode = SBC_MODE_JOINT_STEREO;
>>>>> + break;
>>>>> + case SBC_CHANNEL_MODE_STEREO:
>>>>> + out->mode = SBC_MODE_STEREO;
>>>>> + break;
>>>>> + }
>>>>> +
>>>>> + out->endian = SBC_LE;
>>>>> +
>>>>> + out->bitpool = in->max_bitpool;
>>>>> +
>>>>> + out->allocation = in->allocation_method == SBC_ALLOCATION_SNR ?
>>>>> + SBC_AM_SNR : SBC_AM_LOUDNESS;
>>>>> +
>>>>> + switch (in->block_length) {
>>>>> + case SBC_BLOCK_LENGTH_4:
>>>>> + out->blocks = SBC_BLK_4;
>>>>> + break;
>>>>> + case SBC_BLOCK_LENGTH_8:
>>>>> + out->blocks = SBC_BLK_8;
>>>>> + break;
>>>>> + case SBC_BLOCK_LENGTH_12:
>>>>> + out->blocks = SBC_BLK_12;
>>>>> + break;
>>>>> + case SBC_BLOCK_LENGTH_16:
>>>>> + out->blocks = SBC_BLK_16;
>>>>> + break;
>>>>> + }
>>>>
>>>> aren’t the values all the same? This looks pretty complicated for something that should be dead simple. Does Android really had to duplicate every single definition with the same prefix?
>>>
>>> Actually symbols for 'in' come from a2dp-codecs.h and 'out' from sbc.h
>>> ;-) And they have different values since A2DP uses shifted-bit values
>>> while sbc.h are just ordinal values so cannot assign them directly.
>>
>> so this a problem we created by ourselves. Yeah. Seems no cookie for me tonight ;)
>>
>> We need to start fixing a2dp-codecs.h then and prefix it with A2DP. This current situation is bad. Luiz?
>
> Looks like it, what about a helper function inside sbc that takes care
> of this conversion?
please send me libsbc patches that I can look at it. I am open for adding this.
Regards
Marcel
^ permalink raw reply
* Re: Dualshock4 - 'HIDP: Handshake: Unsupported request' after 'unplug virtual cable'.
From: simon @ 2014-01-17 20:17 UTC (permalink / raw)
To: David Herrmann; +Cc: Simon Wood, linux-bluetooth@vger.kernel.org, Frank Praznik
In-Reply-To: <CANq1E4TaM-eG5rBU8X2T9ux8fMgTCyaXpxF2ydZU=71QsX0UBQ@mail.gmail.com>
> So the problem is, your host refuses the HIDP connection from the
> device. This is intentional, as we don't want *any* remote Bluetooth
> device to be allowed to provide HID services. This could be used for
> very subtle attacks. The code responsible for that is
> ./profiles/input/server.c in bluez.
I note that there is now some DS3/SixAxis specfic stuff in there:
http://git.kernel.org/cgit/bluetooth/bluez.git/tree/profiles/input/server.c#n167
> Now, there are two ways to go on:
> - try to initiate the HIDP connection from the host instead of the
> device. Simply use "bluetoothctl" and then "connect <bdaddr>"
> - add the remote device to the list of known devices so incoming
> connections are not blocked. You can do this by triggering the
> ->device_probe() callback of the input device. I'm not sure how this
> is done, but I think a simple "connect <bdaddr>" should trigger it on
> *all* available services.
Thanks for your suggestions, I'll try to get some logs early next week.
Cheers,
Simon
^ permalink raw reply
* Re: [PATCH 8/9] android/hal-audio: Read fd from Output Stream response
From: Luiz Augusto von Dentz @ 2014-01-17 19:57 UTC (permalink / raw)
To: Szymon Janc; +Cc: Andrzej Kaczmarek, linux-bluetooth@vger.kernel.org
In-Reply-To: <1772554.HcRPMI1tWs@athlon>
Hi Szymon,
On Fri, Jan 17, 2014 at 8:13 PM, Szymon Janc <szymon.janc@gmail.com> wrote:
> Hi Andrzej,
>
> On Friday 17 January 2014 16:40:12 Andrzej Kaczmarek wrote:
>> ---
>> android/hal-audio.c | 11 +++++++----
>> 1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>> index f2cb12a..d8438f7 100644
>> --- a/android/hal-audio.c
>> +++ b/android/hal-audio.c
>> @@ -575,7 +575,7 @@ static int ipc_close_cmd(uint8_t endpoint_id)
>> return result;
>> }
>>
>> -static int ipc_open_stream_cmd(uint8_t endpoint_id, uint16_t *mtu,
>> +static int ipc_open_stream_cmd(uint8_t endpoint_id, uint16_t *mtu, int *fd,
>> struct audio_preset **caps)
>> {
>> char buf[BLUEZ_AUDIO_MTU];
>> @@ -593,7 +593,7 @@ static int ipc_open_stream_cmd(uint8_t endpoint_id,
>> uint16_t *mtu, cmd.id = endpoint_id;
>>
>> result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_OPEN_STREAM,
>> - sizeof(cmd), &cmd, &rsp_len, rsp, NULL);
>> + sizeof(cmd), &cmd, &rsp_len, rsp, fd);
>>
>> if (result == AUDIO_STATUS_SUCCESS) {
>> size_t buf_len = sizeof(struct audio_preset) +
>> @@ -990,6 +990,7 @@ static int audio_open_output_stream(struct
>> audio_hw_device *dev, struct audio_preset *preset;
>> const struct audio_codec *codec;
>> uint16_t mtu;
>> + int fd;
>>
>> out = calloc(1, sizeof(struct a2dp_stream_out));
>> if (!out)
>> @@ -1017,13 +1018,15 @@ static int audio_open_output_stream(struct
>> audio_hw_device *dev, /* TODO: for now we always use endpoint 0 */
>> out->ep = &audio_endpoints[0];
>>
>> - if (ipc_open_stream_cmd(out->ep->id, &mtu, &preset) !=
>> + if (ipc_open_stream_cmd(out->ep->id, &mtu, &fd, &preset) !=
>> AUDIO_STATUS_SUCCESS)
>> goto fail;
>>
>> - if (!preset)
>> + if (!preset || fd < 0)
>> goto fail;
>
> For sanity, code under fail label should be updated to handle that either
> preset or fd might be valid here.
>
>>
>> + out->ep->fd = fd;
>> +
>
> I might be missing something but fd is never closed. Should this be done in
> audio_close_output_stream() ?
Yep, the fd should be closed every time we suspend as we will get
another fd on open so we will end up with duplicated fds.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [RFC v2 1/6] android: Add sample init.bluetooth.rc file
From: Szymon Janc @ 2014-01-17 19:47 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1389972646-3761-1-git-send-email-szymon.janc@tieto.com>
Hi,
On Friday 17 January 2014 16:30:41 Szymon Janc wrote:
> This file is intended to be included from device init.rc.
> ---
> android/Android.mk | 16 +++++++++++++++-
> android/Makefile.am | 1 +
> android/init.bluetooth.rc | 37 +++++++++++++++++++++++++++++++++++++
> 3 files changed, 53 insertions(+), 1 deletion(-)
> create mode 100644 android/init.bluetooth.rc
>
> diff --git a/android/Android.mk b/android/Android.mk
> index 7e97ec8..afa3a51 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -109,7 +109,7 @@ LOCAL_MODULE := bluetooth.default
> LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
> LOCAL_MODULE_TAGS := optional
> LOCAL_MODULE_CLASS := SHARED_LIBRARIES
> -LOCAL_REQUIRED_MODULES := bluetoothd bluetoothd-snoop
> +LOCAL_REQUIRED_MODULES := bluetoothd bluetoothd-snoop init.bluetooth.rc
>
> include $(BUILD_SHARED_LIBRARY)
>
> @@ -282,3 +282,17 @@ LOCAL_MODULE_TAGS := optional
> LOCAL_MODULE := bluetoothd-snoop
>
> include $(BUILD_EXECUTABLE)
> +
> +#
> +# init.bluetooth.rc
> +#
> +
> +include $(CLEAR_VARS)
> +
> +LOCAL_MODULE := init.bluetooth.rc
> +LOCAL_MODULE_CLASS := ETC
> +LOCAL_SRC_FILES := $(LOCAL_MODULE)
> +LOCAL_MODULE_TAGS := optional
> +LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
> +
> +include $(BUILD_PREBUILT)
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 8d2714d..5aa3995 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -136,6 +136,7 @@ android_audio_a2dp_default_la_LDFLAGS = $(AM_LDFLAGS)
> -module -avoid-version \ endif
>
> EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
> + android/init.bluetooth.rc \
> android/pics-gap.txt android/pics-hid.txt \
> android/pics-pan.txt android/pics-did.txt \
> android/pics-opp.txt android/pics-pbap.txt \
> diff --git a/android/init.bluetooth.rc b/android/init.bluetooth.rc
> new file mode 100644
> index 0000000..9f9aa84
> --- /dev/null
> +++ b/android/init.bluetooth.rc
> @@ -0,0 +1,37 @@
> +# required permissions
> +on boot
> + chown bluetooth bluetooth /data/misc/bluetooth
> + chown bluetooth bluetooth /dev/uhid
> +
> +# services
> +on property:bluetooth.start=daemon
> + setprop bluetooth.start none
> + start bluetoothd
> +
> +on property:bluetooth.stop=daemon
> + setprop bluetooth.stop none
> + stop bluetoothd
> +
> +on property:bluetooth.start=snoop
> + setprop bluetooth.start none
> + start bluetoothd-snoop
> +
> +on property:bluetooth.stop=snoop
> + setprop bluetooth.stop none
> + stop bluetoothd-snoop
> +
> +service bluetoothd /system/bin/logwrapper /system/bin/bluetoothd
> + class main
> + # init does not yet support setting capabilities so run as root,
> + # bluetoothd drop uid to bluetooth with the right linux capabilities
> + group bluetooth
> + disabled
> + oneshot
> +
> +service bluetoothd-snoop /system/bin/logwrapper
> /system/bin/bluetoothd-snoop + class main
> + # init does not yet support setting capabilities so run as root,
> + # bluetoothd-snoop drops unneeded linux capabilities
> + group nobody
> + disabled
> + oneshot
This is now upstream.
--
Szymon K. Janc
szymon.janc@gmail.com
^ permalink raw reply
* Re: [PATCH 5/9] android/hal-audio: Calculate SBC stream parameters
From: Luiz Augusto von Dentz @ 2014-01-17 19:42 UTC (permalink / raw)
To: Andrzej Kaczmarek
Cc: Marcel Holtmann, linux-bluetooth@vger.kernel.org development
In-Reply-To: <CAF3PWx0KN9mtfy=czsmjYPEZj_c6X_buPBOAtbirdyQm01QqJw@mail.gmail.com>
Hi Andrzej,
On Fri, Jan 17, 2014 at 9:17 PM, Andrzej Kaczmarek
<andrzej.kaczmarek@tieto.com> wrote:
> Hi Marcel,
>
> On 17 January 2014 19:25, Marcel Holtmann <marcel@holtmann.org> wrote:
>> Hi Andrzej,
>>
>>> This patch adds necessary calculations for SBC stream parameters.
>>>
>>> Both input and output buffers are expected to have exact amount of
>>> data to fill single media packet (based on transport channel MTU).
>>>
>>> Frame duration will be used to synchronize input and output streams.
>>> ---
>>> android/hal-audio.c | 50 ++++++++++++++++++++++++++++++-----
>>> android/rtp.h | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> 2 files changed, 120 insertions(+), 6 deletions(-)
>>> create mode 100644 android/rtp.h
>>>
>>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>>> index e5c646c..3f53295 100644
>>> --- a/android/hal-audio.c
>>> +++ b/android/hal-audio.c
>>> @@ -33,6 +33,7 @@
>>> #include "hal-msg.h"
>>> #include "../profiles/audio/a2dp-codecs.h"
>>> #include <sbc/sbc.h>
>>> +#include "rtp.h"
>>>
>>> static const uint8_t a2dp_src_uuid[] = {
>>> 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x10, 0x00,
>>> @@ -46,6 +47,12 @@ static pthread_t ipc_th = 0;
>>> static pthread_mutex_t close_mutex = PTHREAD_MUTEX_INITIALIZER;
>>> static pthread_mutex_t sk_mutex = PTHREAD_MUTEX_INITIALIZER;
>>>
>>> +struct media_packet {
>>> + struct rtp_header hdr;
>>> + struct rtp_payload payload;
>>> + uint8_t data[0];
>>> +};
>>> +
>>> struct audio_input_config {
>>> uint32_t rate;
>>> uint32_t channels;
>>> @@ -56,10 +63,19 @@ struct sbc_data {
>>> a2dp_sbc_t sbc;
>>>
>>> sbc_t enc;
>>> +
>>> + size_t in_frame_len;
>>> + size_t in_buf_size;
>>> +
>>> + size_t out_buf_size;
>>> + uint8_t *out_buf;
>>> +
>>> + unsigned frame_duration;
>>> };
>>>
>>> static int sbc_get_presets(struct audio_preset *preset, size_t *len);
>>> -static int sbc_codec_init(struct audio_preset *preset, void **codec_data);
>>> +static int sbc_codec_init(struct audio_preset *preset, uint16_t mtu,
>>> + void **codec_data);
>>> static int sbc_cleanup(void *codec_data);
>>> static int sbc_get_config(void *codec_data,
>>> struct audio_input_config *config);
>>> @@ -69,7 +85,8 @@ struct audio_codec {
>>>
>>> int (*get_presets) (struct audio_preset *preset, size_t *len);
>>>
>>> - int (*init) (struct audio_preset *preset, void **codec_data);
>>> + int (*init) (struct audio_preset *preset, uint16_t mtu,
>>> + void **codec_data);
>>> int (*cleanup) (void *codec_data);
>>> int (*get_config) (void *codec_data,
>>> struct audio_input_config *config);
>>> @@ -251,9 +268,14 @@ static void sbc_init_encoder(struct sbc_data *sbc_data)
>>> }
>>> }
>>>
>>> -static int sbc_codec_init(struct audio_preset *preset, void **codec_data)
>>> +static int sbc_codec_init(struct audio_preset *preset, uint16_t mtu,
>>> + void **codec_data)
>>> {
>>> struct sbc_data *sbc_data;
>>> + size_t hdr_len = sizeof(struct media_packet);
>>> + size_t in_frame_len;
>>> + size_t out_frame_len;
>>> + size_t num_frames;
>>>
>>> DBG("");
>>>
>>> @@ -268,6 +290,18 @@ static int sbc_codec_init(struct audio_preset *preset, void **codec_data)
>>>
>>> sbc_init_encoder(sbc_data);
>>>
>>> + in_frame_len = sbc_get_codesize(&sbc_data->enc);
>>> + out_frame_len = sbc_get_frame_length(&sbc_data->enc);
>>> + num_frames = (mtu - hdr_len) / out_frame_len;
>>> +
>>> + sbc_data->in_frame_len = in_frame_len;
>>> + sbc_data->in_buf_size = num_frames * in_frame_len;
>>> +
>>> + sbc_data->out_buf_size = hdr_len + num_frames * out_frame_len;
>>> + sbc_data->out_buf = calloc(1, sbc_data->out_buf_size);
>>> +
>>> + sbc_data->frame_duration = sbc_get_frame_duration(&sbc_data->enc);
>>> +
>>> *codec_data = sbc_data;
>>>
>>> return AUDIO_STATUS_SUCCESS;
>>> @@ -280,6 +314,7 @@ static int sbc_cleanup(void *codec_data)
>>> DBG("");
>>>
>>> sbc_finish(&sbc_data->enc);
>>> + free(sbc_data->out_buf);
>>> free(codec_data);
>>>
>>> return AUDIO_STATUS_SUCCESS;
>>> @@ -511,7 +546,7 @@ static int ipc_close_cmd(uint8_t endpoint_id)
>>> return result;
>>> }
>>>
>>> -static int ipc_open_stream_cmd(uint8_t endpoint_id,
>>> +static int ipc_open_stream_cmd(uint8_t endpoint_id, uint16_t *mtu,
>>> struct audio_preset **caps)
>>> {
>>> char buf[BLUEZ_AUDIO_MTU];
>>> @@ -534,6 +569,7 @@ static int ipc_open_stream_cmd(uint8_t endpoint_id,
>>> if (result == AUDIO_STATUS_SUCCESS) {
>>> size_t buf_len = sizeof(struct audio_preset) +
>>> rsp->preset[0].len;
>>> + *mtu = rsp->mtu;
>>> *caps = malloc(buf_len);
>>> memcpy(*caps, &rsp->preset, buf_len);
>>> } else {
>>> @@ -919,6 +955,7 @@ static int audio_open_output_stream(struct audio_hw_device *dev,
>>> struct a2dp_stream_out *out;
>>> struct audio_preset *preset;
>>> const struct audio_codec *codec;
>>> + uint16_t mtu;
>>>
>>> out = calloc(1, sizeof(struct a2dp_stream_out));
>>> if (!out)
>>> @@ -946,7 +983,8 @@ static int audio_open_output_stream(struct audio_hw_device *dev,
>>> /* TODO: for now we always use endpoint 0 */
>>> out->ep = &audio_endpoints[0];
>>>
>>> - if (ipc_open_stream_cmd(out->ep->id, &preset) != AUDIO_STATUS_SUCCESS)
>>> + if (ipc_open_stream_cmd(out->ep->id, &mtu, &preset) !=
>>> + AUDIO_STATUS_SUCCESS)
>>> goto fail;
>>>
>>> if (!preset)
>>> @@ -954,7 +992,7 @@ static int audio_open_output_stream(struct audio_hw_device *dev,
>>>
>>> codec = out->ep->codec;
>>>
>>> - codec->init(preset, &out->ep->codec_data);
>>> + codec->init(preset, mtu, &out->ep->codec_data);
>>> codec->get_config(out->ep->codec_data, &out->cfg);
>>>
>>> DBG("rate=%d channels=%d format=%d", out->cfg.rate,
>>> diff --git a/android/rtp.h b/android/rtp.h
>>> new file mode 100644
>>> index 0000000..45fddcf
>>> --- /dev/null
>>> +++ b/android/rtp.h
>>> @@ -0,0 +1,76 @@
>>> +/*
>>> + *
>>> + * BlueZ - Bluetooth protocol stack for Linux
>>> + *
>>> + * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
>>> + *
>>> + *
>>> + * This library is free software; you can redistribute it and/or
>>> + * modify it under the terms of the GNU Lesser General Public
>>> + * License as published by the Free Software Foundation; either
>>> + * version 2.1 of the License, or (at your option) any later version.
>>> + *
>>> + * This library is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>>> + * Lesser General Public License for more details.
>>> + *
>>> + * You should have received a copy of the GNU Lesser General Public
>>> + * License along with this library; if not, write to the Free Software
>>> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
>>> + *
>>> + */
>>
>> where is this file coming from? Why do we need a copy of it?
>
> From BlueZ but it was removed (was used in pcm_bluetooth.c) so I just
> added it again since we need RTP header structures. Or should these
> just be added inline to hal-audio.c?
I would just add these to hal-audio.c, nothing else should need it.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 4/9] android/hal-audio: Initialize SBC encoder
From: Luiz Augusto von Dentz @ 2014-01-17 19:38 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Andrzej Kaczmarek, linux-bluetooth@vger.kernel.org development
In-Reply-To: <127C43B2-4418-44A2-9F44-27908E587B11@holtmann.org>
Hi Marcel,
On Fri, Jan 17, 2014 at 9:28 PM, Marcel Holtmann <marcel@holtmann.org> wrot=
e:
> Hi Andrezj,
>
>>>> ---
>>>> android/hal-audio.c | 72 +++++++++++++++++++++++++++++++++++++++++++++=
++++++++
>>>> 1 file changed, 72 insertions(+)
>>>>
>>>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>>>> index f53dba0..e5c646c 100644
>>>> --- a/android/hal-audio.c
>>>> +++ b/android/hal-audio.c
>>>> @@ -32,6 +32,7 @@
>>>> #include "hal-log.h"
>>>> #include "hal-msg.h"
>>>> #include "../profiles/audio/a2dp-codecs.h"
>>>> +#include <sbc/sbc.h>
>>>>
>>>> static const uint8_t a2dp_src_uuid[] =3D {
>>>> 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x10, 0x00,
>>>> @@ -53,6 +54,8 @@ struct audio_input_config {
>>>>
>>>> struct sbc_data {
>>>> a2dp_sbc_t sbc;
>>>> +
>>>> + sbc_t enc;
>>>> };
>>>>
>>>> static int sbc_get_presets(struct audio_preset *preset, size_t *len);
>>>> @@ -184,6 +187,70 @@ static int sbc_get_presets(struct audio_preset *p=
reset, size_t *len)
>>>> return i;
>>>> }
>>>>
>>>> +static void sbc_init_encoder(struct sbc_data *sbc_data)
>>>> +{
>>>> + a2dp_sbc_t *in =3D &sbc_data->sbc;
>>>> + sbc_t *out =3D &sbc_data->enc;
>>>> +
>>>> + DBG("");
>>>> +
>>>> + sbc_init(out, 0L);
>>>> +
>>>> + switch (in->frequency) {
>>>> + case SBC_SAMPLING_FREQ_16000:
>>>> + out->frequency =3D SBC_FREQ_16000;
>>>> + break;
>>>> + case SBC_SAMPLING_FREQ_32000:
>>>> + out->frequency =3D SBC_FREQ_32000;
>>>> + break;
>>>> + case SBC_SAMPLING_FREQ_44100:
>>>> + out->frequency =3D SBC_FREQ_44100;
>>>> + break;
>>>> + case SBC_SAMPLING_FREQ_48000:
>>>> + out->frequency =3D SBC_FREQ_48000;
>>>> + break;
>>>> + }
>>>> +
>>>> + out->subbands =3D in->subbands =3D=3D SBC_SUBBANDS_4 ? SBC_SB_4 =
: SBC_SB_8;
>>>> +
>>>> + switch (in->channel_mode) {
>>>> + case SBC_CHANNEL_MODE_MONO:
>>>> + out->mode =3D SBC_MODE_MONO;
>>>> + break;
>>>> + case SBC_CHANNEL_MODE_DUAL_CHANNEL:
>>>> + out->mode =3D SBC_MODE_DUAL_CHANNEL;
>>>> + break;
>>>> + case SBC_CHANNEL_MODE_JOINT_STEREO:
>>>> + out->mode =3D SBC_MODE_JOINT_STEREO;
>>>> + break;
>>>> + case SBC_CHANNEL_MODE_STEREO:
>>>> + out->mode =3D SBC_MODE_STEREO;
>>>> + break;
>>>> + }
>>>> +
>>>> + out->endian =3D SBC_LE;
>>>> +
>>>> + out->bitpool =3D in->max_bitpool;
>>>> +
>>>> + out->allocation =3D in->allocation_method =3D=3D SBC_ALLOCATION_=
SNR ?
>>>> + SBC_AM_SNR : SBC_AM_LOUDNESS;
>>>> +
>>>> + switch (in->block_length) {
>>>> + case SBC_BLOCK_LENGTH_4:
>>>> + out->blocks =3D SBC_BLK_4;
>>>> + break;
>>>> + case SBC_BLOCK_LENGTH_8:
>>>> + out->blocks =3D SBC_BLK_8;
>>>> + break;
>>>> + case SBC_BLOCK_LENGTH_12:
>>>> + out->blocks =3D SBC_BLK_12;
>>>> + break;
>>>> + case SBC_BLOCK_LENGTH_16:
>>>> + out->blocks =3D SBC_BLK_16;
>>>> + break;
>>>> + }
>>>
>>> aren=92t the values all the same? This looks pretty complicated for som=
ething that should be dead simple. Does Android really had to duplicate eve=
ry single definition with the same prefix?
>>
>> Actually symbols for 'in' come from a2dp-codecs.h and 'out' from sbc.h
>> ;-) And they have different values since A2DP uses shifted-bit values
>> while sbc.h are just ordinal values so cannot assign them directly.
>
> so this a problem we created by ourselves. Yeah. Seems no cookie for me t=
onight ;)
>
> We need to start fixing a2dp-codecs.h then and prefix it with A2DP. This =
current situation is bad. Luiz?
Looks like it, what about a helper function inside sbc that takes care
of this conversion?
--=20
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 4/9] android/hal-audio: Initialize SBC encoder
From: Luiz Augusto von Dentz @ 2014-01-17 19:36 UTC (permalink / raw)
To: Andrzej Kaczmarek
Cc: Marcel Holtmann, linux-bluetooth@vger.kernel.org development
In-Reply-To: <CAF3PWx3PZuAaJWacG77GSD7PRAaFuXi_o6LMe1zTWMrW1qYKaA@mail.gmail.com>
Hi Andrzej,
On Fri, Jan 17, 2014 at 9:26 PM, Andrzej Kaczmarek
<andrzej.kaczmarek@tieto.com> wrote:
> Hi Marcel,
>
> On 17 January 2014 19:24, Marcel Holtmann <marcel@holtmann.org> wrote:
>> Hi Andrzej,
>>
>>> ---
>>> android/hal-audio.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++=
+++++++
>>> 1 file changed, 72 insertions(+)
>>>
>>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>>> index f53dba0..e5c646c 100644
>>> --- a/android/hal-audio.c
>>> +++ b/android/hal-audio.c
>>> @@ -32,6 +32,7 @@
>>> #include "hal-log.h"
>>> #include "hal-msg.h"
>>> #include "../profiles/audio/a2dp-codecs.h"
>>> +#include <sbc/sbc.h>
>>>
>>> static const uint8_t a2dp_src_uuid[] =3D {
>>> 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x10, 0x00,
>>> @@ -53,6 +54,8 @@ struct audio_input_config {
>>>
>>> struct sbc_data {
>>> a2dp_sbc_t sbc;
>>> +
>>> + sbc_t enc;
>>> };
>>>
>>> static int sbc_get_presets(struct audio_preset *preset, size_t *len);
>>> @@ -184,6 +187,70 @@ static int sbc_get_presets(struct audio_preset *pr=
eset, size_t *len)
>>> return i;
>>> }
>>>
>>> +static void sbc_init_encoder(struct sbc_data *sbc_data)
>>> +{
>>> + a2dp_sbc_t *in =3D &sbc_data->sbc;
>>> + sbc_t *out =3D &sbc_data->enc;
>>> +
>>> + DBG("");
>>> +
>>> + sbc_init(out, 0L);
>>> +
>>> + switch (in->frequency) {
>>> + case SBC_SAMPLING_FREQ_16000:
>>> + out->frequency =3D SBC_FREQ_16000;
>>> + break;
>>> + case SBC_SAMPLING_FREQ_32000:
>>> + out->frequency =3D SBC_FREQ_32000;
>>> + break;
>>> + case SBC_SAMPLING_FREQ_44100:
>>> + out->frequency =3D SBC_FREQ_44100;
>>> + break;
>>> + case SBC_SAMPLING_FREQ_48000:
>>> + out->frequency =3D SBC_FREQ_48000;
>>> + break;
>>> + }
>>> +
>>> + out->subbands =3D in->subbands =3D=3D SBC_SUBBANDS_4 ? SBC_SB_4 :=
SBC_SB_8;
>>> +
>>> + switch (in->channel_mode) {
>>> + case SBC_CHANNEL_MODE_MONO:
>>> + out->mode =3D SBC_MODE_MONO;
>>> + break;
>>> + case SBC_CHANNEL_MODE_DUAL_CHANNEL:
>>> + out->mode =3D SBC_MODE_DUAL_CHANNEL;
>>> + break;
>>> + case SBC_CHANNEL_MODE_JOINT_STEREO:
>>> + out->mode =3D SBC_MODE_JOINT_STEREO;
>>> + break;
>>> + case SBC_CHANNEL_MODE_STEREO:
>>> + out->mode =3D SBC_MODE_STEREO;
>>> + break;
>>> + }
>>> +
>>> + out->endian =3D SBC_LE;
>>> +
>>> + out->bitpool =3D in->max_bitpool;
>>> +
>>> + out->allocation =3D in->allocation_method =3D=3D SBC_ALLOCATION_S=
NR ?
>>> + SBC_AM_SNR : SBC_AM_LOUDNESS;
>>> +
>>> + switch (in->block_length) {
>>> + case SBC_BLOCK_LENGTH_4:
>>> + out->blocks =3D SBC_BLK_4;
>>> + break;
>>> + case SBC_BLOCK_LENGTH_8:
>>> + out->blocks =3D SBC_BLK_8;
>>> + break;
>>> + case SBC_BLOCK_LENGTH_12:
>>> + out->blocks =3D SBC_BLK_12;
>>> + break;
>>> + case SBC_BLOCK_LENGTH_16:
>>> + out->blocks =3D SBC_BLK_16;
>>> + break;
>>> + }
>>
>> aren=92t the values all the same? This looks pretty complicated for some=
thing that should be dead simple. Does Android really had to duplicate ever=
y single definition with the same prefix?
>
> Actually symbols for 'in' come from a2dp-codecs.h and 'out' from sbc.h
> ;-) And they have different values since A2DP uses shifted-bit values
> while sbc.h are just ordinal values so cannot assign them directly.
Perhaps we should create some helper function in sbc code to do that
translation for us, I was even considering stuff the rtp packing there
as well.
--=20
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 4/9] android/hal-audio: Initialize SBC encoder
From: Luiz Augusto von Dentz @ 2014-01-17 19:33 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Andrzej Kaczmarek, linux-bluetooth@vger.kernel.org development
In-Reply-To: <D34DEF28-690B-4697-B88F-B224F7583782@holtmann.org>
Hi Marcel,
On Fri, Jan 17, 2014 at 8:24 PM, Marcel Holtmann <marcel@holtmann.org> wrot=
e:
> Hi Andrzej,
>
>> ---
>> android/hal-audio.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++=
++++++
>> 1 file changed, 72 insertions(+)
>>
>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>> index f53dba0..e5c646c 100644
>> --- a/android/hal-audio.c
>> +++ b/android/hal-audio.c
>> @@ -32,6 +32,7 @@
>> #include "hal-log.h"
>> #include "hal-msg.h"
>> #include "../profiles/audio/a2dp-codecs.h"
>> +#include <sbc/sbc.h>
>>
>> static const uint8_t a2dp_src_uuid[] =3D {
>> 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x10, 0x00,
>> @@ -53,6 +54,8 @@ struct audio_input_config {
>>
>> struct sbc_data {
>> a2dp_sbc_t sbc;
>> +
>> + sbc_t enc;
>> };
>>
>> static int sbc_get_presets(struct audio_preset *preset, size_t *len);
>> @@ -184,6 +187,70 @@ static int sbc_get_presets(struct audio_preset *pre=
set, size_t *len)
>> return i;
>> }
>>
>> +static void sbc_init_encoder(struct sbc_data *sbc_data)
>> +{
>> + a2dp_sbc_t *in =3D &sbc_data->sbc;
>> + sbc_t *out =3D &sbc_data->enc;
>> +
>> + DBG("");
>> +
>> + sbc_init(out, 0L);
>> +
>> + switch (in->frequency) {
>> + case SBC_SAMPLING_FREQ_16000:
>> + out->frequency =3D SBC_FREQ_16000;
>> + break;
>> + case SBC_SAMPLING_FREQ_32000:
>> + out->frequency =3D SBC_FREQ_32000;
>> + break;
>> + case SBC_SAMPLING_FREQ_44100:
>> + out->frequency =3D SBC_FREQ_44100;
>> + break;
>> + case SBC_SAMPLING_FREQ_48000:
>> + out->frequency =3D SBC_FREQ_48000;
>> + break;
>> + }
>> +
>> + out->subbands =3D in->subbands =3D=3D SBC_SUBBANDS_4 ? SBC_SB_4 : =
SBC_SB_8;
>> +
>> + switch (in->channel_mode) {
>> + case SBC_CHANNEL_MODE_MONO:
>> + out->mode =3D SBC_MODE_MONO;
>> + break;
>> + case SBC_CHANNEL_MODE_DUAL_CHANNEL:
>> + out->mode =3D SBC_MODE_DUAL_CHANNEL;
>> + break;
>> + case SBC_CHANNEL_MODE_JOINT_STEREO:
>> + out->mode =3D SBC_MODE_JOINT_STEREO;
>> + break;
>> + case SBC_CHANNEL_MODE_STEREO:
>> + out->mode =3D SBC_MODE_STEREO;
>> + break;
>> + }
>> +
>> + out->endian =3D SBC_LE;
>> +
>> + out->bitpool =3D in->max_bitpool;
>> +
>> + out->allocation =3D in->allocation_method =3D=3D SBC_ALLOCATION_SN=
R ?
>> + SBC_AM_SNR : SBC_AM_LOUDNESS;
>> +
>> + switch (in->block_length) {
>> + case SBC_BLOCK_LENGTH_4:
>> + out->blocks =3D SBC_BLK_4;
>> + break;
>> + case SBC_BLOCK_LENGTH_8:
>> + out->blocks =3D SBC_BLK_8;
>> + break;
>> + case SBC_BLOCK_LENGTH_12:
>> + out->blocks =3D SBC_BLK_12;
>> + break;
>> + case SBC_BLOCK_LENGTH_16:
>> + out->blocks =3D SBC_BLK_16;
>> + break;
>> + }
>
> aren=92t the values all the same? This looks pretty complicated for somet=
hing that should be dead simple. Does Android really had to duplicate every=
single definition with the same prefix?
This is the conversion from A2DP configuration to libsbc
representation but I believe we don't really need to do the switch
statement, which anyway are done with defines from sbc.h instead of
a2dp-codecs.h.
^ permalink raw reply
* Re: [PATCH 4/9] android/hal-audio: Initialize SBC encoder
From: Marcel Holtmann @ 2014-01-17 19:28 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <CAF3PWx3PZuAaJWacG77GSD7PRAaFuXi_o6LMe1zTWMrW1qYKaA@mail.gmail.com>
Hi Andrezj,
>>> ---
>>> android/hal-audio.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 72 insertions(+)
>>>
>>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>>> index f53dba0..e5c646c 100644
>>> --- a/android/hal-audio.c
>>> +++ b/android/hal-audio.c
>>> @@ -32,6 +32,7 @@
>>> #include "hal-log.h"
>>> #include "hal-msg.h"
>>> #include "../profiles/audio/a2dp-codecs.h"
>>> +#include <sbc/sbc.h>
>>>
>>> static const uint8_t a2dp_src_uuid[] = {
>>> 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x10, 0x00,
>>> @@ -53,6 +54,8 @@ struct audio_input_config {
>>>
>>> struct sbc_data {
>>> a2dp_sbc_t sbc;
>>> +
>>> + sbc_t enc;
>>> };
>>>
>>> static int sbc_get_presets(struct audio_preset *preset, size_t *len);
>>> @@ -184,6 +187,70 @@ static int sbc_get_presets(struct audio_preset *preset, size_t *len)
>>> return i;
>>> }
>>>
>>> +static void sbc_init_encoder(struct sbc_data *sbc_data)
>>> +{
>>> + a2dp_sbc_t *in = &sbc_data->sbc;
>>> + sbc_t *out = &sbc_data->enc;
>>> +
>>> + DBG("");
>>> +
>>> + sbc_init(out, 0L);
>>> +
>>> + switch (in->frequency) {
>>> + case SBC_SAMPLING_FREQ_16000:
>>> + out->frequency = SBC_FREQ_16000;
>>> + break;
>>> + case SBC_SAMPLING_FREQ_32000:
>>> + out->frequency = SBC_FREQ_32000;
>>> + break;
>>> + case SBC_SAMPLING_FREQ_44100:
>>> + out->frequency = SBC_FREQ_44100;
>>> + break;
>>> + case SBC_SAMPLING_FREQ_48000:
>>> + out->frequency = SBC_FREQ_48000;
>>> + break;
>>> + }
>>> +
>>> + out->subbands = in->subbands == SBC_SUBBANDS_4 ? SBC_SB_4 : SBC_SB_8;
>>> +
>>> + switch (in->channel_mode) {
>>> + case SBC_CHANNEL_MODE_MONO:
>>> + out->mode = SBC_MODE_MONO;
>>> + break;
>>> + case SBC_CHANNEL_MODE_DUAL_CHANNEL:
>>> + out->mode = SBC_MODE_DUAL_CHANNEL;
>>> + break;
>>> + case SBC_CHANNEL_MODE_JOINT_STEREO:
>>> + out->mode = SBC_MODE_JOINT_STEREO;
>>> + break;
>>> + case SBC_CHANNEL_MODE_STEREO:
>>> + out->mode = SBC_MODE_STEREO;
>>> + break;
>>> + }
>>> +
>>> + out->endian = SBC_LE;
>>> +
>>> + out->bitpool = in->max_bitpool;
>>> +
>>> + out->allocation = in->allocation_method == SBC_ALLOCATION_SNR ?
>>> + SBC_AM_SNR : SBC_AM_LOUDNESS;
>>> +
>>> + switch (in->block_length) {
>>> + case SBC_BLOCK_LENGTH_4:
>>> + out->blocks = SBC_BLK_4;
>>> + break;
>>> + case SBC_BLOCK_LENGTH_8:
>>> + out->blocks = SBC_BLK_8;
>>> + break;
>>> + case SBC_BLOCK_LENGTH_12:
>>> + out->blocks = SBC_BLK_12;
>>> + break;
>>> + case SBC_BLOCK_LENGTH_16:
>>> + out->blocks = SBC_BLK_16;
>>> + break;
>>> + }
>>
>> aren’t the values all the same? This looks pretty complicated for something that should be dead simple. Does Android really had to duplicate every single definition with the same prefix?
>
> Actually symbols for 'in' come from a2dp-codecs.h and 'out' from sbc.h
> ;-) And they have different values since A2DP uses shifted-bit values
> while sbc.h are just ordinal values so cannot assign them directly.
so this a problem we created by ourselves. Yeah. Seems no cookie for me tonight ;)
We need to start fixing a2dp-codecs.h then and prefix it with A2DP. This current situation is bad. Luiz?
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 4/9] android/hal-audio: Initialize SBC encoder
From: Andrzej Kaczmarek @ 2014-01-17 19:26 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <D34DEF28-690B-4697-B88F-B224F7583782@holtmann.org>
Hi Marcel,
On 17 January 2014 19:24, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Andrzej,
>
>> ---
>> android/hal-audio.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++=
++++++
>> 1 file changed, 72 insertions(+)
>>
>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>> index f53dba0..e5c646c 100644
>> --- a/android/hal-audio.c
>> +++ b/android/hal-audio.c
>> @@ -32,6 +32,7 @@
>> #include "hal-log.h"
>> #include "hal-msg.h"
>> #include "../profiles/audio/a2dp-codecs.h"
>> +#include <sbc/sbc.h>
>>
>> static const uint8_t a2dp_src_uuid[] =3D {
>> 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x10, 0x00,
>> @@ -53,6 +54,8 @@ struct audio_input_config {
>>
>> struct sbc_data {
>> a2dp_sbc_t sbc;
>> +
>> + sbc_t enc;
>> };
>>
>> static int sbc_get_presets(struct audio_preset *preset, size_t *len);
>> @@ -184,6 +187,70 @@ static int sbc_get_presets(struct audio_preset *pre=
set, size_t *len)
>> return i;
>> }
>>
>> +static void sbc_init_encoder(struct sbc_data *sbc_data)
>> +{
>> + a2dp_sbc_t *in =3D &sbc_data->sbc;
>> + sbc_t *out =3D &sbc_data->enc;
>> +
>> + DBG("");
>> +
>> + sbc_init(out, 0L);
>> +
>> + switch (in->frequency) {
>> + case SBC_SAMPLING_FREQ_16000:
>> + out->frequency =3D SBC_FREQ_16000;
>> + break;
>> + case SBC_SAMPLING_FREQ_32000:
>> + out->frequency =3D SBC_FREQ_32000;
>> + break;
>> + case SBC_SAMPLING_FREQ_44100:
>> + out->frequency =3D SBC_FREQ_44100;
>> + break;
>> + case SBC_SAMPLING_FREQ_48000:
>> + out->frequency =3D SBC_FREQ_48000;
>> + break;
>> + }
>> +
>> + out->subbands =3D in->subbands =3D=3D SBC_SUBBANDS_4 ? SBC_SB_4 : =
SBC_SB_8;
>> +
>> + switch (in->channel_mode) {
>> + case SBC_CHANNEL_MODE_MONO:
>> + out->mode =3D SBC_MODE_MONO;
>> + break;
>> + case SBC_CHANNEL_MODE_DUAL_CHANNEL:
>> + out->mode =3D SBC_MODE_DUAL_CHANNEL;
>> + break;
>> + case SBC_CHANNEL_MODE_JOINT_STEREO:
>> + out->mode =3D SBC_MODE_JOINT_STEREO;
>> + break;
>> + case SBC_CHANNEL_MODE_STEREO:
>> + out->mode =3D SBC_MODE_STEREO;
>> + break;
>> + }
>> +
>> + out->endian =3D SBC_LE;
>> +
>> + out->bitpool =3D in->max_bitpool;
>> +
>> + out->allocation =3D in->allocation_method =3D=3D SBC_ALLOCATION_SN=
R ?
>> + SBC_AM_SNR : SBC_AM_LOUDNESS;
>> +
>> + switch (in->block_length) {
>> + case SBC_BLOCK_LENGTH_4:
>> + out->blocks =3D SBC_BLK_4;
>> + break;
>> + case SBC_BLOCK_LENGTH_8:
>> + out->blocks =3D SBC_BLK_8;
>> + break;
>> + case SBC_BLOCK_LENGTH_12:
>> + out->blocks =3D SBC_BLK_12;
>> + break;
>> + case SBC_BLOCK_LENGTH_16:
>> + out->blocks =3D SBC_BLK_16;
>> + break;
>> + }
>
> aren=92t the values all the same? This looks pretty complicated for somet=
hing that should be dead simple. Does Android really had to duplicate every=
single definition with the same prefix?
Actually symbols for 'in' come from a2dp-codecs.h and 'out' from sbc.h
;-) And they have different values since A2DP uses shifted-bit values
while sbc.h are just ordinal values so cannot assign them directly.
BR,
Andrzej
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox