Fail mp3 loading when attempting to load invalid mp3s

This also adds a warning for unspecified MP3 loading error codes

(cherry picked from commit 936767deca)
This commit is contained in:
Ellen Poe 2021-02-14 20:08:49 -08:00 committed by Rémi Verschelde
parent ec0085973f
commit 5db83defcd
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -159,7 +159,8 @@ void AudioStreamMP3::set_data(const PoolVector<uint8_t> &p_data) {
PoolVector<uint8_t>::Read src_datar = p_data.read(); PoolVector<uint8_t>::Read src_datar = p_data.read();
mp3dec_ex_t mp3d; mp3dec_ex_t mp3d;
mp3dec_ex_open_buf(&mp3d, src_datar.ptr(), src_data_len, MP3D_SEEK_TO_SAMPLE); int err = mp3dec_ex_open_buf(&mp3d, src_datar.ptr(), src_data_len, MP3D_SEEK_TO_SAMPLE);
ERR_FAIL_COND(err != 0);
channels = mp3d.info.channels; channels = mp3d.info.channels;
sample_rate = mp3d.info.hz; sample_rate = mp3d.info.hz;