I am having a problem getting SDL2 audio working on both Ubuntu 32bit 12.04
and 12.10 (on two different machines). If anyone could help me resolve this
matter I’d very much appreciate your advice. I have built SDL2 using with
the following commands:
hg clone http://hg.libsdl.org/SDL
mkdir build
cd build
cmake …/SDL
make
Here is cmake’s output:
http://www.codebot.org/sdl/cmake.txt
I also wrote a short audio test which outputs the following (note the
failure on SDL_OpenAudio):
Number of drivers: 3
driver 0: dsp
driver 1: disk
driver 2: dummy
Number of capture devices: 0
Number of output devices: 0
SDL failed to open audio: No such audio device
Done test
Audio test source code:
procedure ProccessAudio(userdata: Pointer; stream: PUInt8; len: Integer);
cdecl;
begin
end;
procedure PrintAudioDrivers;
var
I, J: Integer;
begin
J := SDL_GetNumAudioDrivers;
WriteLn('Number of drivers: ‘, J);
for I := 0 to J -1 do
WriteLn(’ driver ', I, ': ', SDL_GetAudioDriver(I));
end;
procedure PrintAudioDevices(iscapture: LongInt);
const
DeviceType: array[0…1] of AnsiString = (‘capture’, ‘output’);
var
I, J: Integer;
begin
J := SDL_GetNumAudioDevices(iscapture);
WriteLn('Number of ', DeviceType[iscapture], ’ devices: ‘, J);
for I := 0 to J -1 do
WriteLn(’ device ', I, ': ', SDL_GetAudioDeviceName(I, iscapture));
end;
procedure TestSound;
var
Desired, Obtained: TSDL_AudioSpec;
begin
if SDL_Init(SDL_INIT_AUDIO) <> 0 then
begin
WriteLn('SDL failed to initialize audio: ', SDL_GetError);
Exit;
end;
PrintAudioDrivers;
PrintAudioDevices(0);
PrintAudioDevices(1);
Desired.freq := 22050;
Desired.format := AUDIO_U8;
Desired.channels := 2;
Desired.samples := 512;
Desired.callback := ProccessAudio;
Desired.userdata := nil;
if SDL_OpenAudio(@Desired, @Obtained) <> 0 then
WriteLn('SDL failed to open audio: ', SDL_GetError);
SDL_Quit;
WriteLn(‘Done test’);
end;