mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
bluetooth: pass output_rate_refresh_interval_ms module parameter
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/488>
This commit is contained in:
parent
c686215268
commit
c6309a9c18
3 changed files with 24 additions and 8 deletions
|
|
@ -23,6 +23,7 @@
|
||||||
#include <pulsecore/core.h>
|
#include <pulsecore/core.h>
|
||||||
|
|
||||||
#define MAX_A2DP_CAPS_SIZE 254
|
#define MAX_A2DP_CAPS_SIZE 254
|
||||||
|
#define DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS 500
|
||||||
|
|
||||||
typedef struct pa_a2dp_codec_capabilities {
|
typedef struct pa_a2dp_codec_capabilities {
|
||||||
uint8_t size;
|
uint8_t size;
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,11 @@ PA_MODULE_AUTHOR("João Paulo Rechi Vita");
|
||||||
PA_MODULE_DESCRIPTION("BlueZ 5 Bluetooth audio sink and source");
|
PA_MODULE_DESCRIPTION("BlueZ 5 Bluetooth audio sink and source");
|
||||||
PA_MODULE_VERSION(PACKAGE_VERSION);
|
PA_MODULE_VERSION(PACKAGE_VERSION);
|
||||||
PA_MODULE_LOAD_ONCE(false);
|
PA_MODULE_LOAD_ONCE(false);
|
||||||
PA_MODULE_USAGE("path=<device object path>"
|
PA_MODULE_USAGE(
|
||||||
"autodetect_mtu=<boolean>");
|
"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_A2DP (25 * PA_USEC_PER_MSEC)
|
||||||
#define FIXED_LATENCY_PLAYBACK_SCO (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 HSP_MAX_GAIN 15
|
||||||
|
|
||||||
#define DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS 500
|
|
||||||
|
|
||||||
static const char* const valid_modargs[] = {
|
static const char* const valid_modargs[] = {
|
||||||
"path",
|
"path",
|
||||||
"autodetect_mtu",
|
"autodetect_mtu",
|
||||||
|
"output_rate_refresh_interval_ms",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -2508,7 +2510,7 @@ int pa__init(pa_module* m) {
|
||||||
pa_modargs *ma;
|
pa_modargs *ma;
|
||||||
bool autodetect_mtu;
|
bool autodetect_mtu;
|
||||||
char *message_handler_path;
|
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);
|
pa_assert(m);
|
||||||
|
|
||||||
|
|
@ -2547,8 +2549,9 @@ int pa__init(pa_module* m) {
|
||||||
|
|
||||||
u->device->autodetect_mtu = autodetect_mtu;
|
u->device->autodetect_mtu = autodetect_mtu;
|
||||||
|
|
||||||
if (pa_modargs_get_value_u32(ma, "output-rate-refresh-interval-ms", &output_rate_refresh_interval_ms) < 0) {
|
output_rate_refresh_interval_ms = DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS;
|
||||||
pa_log("Invalid output_rate_refresh_interval.");
|
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;
|
goto fail_free_modargs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,13 @@ PA_MODULE_LOAD_ONCE(true);
|
||||||
PA_MODULE_USAGE(
|
PA_MODULE_USAGE(
|
||||||
"headset=ofono|native|auto"
|
"headset=ofono|native|auto"
|
||||||
"autodetect_mtu=<boolean>"
|
"autodetect_mtu=<boolean>"
|
||||||
|
"output_rate_refresh_interval_ms=<interval between attempts to improve output rate in milliseconds>"
|
||||||
);
|
);
|
||||||
|
|
||||||
static const char* const valid_modargs[] = {
|
static const char* const valid_modargs[] = {
|
||||||
"headset",
|
"headset",
|
||||||
"autodetect_mtu",
|
"autodetect_mtu",
|
||||||
|
"output_rate_refresh_interval_ms",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -52,6 +54,7 @@ struct userdata {
|
||||||
pa_hook_slot *device_connection_changed_slot;
|
pa_hook_slot *device_connection_changed_slot;
|
||||||
pa_bluetooth_discovery *discovery;
|
pa_bluetooth_discovery *discovery;
|
||||||
bool autodetect_mtu;
|
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) {
|
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)) {
|
if (!module_loaded && pa_bluetooth_device_any_transport_connected(d)) {
|
||||||
/* a new device has been connected */
|
/* a new device has been connected */
|
||||||
pa_module *m;
|
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_log_debug("Loading module-bluez5-device %s", args);
|
||||||
pa_module_load(&m, u->module->core, "module-bluez5-device", 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;
|
const char *headset_str;
|
||||||
int headset_backend;
|
int headset_backend;
|
||||||
bool autodetect_mtu;
|
bool autodetect_mtu;
|
||||||
|
uint32_t output_rate_refresh_interval_ms;
|
||||||
|
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
|
|
@ -131,10 +136,17 @@ int pa__init(pa_module *m) {
|
||||||
goto fail;
|
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);
|
m->userdata = u = pa_xnew0(struct userdata, 1);
|
||||||
u->module = m;
|
u->module = m;
|
||||||
u->core = m->core;
|
u->core = m->core;
|
||||||
u->autodetect_mtu = autodetect_mtu;
|
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);
|
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)))
|
if (!(u->discovery = pa_bluetooth_discovery_get(u->core, headset_backend)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue