* Convert libmpg123's format to an #AudioFormat instance. * * @param handle a handle which was created before; on error, this * function will not free it * @param audio_format this parameter is filled after successful * return * @return true on success */
| 155 | * @return true on success |
| 156 | */ |
| 157 | static bool |
| 158 | GetAudioFormat(mpg123_handle &handle, AudioFormat &audio_format) |
| 159 | { |
| 160 | long rate; |
| 161 | int channels, encoding; |
| 162 | if (const int error = mpg123_getformat(&handle, &rate, &channels, &encoding); |
| 163 | error != MPG123_OK) { |
| 164 | FmtWarning(mpg123_domain, |
| 165 | "mpg123_getformat() failed: {}", |
| 166 | mpg123_plain_strerror(error)); |
| 167 | return false; |
| 168 | } |
| 169 | |
| 170 | if (encoding != MPG123_ENC_SIGNED_16) { |
| 171 | /* other formats not yet implemented */ |
| 172 | FmtWarning(mpg123_domain, |
| 173 | "expected MPG123_ENC_SIGNED_16, got {}", |
| 174 | encoding); |
| 175 | return false; |
| 176 | } |
| 177 | |
| 178 | audio_format = CheckAudioFormat(rate, SampleFormat::S16, channels); |
| 179 | return true; |
| 180 | } |
| 181 | |
| 182 | #ifdef ENABLE_ID3TAG |
| 183 |
no test coverage detected