mirror of
https://github.com/Genymobile/scrcpy
synced 2025-02-17 04:57:24 +00: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
@ -37,6 +37,7 @@ sc_audiobuf_read(struct sc_audiobuf *buf, void *to_, uint32_t samples_count) {
|
||||
assert(samples_count);
|
||||
|
||||
uint8_t *to = to_;
|
||||
assert(to);
|
||||
|
||||
// The tail cursor may be updated by the writer thread to drop samples
|
||||
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;
|
||||
}
|
||||
|
||||
if (to) {
|
||||
uint32_t right_count = buf->alloc_size - tail;
|
||||
if (right_count > samples_count) {
|
||||
right_count = samples_count;
|
||||
}
|
||||
memcpy(to,
|
||||
buf->data + (tail * buf->sample_size),
|
||||
right_count * buf->sample_size);
|
||||
uint32_t right_count = buf->alloc_size - tail;
|
||||
if (right_count > samples_count) {
|
||||
right_count = samples_count;
|
||||
}
|
||||
memcpy(to,
|
||||
buf->data + (tail * buf->sample_size),
|
||||
right_count * buf->sample_size);
|
||||
|
||||
if (samples_count > right_count) {
|
||||
uint32_t left_count = samples_count - right_count;
|
||||
memcpy(to + (right_count * buf->sample_size),
|
||||
buf->data,
|
||||
left_count * buf->sample_size);
|
||||
}
|
||||
if (samples_count > right_count) {
|
||||
uint32_t left_count = samples_count - right_count;
|
||||
memcpy(to + (right_count * buf->sample_size),
|
||||
buf->data,
|
||||
left_count * buf->sample_size);
|
||||
}
|
||||
|
||||
uint32_t new_tail = (tail + samples_count) % buf->alloc_size;
|
||||
|
Loading…
Reference in New Issue
Block a user