BeagleBone Black:SDL_OpenAudio失败了除了虚拟驱动程序之外的任何东西

时间:2013-07-07 20:25:49

标签: sdl beagleboard

  • 操作系统:Angstrom Linux 2012.12,内核3.8.13在BeagleBone Black Rev A5B上运行。
  • SDL:libsdl 1.2.0,sdl-config 1.2.15

我正在尝试使用SDL在BeagleBone Black上编写音源。但是,除非我使用dummy驱动程序,否则SDL音频似乎不起作用。我正在使用以下代码来尝试诊断SDL_AudioOpen问题:

#include <SDL/SDL.h>
#include <SDL/SDL_audio.h>
#include <iostream>

void audio_callback (void*, Uint8*, int) { }

void ReportError (const char *where, int status) {
  std::cerr << "SDL Error: " << where << " (" << status << ") "
            << SDL_GetError () << std::endl;
  exit (1);
}

void ReportEnv (const char *var) {
  const char *driver = getenv (var);
  if (NULL == driver)
    std::cerr << var << " is null" << std::endl;
  else
    std::cerr << var << ": " << driver << std::endl;
}

int main (int argc, char **argv)
{ ReportEnv ("SDL_AUDIODRIVER");

  int ret = SDL_Init (SDL_INIT_AUDIO);
  if (0 != ret)
    ReportError ("SDL_Init", ret);

  SDL_AudioSpec ds, obtained;
  ds . freq = 44100;
  ds . format = AUDIO_S16;
  ds . channels = 1;
  ds . samples = 1024;
  ds . callback = audio_callback;
  ds . userdata = NULL;

  ret = SDL_OpenAudio (&ds, &obtained);
  if (0 != ret)
    ReportError ("SDL_OpenAudio", ret);

  std::cout << "Success" << std::endl;

  return 0;
}

我得到以下结果:

% SDL_AUDIODRIVER=dummy ./simple
SDL_AUDIODRIVER: dummy
Success
% SDL_AUDIODRIVER=alsa ./simple
SDL_AUDIODRIVER: alsa
SDL Error: SDL_OpenAudio (-1) No available audio device
% SDL_AUDIODRIVER=disk ./simple
SDL_AUDIODRIVER: disk
SDL Error: SDL_OpenAudio (-1) No available audio device
% 

aplay有效,因此似乎ALSA至少部分配置正确。

我错过了什么?似乎disk驱动程序应该在所有情况下都可以工作。

0 个答案:

没有答案