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.
This commit is contained in:
Huang-Huang Bao 2021-03-22 13:51:28 +08:00
parent 5cddd61c6c
commit 8b7502c8db
No known key found for this signature in database
GPG key ID: 33C3271387A13D1B

View file

@ -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);