mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
LibAudio: Buffer API improvements
This consists of two changes: First, a utility function create_empty allows the user to quickly create an empty buffer. Second, most creation functions now return a NonnullRefPtr, as their failure causes a VERIFY crash anyways.
This commit is contained in:
parent
14d330faba
commit
ec8bd8116d
2 changed files with 11 additions and 5 deletions
|
@ -122,13 +122,13 @@ static double read_norm_sample_8(InputMemoryStream& stream)
|
|||
return double(sample) / NumericLimits<u8>::max();
|
||||
}
|
||||
|
||||
RefPtr<Buffer> Buffer::from_pcm_data(ReadonlyBytes data, int num_channels, PcmSampleFormat sample_format)
|
||||
NonnullRefPtr<Buffer> Buffer::from_pcm_data(ReadonlyBytes data, int num_channels, PcmSampleFormat sample_format)
|
||||
{
|
||||
InputMemoryStream stream { data };
|
||||
return from_pcm_stream(stream, num_channels, sample_format, data.size() / (pcm_bits_per_sample(sample_format) / 8));
|
||||
}
|
||||
|
||||
RefPtr<Buffer> Buffer::from_pcm_stream(InputMemoryStream& stream, int num_channels, PcmSampleFormat sample_format, int num_samples)
|
||||
NonnullRefPtr<Buffer> Buffer::from_pcm_stream(InputMemoryStream& stream, int num_channels, PcmSampleFormat sample_format, int num_samples)
|
||||
{
|
||||
Vector<Sample> fdata;
|
||||
fdata.ensure_capacity(num_samples);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue