[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] bluetooth: pass output_rate_refresh_interval_ms module parameter

PulseAudio Marge Bot gitlab at gitlab.freedesktop.org
Tue Jan 26 15:40:22 UTC 2021



PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio


Commits:
c6309a9c by Igor V. Kovalenko at 2021-01-26T10:01:47+03:00
bluetooth: pass output_rate_refresh_interval_ms module parameter

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/488>

- - - - -


3 changed files:

- src/modules/bluetooth/a2dp-codec-api.h
- src/modules/bluetooth/module-bluez5-device.c
- src/modules/bluetooth/module-bluez5-discover.c


Changes:

=====================================
src/modules/bluetooth/a2dp-codec-api.h
=====================================
@@ -23,6 +23,7 @@
 #include <pulsecore/core.h>
 
 #define MAX_A2DP_CAPS_SIZE 254
+#define DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS 500
 
 typedef struct pa_a2dp_codec_capabilities {
     uint8_t size;


=====================================
src/modules/bluetooth/module-bluez5-device.c
=====================================
@@ -56,8 +56,11 @@ PA_MODULE_AUTHOR("João Paulo Rechi Vita");
 PA_MODULE_DESCRIPTION("BlueZ 5 Bluetooth audio sink and source");
 PA_MODULE_VERSION(PACKAGE_VERSION);
 PA_MODULE_LOAD_ONCE(false);
-PA_MODULE_USAGE("path=<device object path>"
-                "autodetect_mtu=<boolean>");
+PA_MODULE_USAGE(
+    "path=<device object path>"
+    "autodetect_mtu=<boolean>"
+    "output_rate_refresh_interval_ms=<interval between attempts to improve output rate in milliseconds>"
+);
 
 #define FIXED_LATENCY_PLAYBACK_A2DP (25 * PA_USEC_PER_MSEC)
 #define FIXED_LATENCY_PLAYBACK_SCO  (25 * PA_USEC_PER_MSEC)
@@ -66,11 +69,10 @@ PA_MODULE_USAGE("path=<device object path>"
 
 #define HSP_MAX_GAIN 15
 
-#define DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS 500
-
 static const char* const valid_modargs[] = {
     "path",
     "autodetect_mtu",
+    "output_rate_refresh_interval_ms",
     NULL
 };
 
@@ -2508,7 +2510,7 @@ int pa__init(pa_module* m) {
     pa_modargs *ma;
     bool autodetect_mtu;
     char *message_handler_path;
-    uint32_t output_rate_refresh_interval_ms = DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS;
+    uint32_t output_rate_refresh_interval_ms;
 
     pa_assert(m);
 
@@ -2547,8 +2549,9 @@ int pa__init(pa_module* m) {
 
     u->device->autodetect_mtu = autodetect_mtu;
 
-    if (pa_modargs_get_value_u32(ma, "output-rate-refresh-interval-ms", &output_rate_refresh_interval_ms) < 0) {
-        pa_log("Invalid output_rate_refresh_interval.");
+    output_rate_refresh_interval_ms = DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS;
+    if (pa_modargs_get_value_u32(ma, "output_rate_refresh_interval_ms", &output_rate_refresh_interval_ms) < 0) {
+        pa_log("Invalid value for output_rate_refresh_interval parameter.");
         goto fail_free_modargs;
     }
 


=====================================
src/modules/bluetooth/module-bluez5-discover.c
=====================================
@@ -37,11 +37,13 @@ PA_MODULE_LOAD_ONCE(true);
 PA_MODULE_USAGE(
     "headset=ofono|native|auto"
     "autodetect_mtu=<boolean>"
+    "output_rate_refresh_interval_ms=<interval between attempts to improve output rate in milliseconds>"
 );
 
 static const char* const valid_modargs[] = {
     "headset",
     "autodetect_mtu",
+    "output_rate_refresh_interval_ms",
     NULL
 };
 
@@ -52,6 +54,7 @@ struct userdata {
     pa_hook_slot *device_connection_changed_slot;
     pa_bluetooth_discovery *discovery;
     bool autodetect_mtu;
+    uint32_t output_rate_refresh_interval_ms;
 };
 
 static pa_hook_result_t device_connection_changed_cb(pa_bluetooth_discovery *y, const pa_bluetooth_device *d, struct userdata *u) {
@@ -74,7 +77,8 @@ static pa_hook_result_t device_connection_changed_cb(pa_bluetooth_discovery *y,
     if (!module_loaded && pa_bluetooth_device_any_transport_connected(d)) {
         /* a new device has been connected */
         pa_module *m;
-        char *args = pa_sprintf_malloc("path=%s autodetect_mtu=%i", d->path, (int)u->autodetect_mtu);
+        char *args = pa_sprintf_malloc("path=%s autodetect_mtu=%i output_rate_refresh_interval_ms=%u",
+                                       d->path, (int)u->autodetect_mtu, u->output_rate_refresh_interval_ms);
 
         pa_log_debug("Loading module-bluez5-device %s", args);
         pa_module_load(&m, u->module->core, "module-bluez5-device", args);
@@ -105,6 +109,7 @@ int pa__init(pa_module *m) {
     const char *headset_str;
     int headset_backend;
     bool autodetect_mtu;
+    uint32_t output_rate_refresh_interval_ms;
 
     pa_assert(m);
 
@@ -131,10 +136,17 @@ int pa__init(pa_module *m) {
         goto fail;
     }
 
+    output_rate_refresh_interval_ms = DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS;
+    if (pa_modargs_get_value_u32(ma, "output_rate_refresh_interval_ms", &output_rate_refresh_interval_ms) < 0) {
+        pa_log("Invalid value for output_rate_refresh_interval parameter.");
+        goto fail;
+    }
+
     m->userdata = u = pa_xnew0(struct userdata, 1);
     u->module = m;
     u->core = m->core;
     u->autodetect_mtu = autodetect_mtu;
+    u->output_rate_refresh_interval_ms = output_rate_refresh_interval_ms;
     u->loaded_device_paths = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
 
     if (!(u->discovery = pa_bluetooth_discovery_get(u->core, headset_backend)))



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/c6309a9c186cc185459d6fbcc9ec1f3a67b256ef

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/c6309a9c186cc185459d6fbcc9ec1f3a67b256ef
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20210126/56213399/attachment-0001.htm>


More information about the pulseaudio-commits mailing list