mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
bluez5: telephony: use spa_callbacks instead of spa_hook_list
This commit is contained in:
parent
627515f641
commit
9d1862a6f8
3 changed files with 30 additions and 37 deletions
|
|
@ -153,7 +153,6 @@ struct rfcomm_volume {
|
|||
struct rfcomm_call_data {
|
||||
struct rfcomm *rfcomm;
|
||||
struct spa_bt_telephony_call *call;
|
||||
struct spa_hook listener;
|
||||
};
|
||||
|
||||
struct rfcomm {
|
||||
|
|
@ -1331,7 +1330,7 @@ static bool hfp_hf_wait_for_reply(struct rfcomm *rfcomm, char *buf, size_t len)
|
|||
|
||||
static void hfp_hf_answer(void *data, enum spa_bt_telephony_error *err)
|
||||
{
|
||||
struct rfcomm_call_data *call_data = telephony_call_get_user_data(data);
|
||||
struct rfcomm_call_data *call_data = data;
|
||||
struct rfcomm *rfcomm = call_data->rfcomm;
|
||||
struct impl *backend = rfcomm->backend;
|
||||
char reply[20];
|
||||
|
|
@ -1353,7 +1352,7 @@ static void hfp_hf_answer(void *data, enum spa_bt_telephony_error *err)
|
|||
|
||||
static void hfp_hf_hangup(void *data, enum spa_bt_telephony_error *err)
|
||||
{
|
||||
struct rfcomm_call_data *call_data = telephony_call_get_user_data(data);
|
||||
struct rfcomm_call_data *call_data = data;
|
||||
struct rfcomm *rfcomm = call_data->rfcomm;
|
||||
struct impl *backend = rfcomm->backend;
|
||||
char reply[20];
|
||||
|
|
@ -1383,8 +1382,8 @@ static void hfp_hf_hangup(void *data, enum spa_bt_telephony_error *err)
|
|||
*err = BT_TELEPHONY_ERROR_NONE;
|
||||
}
|
||||
|
||||
static const struct spa_bt_telephony_call_events telephony_call_events = {
|
||||
SPA_VERSION_BT_TELEPHONY_AG_EVENTS,
|
||||
static const struct spa_bt_telephony_call_callbacks telephony_call_callbacks = {
|
||||
SPA_VERSION_BT_TELEPHONY_AG_CALLBACKS,
|
||||
.answer = hfp_hf_answer,
|
||||
.hangup = hfp_hf_hangup,
|
||||
};
|
||||
|
|
@ -1404,7 +1403,7 @@ static struct spa_bt_telephony_call *hfp_hf_add_call(struct rfcomm *rfcomm, stru
|
|||
data = telephony_call_get_user_data(call);
|
||||
data->rfcomm = rfcomm;
|
||||
data->call = call;
|
||||
telephony_call_add_listener(call, &data->listener, &telephony_call_events, call);
|
||||
telephony_call_set_callbacks(call, &telephony_call_callbacks, data);
|
||||
telephony_call_register(call);
|
||||
|
||||
return call;
|
||||
|
|
@ -1723,8 +1722,8 @@ static void hfp_hf_send_tones(void *data, const char *tones, enum spa_bt_telepho
|
|||
*err = BT_TELEPHONY_ERROR_NONE;
|
||||
}
|
||||
|
||||
static const struct spa_bt_telephony_ag_events telephony_ag_events = {
|
||||
SPA_VERSION_BT_TELEPHONY_AG_EVENTS,
|
||||
static const struct spa_bt_telephony_ag_callbacks telephony_ag_callbacks = {
|
||||
SPA_VERSION_BT_TELEPHONY_AG_CALLBACKS,
|
||||
.dial = hfp_hf_dial,
|
||||
.swap_calls = hfp_hf_swap_calls,
|
||||
.release_and_answer = hfp_hf_release_and_answer,
|
||||
|
|
@ -2137,9 +2136,9 @@ static bool rfcomm_hfp_hf(struct rfcomm *rfcomm, char* token)
|
|||
}
|
||||
}
|
||||
|
||||
rfcomm->telephony_ag = telephony_ag_new(backend->telephony, sizeof(struct spa_hook));
|
||||
telephony_ag_add_listener(rfcomm->telephony_ag, telephony_ag_get_user_data(rfcomm->telephony_ag),
|
||||
&telephony_ag_events, rfcomm);
|
||||
rfcomm->telephony_ag = telephony_ag_new(backend->telephony, 0);
|
||||
telephony_ag_set_callbacks(rfcomm->telephony_ag,
|
||||
&telephony_ag_callbacks, rfcomm);
|
||||
if (rfcomm->transport) {
|
||||
rfcomm->telephony_ag->transport.codec = rfcomm->transport->codec;
|
||||
rfcomm->telephony_ag->transport.state = rfcomm->transport->state;
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ struct agimpl {
|
|||
struct spa_bt_telephony_ag this;
|
||||
struct spa_list link;
|
||||
char *path;
|
||||
struct spa_hook_list listener_list;
|
||||
struct spa_callbacks callbacks;
|
||||
void *user_data;
|
||||
|
||||
bool dial_in_progress;
|
||||
|
|
@ -205,7 +205,7 @@ struct agimpl {
|
|||
struct callimpl {
|
||||
struct spa_bt_telephony_call this;
|
||||
char *path;
|
||||
struct spa_hook_list listener_list;
|
||||
struct spa_callbacks callbacks;
|
||||
void *user_data;
|
||||
|
||||
/* previous values of properties */
|
||||
|
|
@ -218,7 +218,7 @@ struct callimpl {
|
|||
} prev;
|
||||
};
|
||||
|
||||
#define ag_emit(ag,m,v,...) spa_hook_list_call_once(&ag->listener_list, struct spa_bt_telephony_ag_events, m, v, ##__VA_ARGS__)
|
||||
#define ag_emit(ag,m,v,...) spa_callbacks_call(&ag->callbacks, struct spa_bt_telephony_ag_callbacks, m, v, ##__VA_ARGS__)
|
||||
#define ag_emit_dial(s,n,e) ag_emit(s,dial,0,n,e)
|
||||
#define ag_emit_swap_calls(s,e) ag_emit(s,swap_calls,0,e)
|
||||
#define ag_emit_release_and_answer(s,e) ag_emit(s,release_and_answer,0,e)
|
||||
|
|
@ -228,7 +228,7 @@ struct callimpl {
|
|||
#define ag_emit_create_multiparty(s,e) ag_emit(s,create_multiparty,0,e)
|
||||
#define ag_emit_send_tones(s,t,e) ag_emit(s,send_tones,0,t,e)
|
||||
|
||||
#define call_emit(c,m,v,...) spa_hook_list_call_once(&c->listener_list, struct spa_bt_telephony_call_events, m, v, ##__VA_ARGS__)
|
||||
#define call_emit(c,m,v,...) spa_callbacks_call(&c->callbacks, struct spa_bt_telephony_call_callbacks, m, v, ##__VA_ARGS__)
|
||||
#define call_emit_answer(s,e) call_emit(s,answer,0,e)
|
||||
#define call_emit_hangup(s,e) call_emit(s,hangup,0,e)
|
||||
|
||||
|
|
@ -913,7 +913,6 @@ telephony_ag_new(struct spa_bt_telephony *telephony, size_t user_data_size)
|
|||
agimpl->this.telephony = telephony;
|
||||
agimpl->this.id = find_free_object_id(&impl->ag_list, struct agimpl, link);
|
||||
spa_list_init(&agimpl->this.call_list);
|
||||
spa_hook_list_init(&agimpl->listener_list);
|
||||
|
||||
spa_list_append(&impl->ag_list, &agimpl->link);
|
||||
|
||||
|
|
@ -934,7 +933,6 @@ void telephony_ag_destroy(struct spa_bt_telephony_ag *ag)
|
|||
|
||||
telephony_ag_unregister(ag);
|
||||
spa_list_remove(&agimpl->link);
|
||||
spa_hook_list_clean(&agimpl->listener_list);
|
||||
|
||||
free(agimpl);
|
||||
}
|
||||
|
|
@ -1088,13 +1086,13 @@ void telephony_ag_transport_notify_updated_props(struct spa_bt_telephony_ag *ag)
|
|||
telephony_ag_transport_commit_properties(ag);
|
||||
}
|
||||
|
||||
void telephony_ag_add_listener(struct spa_bt_telephony_ag *ag,
|
||||
struct spa_hook *listener,
|
||||
const struct spa_bt_telephony_ag_events *events,
|
||||
void telephony_ag_set_callbacks(struct spa_bt_telephony_ag *ag,
|
||||
const struct spa_bt_telephony_ag_callbacks *cbs,
|
||||
void *data)
|
||||
{
|
||||
struct agimpl *agimpl = SPA_CONTAINER_OF(ag, struct agimpl, this);
|
||||
spa_hook_list_append(&agimpl->listener_list, listener, events, data);
|
||||
agimpl->callbacks.funcs = cbs;
|
||||
agimpl->callbacks.data = data;
|
||||
}
|
||||
|
||||
struct spa_bt_telephony_call *
|
||||
|
|
@ -1111,7 +1109,6 @@ telephony_call_new(struct spa_bt_telephony_ag *ag, size_t user_data_size)
|
|||
|
||||
callimpl->this.ag = ag;
|
||||
callimpl->this.id = find_free_object_id(&ag->call_list, struct callimpl, this.link);
|
||||
spa_hook_list_init(&callimpl->listener_list);
|
||||
|
||||
spa_list_append(&ag->call_list, &callimpl->this.link);
|
||||
|
||||
|
|
@ -1131,7 +1128,6 @@ void telephony_call_destroy(struct spa_bt_telephony_call *call)
|
|||
|
||||
telephony_call_unregister(call);
|
||||
spa_list_remove(&call->link);
|
||||
spa_hook_list_clean(&callimpl->listener_list);
|
||||
|
||||
free(callimpl->prev.line_identification);
|
||||
free(callimpl->prev.incoming_line);
|
||||
|
|
@ -1698,11 +1694,11 @@ void telephony_call_notify_updated_props(struct spa_bt_telephony_call *call)
|
|||
telephony_call_commit_properties(call);
|
||||
}
|
||||
|
||||
void telephony_call_add_listener(struct spa_bt_telephony_call *call,
|
||||
struct spa_hook *listener,
|
||||
const struct spa_bt_telephony_call_events *events,
|
||||
void telephony_call_set_callbacks(struct spa_bt_telephony_call *call,
|
||||
const struct spa_bt_telephony_call_callbacks *cbs,
|
||||
void *data)
|
||||
{
|
||||
struct callimpl *callimpl = SPA_CONTAINER_OF(call, struct callimpl, this);
|
||||
spa_hook_list_append(&callimpl->listener_list, listener, events, data);
|
||||
callimpl->callbacks.funcs = cbs;
|
||||
callimpl->callbacks.data = data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ struct spa_bt_telephony_call {
|
|||
enum spa_bt_telephony_call_state state;
|
||||
};
|
||||
|
||||
struct spa_bt_telephony_ag_events {
|
||||
#define SPA_VERSION_BT_TELEPHONY_AG_EVENTS 0
|
||||
struct spa_bt_telephony_ag_callbacks {
|
||||
#define SPA_VERSION_BT_TELEPHONY_AG_CALLBACKS 0
|
||||
uint32_t version;
|
||||
|
||||
void (*dial)(void *data, const char *number, enum spa_bt_telephony_error *err);
|
||||
|
|
@ -73,8 +73,8 @@ struct spa_bt_telephony_ag_events {
|
|||
void (*send_tones)(void *data, const char *tones, enum spa_bt_telephony_error *err);
|
||||
};
|
||||
|
||||
struct spa_bt_telephony_call_events {
|
||||
#define SPA_VERSION_BT_TELEPHONY_CALL_EVENTS 0
|
||||
struct spa_bt_telephony_call_callbacks {
|
||||
#define SPA_VERSION_BT_TELEPHONY_CALL_CALLBACKS 0
|
||||
uint32_t version;
|
||||
|
||||
void (*answer)(void *data, enum spa_bt_telephony_error *err);
|
||||
|
|
@ -94,9 +94,8 @@ void telephony_ag_destroy(struct spa_bt_telephony_ag *ag);
|
|||
/* get the user data structure; struct size is set when creating the AG */
|
||||
void *telephony_ag_get_user_data(struct spa_bt_telephony_ag *ag);
|
||||
|
||||
void telephony_ag_add_listener(struct spa_bt_telephony_ag *ag,
|
||||
struct spa_hook *listener,
|
||||
const struct spa_bt_telephony_ag_events *events,
|
||||
void telephony_ag_set_callbacks(struct spa_bt_telephony_ag *ag,
|
||||
const struct spa_bt_telephony_ag_callbacks *cbs,
|
||||
void *data);
|
||||
|
||||
void telephony_ag_transport_notify_updated_props(struct spa_bt_telephony_ag *ag);
|
||||
|
|
@ -121,9 +120,8 @@ void telephony_call_unregister(struct spa_bt_telephony_call *call);
|
|||
/* send message to notify about property changes */
|
||||
void telephony_call_notify_updated_props(struct spa_bt_telephony_call *call);
|
||||
|
||||
void telephony_call_add_listener(struct spa_bt_telephony_call *call,
|
||||
struct spa_hook *listener,
|
||||
const struct spa_bt_telephony_call_events *events,
|
||||
void telephony_call_set_callbacks(struct spa_bt_telephony_call *call,
|
||||
const struct spa_bt_telephony_call_callbacks *cbs,
|
||||
void *data);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue