* [PATCH v4 01/12] include: Voice recognition in handsfree public api
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 02/12] handsfree: Implement voice recognition function Mikel Astiz
` (11 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1298 bytes --]
---
include/handsfree.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/handsfree.h b/include/handsfree.h
index 4882352..1559ba1 100644
--- a/include/handsfree.h
+++ b/include/handsfree.h
@@ -31,6 +31,8 @@ extern "C" {
struct ofono_handsfree;
+typedef void (*ofono_handsfree_cb_t)(const struct ofono_error *error,
+ void *data);
typedef void (*ofono_handsfree_phone_cb_t)(const struct ofono_error *error,
const struct ofono_phone_number *number,
void *data);
@@ -43,12 +45,17 @@ struct ofono_handsfree_driver {
void (*request_phone_number) (struct ofono_handsfree *hf,
ofono_handsfree_phone_cb_t cb,
void *data);
+ void (*voice_recognition)(struct ofono_handsfree *hf,
+ ofono_bool_t enabled,
+ ofono_handsfree_cb_t cb, void *data);
};
void ofono_handsfree_set_ag_features(struct ofono_handsfree *hf,
unsigned int ag_features);
void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
ofono_bool_t enabled);
+void ofono_handsfree_voice_recognition_notify(struct ofono_handsfree *hf,
+ ofono_bool_t enabled);
int ofono_handsfree_driver_register(const struct ofono_handsfree_driver *d);
void ofono_handsfree_driver_unregister(
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v4 02/12] handsfree: Implement voice recognition function
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 01/12] include: Voice recognition in handsfree public api Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 03/12] hfpmodem: Support for AT+BVRA Mikel Astiz
` (10 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3897 bytes --]
---
src/handsfree.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/src/handsfree.c b/src/handsfree.c
index efebcc0..24f2349 100644
--- a/src/handsfree.c
+++ b/src/handsfree.c
@@ -45,6 +45,9 @@ static GSList *g_drivers = NULL;
struct ofono_handsfree {
ofono_bool_t inband_ringing;
+ ofono_bool_t voice_recognition;
+ ofono_bool_t voice_recognition_pending;
+
const struct ofono_handsfree_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -72,6 +75,24 @@ void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
&dbus_enabled);
}
+void ofono_handsfree_voice_recognition_notify(struct ofono_handsfree *hf,
+ ofono_bool_t enabled)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(hf->atom);
+ dbus_bool_t dbus_enabled = enabled;
+
+ if (hf->voice_recognition == enabled)
+ return;
+
+ hf->voice_recognition = enabled;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_HANDSFREE_INTERFACE,
+ "VoiceRecognition", DBUS_TYPE_BOOLEAN,
+ &dbus_enabled);
+}
+
static DBusMessage *handsfree_get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -80,6 +101,7 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
DBusMessageIter iter;
DBusMessageIter dict;
dbus_bool_t inband_ringing;
+ dbus_bool_t voice_recognition;
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -95,17 +117,49 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
ofono_dbus_dict_append(&dict, "InbandRinging", DBUS_TYPE_BOOLEAN,
&inband_ringing);
+ voice_recognition = hf->voice_recognition;
+ ofono_dbus_dict_append(&dict, "VoiceRecognition", DBUS_TYPE_BOOLEAN,
+ &voice_recognition);
+
dbus_message_iter_close_container(&iter, &dict);
return reply;
}
+static void voicerec_set_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_handsfree *hf = data;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(hf->atom);
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ __ofono_dbus_pending_reply(&hf->pending,
+ __ofono_error_failed(hf->pending));
+ return;
+ }
+
+ hf->voice_recognition = hf->voice_recognition_pending;
+
+ __ofono_dbus_pending_reply(&hf->pending,
+ dbus_message_new_method_return(hf->pending));
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_HANDSFREE_INTERFACE,
+ "VoiceRecognition",
+ DBUS_TYPE_BOOLEAN,
+ &hf->voice_recognition);
+}
+
static DBusMessage *handsfree_set_property(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct ofono_handsfree *hf = data;
DBusMessageIter iter, var;
const char *name;
+ if (hf->pending)
+ return __ofono_error_busy(msg);
+
if (dbus_message_iter_init(msg, &iter) == FALSE)
return __ofono_error_invalid_args(msg);
@@ -120,6 +174,27 @@ static DBusMessage *handsfree_set_property(DBusConnection *conn,
dbus_message_iter_recurse(&iter, &var);
+ if (g_str_equal(name, "VoiceRecognition") == TRUE) {
+ ofono_bool_t enabled;
+
+ if (!hf->driver->voice_recognition)
+ return __ofono_error_not_implemented(msg);
+
+ if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&var, &enabled);
+
+ if (hf->voice_recognition == enabled)
+ return dbus_message_new_method_return(msg);
+
+ hf->voice_recognition_pending = enabled;
+ hf->pending = dbus_message_ref(msg);
+ hf->driver->voice_recognition(hf, enabled, voicerec_set_cb, hf);
+
+ return NULL;
+ }
+
return __ofono_error_invalid_args(msg);
}
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v4 03/12] hfpmodem: Support for AT+BVRA
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 01/12] include: Voice recognition in handsfree public api Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 02/12] handsfree: Implement voice recognition function Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 04/12] doc: Handsfree exposes supported AG features Mikel Astiz
` (9 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2896 bytes --]
---
drivers/hfpmodem/handsfree.c | 53 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/drivers/hfpmodem/handsfree.c b/drivers/hfpmodem/handsfree.c
index 54a5fba..ad656ce 100644
--- a/drivers/hfpmodem/handsfree.c
+++ b/drivers/hfpmodem/handsfree.c
@@ -43,12 +43,25 @@
#include "slc.h"
static const char *binp_prefix[] = { "+BINP:", NULL };
+static const char *bvra_prefix[] = { "+BVRA:", NULL };
struct hf_data {
GAtChat *chat;
unsigned int ag_features;
};
+static void hf_generic_set_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_handsfree_cb_t cb = cbd->cb;
+ struct ofono_error error;
+
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ cb(&error, cbd->data);
+}
+
static void bsir_notify(GAtResult *result, gpointer user_data)
{
struct ofono_handsfree *hf = user_data;
@@ -66,12 +79,30 @@ static void bsir_notify(GAtResult *result, gpointer user_data)
ofono_handsfree_set_inband_ringing(hf, (ofono_bool_t) value);
}
+static void bvra_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_handsfree *hf = user_data;
+ GAtResultIter iter;
+ int value;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+BVRA:"))
+ return;
+
+ if (!g_at_result_iter_next_number(&iter, &value))
+ return;
+
+ ofono_handsfree_voice_recognition_notify(hf, (ofono_bool_t) value);
+}
+
static gboolean hfp_handsfree_register(gpointer user_data)
{
struct ofono_handsfree *hf = user_data;
struct hf_data *hd = ofono_handsfree_get_data(hf);
g_at_chat_register(hd->chat, "+BSIR:", bsir_notify, FALSE, hf, NULL);
+ g_at_chat_register(hd->chat, "+BVRA:", bvra_notify, FALSE, hf, NULL);
if (hd->ag_features & HFP_AG_FEATURE_IN_BAND_RING_TONE)
ofono_handsfree_set_inband_ringing(hf, TRUE);
@@ -169,11 +200,33 @@ static void hfp_request_phone_number(struct ofono_handsfree *hf,
CALLBACK_WITH_FAILURE(cb, NULL, data);
}
+static void hfp_voice_recognition(struct ofono_handsfree *hf,
+ ofono_bool_t enabled,
+ ofono_handsfree_cb_t cb, void *data)
+{
+ struct hf_data *hd = ofono_handsfree_get_data(hf);
+ struct cb_data *cbd = cb_data_new(cb, data);
+ char buf[64];
+
+ snprintf(buf, sizeof(buf), "AT+BVRA=%d",
+ (int)(enabled));
+
+ if (g_at_chat_send(hd->chat, buf, bvra_prefix,
+ hf_generic_set_cb,
+ cbd, g_free) > 0)
+ return;
+
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, data);
+}
+
static struct ofono_handsfree_driver driver = {
.name = "hfpmodem",
.probe = hfp_handsfree_probe,
.remove = hfp_handsfree_remove,
.request_phone_number = hfp_request_phone_number,
+ .voice_recognition = hfp_voice_recognition,
};
void hfp_handsfree_init(void)
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v4 04/12] doc: Handsfree exposes supported AG features
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (2 preceding siblings ...)
2011-10-21 16:51 ` [PATCH v4 03/12] hfpmodem: Support for AT+BVRA Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 05/12] handsfree: Supported AG features exposed in D-Bus Mikel Astiz
` (8 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 791 bytes --]
---
doc/handsfree-api.txt | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/doc/handsfree-api.txt b/doc/handsfree-api.txt
index 9355946..7f9deec 100644
--- a/doc/handsfree-api.txt
+++ b/doc/handsfree-api.txt
@@ -38,7 +38,14 @@ Signals PropertyChanged(string property, variant value)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.
-Properties boolean InbandRinging [readonly]
+Properties array{string} Features [readonly]
+
+ List of features supported by the AG. The currently
+ supported values are:
+ "voice-recognition"
+ "attach-voice-tag"
+
+ boolean InbandRinging [readonly]
Boolean representing whether inband ringing is enabled.
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v4 05/12] handsfree: Supported AG features exposed in D-Bus
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (3 preceding siblings ...)
2011-10-21 16:51 ` [PATCH v4 04/12] doc: Handsfree exposes supported AG features Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 19:32 ` Denis Kenzior
2011-10-21 16:51 ` [PATCH v4 06/12] hfpmodem: Report features supported by AG Mikel Astiz
` (7 subsequent siblings)
12 siblings, 1 reply; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2690 bytes --]
---
src/handsfree.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/src/handsfree.c b/src/handsfree.c
index 24f2349..27af31c 100644
--- a/src/handsfree.c
+++ b/src/handsfree.c
@@ -41,9 +41,12 @@
#include "ofono.h"
#include "common.h"
+#define MAX_AG_FEATURE_COUNT 32
+
static GSList *g_drivers = NULL;
struct ofono_handsfree {
+ unsigned int ag_features;
ofono_bool_t inband_ringing;
ofono_bool_t voice_recognition;
ofono_bool_t voice_recognition_pending;
@@ -54,6 +57,54 @@ struct ofono_handsfree {
DBusMessage *pending;
};
+static void append_ag_features(struct ofono_handsfree *hf, char **features)
+{
+ unsigned int bit;
+ int feature_count = 0;
+
+ for (bit = 1; bit != 0; bit <<= 1) {
+ if (hf->ag_features & bit) {
+ char *name = NULL;
+
+ switch ((enum hfp_ag_feature) bit) {
+ case HFP_AG_FEATURE_VOICE_RECOG:
+ name = "voice-recognition";
+ break;
+ case HFP_AG_FEATURE_ATTACH_VOICE_TAG:
+ name = "attach-voice-tag";
+ break;
+ default:
+ continue;
+ }
+
+ features[feature_count++] = name;
+ }
+ }
+
+ features[feature_count] = NULL;
+}
+
+void ofono_handsfree_set_ag_features(struct ofono_handsfree *hf,
+ unsigned int ag_features)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(hf->atom);
+ char **features;
+
+ if (hf->ag_features == ag_features)
+ return;
+
+ hf->ag_features = ag_features;
+
+ features = g_new0(char *, MAX_AG_FEATURE_COUNT + 1);
+ append_ag_features(hf, features);
+ ofono_dbus_signal_array_property_changed(conn, path,
+ OFONO_HANDSFREE_INTERFACE,
+ "Features", DBUS_TYPE_STRING,
+ &features);
+ g_free(features);
+}
+
void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
ofono_bool_t enabled)
{
@@ -102,6 +153,7 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
DBusMessageIter dict;
dbus_bool_t inband_ringing;
dbus_bool_t voice_recognition;
+ char **features;
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -121,6 +173,12 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
ofono_dbus_dict_append(&dict, "VoiceRecognition", DBUS_TYPE_BOOLEAN,
&voice_recognition);
+ features = g_new0(char *, MAX_AG_FEATURE_COUNT + 1);
+ append_ag_features(hf, features);
+ ofono_dbus_dict_append_array(&dict, "Features", DBUS_TYPE_STRING,
+ &features);
+ g_free(features);
+
dbus_message_iter_close_container(&iter, &dict);
return reply;
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH v4 05/12] handsfree: Supported AG features exposed in D-Bus
2011-10-21 16:51 ` [PATCH v4 05/12] handsfree: Supported AG features exposed in D-Bus Mikel Astiz
@ 2011-10-21 19:32 ` Denis Kenzior
0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-10-21 19:32 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3487 bytes --]
Hi Mikel,
On 10/21/2011 11:51 AM, Mikel Astiz wrote:
> ---
> src/handsfree.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 58 insertions(+), 0 deletions(-)
>
> diff --git a/src/handsfree.c b/src/handsfree.c
> index 24f2349..27af31c 100644
> --- a/src/handsfree.c
> +++ b/src/handsfree.c
> @@ -41,9 +41,12 @@
> #include "ofono.h"
> #include "common.h"
>
> +#define MAX_AG_FEATURE_COUNT 32
> +
So you probably meant 33 here right?
> static GSList *g_drivers = NULL;
>
> struct ofono_handsfree {
> + unsigned int ag_features;
> ofono_bool_t inband_ringing;
> ofono_bool_t voice_recognition;
> ofono_bool_t voice_recognition_pending;
> @@ -54,6 +57,54 @@ struct ofono_handsfree {
> DBusMessage *pending;
> };
>
> +static void append_ag_features(struct ofono_handsfree *hf, char **features)
> +{
> + unsigned int bit;
> + int feature_count = 0;
> +
> + for (bit = 1; bit != 0; bit <<= 1) {
> + if (hf->ag_features & bit) {
> + char *name = NULL;
> +
> + switch ((enum hfp_ag_feature) bit) {
> + case HFP_AG_FEATURE_VOICE_RECOG:
> + name = "voice-recognition";
> + break;
> + case HFP_AG_FEATURE_ATTACH_VOICE_TAG:
> + name = "attach-voice-tag";
> + break;
> + default:
> + continue;
> + }
> +
> + features[feature_count++] = name;
> + }
> + }
> +
> + features[feature_count] = NULL;
> +}
> +
This function seemed way too complicated for what you were trying to
accomplish.
> +void ofono_handsfree_set_ag_features(struct ofono_handsfree *hf,
> + unsigned int ag_features)
> +{
> + DBusConnection *conn = ofono_dbus_get_connection();
> + const char *path = __ofono_atom_get_path(hf->atom);
> + char **features;
> +
> + if (hf->ag_features == ag_features)
> + return;
> +
> + hf->ag_features = ag_features;
> +
> + features = g_new0(char *, MAX_AG_FEATURE_COUNT + 1);
> + append_ag_features(hf, features);
> + ofono_dbus_signal_array_property_changed(conn, path,
> + OFONO_HANDSFREE_INTERFACE,
> + "Features", DBUS_TYPE_STRING,
> + &features);
> + g_free(features);
I also didn't like this part. The AG features should be set by the atom
driver prior to calling ofono_handsfree_register. And since the BRSF
cannot be changed during the lifetime of the atom, there's no need for
signaling the property and the rest of the logic in this implementation.
> +}
> +
> void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
> ofono_bool_t enabled)
> {
> @@ -102,6 +153,7 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
> DBusMessageIter dict;
> dbus_bool_t inband_ringing;
> dbus_bool_t voice_recognition;
> + char **features;
>
> reply = dbus_message_new_method_return(msg);
> if (reply == NULL)
> @@ -121,6 +173,12 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
> ofono_dbus_dict_append(&dict, "VoiceRecognition", DBUS_TYPE_BOOLEAN,
> &voice_recognition);
>
> + features = g_new0(char *, MAX_AG_FEATURE_COUNT + 1);
> + append_ag_features(hf, features);
> + ofono_dbus_dict_append_array(&dict, "Features", DBUS_TYPE_STRING,
> + &features);
> + g_free(features);
> +
> dbus_message_iter_close_container(&iter, &dict);
>
> return reply;
I went ahead and pushed my own version of this patch. Please review it
and let me know if you find any problems.
Regards,
-Denis
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v4 06/12] hfpmodem: Report features supported by AG
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (4 preceding siblings ...)
2011-10-21 16:51 ` [PATCH v4 05/12] handsfree: Supported AG features exposed in D-Bus Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 07/12] hfpmodem: Avoid segfault in network-registration Mikel Astiz
` (6 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 593 bytes --]
---
drivers/hfpmodem/handsfree.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/hfpmodem/handsfree.c b/drivers/hfpmodem/handsfree.c
index ad656ce..984708d 100644
--- a/drivers/hfpmodem/handsfree.c
+++ b/drivers/hfpmodem/handsfree.c
@@ -107,6 +107,7 @@ static gboolean hfp_handsfree_register(gpointer user_data)
if (hd->ag_features & HFP_AG_FEATURE_IN_BAND_RING_TONE)
ofono_handsfree_set_inband_ringing(hf, TRUE);
+ ofono_handsfree_set_ag_features(hf, hd->ag_features);
ofono_handsfree_register(hf);
return FALSE;
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v4 07/12] hfpmodem: Avoid segfault in network-registration
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (5 preceding siblings ...)
2011-10-21 16:51 ` [PATCH v4 06/12] hfpmodem: Report features supported by AG Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 08/12] hfpmodem: Avoid segfault in call-volume Mikel Astiz
` (5 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1633 bytes --]
The use of g_idle_add can cause a segmentation fault if the object is
destroyed in the meantime.
---
drivers/hfpmodem/network-registration.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/drivers/hfpmodem/network-registration.c b/drivers/hfpmodem/network-registration.c
index da7d8eb..4b9f875 100644
--- a/drivers/hfpmodem/network-registration.c
+++ b/drivers/hfpmodem/network-registration.c
@@ -51,6 +51,7 @@ struct netreg_data {
GAtChat *chat;
unsigned char cind_pos[HFP_INDICATOR_LAST];
int cind_val[HFP_INDICATOR_LAST];
+ guint register_source;
};
static void cops_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -297,6 +298,9 @@ static void hfp_signal_strength(struct ofono_netreg *netreg,
static gboolean hfp_netreg_register(gpointer user_data)
{
struct ofono_netreg *netreg = user_data;
+ struct netreg_data *nd = ofono_netreg_get_data(netreg);
+
+ nd->register_source = 0;
ofono_netreg_register(netreg);
@@ -320,7 +324,7 @@ static int hfp_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
g_at_chat_register(nd->chat, "+CIEV:", ciev_notify, FALSE,
netreg, NULL);
- g_idle_add(hfp_netreg_register, netreg);
+ nd->register_source = g_idle_add(hfp_netreg_register, netreg);
return 0;
}
@@ -329,6 +333,9 @@ static void hfp_netreg_remove(struct ofono_netreg *netreg)
{
struct netreg_data *nd = ofono_netreg_get_data(netreg);
+ if (nd->register_source != 0)
+ g_source_remove(nd->register_source);
+
ofono_netreg_set_data(netreg, NULL);
g_at_chat_unref(nd->chat);
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v4 08/12] hfpmodem: Avoid segfault in call-volume
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (6 preceding siblings ...)
2011-10-21 16:51 ` [PATCH v4 07/12] hfpmodem: Avoid segfault in network-registration Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 09/12] hfpmodem: Avoid segfault in handsfree Mikel Astiz
` (4 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1454 bytes --]
The use of g_idle_add can cause a segmentation fault if the object is
destroyed in the meantime.
---
drivers/hfpmodem/call-volume.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/hfpmodem/call-volume.c b/drivers/hfpmodem/call-volume.c
index 504b0a5..0d7431e 100644
--- a/drivers/hfpmodem/call-volume.c
+++ b/drivers/hfpmodem/call-volume.c
@@ -50,6 +50,7 @@ struct cv_data {
GAtChat *chat;
unsigned char sp_volume;
unsigned char mic_volume;
+ guint register_source;
};
static void cv_generic_set_cb(gboolean ok, GAtResult *result,
@@ -173,6 +174,8 @@ static gboolean hfp_call_volume_register(gpointer user_data)
DBG("");
+ vd->register_source = 0;
+
g_at_chat_register(vd->chat, "+VGS:", vgs_notify, FALSE, cv, NULL);
g_at_chat_register(vd->chat, "+VGM:", vgm_notify, FALSE, cv, NULL);
@@ -197,7 +200,7 @@ static int hfp_call_volume_probe(struct ofono_call_volume *cv,
ofono_call_volume_set_data(cv, vd);
- g_idle_add(hfp_call_volume_register, cv);
+ vd->register_source = g_idle_add(hfp_call_volume_register, cv);
return 0;
}
@@ -206,6 +209,9 @@ static void hfp_call_volume_remove(struct ofono_call_volume *cv)
{
struct cv_data *vd = ofono_call_volume_get_data(cv);
+ if (vd->register_source != 0)
+ g_source_remove(vd->register_source);
+
ofono_call_volume_set_data(cv, NULL);
g_at_chat_unref(vd->chat);
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v4 09/12] hfpmodem: Avoid segfault in handsfree
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (7 preceding siblings ...)
2011-10-21 16:51 ` [PATCH v4 08/12] hfpmodem: Avoid segfault in call-volume Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 10/12] devinfo: avoid crash if query_model not supported Mikel Astiz
` (3 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1539 bytes --]
The use of g_idle_add can cause a segmentation fault if the object is
destroyed in the meantime.
---
drivers/hfpmodem/handsfree.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/hfpmodem/handsfree.c b/drivers/hfpmodem/handsfree.c
index 984708d..abe2ad2 100644
--- a/drivers/hfpmodem/handsfree.c
+++ b/drivers/hfpmodem/handsfree.c
@@ -48,6 +48,7 @@ static const char *bvra_prefix[] = { "+BVRA:", NULL };
struct hf_data {
GAtChat *chat;
unsigned int ag_features;
+ guint register_source;
};
static void hf_generic_set_cb(gboolean ok, GAtResult *result,
@@ -101,6 +102,8 @@ static gboolean hfp_handsfree_register(gpointer user_data)
struct ofono_handsfree *hf = user_data;
struct hf_data *hd = ofono_handsfree_get_data(hf);
+ hd->register_source = 0;
+
g_at_chat_register(hd->chat, "+BSIR:", bsir_notify, FALSE, hf, NULL);
g_at_chat_register(hd->chat, "+BVRA:", bvra_notify, FALSE, hf, NULL);
@@ -126,7 +129,7 @@ static int hfp_handsfree_probe(struct ofono_handsfree *hf,
ofono_handsfree_set_data(hf, hd);
- g_idle_add(hfp_handsfree_register, hf);
+ hd->register_source = g_idle_add(hfp_handsfree_register, hf);
return 0;
}
@@ -135,6 +138,9 @@ static void hfp_handsfree_remove(struct ofono_handsfree *hf)
{
struct hf_data *hd = ofono_handsfree_get_data(hf);
+ if (hd->register_source != 0)
+ g_source_remove(hd->register_source);
+
ofono_handsfree_set_data(hf, NULL);
g_at_chat_unref(hd->chat);
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v4 10/12] devinfo: avoid crash if query_model not supported
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (8 preceding siblings ...)
2011-10-21 16:51 ` [PATCH v4 09/12] hfpmodem: Avoid segfault in handsfree Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 11/12] hfpmodem: devinfo atom added to export BT address Mikel Astiz
` (2 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 495 bytes --]
---
src/modem.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/modem.c b/src/modem.c
index 52b9714..344a2a6 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -1398,6 +1398,7 @@ static void query_model(struct ofono_devinfo *info)
if (info->driver->query_model == NULL) {
/* If model is not supported, don't bother querying revision */
query_serial(info);
+ return;
}
info->driver->query_model(info, query_model_cb, info);
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v4 11/12] hfpmodem: devinfo atom added to export BT address
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (9 preceding siblings ...)
2011-10-21 16:51 ` [PATCH v4 10/12] devinfo: avoid crash if query_model not supported Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 16:51 ` [PATCH v4 12/12] hfp_hf: BT address exposed through Serial property Mikel Astiz
2011-10-21 19:30 ` [PATCH v4 00/12] Bluetooth HFP-specific extensions Denis Kenzior
12 siblings, 0 replies; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4648 bytes --]
---
Makefile.am | 1 +
drivers/hfpmodem/devinfo.c | 109 +++++++++++++++++++++++++++++++++++++++++++
drivers/hfpmodem/hfpmodem.c | 2 +
drivers/hfpmodem/hfpmodem.h | 3 +
4 files changed, 115 insertions(+), 0 deletions(-)
create mode 100644 drivers/hfpmodem/devinfo.c
diff --git a/Makefile.am b/Makefile.am
index 8771cb2..83b7737 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -255,6 +255,7 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/hfpmodem/voicecall.c \
drivers/hfpmodem/network-registration.c \
drivers/hfpmodem/call-volume.c \
+ drivers/hfpmodem/devinfo.c \
drivers/hfpmodem/handsfree.c
if PHONESIM
diff --git a/drivers/hfpmodem/devinfo.c b/drivers/hfpmodem/devinfo.c
new file mode 100644
index 0000000..04929c9
--- /dev/null
+++ b/drivers/hfpmodem/devinfo.c
@@ -0,0 +1,109 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
+ * Copyright (C) 2011 BMW Car IT GmbH. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+
+#include <glib.h>
+#include <gatchat.h>
+#include <gatresult.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/devinfo.h>
+
+#include "hfpmodem.h"
+
+struct devinfo_data {
+ char *device_address;
+ guint register_source;
+};
+
+static void hfp_query_serial(struct ofono_devinfo *info,
+ ofono_devinfo_query_cb_t cb,
+ void *data)
+{
+ struct devinfo_data *dev = ofono_devinfo_get_data(info);
+ CALLBACK_WITH_SUCCESS(cb, dev->device_address, data);
+}
+
+static gboolean hfp_devinfo_register(gpointer user_data)
+{
+ struct ofono_devinfo *info = user_data;
+ struct devinfo_data *dd = ofono_devinfo_get_data(info);
+
+ dd->register_source = 0;
+
+ ofono_devinfo_register(info);
+
+ return FALSE;
+}
+
+static int hfp_devinfo_probe(struct ofono_devinfo *info, unsigned int vendor,
+ void *user)
+{
+ const char *device_address = user;
+ struct devinfo_data *dd;
+
+ dd = g_new0(struct devinfo_data, 1);
+ dd->device_address = g_strdup(device_address);
+
+ ofono_devinfo_set_data(info, dd);
+
+ dd->register_source = g_idle_add(hfp_devinfo_register, info);
+ return 0;
+}
+
+static void hfp_devinfo_remove(struct ofono_devinfo *info)
+{
+ struct devinfo_data *dd = ofono_devinfo_get_data(info);
+
+ ofono_devinfo_set_data(info, NULL);
+ if (dd == NULL)
+ return;
+
+ if (dd->register_source != 0)
+ g_source_remove(dd->register_source);
+
+ g_free(dd->device_address);
+ g_free(dd);
+}
+
+static struct ofono_devinfo_driver driver = {
+ .name = "hfpmodem",
+ .probe = hfp_devinfo_probe,
+ .remove = hfp_devinfo_remove,
+ .query_serial = hfp_query_serial
+};
+
+void hfp_devinfo_init(void)
+{
+ ofono_devinfo_driver_register(&driver);
+}
+
+void hfp_devinfo_exit(void)
+{
+ ofono_devinfo_driver_unregister(&driver);
+}
diff --git a/drivers/hfpmodem/hfpmodem.c b/drivers/hfpmodem/hfpmodem.c
index 13d7766..1348beb 100644
--- a/drivers/hfpmodem/hfpmodem.c
+++ b/drivers/hfpmodem/hfpmodem.c
@@ -35,6 +35,7 @@
static int hfpmodem_init(void)
{
hfp_voicecall_init();
+ hfp_devinfo_init();
hfp_netreg_init();
hfp_call_volume_init();
hfp_handsfree_init();
@@ -45,6 +46,7 @@ static int hfpmodem_init(void)
static void hfpmodem_exit(void)
{
hfp_voicecall_exit();
+ hfp_devinfo_exit();
hfp_netreg_exit();
hfp_call_volume_exit();
hfp_handsfree_exit();
diff --git a/drivers/hfpmodem/hfpmodem.h b/drivers/hfpmodem/hfpmodem.h
index 4a996cf..ef7aea5 100644
--- a/drivers/hfpmodem/hfpmodem.h
+++ b/drivers/hfpmodem/hfpmodem.h
@@ -33,3 +33,6 @@ extern void hfp_voicecall_exit(void);
extern void hfp_handsfree_init(void);
extern void hfp_handsfree_exit(void);
+
+extern void hfp_devinfo_init(void);
+extern void hfp_devinfo_exit(void);
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v4 12/12] hfp_hf: BT address exposed through Serial property
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (10 preceding siblings ...)
2011-10-21 16:51 ` [PATCH v4 11/12] hfpmodem: devinfo atom added to export BT address Mikel Astiz
@ 2011-10-21 16:51 ` Mikel Astiz
2011-10-21 19:33 ` Denis Kenzior
2011-10-21 19:30 ` [PATCH v4 00/12] Bluetooth HFP-specific extensions Denis Kenzior
12 siblings, 1 reply; 16+ messages in thread
From: Mikel Astiz @ 2011-10-21 16:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 789 bytes --]
---
plugins/hfp_hf.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index ba06434..c9451d2 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -38,6 +38,7 @@
#include <ofono/plugin.h>
#include <ofono/log.h>
#include <ofono/modem.h>
+#include <ofono/devinfo.h>
#include <ofono/netreg.h>
#include <ofono/voicecall.h>
#include <ofono/call-volume.h>
@@ -232,6 +233,9 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
ofono_modem_set_data(modem, data);
ofono_modem_set_name(modem, alias);
+
+ ofono_devinfo_create(modem, 0, "hfpmodem", (void *) dev_addr);
+
ofono_modem_register(modem);
g_hash_table_insert(modem_hash, g_strdup(device), modem);
--
1.7.6.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH v4 12/12] hfp_hf: BT address exposed through Serial property
2011-10-21 16:51 ` [PATCH v4 12/12] hfp_hf: BT address exposed through Serial property Mikel Astiz
@ 2011-10-21 19:33 ` Denis Kenzior
0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-10-21 19:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 956 bytes --]
Hi Mikel,
On 10/21/2011 11:51 AM, Mikel Astiz wrote:
> ---
> plugins/hfp_hf.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
> index ba06434..c9451d2 100644
> --- a/plugins/hfp_hf.c
> +++ b/plugins/hfp_hf.c
> @@ -38,6 +38,7 @@
> #include <ofono/plugin.h>
> #include <ofono/log.h>
> #include <ofono/modem.h>
> +#include <ofono/devinfo.h>
> #include <ofono/netreg.h>
> #include <ofono/voicecall.h>
> #include <ofono/call-volume.h>
> @@ -232,6 +233,9 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
>
> ofono_modem_set_data(modem, data);
> ofono_modem_set_name(modem, alias);
> +
> + ofono_devinfo_create(modem, 0, "hfpmodem", (void *) dev_addr);
> +
Why is this being done in probe and not pre_sim?
> ofono_modem_register(modem);
>
> g_hash_table_insert(modem_hash, g_strdup(device), modem);
Regards,
-Denis
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 00/12] Bluetooth HFP-specific extensions
2011-10-21 16:51 [PATCH v4 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (11 preceding siblings ...)
2011-10-21 16:51 ` [PATCH v4 12/12] hfp_hf: BT address exposed through Serial property Mikel Astiz
@ 2011-10-21 19:30 ` Denis Kenzior
12 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-10-21 19:30 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1721 bytes --]
Hi Mikel,
On 10/21/2011 11:51 AM, Mikel Astiz wrote:
> Modifications to the previously proposed patches, according to the review.
>
> Mikel Astiz (12):
> include: Voice recognition in handsfree public api
> handsfree: Implement voice recognition function
> hfpmodem: Support for AT+BVRA
> doc: Handsfree exposes supported AG features
> handsfree: Supported AG features exposed in D-Bus
> hfpmodem: Report features supported by AG
> hfpmodem: Avoid segfault in network-registration
> hfpmodem: Avoid segfault in call-volume
> hfpmodem: Avoid segfault in handsfree
> devinfo: avoid crash if query_model not supported
> hfpmodem: devinfo atom added to export BT address
> hfp_hf: BT address exposed through Serial property
>
> Makefile.am | 1 +
> doc/handsfree-api.txt | 9 ++-
> drivers/hfpmodem/call-volume.c | 8 ++-
> drivers/hfpmodem/devinfo.c | 109 +++++++++++++++++++++++++
> drivers/hfpmodem/handsfree.c | 62 ++++++++++++++-
> drivers/hfpmodem/hfpmodem.c | 2 +
> drivers/hfpmodem/hfpmodem.h | 3 +
> drivers/hfpmodem/network-registration.c | 9 ++-
> include/handsfree.h | 7 ++
> plugins/hfp_hf.c | 4 +
> src/handsfree.c | 133 +++++++++++++++++++++++++++++++
> src/modem.c | 1 +
> 12 files changed, 344 insertions(+), 4 deletions(-)
> create mode 100644 drivers/hfpmodem/devinfo.c
>
All patches in this series except patch 5 and 12 have been applied. See
my comments for those two patches.
Regards,
-Denis
^ permalink raw reply [flat|nested] 16+ messages in thread