mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:18:10 +00:00
LibAudio: Use new format functions.
This commit is contained in:
parent
80e23d1b98
commit
805ed03b48
2 changed files with 16 additions and 16 deletions
|
@ -37,7 +37,7 @@ WavLoader::WavLoader(const StringView& path)
|
||||||
: m_file(Core::File::construct(path))
|
: m_file(Core::File::construct(path))
|
||||||
{
|
{
|
||||||
if (!m_file->open(Core::IODevice::ReadOnly)) {
|
if (!m_file->open(Core::IODevice::ReadOnly)) {
|
||||||
m_error_string = String::format("Can't open file: %s", m_file->error_string());
|
m_error_string = String::formatted("Can't open file: {}", m_file->error_string());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ WavLoader::WavLoader(const StringView& path)
|
||||||
RefPtr<Buffer> WavLoader::get_more_samples(size_t max_bytes_to_read_from_input)
|
RefPtr<Buffer> WavLoader::get_more_samples(size_t max_bytes_to_read_from_input)
|
||||||
{
|
{
|
||||||
#ifdef AWAVLOADER_DEBUG
|
#ifdef AWAVLOADER_DEBUG
|
||||||
dbgprintf("Read WAV of format PCM with num_channels %u sample rate %u, bits per sample %u\n", m_num_channels, m_sample_rate, m_bits_per_sample);
|
dbgln("Read WAV of format PCM with num_channels {} sample rate {}, bits per sample {}", m_num_channels, m_sample_rate, m_bits_per_sample);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto raw_samples = m_file->read(max_bytes_to_read_from_input);
|
auto raw_samples = m_file->read(max_bytes_to_read_from_input);
|
||||||
|
@ -82,18 +82,18 @@ bool WavLoader::parse_header()
|
||||||
{
|
{
|
||||||
Core::IODeviceStreamReader stream(*m_file);
|
Core::IODeviceStreamReader stream(*m_file);
|
||||||
|
|
||||||
#define CHECK_OK(msg) \
|
#define CHECK_OK(msg) \
|
||||||
do { \
|
do { \
|
||||||
if (stream.handle_read_failure()) { \
|
if (stream.handle_read_failure()) { \
|
||||||
m_error_string = String::format("Premature stream EOF at %s", msg); \
|
m_error_string = String::formatted("Premature stream EOF at {}", msg); \
|
||||||
return {}; \
|
return {}; \
|
||||||
} \
|
} \
|
||||||
if (!ok) { \
|
if (!ok) { \
|
||||||
m_error_string = String::format("Parsing failed: %s", msg); \
|
m_error_string = String::formatted("Parsing failed: {}", msg); \
|
||||||
return {}; \
|
return {}; \
|
||||||
} else { \
|
} else { \
|
||||||
dbgprintf("%s is OK!\n", msg); \
|
dbgln("{} is OK!", msg); \
|
||||||
} \
|
} \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
@ -294,7 +294,7 @@ RefPtr<Buffer> Buffer::from_pcm_data(ReadonlyBytes data, ResampleHelper& resampl
|
||||||
Vector<Sample> fdata;
|
Vector<Sample> fdata;
|
||||||
fdata.ensure_capacity(data.size() / (bits_per_sample / 8));
|
fdata.ensure_capacity(data.size() / (bits_per_sample / 8));
|
||||||
#ifdef AWAVLOADER_DEBUG
|
#ifdef AWAVLOADER_DEBUG
|
||||||
dbg() << "Reading " << bits_per_sample << " bits and " << num_channels << " channels, total bytes: " << data.size();
|
dbgln("Reading {} bits and {} channels, total bytes: {}", bits_per_sample, num_channels, data.size());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (bits_per_sample) {
|
switch (bits_per_sample) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ void WavWriter::set_file(const StringView& path)
|
||||||
{
|
{
|
||||||
m_file = Core::File::construct(path);
|
m_file = Core::File::construct(path);
|
||||||
if (!m_file->open(Core::IODevice::ReadWrite)) {
|
if (!m_file->open(Core::IODevice::ReadWrite)) {
|
||||||
m_error_string = String::format("Can't open file: %s", m_file->error_string());
|
m_error_string = String::formatted("Can't open file: {}", m_file->error_string());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_file->seek(44);
|
m_file->seek(44);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue