Skip to content

Commit

Permalink
chore: Add pipewire spec file with Valve's patches
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo committed Dec 6, 2023
1 parent 162dd80 commit 12c4f12
Show file tree
Hide file tree
Showing 5 changed files with 1,711 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
diff --git a/spa/plugins/bluez5/backend-native.c b/spa/plugins/bluez5/backend-native.c
index 8144b09..51331a6 100644
--- a/spa/plugins/bluez5/backend-native.c
+++ b/spa/plugins/bluez5/backend-native.c
@@ -422,7 +422,7 @@ static void rfcomm_emit_volume_changed(struct rfcomm *rfcomm, int id, int hw_vol
static bool rfcomm_hsp_ag(struct rfcomm *rfcomm, char* buf)
{
struct impl *backend = rfcomm->backend;
- unsigned int gain, dummy;
+ unsigned int gain;

/* There are only three HSP AT commands:
* AT+VGS=value: value between 0 and 15, sent by the HS to AG to set the speaker gain.
@@ -445,8 +445,9 @@ static bool rfcomm_hsp_ag(struct rfcomm *rfcomm, char* buf)
rfcomm_send_reply(rfcomm, "ERROR");
spa_log_debug(backend->log, "RFCOMM receive unsupported VGM gain: %s", buf);
}
- } else if (sscanf(buf, "AT+CKPD=%d", &dummy) == 1) {
+ } else if (spa_strstartswith(buf, "AT+CKPD=200") == 1) {
rfcomm_send_reply(rfcomm, "OK");
+ spa_bt_device_emit_switch_profile(rfcomm->device);
} else {
return false;
}
diff --git a/spa/plugins/bluez5/bluez5-device.c b/spa/plugins/bluez5/bluez5-device.c
index 8d6ef49..40acd24 100644
--- a/spa/plugins/bluez5/bluez5-device.c
+++ b/spa/plugins/bluez5/bluez5-device.c
@@ -1370,11 +1370,33 @@ static void device_connected(void *userdata, bool connected)
}
}

+static void device_switch_profile(void *userdata)
+{
+ struct impl *this = userdata;
+ uint32_t profile;
+
+ switch(this->profile) {
+ case DEVICE_PROFILE_OFF:
+ profile = DEVICE_PROFILE_HSP_HFP;
+ break;
+ case DEVICE_PROFILE_HSP_HFP:
+ profile = DEVICE_PROFILE_OFF;
+ break;
+ default:
+ return;
+ }
+
+ spa_log_debug(this->log, "%p: device switch profile %d -> %d", this, this->profile, profile);
+
+ set_profile(this, profile, 0, false);
+}
+
static const struct spa_bt_device_events bt_dev_events = {
SPA_VERSION_BT_DEVICE_EVENTS,
.connected = device_connected,
.codec_switched = codec_switched,
.profiles_changed = profiles_changed,
+ .switch_profile = device_switch_profile,
.device_set_changed = device_set_changed,
};

diff --git a/spa/plugins/bluez5/defs.h b/spa/plugins/bluez5/defs.h
index 81e5164..258b4f6 100644
--- a/spa/plugins/bluez5/defs.h
+++ b/spa/plugins/bluez5/defs.h
@@ -459,6 +459,9 @@ struct spa_bt_device_events {
/** Profile configuration changed */
void (*profiles_changed) (void *data, uint32_t prev_profiles, uint32_t prev_connected);

+ /** Switch profile between OFF and HSP_HFP */
+ void (*switch_profile) (void *data);
+
/** Device set configuration changed */
void (*device_set_changed) (void *data);

@@ -553,6 +556,7 @@ void spa_bt_device_update_last_bluez_action_time(struct spa_bt_device *device);
#define spa_bt_device_emit_connected(d,...) spa_bt_device_emit(d, connected, 0, __VA_ARGS__)
#define spa_bt_device_emit_codec_switched(d,...) spa_bt_device_emit(d, codec_switched, 0, __VA_ARGS__)
#define spa_bt_device_emit_profiles_changed(d,...) spa_bt_device_emit(d, profiles_changed, 0, __VA_ARGS__)
+#define spa_bt_device_emit_switch_profile(d) spa_bt_device_emit(d, switch_profile, 0)
#define spa_bt_device_emit_device_set_changed(d) spa_bt_device_emit(d, device_set_changed, 0)
#define spa_bt_device_emit_destroy(d) spa_bt_device_emit(d, destroy, 0)
#define spa_bt_device_add_listener(d,listener,events,data) \
13 changes: 13 additions & 0 deletions spec_files/pipewire/acf7c0af0bf31b937c41e916a73c67ae0a253632.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/spa/plugins/alsa/alsa-pcm.h b/spa/plugins/alsa/alsa-pcm.h
index c3cfe0e..fa75809 100644
--- a/spa/plugins/alsa/alsa-pcm.h
+++ b/spa/plugins/alsa/alsa-pcm.h
@@ -66,7 +66,7 @@ struct buffer {
#define BW_MAX 0.128
#define BW_MED 0.064
#define BW_MIN 0.016
-#define BW_PERIOD (3 * SPA_NSEC_PER_SEC)
+#define BW_PERIOD (4 * SPA_NSEC_PER_SEC)

struct channel_map {
uint32_t channels;
13 changes: 13 additions & 0 deletions spec_files/pipewire/bc435841c141ad38768b6cb1a7ad45e8bb13c7d2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/modules/module-echo-cancel.c b/src/modules/module-echo-cancel.c
index 7b33c47..def6476 100644
--- a/src/modules/module-echo-cancel.c
+++ b/src/modules/module-echo-cancel.c
@@ -1243,7 +1243,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
goto error;
}

- impl->monitor_mode = false;
+ impl->monitor_mode = true;
if ((str = pw_properties_get(props, "monitor.mode")) != NULL)
impl->monitor_mode = pw_properties_parse_bool(str);

Loading

0 comments on commit 12c4f12

Please sign in to comment.