mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +00:00
LibAudio+aplay: Make the aplay output look a little funner.
Show some information about the file we're playing, and display how many samples we've played out of how many total. This might be a bit buggy as I haven't tested it with many different files, but it's a start. :^)
This commit is contained in:
parent
b44d3faa1c
commit
ae4a9e017a
3 changed files with 31 additions and 13 deletions
|
@ -25,7 +25,10 @@ RefPtr<ABuffer> AWavLoader::get_more_samples()
|
|||
auto raw_samples = m_file.read(128 * KB);
|
||||
if (raw_samples.is_empty())
|
||||
return nullptr;
|
||||
return ABuffer::from_pcm_data(raw_samples, m_num_channels, m_bits_per_sample, m_sample_rate);
|
||||
|
||||
auto buffer = ABuffer::from_pcm_data(raw_samples, m_num_channels, m_bits_per_sample, m_sample_rate);
|
||||
m_loaded_samples += buffer->sample_count();
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool AWavLoader::parse_header()
|
||||
|
@ -125,6 +128,9 @@ bool AWavLoader::parse_header()
|
|||
ok = ok && data_sz < INT32_MAX;
|
||||
CHECK_OK("Data was too large");
|
||||
|
||||
int bytes_per_sample = (m_bits_per_sample / 8) * m_num_channels;
|
||||
m_total_samples = data_sz / bytes_per_sample;
|
||||
|
||||
// Just make sure we're good before we read the data...
|
||||
ASSERT(!stream.handle_read_failure());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue