diff options
author | Frédéric Dalleau <frederic.dalleau@linux.intel.com> | 2013-07-05 17:46:43 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-08-01 12:36:25 +0300 |
commit | cf721a536434f91b15a346e990d9b87d73afbc42 (patch) | |
tree | 1fc001680c8ff38d3a1c8b8e4b869a8f978e67b3 /btio | |
parent | c594291320709e51e90de9973200a00db91de89c (diff) |
btio: Add option for SCO voice setting
Diffstat (limited to 'btio')
-rw-r--r-- | btio/btio.c | 24 | ||||
-rw-r--r-- | btio/btio.h | 1 |
2 files changed, 21 insertions, 4 deletions
diff --git a/btio/btio.c b/btio/btio.c index cb8860a92..f62a53305 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -78,6 +78,7 @@ struct set_opts { uint8_t mode; int flushable; uint32_t priority; + uint16_t voice; }; struct connect { @@ -723,13 +724,14 @@ static int sco_connect(int sock, const bdaddr_t *dst) return 0; } -static gboolean sco_set(int sock, uint16_t mtu, GError **err) +static gboolean sco_set(int sock, uint16_t mtu, uint16_t voice, GError **err) { struct sco_options sco_opt; + struct bt_voice bt_voice; socklen_t len; if (!mtu) - return TRUE; + goto voice; len = sizeof(sco_opt); memset(&sco_opt, 0, len); @@ -745,6 +747,17 @@ static gboolean sco_set(int sock, uint16_t mtu, GError **err) return FALSE; } +voice: + if (!voice) + return TRUE; + + bt_voice.setting = voice; + if (setsockopt(sock, SOL_BLUETOOTH, BT_VOICE, &bt_voice, + sizeof(bt_voice)) < 0) { + ERROR_FAILED(err, "setsockopt(BT_VOICE)", errno); + return FALSE; + } + return TRUE; } @@ -832,6 +845,9 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err, case BT_IO_OPT_PRIORITY: opts->priority = va_arg(args, int); break; + case BT_IO_OPT_VOICE: + opts->voice = va_arg(args, int); + break; default: g_set_error(err, BT_IO_ERROR, EINVAL, "Unknown option %d", opt); @@ -1310,7 +1326,7 @@ gboolean bt_io_set(GIOChannel *io, GError **err, BtIOOption opt1, ...) case BT_IO_RFCOMM: return rfcomm_set(sock, opts.sec_level, opts.master, err); case BT_IO_SCO: - return sco_set(sock, opts.mtu, err); + return sco_set(sock, opts.mtu, opts.voice, err); default: g_set_error(err, BT_IO_ERROR, EINVAL, "Unknown BtIO type %d", type); @@ -1377,7 +1393,7 @@ static GIOChannel *create_io(gboolean server, struct set_opts *opts, } if (sco_bind(sock, &opts->src, err) < 0) goto failed; - if (!sco_set(sock, opts->mtu, err)) + if (!sco_set(sock, opts->mtu, opts->voice, err)) goto failed; break; default: diff --git a/btio/btio.h b/btio/btio.h index ac1366bb6..2dce9f0c1 100644 --- a/btio/btio.h +++ b/btio/btio.h @@ -55,6 +55,7 @@ typedef enum { BT_IO_OPT_MODE, BT_IO_OPT_FLUSHABLE, BT_IO_OPT_PRIORITY, + BT_IO_OPT_VOICE, } BtIOOption; typedef enum { |