Skip to content

Commit

Permalink
TT#50652 split out packet dequeuing and sending function
Browse files Browse the repository at this point in the history
Change-Id: I303bcfb8869699554ff7381c68767c56fdcdda87
  • Loading branch information
rfuchs committed Mar 6, 2019
1 parent 3374254 commit 6ba60d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
33 changes: 20 additions & 13 deletions daemon/media_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,25 @@ static int do_rtcp(struct packet_handler_ctx *phc) {
}


// appropriate locks must be held
int media_socket_dequeue(struct media_packet *mp, struct packet_stream *sink) {
struct codec_packet *p;
while ((p = g_queue_pop_head(&mp->packets_out))) {
__C_DBG("Forward to sink endpoint: %s:%d", sockaddr_print_buf(&sink->endpoint.address),
sink->endpoint.port);

int ret = socket_sendto(&sink->selected_sfd->socket,
p->s.s, p->s.len, &sink->endpoint);

codec_packet_free(p);

if (ret == -1)
return -1;
}
return 0;
}


/* called lock-free */
static int stream_packet(struct packet_handler_ctx *phc) {
/**
Expand Down Expand Up @@ -1696,19 +1715,7 @@ static int stream_packet(struct packet_handler_ctx *phc) {
goto drop;
}

struct codec_packet *p;
ret = 0;
while ((p = g_queue_pop_head(&phc->mp.packets_out))) {
__C_DBG("Forward to sink endpoint: %s:%d", sockaddr_print_buf(&phc->sink->endpoint.address),
phc->sink->endpoint.port);

ret = socket_sendto(&phc->sink->selected_sfd->socket, p->s.s, p->s.len, &phc->sink->endpoint);

codec_packet_free(p);

if (ret == -1)
break;
}
ret = media_socket_dequeue(&phc->mp, phc->sink);

mutex_unlock(&phc->sink->out_lock);

Expand Down
2 changes: 2 additions & 0 deletions include/media_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ void __unkernelize(struct packet_stream *);
void unkernelize(struct packet_stream *);
void __stream_unconfirm(struct packet_stream *);

int media_socket_dequeue(struct media_packet *mp, struct packet_stream *sink);

/* XXX shouldn't be necessary */
/*
INLINE struct local_intf *get_interface_from_address(const struct logical_intf *lif,
Expand Down

0 comments on commit 6ba60d5

Please sign in to comment.