SDL_mixer: streaming a music file from a large file

There doesn’t seem to be a way to play music with SDL_mixer if the media
file resides “bundled” in a larger file. Mix_LoadMUS() doesn’t provide
any arguments for file offset and media length. SDL_RWFromFP() and
SDL_RWFromFile() also don’t seem to offer this.

Is there some kind of hack I can do to achieve this? (Without modifying
the SDL library.) Currently, I map the part of the file in which the
media data resides in into memory, and create an RWOps for it which I
then load with Mix_LoadMUS_RW(). This however wastes a lot of memory;
the whole media file ends up in memory and is not streamed from the disk
file.

There doesn’t seem to be a way to play music with SDL_mixer if the
media file resides “bundled” in a larger file. Mix_LoadMUS() doesn’t
provide any arguments for file offset and media length. SDL_RWFromFP()
and SDL_RWFromFile() also don’t seem to offer this.

Is there some kind of hack I can do to achieve this? (Without
modifying the SDL library.) Currently, I map the part of the file in
which the media data resides in into memory, and create an RWOps for
it which I then load with Mix_LoadMUS_RW(). This however wastes a lot
of memory; the whole media file ends up in memory and is not streamed
from the disk file.
You can implement a SDL_RWops that takes a file (pointer or name, your
choice), an offset and a size and implement RWops functions that take
the offset and size into account.

Cheers,

AndreOn 10/06/2011 19:59, Nikos Chantziaras wrote:


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Here is a nice “tutorial” on SDL_RWops:
http://kekkai.org/roger/sdl/rwops/rwops.htmlOn 6/10/11 4:07 PM, Andre Leiradella wrote:

On 10/06/2011 19:59, Nikos Chantziaras wrote:

There doesn’t seem to be a way to play music with SDL_mixer if the
media file resides “bundled” in a larger file. Mix_LoadMUS() doesn’t
provide any arguments for file offset and media length.
SDL_RWFromFP() and SDL_RWFromFile() also don’t seem to offer this.

Is there some kind of hack I can do to achieve this? (Without
modifying the SDL library.) Currently, I map the part of the file in
which the media data resides in into memory, and create an RWOps for
it which I then load with Mix_LoadMUS_RW(). This however wastes a
lot of memory; the whole media file ends up in memory and is not
streamed from the disk file.
You can implement a SDL_RWops that takes a file (pointer or name, your
choice), an offset and a size and implement RWops functions that take
the offset and size into account.

Cheers,

Andre


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Ah, there are callbacks in the RWops struct. Didn’t really notice
before; I considered the RWops type as being opaque and its internals
not to be used if you want your code to be portable.

Thanks for pointing this out.On 06/11/2011 02:07 AM, Andre Leiradella wrote:

On 10/06/2011 19:59, Nikos Chantziaras wrote:

There doesn’t seem to be a way to play music with SDL_mixer if the
media file resides “bundled” in a larger file. Mix_LoadMUS() doesn’t
provide any arguments for file offset and media length. SDL_RWFromFP()
and SDL_RWFromFile() also don’t seem to offer this.

Is there some kind of hack I can do to achieve this? (Without
modifying the SDL library.) Currently, I map the part of the file in
which the media data resides in into memory, and create an RWOps for
it which I then load with Mix_LoadMUS_RW(). This however wastes a lot
of memory; the whole media file ends up in memory and is not streamed
from the disk file.
You can implement a SDL_RWops that takes a file (pointer or name, your
choice), an offset and a size and implement RWops functions that take
the offset and size into account.