SDL_Sound rewind - was SDL_mixer RWops

well, i’ve got my looping of audio working with sdl_sound, so i think i’ll
stick with it. however, i can only use a predecoded file to loop, there are
problems when using the sound_rewind function. it can’t. i’m using the
mpg123 lib and not the smpeg. i’ve looked into the code and the function
uses the SDL_RWops->seek method to rewind the Sound_SampleInternal->rw
SDL_RWops structure, but doesn’t. i remember reading somewhere that this can
be avoided by wrapping it in some sort of buffering SDL_RWops… but i’m
not sure how to do this…can anyone help please .

thanks,
–Keith

well, i’ve got my looping of audio working with sdl_sound, so i think i’ll
stick with it. however, i can only use a predecoded file to loop, there are
problems when using the sound_rewind function. it can’t. i’m using the
mpg123 lib and not the smpeg. i’ve looked into the code and the function
uses the SDL_RWops->seek method to rewind the Sound_SampleInternal->rw
SDL_RWops structure, but doesn’t. i remember reading somewhere that this can
be avoided by wrapping it in some sort of buffering SDL_RWops… but i’m
not sure how to do this…can anyone help please .

The buffering RWops was never written, since it’s roughly equivalent to
predecoding. That being said, Sound_Rewind() works here with MPGLIB.

What type of RWops do you have? Can we see the code?

(We should also move this discussion to the SDL_sound mailing list: blank
email to sdlsound-subscribe at icculus.org to get on that list.)

–ryan.

well i could send the code, but essentially it’s from the playwav.c example
with the loop structure changed a bit. it was able to continually loop, so i
just changed it a bit to set the number of loops. other than that, i am
using the paragui wrapper function to the physfs function that opens the mp3
from a zip file as RWops. and in the read_more_data function, after playing
once, if you have it set to loop, it calls the sound_rewind function, which
is returning an error for me.

but, if you would really like to see the code i can send it all… but
here is just the clips of the read_more_data function and the function i use
to open the RWops

static int read_more_data(Sound_Sample sample)
{
if (done_flag) /
probably a sigint; stop trying to read.
*/
decoded_bytes = 0;

if (decoded_bytes > 0)      /* don't need more data; just return. */
    return(decoded_bytes);

    /* need more. See if there's more to be read... */
if (!(sample->flags & (SOUND_SAMPLEFLAG_ERROR | SOUND_SAMPLEFLAG_EOF)))
{
    decoded_bytes = Sound_Decode(sample);
    decoded_ptr = (unsigned char *)sample->buffer;
    return(read_more_data(sample));  /* handle loops conditions. */
} /* if */

/* No more to be read from stream, but we may want to loop the sample.

*/

//if looping is 0, then we either play once, or this is the final loop of
//the sequence of loops. if -1, we always loop. it’s placed second in the
//if b/c we don’t want the loop count decrement to continue past 0.
if (looping == 0)
return(0);
else if (looping == -1){}
else
looping–;

/* we just need to point predecoded samples to the start of the buffer.

*/
if (predecode)
{
decoded_bytes = sample->buffer_size;
decoded_ptr = (unsigned char )sample->buffer;
return(decoded_bytes);
} /
if /
else
{
if (!Sound_Rewind(sample)){
fprintf(stderr,“in reqind: %s”, Sound_GetError());
return(0);
}
return(read_more_data(sample));
} /
else */

assert(0);  /* shouldn't ever hit this point. */
return(0);

} /* read_more_data */

//opening the mp3 - where rhythm_name is an mp3 in a zip file
SDL_RWops *ff = PG_FileArchive::OpenFileRWops(rhythm_name, PG_OPEN_READ);> ----- Original Message -----

From: icculus@icculus.org (Ryan C. Gordon)
To:
Sent: Wednesday, July 10, 2002 6:29 PM
Subject: Re: [SDL] SDL_Sound rewind - was SDL_mixer RWops

well, i’ve got my looping of audio working with sdl_sound, so i think
i’ll

stick with it. however, i can only use a predecoded file to loop, there
are

problems when using the sound_rewind function. it can’t. i’m using the
mpg123 lib and not the smpeg. i’ve looked into the code and the function
uses the SDL_RWops->seek method to rewind the Sound_SampleInternal->rw
SDL_RWops structure, but doesn’t. i remember reading somewhere that this
can

be avoided by wrapping it in some sort of buffering SDL_RWops… but
i’m

not sure how to do this…can anyone help please .

The buffering RWops was never written, since it’s roughly equivalent to
predecoding. That being said, Sound_Rewind() works here with MPGLIB.

What type of RWops do you have? Can we see the code?

(We should also move this discussion to the SDL_sound mailing list: blank
email to sdlsound-subscribe at icculus.org to get on that list.)

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl