bluez5: iso-io: drop RX data when source is not running

When media-source is not running, we need to drop any RX data so that
there is room in the socket buffer for the latency reporting.
This commit is contained in:
Pauli Virtanen 2024-03-02 00:37:02 +02:00
parent 4f91f0bcb0
commit 9165291c43
2 changed files with 45 additions and 3 deletions

View file

@ -145,6 +145,15 @@ static int set_timers(struct group *group)
return set_timeout(group, group->next);
}
static void drop_rx(int fd)
{
ssize_t res;
do {
res = recv(fd, NULL, 0, MSG_TRUNC | MSG_DONTWAIT);
} while (res >= 0);
}
static void group_on_timeout(struct spa_source *source)
{
struct group *group = source->data;
@ -166,8 +175,13 @@ static void group_on_timeout(struct spa_source *source)
* desynchronization.
*/
spa_list_for_each(stream, &group->streams, link) {
if (!stream->sink)
if (!stream->sink) {
if (!stream->pull) {
/* Source not running: drop any incoming data */
drop_rx(stream->fd);
}
continue;
}
if (stream->this.need_resync) {
resync = true;
@ -453,9 +467,12 @@ static bool group_is_enabled(struct group *group)
{
struct stream *stream;
spa_list_for_each(stream, &group->streams, link)
spa_list_for_each(stream, &group->streams, link) {
if (!stream->sink)
continue;
if (stream->pull)
return true;
}
return false;
}