mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
LibAudio: Avoid reading past the end of sample data
Prior code in `WavLoader::get_more_samples()` would attempt to read the requested number of samples without actually checking whether that many samples were remaining in the stream. This was the cause of an audible pop at the end of a track, due to reading non-audio data that is sometimes at the end of a Wave file. Now we only attempt to read up to the end of sample data, but no further. Also, added comments to clarify the meaning of "sample", and how it should be independent of the number of channels.
This commit is contained in:
parent
df65ff8a1e
commit
dec9ed066d
2 changed files with 34 additions and 16 deletions
|
@ -30,10 +30,18 @@ public:
|
|||
|
||||
virtual void seek(const int sample_index) = 0;
|
||||
|
||||
// total_samples() and loaded_samples() should be independent
|
||||
// of the number of channels.
|
||||
//
|
||||
// For example, with a three-second-long, stereo, 44.1KHz audio file:
|
||||
// num_channels() should return 2
|
||||
// sample_rate() should return 44100 (each channel is sampled at this rate)
|
||||
// total_samples() should return 132300 (sample_rate * three seconds)
|
||||
virtual int loaded_samples() = 0;
|
||||
virtual int total_samples() = 0;
|
||||
virtual u32 sample_rate() = 0;
|
||||
virtual u16 num_channels() = 0;
|
||||
|
||||
virtual PcmSampleFormat pcm_format() = 0;
|
||||
virtual RefPtr<Core::File> file() = 0;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue