mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:08:10 +00:00
LibAudio: Make Loader::seek() treat its input as a sample index
This fixes a bug where if you try to play a Wave file a second time (or loop with `aplay -l`), the second time will be pure noise. The function `Audio::Loader::seek` is meant to seek to a specific audio sample, e.g. seek(0) should go to the first audio sample. However, WavLoader was interpreting seek(0) as the beginning of the file or stream, which contains non-audio header data. This fixes the bug by capturing the byte offset of the start of the audio data, and offseting the raw file/stream seek by that amount.
This commit is contained in:
parent
2a3090d292
commit
23d5b99fbf
3 changed files with 17 additions and 6 deletions
|
@ -27,7 +27,8 @@ public:
|
|||
virtual RefPtr<Buffer> get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) = 0;
|
||||
|
||||
virtual void reset() = 0;
|
||||
virtual void seek(const int position) = 0;
|
||||
|
||||
virtual void seek(const int sample_index) = 0;
|
||||
|
||||
virtual int loaded_samples() = 0;
|
||||
virtual int total_samples() = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue