From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: [RFC v6 10/12] hfp_ag: Add AT+VGS support
Date: Wed, 01 Aug 2012 12:09:45 +0200 [thread overview]
Message-ID: <1343815787-22670-11-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1343815787-22670-1-git-send-email-frederic.danis@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3485 bytes --]
---
plugins/hfp_ag.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/plugins/hfp_ag.c b/plugins/hfp_ag.c
index f865208..3084cd6 100644
--- a/plugins/hfp_ag.c
+++ b/plugins/hfp_ag.c
@@ -56,6 +56,8 @@ struct bt_audio {
guint watch;
int mic_gain;
int mic_pending;
+ int sp_gain;
+ int sp_pending;
};
static guint modemwatch_id;
@@ -214,6 +216,39 @@ fail:
};
}
+static void emulator_vgs_cb(struct ofono_emulator *em,
+ struct ofono_emulator_request *req, void *userdata)
+{
+ struct bt_audio *audio = userdata;
+ struct ofono_error result;
+ int val;
+ dbus_uint16_t dbus_val;
+
+ switch (ofono_emulator_request_get_type(req)) {
+ case OFONO_EMULATOR_REQUEST_TYPE_SET:
+ if (!ofono_emulator_request_next_number(req, &val))
+ goto fail;
+
+ if (val < 0 && val > 15)
+ goto fail;
+
+ if (audio->sp_pending != -1)
+ ofono_error("Receiving AT+VGS while processing one");
+
+ audio->sp_pending = val;
+ dbus_val = val;
+ audio_transport_set_property(audio, "OutputGain",
+ DBUS_TYPE_UINT16, &dbus_val);
+ break;
+
+ default:
+fail:
+ result.error = 0;
+ result.type = OFONO_ERROR_TYPE_FAILURE;
+ ofono_emulator_send_final(em, &result);
+ };
+}
+
static gboolean audio_property_changed(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
@@ -286,6 +321,43 @@ static gboolean audio_property_changed(DBusConnection *connection,
} else if (audio->mic_pending == value)
audio->mic_pending = -1;
audio->mic_gain = value;
+ } else if (g_str_equal(property, "OutputGain") == TRUE) {
+ DBusMessageIter variant;
+ dbus_uint16_t dbus_val;
+ int value;
+
+ if (!(audio->r_features & HFP_HF_FEATURE_REMOTE_VOLUME_CONTROL))
+ return TRUE;
+
+ if (!dbus_message_iter_next(&iter))
+ return TRUE;
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
+ return TRUE;
+
+ dbus_message_iter_recurse(&iter, &variant);
+
+ if (dbus_message_iter_get_arg_type(&variant) !=
+ DBUS_TYPE_UINT16)
+ return TRUE;
+
+ dbus_message_iter_get_basic(&variant, &dbus_val);
+ value = dbus_val;
+
+ /* Send unsolicited +VGS only if :
+ * - the value has changed
+ * - and this is not a side effect of AT+VGS
+ * But, if we receive a value change while waiting for another
+ * pending change, we may have to send +VGS for other changes
+ * (multiple AT+VGS received) to keep speaker gain in sync
+ */
+ if (audio->sp_pending != value && audio->sp_gain != value) {
+ sprintf(buf, "+VGS: %d", value);
+ ofono_emulator_send_unsolicited(audio->em, buf);
+ audio->sp_pending = -1;
+ } else if (audio->sp_pending == value)
+ audio->sp_pending = -1;
+ audio->sp_gain = value;
}
return TRUE;
@@ -348,11 +420,13 @@ static DBusMessage *hfp_ag_agent_new_connection(DBusConnection *conn,
audio->path = g_strdup(path);
audio->r_features = features;
audio->mic_pending = -1;
+ audio->sp_pending = -1;
ofono_emulator_set_data(em, audio,
(ofono_destroy_func)free_audio_management);
ofono_emulator_add_handler(em, "+NREC", emulator_nrec_cb, audio, NULL);
ofono_emulator_add_handler(em, "+VGM", emulator_vgm_cb, audio, NULL);
+ ofono_emulator_add_handler(em, "+VGS", emulator_vgs_cb, audio, NULL);
audio->watch = g_dbus_add_signal_watch(conn, NULL, path,
BLUEZ_TRANSPORT_INTERFACE,
--
1.7.9.5
next prev parent reply other threads:[~2012-08-01 10:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-01 10:09 [RFC v6 00/12] Add org.bluez.Telephony interface =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` [RFC v6 01/12] bluetooth: Add org.bluez.Telephony helpers =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` [RFC v6 02/12] hfp_hf: Update to org.bluez.Telephony interface =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` [RFC v6 03/12] hfp_ag: " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` [RFC v6 04/12] bluetooth: Add define for MediaTransport interface =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` [RFC v6 05/12] include: Add set/get data APIs to emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` [RFC v6 06/12] emulator: Add set/get data APIs =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` [RFC v6 07/12] hfp_ag: Add AT+NREC support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` [RFC v6 08/12] hfp_ag: Add +BSIR support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` [RFC v6 09/12] hfp_ag: Add AT+VGM support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2012-08-01 10:09 ` [RFC v6 11/12] emulator: Update supported features =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-08-01 10:09 ` [RFC v6 12/12] dun_gw: Update to org.bluez.Telephony interface =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1343815787-22670-11-git-send-email-frederic.danis@linux.intel.com \
--to=frederic.danis@linux.intel.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox