diff --git a/spa/plugins/bluez5/media-sink.c b/spa/plugins/bluez5/media-sink.c index 63d9cd760..92c4e2cb2 100644 --- a/spa/plugins/bluez5/media-sink.c +++ b/spa/plugins/bluez5/media-sink.c @@ -1083,7 +1083,7 @@ static void media_on_timeout(struct spa_source *source) uint32_t rate; struct spa_io_buffers *io = port->io; uint64_t prev_time, now_time; - int res; + int status, res; if (this->started) { if ((res = spa_system_timerfd_read(this->data_system, this->timerfd, &exp)) < 0) { @@ -1131,10 +1131,12 @@ static void media_on_timeout(struct spa_source *source) this->clock->delay = (delay_nsec * this->clock->rate.denom) / SPA_NSEC_PER_SEC; } + status = this->transport_started ? SPA_STATUS_NEED_DATA : SPA_STATUS_HAVE_DATA; - spa_log_trace(this->log, "%p: %d", this, io->status); - io->status = SPA_STATUS_NEED_DATA; - spa_node_call_ready(&this->callbacks, SPA_STATUS_NEED_DATA); + spa_log_trace(this->log, "%p: %d -> %d", this, io->status, status); + io->status = status; + io->buffer_id = SPA_ID_INVALID; + spa_node_call_ready(&this->callbacks, status); set_timeout(this, this->next_time); } @@ -1847,8 +1849,13 @@ static int impl_node_process(void *object) return SPA_STATUS_HAVE_DATA; } - if (!this->started || !this->transport_started) - return SPA_STATUS_OK; + if (!this->started || !this->transport_started) { + if (io->status != SPA_STATUS_HAVE_DATA) { + io->status = SPA_STATUS_HAVE_DATA; + io->buffer_id = SPA_ID_INVALID; + } + return SPA_STATUS_HAVE_DATA; + } if (io->status == SPA_STATUS_HAVE_DATA && io->buffer_id < port->n_buffers) { struct buffer *b = &port->buffers[io->buffer_id]; diff --git a/spa/plugins/bluez5/sco-sink.c b/spa/plugins/bluez5/sco-sink.c index 21f98fa1f..3fe908591 100644 --- a/spa/plugins/bluez5/sco-sink.c +++ b/spa/plugins/bluez5/sco-sink.c @@ -586,7 +586,7 @@ static void sco_on_timeout(struct spa_source *source) uint32_t rate; struct spa_io_buffers *io = port->io; uint64_t prev_time, now_time; - int res; + int status, res; if (this->started) { if ((res = spa_system_timerfd_read(this->data_system, this->timerfd, &exp)) < 0) { @@ -622,9 +622,12 @@ static void sco_on_timeout(struct spa_source *source) this->clock->delay = 0; } - spa_log_trace(this->log, "%p: %d", this, io->status); - io->status = SPA_STATUS_NEED_DATA; - spa_node_call_ready(&this->callbacks, SPA_STATUS_NEED_DATA); + status = this->transport_started ? SPA_STATUS_NEED_DATA : SPA_STATUS_HAVE_DATA; + + spa_log_trace(this->log, "%p: %d -> %d", this, io->status, status); + io->status = status; + io->buffer_id = SPA_ID_INVALID; + spa_node_call_ready(&this->callbacks, status); set_timeout(this, this->next_time); } @@ -1296,8 +1299,13 @@ static int impl_node_process(void *object) return SPA_STATUS_HAVE_DATA; } - if (!this->started || !this->transport_started) - return SPA_STATUS_OK; + if (!this->started || !this->transport_started) { + if (io->status != SPA_STATUS_HAVE_DATA) { + io->status = SPA_STATUS_HAVE_DATA; + io->buffer_id = SPA_ID_INVALID; + } + return SPA_STATUS_HAVE_DATA; + } if (io->status == SPA_STATUS_HAVE_DATA && io->buffer_id < port->n_buffers) { struct buffer *b = &port->buffers[io->buffer_id];