mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-07-21 02:05:38 +00:00
bluez: allow buffers with maxsize < duration*frame_size
Buffer sizes smaller than one cycle are possible, so don't assert that. Instead, just provide as much samples as fits to the buffer. If we are driver when this happens, emit a warning (once). Similarly to ALSA, as driver we produce only one buffer at cycle start, and no new buffers in process. If the whole cycle doesn't fit into the buffer, recording probably will be broken and we want some debug when there will be a bug report about that.
This commit is contained in:
parent
4bb85ef6c9
commit
ff5f6d908b
|
@ -1342,6 +1342,9 @@ static void update_target_latency(struct impl *this)
|
|||
spa_bt_decode_buffer_set_target_latency(&port->buffer, samples);
|
||||
}
|
||||
|
||||
#define WARN_ONCE(cond, ...) \
|
||||
if (SPA_UNLIKELY(cond)) { static bool __once; if (!__once) { __once = true; spa_log_warn(__VA_ARGS__); } }
|
||||
|
||||
static void process_buffering(struct impl *this)
|
||||
{
|
||||
struct port *port = &this->port;
|
||||
|
@ -1364,13 +1367,21 @@ static void process_buffering(struct impl *this)
|
|||
struct spa_data *datas;
|
||||
uint32_t data_size;
|
||||
|
||||
buffer = spa_list_first(&port->free, struct buffer, link);
|
||||
datas = buffer->buf->datas;
|
||||
|
||||
data_size = samples * port->frame_size;
|
||||
|
||||
WARN_ONCE(datas[0].maxsize < data_size && !this->following,
|
||||
this->log, "source buffer too small (%u < %u)",
|
||||
datas[0].maxsize, data_size);
|
||||
|
||||
data_size = SPA_MIN(data_size, SPA_ROUND_DOWN(datas[0].maxsize, port->frame_size));
|
||||
|
||||
avail = SPA_MIN(avail, data_size);
|
||||
|
||||
spa_bt_decode_buffer_read(&port->buffer, avail);
|
||||
|
||||
buffer = spa_list_first(&port->free, struct buffer, link);
|
||||
spa_list_remove(&buffer->link);
|
||||
|
||||
spa_log_trace(this->log, "dequeue %d", buffer->id);
|
||||
|
@ -1381,10 +1392,6 @@ static void process_buffering(struct impl *this)
|
|||
buffer->h->dts_offset = 0;
|
||||
}
|
||||
|
||||
datas = buffer->buf->datas;
|
||||
|
||||
spa_assert(datas[0].maxsize >= data_size);
|
||||
|
||||
datas[0].chunk->offset = 0;
|
||||
datas[0].chunk->size = data_size;
|
||||
datas[0].chunk->stride = port->frame_size;
|
||||
|
|
|
@ -1298,6 +1298,9 @@ static uint32_t get_samples(struct impl *this, uint32_t *result_duration)
|
|||
return samples;
|
||||
}
|
||||
|
||||
#define WARN_ONCE(cond, ...) \
|
||||
if (SPA_UNLIKELY(cond)) { static bool __once; if (!__once) { __once = true; spa_log_warn(__VA_ARGS__); } }
|
||||
|
||||
static void process_buffering(struct impl *this)
|
||||
{
|
||||
struct port *port = &this->port;
|
||||
|
@ -1318,21 +1321,25 @@ static void process_buffering(struct impl *this)
|
|||
struct spa_data *datas;
|
||||
uint32_t data_size;
|
||||
|
||||
buffer = spa_list_first(&port->free, struct buffer, link);
|
||||
datas = buffer->buf->datas;
|
||||
|
||||
data_size = samples * port->frame_size;
|
||||
|
||||
WARN_ONCE(datas[0].maxsize < data_size && !this->following,
|
||||
this->log, "source buffer too small (%u < %u)",
|
||||
datas[0].maxsize, data_size);
|
||||
|
||||
data_size = SPA_MIN(data_size, SPA_ROUND_DOWN(datas[0].maxsize, port->frame_size));
|
||||
|
||||
avail = SPA_MIN(avail, data_size);
|
||||
|
||||
spa_bt_decode_buffer_read(&port->buffer, avail);
|
||||
|
||||
buffer = spa_list_first(&port->free, struct buffer, link);
|
||||
spa_list_remove(&buffer->link);
|
||||
|
||||
spa_log_trace(this->log, "dequeue %d", buffer->id);
|
||||
|
||||
datas = buffer->buf->datas;
|
||||
|
||||
spa_assert(datas[0].maxsize >= data_size);
|
||||
|
||||
datas[0].chunk->offset = 0;
|
||||
datas[0].chunk->size = data_size;
|
||||
datas[0].chunk->stride = port->frame_size;
|
||||
|
|
Loading…
Reference in a new issue