summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--system/gd/rust/topshim/btav/btav_shim.cc11
-rw-r--r--system/gd/rust/topshim/btav_sink/btav_sink_shim.cc11
2 files changed, 8 insertions, 14 deletions
diff --git a/system/gd/rust/topshim/btav/btav_shim.cc b/system/gd/rust/topshim/btav/btav_shim.cc
index 3838d03b66..eed0d54190 100644
--- a/system/gd/rust/topshim/btav/btav_shim.cc
+++ b/system/gd/rust/topshim/btav/btav_shim.cc
@@ -239,18 +239,15 @@ static ::rust::Vec<A2dpCodecConfig> to_rust_codec_config_vec(
return rconfigs;
}
-static A2dpError to_rust_error(const btav_error_t& error) {
+static void connection_state_cb(const RawAddress& addr, btav_connection_state_t state,
+ const btav_error_t& error) {
+ // CAUTION: The error_msg field is a reference and could refer to a rvalue on the stack.
+ // DO NOT make this conversion into a helper function.
A2dpError a2dp_error = {
.status = error.status,
.error_code = error.error_code,
.error_msg = error.error_msg.value_or(""),
};
- return a2dp_error;
-}
-
-static void connection_state_cb(const RawAddress& addr, btav_connection_state_t state,
- const btav_error_t& error) {
- A2dpError a2dp_error = to_rust_error(error);
rusty::connection_state_callback(addr, state, a2dp_error);
}
static void audio_state_cb(const RawAddress& addr, btav_audio_state_t state) {
diff --git a/system/gd/rust/topshim/btav_sink/btav_sink_shim.cc b/system/gd/rust/topshim/btav_sink/btav_sink_shim.cc
index 8b38b9b15a..d2999d9a2c 100644
--- a/system/gd/rust/topshim/btav_sink/btav_sink_shim.cc
+++ b/system/gd/rust/topshim/btav_sink/btav_sink_shim.cc
@@ -32,18 +32,15 @@ namespace rust {
namespace internal {
static A2dpSinkIntf* g_a2dp_sink_if;
-static A2dpError to_rust_error(const btav_error_t& error) {
+static void connection_state_cb(const RawAddress& addr, btav_connection_state_t state,
+ const btav_error_t& error) {
+ // CAUTION: The error_msg field is a reference and could refer to a rvalue on the stack.
+ // DO NOT make this conversion into a helper function.
A2dpError a2dp_error = {
.status = error.status,
.error_code = error.error_code,
.error_msg = error.error_msg.value_or(""),
};
- return a2dp_error;
-}
-
-static void connection_state_cb(const RawAddress& addr, btav_connection_state_t state,
- const btav_error_t& error) {
- A2dpError a2dp_error = to_rust_error(error);
rusty::sink_connection_state_callback(addr, state, a2dp_error);
}
static void audio_state_cb(const RawAddress& addr, btav_audio_state_t state) {