mirror of git://git.sysmocom.de/ofono
handsfree-audio: add type for our audio cards
When registering audio cards for the handsfree and gateway roles we need a way for our users to differentiate between both to decide which of them they start using for their purpose.
This commit is contained in:
parent
8929d131a3
commit
5a7410e9e4
|
@ -89,6 +89,10 @@ Properties string RemoteAddress [readonly]
|
||||||
|
|
||||||
Bluetooth address of the local adapter.
|
Bluetooth address of the local adapter.
|
||||||
|
|
||||||
|
string Type [readonly]
|
||||||
|
|
||||||
|
Type of the card. Valid values are "gateway" or
|
||||||
|
"handsfree".
|
||||||
|
|
||||||
Handsfree Audio Agent hierarchy [experimental]
|
Handsfree Audio Agent hierarchy [experimental]
|
||||||
===============================
|
===============================
|
||||||
|
|
|
@ -30,6 +30,11 @@ extern "C" {
|
||||||
|
|
||||||
struct ofono_handsfree_card;
|
struct ofono_handsfree_card;
|
||||||
|
|
||||||
|
enum ofono_handsfree_card_type {
|
||||||
|
OFONO_HANDSFREE_CARD_TYPE_HANDSFREE,
|
||||||
|
OFONO_HANDSFREE_CARD_TYPE_GATEWAY,
|
||||||
|
};
|
||||||
|
|
||||||
typedef void (*ofono_handsfree_card_connect_cb_t)(
|
typedef void (*ofono_handsfree_card_connect_cb_t)(
|
||||||
const struct ofono_error *error, void *data);
|
const struct ofono_error *error, void *data);
|
||||||
|
|
||||||
|
@ -45,8 +50,9 @@ struct ofono_handsfree_card_driver {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ofono_handsfree_card *ofono_handsfree_card_create(unsigned int vendor,
|
struct ofono_handsfree_card *ofono_handsfree_card_create(unsigned int vendor,
|
||||||
const char *driver,
|
enum ofono_handsfree_card_type type,
|
||||||
void *data);
|
const char *driver,
|
||||||
|
void *data);
|
||||||
int ofono_handsfree_card_register(struct ofono_handsfree_card *card);
|
int ofono_handsfree_card_register(struct ofono_handsfree_card *card);
|
||||||
void ofono_handsfree_card_remove(struct ofono_handsfree_card *card);
|
void ofono_handsfree_card_remove(struct ofono_handsfree_card *card);
|
||||||
ofono_bool_t ofono_handsfree_card_set_codec(struct ofono_handsfree_card *card,
|
ofono_bool_t ofono_handsfree_card_set_codec(struct ofono_handsfree_card *card,
|
||||||
|
|
|
@ -589,7 +589,9 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
|
||||||
if (version >= HFP_VERSION_1_6)
|
if (version >= HFP_VERSION_1_6)
|
||||||
driver = HFP16_HF_DRIVER;
|
driver = HFP16_HF_DRIVER;
|
||||||
|
|
||||||
hfp->card = ofono_handsfree_card_create(0, driver, hfp);
|
hfp->card = ofono_handsfree_card_create(0,
|
||||||
|
OFONO_HANDSFREE_CARD_TYPE_HANDSFREE,
|
||||||
|
driver, hfp);
|
||||||
ofono_handsfree_card_set_data(hfp->card, hfp);
|
ofono_handsfree_card_set_data(hfp->card, hfp);
|
||||||
|
|
||||||
ofono_handsfree_card_set_local(hfp->card, local);
|
ofono_handsfree_card_set_local(hfp->card, local);
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#define HFP_AUDIO_CARD_INTERFACE OFONO_SERVICE ".HandsfreeAudioCard"
|
#define HFP_AUDIO_CARD_INTERFACE OFONO_SERVICE ".HandsfreeAudioCard"
|
||||||
|
|
||||||
struct ofono_handsfree_card {
|
struct ofono_handsfree_card {
|
||||||
|
enum ofono_handsfree_card_type type;
|
||||||
char *remote;
|
char *remote;
|
||||||
char *local;
|
char *local;
|
||||||
char *path;
|
char *path;
|
||||||
|
@ -69,6 +70,17 @@ static ofono_bool_t has_wideband = FALSE;
|
||||||
static int defer_setup = 1;
|
static int defer_setup = 1;
|
||||||
static ofono_bool_t transparent_sco = FALSE;
|
static ofono_bool_t transparent_sco = FALSE;
|
||||||
|
|
||||||
|
static const char *card_type_to_string(enum ofono_handsfree_card_type type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case OFONO_HANDSFREE_CARD_TYPE_HANDSFREE:
|
||||||
|
return "handsfree";
|
||||||
|
case OFONO_HANDSFREE_CARD_TYPE_GATEWAY:
|
||||||
|
return "gateway";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
static uint16_t codec2setting(uint8_t codec)
|
static uint16_t codec2setting(uint8_t codec)
|
||||||
{
|
{
|
||||||
switch (codec) {
|
switch (codec) {
|
||||||
|
@ -255,6 +267,12 @@ static int sco_init(void)
|
||||||
static void card_append_properties(struct ofono_handsfree_card *card,
|
static void card_append_properties(struct ofono_handsfree_card *card,
|
||||||
DBusMessageIter *dict)
|
DBusMessageIter *dict)
|
||||||
{
|
{
|
||||||
|
const char *type;
|
||||||
|
|
||||||
|
type = card_type_to_string(card->type);
|
||||||
|
ofono_dbus_dict_append(dict, "Type",
|
||||||
|
DBUS_TYPE_STRING, &type);
|
||||||
|
|
||||||
ofono_dbus_dict_append(dict, "RemoteAddress",
|
ofono_dbus_dict_append(dict, "RemoteAddress",
|
||||||
DBUS_TYPE_STRING, &card->remote);
|
DBUS_TYPE_STRING, &card->remote);
|
||||||
|
|
||||||
|
@ -395,14 +413,16 @@ static const GDBusSignalTable card_signals[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ofono_handsfree_card *ofono_handsfree_card_create(unsigned int vendor,
|
struct ofono_handsfree_card *ofono_handsfree_card_create(unsigned int vendor,
|
||||||
const char *driver,
|
enum ofono_handsfree_card_type type,
|
||||||
void *data)
|
const char *driver,
|
||||||
|
void *data)
|
||||||
{
|
{
|
||||||
struct ofono_handsfree_card *card;
|
struct ofono_handsfree_card *card;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
card = g_new0(struct ofono_handsfree_card, 1);
|
card = g_new0(struct ofono_handsfree_card, 1);
|
||||||
|
|
||||||
|
card->type = type;
|
||||||
card->selected_codec = HFP_CODEC_CVSD;
|
card->selected_codec = HFP_CODEC_CVSD;
|
||||||
|
|
||||||
card_list = g_slist_prepend(card_list, card);
|
card_list = g_slist_prepend(card_list, card);
|
||||||
|
|
Loading…
Reference in New Issue