mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
LibAudio/aplay: Handle WAV header errors properly
We shouldn't just ASSERT() if the header parse fails. This was crashing Piano completely.
This commit is contained in:
parent
4ad96df0d4
commit
d55d2b2794
2 changed files with 7 additions and 2 deletions
|
@ -40,7 +40,9 @@ WavLoader::WavLoader(const StringView& path)
|
|||
return;
|
||||
}
|
||||
|
||||
parse_header();
|
||||
if (!parse_header())
|
||||
return;
|
||||
|
||||
m_resampler = make<ResampleHelper>(m_sample_rate, 44100);
|
||||
}
|
||||
|
||||
|
@ -81,7 +83,6 @@ bool WavLoader::parse_header()
|
|||
|
||||
#define CHECK_OK(msg) \
|
||||
do { \
|
||||
ASSERT(ok); \
|
||||
if (stream.handle_read_failure()) { \
|
||||
m_error_string = String::format("Premature stream EOF at %s", msg); \
|
||||
return {}; \
|
||||
|
|
|
@ -41,6 +41,10 @@ int main(int argc, char** argv)
|
|||
auto audio_client = Audio::ClientConnection::construct();
|
||||
audio_client->handshake();
|
||||
Audio::WavLoader loader(argv[1]);
|
||||
if (loader.has_error()) {
|
||||
fprintf(stderr, "Failed to load WAV file: %s\n", loader.error_string());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("\033[34;1m Playing\033[0m: %s\n", argv[1]);
|
||||
printf("\033[34;1m Format\033[0m: %u Hz, %u-bit, %s\n",
|
||||
|
|
Loading…
Add table
Reference in a new issue