mirror of
https://github.com/Genymobile/scrcpy.git
synced 2024-09-12 05:21:18 +02:00
Remove useless skip feature in audio buffer
After the refactor from the previous commit, sc_audiobuf_read() is never called with a NULL destination (used to skip samples).
This commit is contained in:
parent
a14b798185
commit
c74b716e11
1 changed files with 13 additions and 14 deletions
|
@ -37,6 +37,7 @@ sc_audiobuf_read(struct sc_audiobuf *buf, void *to_, uint32_t samples_count) {
|
||||||
assert(samples_count);
|
assert(samples_count);
|
||||||
|
|
||||||
uint8_t *to = to_;
|
uint8_t *to = to_;
|
||||||
|
assert(to);
|
||||||
|
|
||||||
// The tail cursor may be updated by the writer thread to drop samples
|
// The tail cursor may be updated by the writer thread to drop samples
|
||||||
uint32_t tail = atomic_load_explicit(&buf->tail, memory_order_acquire);
|
uint32_t tail = atomic_load_explicit(&buf->tail, memory_order_acquire);
|
||||||
|
@ -52,21 +53,19 @@ sc_audiobuf_read(struct sc_audiobuf *buf, void *to_, uint32_t samples_count) {
|
||||||
samples_count = can_read;
|
samples_count = can_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to) {
|
uint32_t right_count = buf->alloc_size - tail;
|
||||||
uint32_t right_count = buf->alloc_size - tail;
|
if (right_count > samples_count) {
|
||||||
if (right_count > samples_count) {
|
right_count = samples_count;
|
||||||
right_count = samples_count;
|
}
|
||||||
}
|
memcpy(to,
|
||||||
memcpy(to,
|
buf->data + (tail * buf->sample_size),
|
||||||
buf->data + (tail * buf->sample_size),
|
right_count * buf->sample_size);
|
||||||
right_count * buf->sample_size);
|
|
||||||
|
|
||||||
if (samples_count > right_count) {
|
if (samples_count > right_count) {
|
||||||
uint32_t left_count = samples_count - right_count;
|
uint32_t left_count = samples_count - right_count;
|
||||||
memcpy(to + (right_count * buf->sample_size),
|
memcpy(to + (right_count * buf->sample_size),
|
||||||
buf->data,
|
buf->data,
|
||||||
left_count * buf->sample_size);
|
left_count * buf->sample_size);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t new_tail = (tail + samples_count) % buf->alloc_size;
|
uint32_t new_tail = (tail + samples_count) % buf->alloc_size;
|
||||||
|
|
Loading…
Reference in a new issue