| 268 | } |
| 269 | |
| 270 | uint32_t AudioDecoderMp3::read(uint32_t framesToRead, char* pcmBuf) |
| 271 | { |
| 272 | #if !AX_USE_MPG123 |
| 273 | auto sampelsToRead = framesToRead * _channelCount; |
| 274 | auto samplesRead = mp3dec_ex_read(&_handle->_dec, (mp3d_sample_t*)pcmBuf, sampelsToRead); |
| 275 | return static_cast<uint32_t>(samplesRead / _channelCount); |
| 276 | #else |
| 277 | int bytesToRead = framesToBytes(framesToRead); |
| 278 | size_t bytesRead = 0; |
| 279 | int err = mpg123_read(_handle, (unsigned char*)pcmBuf, bytesToRead, &bytesRead); |
| 280 | if (err == MPG123_ERR) |
| 281 | { |
| 282 | AXLOGE("Trouble with mpg123: {}\n", mpg123_strerror(_handle)); |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | return bytesToFrames(bytesRead); |
| 287 | #endif |
| 288 | } |
| 289 | |
| 290 | bool AudioDecoderMp3::seek(uint32_t frameOffset) |
| 291 | { |
no test coverage detected