mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
bluetooth: Fix timing to count based on decoded data
Currently the latency information is being updated based on the encoded SBC data instead of the decoded PCM data. Fixing this required moving the timing update to be after the packet has been decoded.
This commit is contained in:
parent
4a5f48e7a4
commit
3f21c21628
2 changed files with 14 additions and 10 deletions
|
|
@ -881,6 +881,7 @@ static int a2dp_process_push(struct userdata *u) {
|
|||
void *d;
|
||||
ssize_t l;
|
||||
size_t to_write, to_decode;
|
||||
size_t total_written = 0;
|
||||
|
||||
a2dp_prepare_buffer(u);
|
||||
|
||||
|
|
@ -907,17 +908,12 @@ static int a2dp_process_push(struct userdata *u) {
|
|||
|
||||
pa_assert((size_t) l <= a2dp->buffer_size);
|
||||
|
||||
u->read_index += (uint64_t) l;
|
||||
|
||||
/* TODO: get timestamp from rtp */
|
||||
if (!found_tstamp) {
|
||||
/* pa_log_warn("Couldn't find SO_TIMESTAMP data in auxiliary recvmsg() data!"); */
|
||||
tstamp = pa_rtclock_now();
|
||||
}
|
||||
|
||||
pa_smoother_put(u->read_smoother, tstamp, pa_bytes_to_usec(u->read_index, &u->sample_spec));
|
||||
pa_smoother_resume(u->read_smoother, tstamp, true);
|
||||
|
||||
p = (uint8_t*) a2dp->buffer + sizeof(*header) + sizeof(*payload);
|
||||
to_decode = l - sizeof(*header) - sizeof(*payload);
|
||||
|
||||
|
|
@ -943,6 +939,8 @@ static int a2dp_process_push(struct userdata *u) {
|
|||
/* pa_log_debug("SBC: decoded: %lu; written: %lu", (unsigned long) decoded, (unsigned long) written); */
|
||||
/* pa_log_debug("SBC: frame_length: %lu; codesize: %lu", (unsigned long) a2dp->frame_length, (unsigned long) a2dp->codesize); */
|
||||
|
||||
total_written += written;
|
||||
|
||||
/* Reset frame length, it can be changed due to bitpool change */
|
||||
a2dp->frame_length = sbc_get_frame_length(&a2dp->sbc);
|
||||
|
||||
|
|
@ -958,6 +956,10 @@ static int a2dp_process_push(struct userdata *u) {
|
|||
to_write -= written;
|
||||
}
|
||||
|
||||
u->read_index += (uint64_t) total_written;
|
||||
pa_smoother_put(u->read_smoother, tstamp, pa_bytes_to_usec(u->read_index, &u->sample_spec));
|
||||
pa_smoother_resume(u->read_smoother, tstamp, true);
|
||||
|
||||
memchunk.length -= to_write;
|
||||
|
||||
pa_memblock_release(memchunk.memblock);
|
||||
|
|
|
|||
|
|
@ -402,6 +402,7 @@ static int a2dp_process_push(struct userdata *u) {
|
|||
void *d;
|
||||
ssize_t l;
|
||||
size_t to_write, to_decode;
|
||||
size_t total_written = 0;
|
||||
|
||||
a2dp_prepare_buffer(u);
|
||||
|
||||
|
|
@ -428,17 +429,12 @@ static int a2dp_process_push(struct userdata *u) {
|
|||
|
||||
pa_assert((size_t) l <= sbc_info->buffer_size);
|
||||
|
||||
u->read_index += (uint64_t) l;
|
||||
|
||||
/* TODO: get timestamp from rtp */
|
||||
if (!found_tstamp) {
|
||||
/* pa_log_warn("Couldn't find SO_TIMESTAMP data in auxiliary recvmsg() data!"); */
|
||||
tstamp = pa_rtclock_now();
|
||||
}
|
||||
|
||||
pa_smoother_put(u->read_smoother, tstamp, pa_bytes_to_usec(u->read_index, &u->sample_spec));
|
||||
pa_smoother_resume(u->read_smoother, tstamp, true);
|
||||
|
||||
p = (uint8_t*) sbc_info->buffer + sizeof(*header) + sizeof(*payload);
|
||||
to_decode = l - sizeof(*header) - sizeof(*payload);
|
||||
|
||||
|
|
@ -461,6 +457,8 @@ static int a2dp_process_push(struct userdata *u) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
total_written += written;
|
||||
|
||||
/* Reset frame length, it can be changed due to bitpool change */
|
||||
sbc_info->frame_length = sbc_get_frame_length(&sbc_info->sbc);
|
||||
|
||||
|
|
@ -476,6 +474,10 @@ static int a2dp_process_push(struct userdata *u) {
|
|||
to_write -= written;
|
||||
}
|
||||
|
||||
u->read_index += (uint64_t) total_written;
|
||||
pa_smoother_put(u->read_smoother, tstamp, pa_bytes_to_usec(u->read_index, &u->sample_spec));
|
||||
pa_smoother_resume(u->read_smoother, tstamp, true);
|
||||
|
||||
memchunk.length -= to_write;
|
||||
|
||||
pa_memblock_release(memchunk.memblock);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue