1

在我的团队中,我们使用 SDL(版本1.2)为嵌入式 Linux 系统(内核版本 4.19)开发 UI。我们运行的主板是 Amlogic A113X。

当我们尝试在我们的“常规”Ubuntu 机器上加载 SDL_mixer 时,一切正常,在板上 SDL_mixer 无法加载。

SDL_mixer 封装在一个AudioPlayer类中,该类使用 PIMPL 将 SDL 依赖项隐藏在 cpp 文件中。

相关代码:

void AudioPlayerImpl::throw_sdl_exception(const char* method_name){
    auto error_message = std::string("AudioPlayerImpl::") + method_name + ", " + SDL_GetError();
    throw std::runtime_error(error_message);
}


AudioPlayerImpl::AudioPlayerImpl()  :
    m_audio_context(nullptr),
    m_working(true),
    m_stop_music_requested(false){
    const auto code = ::Mix_Init(MIX_INIT_MP3);
    if (code & MIX_INIT_MP3 != MIX_INIT_MP3) {
        throw_sdl_exception("AudioPlayerImpl");
    }

    if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 4096) != 0) {
        throw_sdl_exception("AudioPlayerImpl");
    }

    m_audio_worker = std::thread([this]{
        work_loop();
    });
}

错误:

AudioPlayerImpl::AudioPlayerImpl, Mixer not built with MP3 support

试听信息:ALSA 和 mpg123 都存在于/usr/lib

下一步该怎么做?据我所知,libmpg123 是 SDL 用于播放 mp3 的依赖项,并且该依赖项位于正确的位置。

4

0 回答 0