bluez5: allow codecs to produce multiple packets from same data

Codecs may need to fragment a single encoder frame across multiple
packets that are sent consecutively.

Allow codec->encode() to set need_flush=NEED_FLUSH_FRAGMENT, so that
sink should immediately call start_encode + encode with NULL input data,
to produce the next packet.

Previously, other return values than need_flush=1 were unused, so no
need to bump codec ABI for this.
This commit is contained in:
Pauli Virtanen 2022-04-30 20:54:32 +03:00
parent 0cab700c06
commit 3d4eafcb0f
7 changed files with 66 additions and 6 deletions

View file

@ -404,7 +404,7 @@ static int codec_encode(void *data,
avail_dst_size = (this->max_frames - this->frame_count) * this->frame_length;
if (SPA_UNLIKELY(dst_size < avail_dst_size)) {
*need_flush = 1;
*need_flush = NEED_FLUSH_ALL;
return 0;
}
@ -414,7 +414,7 @@ static int codec_encode(void *data,
return -EINVAL;
this->frame_count += *dst_out / this->frame_length;
*need_flush = this->frame_count >= this->max_frames;
*need_flush = (this->frame_count >= this->max_frames) ? NEED_FLUSH_ALL : NEED_FLUSH_NO;
return res;
}