亚历山大的回答很好,非常感谢
当您下载 mpg123-1.15.1-x86.zip 时,我有一件小事要补充
您会看到 libmpg123-0.dll(dll)和 libmpg123-0.dll.def 用于制作上述 .lib 的东西。最好将名称更改为 libmpg123-0.def 否则它将寻找一个名为 libmpg123-0.dll.dll 的 dll,这不是很好
除此之外,它工作得很好。我不敢相信这些信息几年前不在互联网上。感谢亚历山大,感谢stackoverflow
仅供参考,这是一个使用 mpg123 的简单 mp3 解码器
#include "mpg123/mpg123.h"
#define INBUFF 16384
#define OUTBUFF 32768
void loadMp3File(const char* filename)
{
mpg123_handle *mh;
unsigned char *buffer;
size_t buffer_size;
size_t done;
int err;
int channels, encoding;
long rate;
mpg123_init();
mh = mpg123_new(NULL, &err);
buffer_size = mpg123_outblock(mh);
buffer = (unsigned char*) malloc(buffer_size * sizeof(unsigned char));
/* open the file and get the decoding format */
mpg123_open(mh, filename);
mpg123_getformat(mh, &rate, &channels, &encoding);
/* set the output format and open the output device */
int m_bits = mpg123_encsize(encoding);
int m_rate = rate;
int m_channels = channels;
/* decode and play */
for (int totalBtyes = 0 ; mpg123_read(mh, buffer, buffer_size, &done) == MPG123_OK ; ) {
totalBtyes += done;
}
/* clean up */
free(buffer);
mpg123_close(mh);
mpg123_delete(mh);
mpg123_exit();
}