MT#55283 use g_auto for call_t

Change-Id: I8fc7e26a48346dae264e38e30b944f0d889b666e
pull/1776/head
Richard Fuchs 2 years ago
parent 2975b2131d
commit c6b907017d

@ -310,11 +310,9 @@ static void streams_parse(const char *s, sdp_streams_q *q) {
i = 0;
pcre2_multi_match(streams_re, s, 4, streams_parse_func, &i, &q->q);
}
void call_unlock_release(call_t **c) {
if (!*c)
return;
rwlock_unlock_w(&(*c)->master_lock);
obj_put(*c);
void call_unlock_release(call_t *c) {
rwlock_unlock_w(&c->master_lock);
obj_put(c);
}
INLINE void call_unlock_release_update(call_t **c) {
if (!*c)
@ -398,7 +396,7 @@ str *call_delete_udp(char **out) {
return str_sprintf("%s 0\n", out[RE_UDP_COOKIE]);
}
str *call_query_udp(char **out) {
AUTO_CLEANUP_NULL(call_t *c, call_unlock_release);
g_autoptr(call_t) c = NULL;
str *ret;
struct call_stats stats;
@ -1959,7 +1957,7 @@ static const char *call_offer_answer_ng(ng_buffer *ngbuf, bencode_item_t *input,
g_auto(str) sdp = STR_NULL;
g_auto(sdp_sessions_q) parsed = TYPED_GQUEUE_INIT;
g_auto(sdp_streams_q) streams = TYPED_GQUEUE_INIT;
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
struct call_monologue * monologues[2];
int ret;
g_auto(sdp_ng_flags) flags;
@ -2813,7 +2811,7 @@ static const char *media_block_match_mult(call_t **call, GQueue *medias,
// XXX these are all identical - unify and use a flags int and/or callback
const char *call_start_forwarding_ng(bencode_item_t *input, bencode_item_t *output) {
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
struct call_monologue *monologue;
const char *errstr = NULL;
g_auto(sdp_ng_flags) flags;
@ -2842,7 +2840,7 @@ const char *call_start_forwarding_ng(bencode_item_t *input, bencode_item_t *outp
}
const char *call_stop_forwarding_ng(bencode_item_t *input, bencode_item_t *output) {
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
struct call_monologue *monologue;
const char *errstr = NULL;
g_auto(sdp_ng_flags) flags;
@ -2921,7 +2919,7 @@ static void call_monologue_set_block_mode(struct call_monologue *ml, sdp_ng_flag
codec_update_all_handlers(ml);
}
const char *call_block_dtmf_ng(bencode_item_t *input, bencode_item_t *output) {
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
struct call_monologue *monologue;
const char *errstr = NULL;
g_auto(sdp_ng_flags) flags;
@ -2962,7 +2960,7 @@ const char *call_block_dtmf_ng(bencode_item_t *input, bencode_item_t *output) {
}
const char *call_unblock_dtmf_ng(bencode_item_t *input, bencode_item_t *output) {
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
struct call_monologue *monologue;
const char *errstr = NULL;
g_auto(sdp_ng_flags) flags;
@ -3024,7 +3022,7 @@ static const char *call_block_silence_media(bencode_item_t *input, bool on_off,
const char *lcase_verb,
unsigned int call_flag, unsigned int ml_flag, size_t attr_offset)
{
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
struct call_monologue *monologue;
const char *errstr = NULL;
g_auto(sdp_ng_flags) flags;
@ -3199,7 +3197,7 @@ static const char *play_media_select_party(call_t **call, GQueue *monologues,
const char *call_play_media_ng(bencode_item_t *input, bencode_item_t *output) {
#ifdef WITH_TRANSCODING
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
g_auto(GQueue) monologues;
const char *err = NULL;
g_auto(sdp_ng_flags) flags;
@ -3254,7 +3252,7 @@ const char *call_play_media_ng(bencode_item_t *input, bencode_item_t *output) {
const char *call_stop_media_ng(bencode_item_t *input, bencode_item_t *output) {
#ifdef WITH_TRANSCODING
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
g_auto(GQueue) monologues;
const char *err = NULL;
long long last_frame_pos = 0;
@ -3287,7 +3285,7 @@ const char *call_stop_media_ng(bencode_item_t *input, bencode_item_t *output) {
const char *call_play_dtmf_ng(bencode_item_t *input, bencode_item_t *output) {
#ifdef WITH_TRANSCODING
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
g_auto(GQueue) monologues;
const char *err = NULL;
g_auto(sdp_ng_flags) flags;
@ -3396,7 +3394,7 @@ const char *call_publish_ng(ng_buffer *ngbuf, bencode_item_t *input, bencode_ite
g_auto(sdp_streams_q) streams = TYPED_GQUEUE_INIT;
g_auto(str) sdp_in = STR_NULL;
g_auto(str) sdp_out = STR_NULL;
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
call_ng_process_flags(&flags, input, OP_PUBLISH);
@ -3449,7 +3447,7 @@ const char *call_subscribe_request_ng(bencode_item_t *input, bencode_item_t *out
const char *err = NULL;
g_auto(sdp_ng_flags) flags;
char rand_buf[65];
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
AUTO_CLEANUP(GQueue srms, media_subscriptions_clear) = G_QUEUE_INIT;
g_auto(str) sdp_out = STR_NULL;
@ -3583,7 +3581,7 @@ const char *call_subscribe_answer_ng(ng_buffer *ngbuf, bencode_item_t *input, be
g_auto(sdp_ng_flags) flags;
g_auto(sdp_sessions_q) parsed = TYPED_GQUEUE_INIT;
g_auto(sdp_streams_q) streams = TYPED_GQUEUE_INIT;
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
call_ng_process_flags(&flags, input, OP_REQ_ANSWER);
@ -3623,7 +3621,7 @@ const char *call_subscribe_answer_ng(ng_buffer *ngbuf, bencode_item_t *input, be
const char *call_unsubscribe_ng(bencode_item_t *input, bencode_item_t *output) {
g_auto(sdp_ng_flags) flags;
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
call_ng_process_flags(&flags, input, OP_REQ_ANSWER);

@ -514,7 +514,7 @@ static const char *janus_videoroom_join(struct websocket_message *wm, struct jan
if (!room)
return "No such room";
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
*retcode = 426;
call = call_get(&room->call_id);
if (!call)
@ -837,13 +837,11 @@ static const char *janus_videoroom_configure(struct websocket_message *wm, struc
if (handle->room != room_id)
return "Not in the room";
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
struct janus_room *room = t_hash_table_lookup(janus_rooms, &room_id);
*retcode = 426;
if (!room)
return "No such room";
call = call_get(&room->call_id);
g_autoptr(call_t) call = call_get(&room->call_id);
// XXX if call is destroyed separately, room persists -> room should be destroyed too
if (!call)
return "No such room";
@ -973,13 +971,11 @@ static const char *janus_videoroom_start(struct websocket_message *wm, struct ja
if (sdp_streams(&parsed, &streams, &flags))
return "Incomplete SDP specification";
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
struct janus_room *room = t_hash_table_lookup(janus_rooms, &room_id);
*retcode = 426;
if (!room)
return "No such room";
call = call_get(&room->call_id);
g_autoptr(call_t) call = call_get(&room->call_id);
if (!call)
return "No such room";
*retcode = 456;
@ -1039,8 +1035,7 @@ static const char *janus_videoroom_unpublish(struct websocket_message *wm, struc
if (!room)
return "No such room";
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
call = call_get(&room->call_id);
g_autoptr(call_t) call = call_get(&room->call_id);
if (!call)
return "No such room";
@ -1606,7 +1601,7 @@ static const char *janus_trickle(JsonReader *reader, struct janus_session *sessi
// fetch call
g_autoptr(char) call_id = NULL;
AUTO_CLEANUP_NULL(call_t *call, call_unlock_release);
g_autoptr(call_t) call = NULL;
{
LOCK(&janus_lock);

@ -252,9 +252,10 @@ void add_media_to_sub_list(GQueue *q, struct call_media *media, struct call_mono
void save_last_sdp(struct call_monologue *ml, str *sdp, sdp_sessions_q *parsed, sdp_streams_q *streams);
void call_ng_flags_init(sdp_ng_flags *out, enum call_opmode opmode);
void call_ng_free_flags(sdp_ng_flags *flags);
void call_unlock_release(call_t **c);
void call_unlock_release(call_t *c);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(sdp_ng_flags, call_ng_free_flags)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(call_t, call_unlock_release)
int call_interfaces_init(void);
void call_interfaces_free(void);

Loading…
Cancel
Save