From 8b7502c8dbdb782dc968426c5844885e37e296f8 Mon Sep 17 00:00:00 2001 From: Huang-Huang Bao Date: Mon, 22 Mar 2021 13:51:28 +0800 Subject: [PATCH] sco-sink: fix no sound issue if first port buffur size is less than write MTU No data is written because 'sco_on_timeout' always reset 'write_buffer_size' to 0. --- spa/plugins/bluez5/sco-sink.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/spa/plugins/bluez5/sco-sink.c b/spa/plugins/bluez5/sco-sink.c index cd2cf06f4..57f3537e3 100644 --- a/spa/plugins/bluez5/sco-sink.c +++ b/spa/plugins/bluez5/sco-sink.c @@ -488,13 +488,6 @@ static void sco_on_timeout(struct spa_source *source) if (this->started && spa_system_timerfd_read(this->data_system, this->timerfd, &exp) < 0) spa_log_warn(this->log, "error reading timerfd: %s", strerror(errno)); - /* Reset if start time is 0 */ - if (this->start_time == 0) { - this->total_samples = 0; - port->ready_offset = 0; - port->write_buffer_size = 0; - } - /* delay if no buffers available */ if (spa_list_is_empty(&port->ready)) { set_timeout(this, this->transport->write_mtu / port->frame_size * SPA_NSEC_PER_SEC / port->current_format.info.raw.rate); @@ -593,6 +586,7 @@ static void drop_port_output(struct impl *this) port->write_buffer_size = 0; port->current_buffer = NULL; + port->ready_offset = 0; while (!spa_list_is_empty(&port->ready)) { struct buffer *b; @@ -615,6 +609,7 @@ static int do_remove_source(struct spa_loop *loop, struct impl *this = user_data; this->start_time = 0; + this->total_samples = 0; set_timeout(this, 0); if (this->source.loop) spa_loop_remove_source(this->data_loop, &this->source);