Release the audio lock early
The final write from the writer thread does not require a lock: it is guaranteed that enough space is available since the reader thread never writes.
This commit is contained in:
parent
5d1d5bdc16
commit
9ea4446369
@ -194,7 +194,11 @@ sc_audio_player_frame_sink_push(struct sc_frame_sink *sink,
|
|||||||
// Still insufficient, drop old samples to make space
|
// Still insufficient, drop old samples to make space
|
||||||
skipped_samples = sc_audiobuf_read(&ap->buf, NULL, remaining);
|
skipped_samples = sc_audiobuf_read(&ap->buf, NULL, remaining);
|
||||||
assert(skipped_samples == remaining);
|
assert(skipped_samples == remaining);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_UnlockAudioDevice(ap->device);
|
||||||
|
|
||||||
|
if (written < samples) {
|
||||||
// Now there is enough space
|
// Now there is enough space
|
||||||
uint32_t w = sc_audiobuf_write(&ap->buf,
|
uint32_t w = sc_audiobuf_write(&ap->buf,
|
||||||
swr_buf + TO_BYTES(written),
|
swr_buf + TO_BYTES(written),
|
||||||
@ -202,8 +206,6 @@ sc_audio_player_frame_sink_push(struct sc_frame_sink *sink,
|
|||||||
assert(w == remaining);
|
assert(w == remaining);
|
||||||
(void) w;
|
(void) w;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockAudioDevice(ap->device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t underflow = 0;
|
uint32_t underflow = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user