We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1480

Summary: SDL_sound unable to decode Ogg Vorbis file
Product: SDL_sound Reporter: Nikos Chantziaras <realnc>
Component: everythingAssignee: Ryan C. Gordon <icculus>
Status: NEW --- QA Contact: Ryan C. Gordon <icculus>
Severity: normal    
Priority: P2    
Version: unspecified   
Hardware: x86_64   
OS: Linux   
Attachments: Ogg Vorbis file that cannot be decoded

Description Nikos Chantziaras 2012-04-21 14:01:30 UTC
Created attachment 847 [details]
Ogg Vorbis file that cannot be decoded

SDL_sound (current hg stable-1.0) cannot decode the attached file in whole.  A part of it is decoded, but at the wrong samplerate.  The SOUND_SAMPLEFLAG_ERROR is set in the sample, but Sound_GetError() doesn't return anything.

SDL_mixer has no problems decoding the file with Mix_LoadWAV_RW, so it's not a problem with the file.  SDL_mixer is unsuitable though, because it doesn't support partial decoding; it decodes the whole file in one go.

libvorbis 1.3.2
libogg 1.3.0

This is a test program that demonstrates the bug:

#include <stdio.h>
#include <SDL_sound.h>

int main(void)
{
    if (SDL_Init(SDL_INIT_AUDIO) != 0) {
        printf("SDL_Init() failed: %s\n", SDL_GetError());
        return 1;
    }

    if (Sound_Init() == 0) {
        printf("Sound_Init() failed: %s\n", Sound_GetError());
        return 1;
    }

    SDL_RWops* rw = SDL_RWFromFile("test.ogg", "rb");
    if (rw == 0) {
        printf("ERROR: %s\n", SDL_GetError());
        return 1;
    }

    Sound_AudioInfo wantedFormat;
    wantedFormat.channels = 2;
    wantedFormat.rate = 44100;
    wantedFormat.format = AUDIO_S16LSB;

    Sound_Sample* sample = Sound_NewSample(rw, "OGG", &wantedFormat, 4096);
    if (sample == 0) {
        printf("ERROR: %s\n", Sound_GetError());
        return 1;
    }
    Sound_DecodeAll(sample);
    if (sample->flags & SOUND_SAMPLEFLAG_ERROR) {
        printf("ERROR: %s\n", Sound_GetError());
    }

    Sound_Quit();
    SDL_Quit();
    return 0;
}