Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac系统下播放音频会有杂音 #3

Open
cocobao opened this issue Jun 2, 2021 · 1 comment
Open

Mac系统下播放音频会有杂音 #3

cocobao opened this issue Jun 2, 2021 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@cocobao
Copy link

cocobao commented Jun 2, 2021

你好,我使用了您的代码运行播放了一段MP3音乐,发现在Mac系统下会有杂音,而在window系统下则没有,我使用的系统版本是11.3。

我大致看了一下代码,觉得比较可能有问题是在musicplayer.cpp的445行

    while (chunks--) {
        QByteArray pcm = d->m_audioBuffer.mid(0, readSize);
        int size = pcm.size();
        d->m_audioBuffer.remove(0, size);

        if (size) d->m_audioDevice->write(pcm);
        if (size != readSize) break;
    }

就是if (size) d->m_audioDevice->write(pcm);这一行

write写入一段音频数据之后会返回一个实际写入播放设备的字节数,这个字节数跟输入缓冲的字节数不是一定相等的。有时候会比实际输入缓冲字节数小,就是说这里可能存在一些数据被丢弃而没有输入播放

@mengps
Copy link
Owner

mengps commented Sep 23, 2021

阿。。抱歉现在才回复(之前看到但是忘了)。关于Mac系统我并没有测试过,因此也不好确定。当然你指出的地方确实是有可能,可以尝试继承QIODevice来写入。

@mengps mengps added the help wanted Extra attention is needed label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants