-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ofono not working anymore #640
Comments
Did you configure BlueALSA with --enable-msbc? If so, I think this may be a bug (in one of my patches 😞 ). Comparing ofono SCO connection acceptance with bluealsa native, I see that with --enable-msbc the native code "authorizes" the socket before getting the MTU for both codecs, but the ofono code only does so for mSBC codec. I suspect that would explain the
to:
|
no, no --enable-msbc was configured |
OK, then there is also some other error in the recent HFP changes. Please can you confirm which BlueALSA commit you were using with your "previously well working ofono setup" and I will try to see what else may have caused this error. If you could possibly do a git bisect to identify the exact commit that introduced this failure that would help speed up the investigation |
reflog: git show @@{1}..@@{0} |
Hmm, it seems that oFono uses BT_DEFER_SETUP on its SCO listen socket, even when mSBC is not supported. That means BlueALSA also has to "authorize" the accepted socket even when mSBC is not supported. That was my mistake - the original code did that, and my patchset removed it. I'll pepare a PR with a fix. In the meantime, please could you try this patch for me: diff --git a/src/ofono.c b/src/ofono.c
index c5dbb10..3e29f03 100644
--- a/src/ofono.c
+++ b/src/ofono.c
@@ -20,6 +20,7 @@
/* IWYU pragma: no_include "config.h" */
#include <errno.h>
+#include <poll.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
@@ -802,11 +803,18 @@ static void ofono_agent_new_connection(GDBusMethodInvocation *inv, void *userdat
}
/* For HF, oFono does not authorize after setting the voice option, so we
- * have to do it ourselves here. */
- if (t->profile == BA_TRANSPORT_PROFILE_HFP_HF &&
- codec == HFP_CODEC_MSBC) {
+ * may have to do it ourselves here. oFono always tries to set the
+ * BT_DEFER_SETUP option, but may not always succeed. So we must first
+ * check if the socket is in defered setup state before authorizing. */
+ if (t->profile == BA_TRANSPORT_PROFILE_HFP_HF) {
+ /* If socket is not writable, it means that it is in the defer setup
+ * state, so it needs to be read to authorize the connection. */
+ struct pollfd pfd = { fd, POLLOUT, 0 };
uint8_t auth;
- if (read(fd, &auth, sizeof(auth)) == -1) {
+
+ if (poll(&pfd, 1, 0) == -1)
+ goto fail;
+ if (!(pfd.revents & POLLOUT) && read(fd, &auth, sizeof(auth)) == -1) {
error("Couldn't authorize oFono SCO link: %s", strerror(errno));
goto fail;
} |
oops - sorry - I forgot to move that clause out of the diff --git a/src/ofono.c b/src/ofono.c
index c5dbb10..cc85e9d 100644
--- a/src/ofono.c
+++ b/src/ofono.c
@@ -20,6 +20,7 @@
/* IWYU pragma: no_include "config.h" */
#include <errno.h>
+#include <poll.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
@@ -801,17 +802,25 @@ static void ofono_agent_new_connection(GDBusMethodInvocation *inv, void *userdat
return;
}
+#endif
+
/* For HF, oFono does not authorize after setting the voice option, so we
- * have to do it ourselves here. */
- if (t->profile == BA_TRANSPORT_PROFILE_HFP_HF &&
- codec == HFP_CODEC_MSBC) {
+ * may have to do it ourselves here. oFono always tries to set the
+ * BT_DEFER_SETUP option, but may not always succeed. So we must first
+ * check if the socket is in defered setup state before authorizing. */
+ if (t->profile == BA_TRANSPORT_PROFILE_HFP_HF) {
+ /* If socket is not writable, it means that it is in the defer setup
+ * state, so it needs to be read to authorize the connection. */
+ struct pollfd pfd = { fd, POLLOUT, 0 };
uint8_t auth;
- if (read(fd, &auth, sizeof(auth)) == -1) {
+
+ if (poll(&pfd, 1, 0) == -1)
+ goto fail;
+ if (!(pfd.revents & POLLOUT) && read(fd, &auth, sizeof(auth)) == -1) {
error("Couldn't authorize oFono SCO link: %s", strerror(errno));
goto fail;
}
}
-#endif
ba_transport_stop(t); |
|
I'm not sure how to read the above log. It seems the |
yes - it seems to be working again - as you discribed, thank you |
That's great. I'll set up my own system to test it later next week, just to be sure, then I'll raise a PR to get this into master branch. Many thanks for taking time with this, and my apologies for not finding this error before raising the original PR. |
oh - the duplication is not clear how it occurs I'll check it again later |
after my latest git pull I have now suddenly problems with my previously well working ofono setup:
are there now minor changes or is this a bug?
The text was updated successfully, but these errors were encountered: