[sdlsound] Question

Ryan C. Gordon icculus at clutteredmind.org
Thu Mar 13 03:05:41 EST 2003

> Hm...  afaik, an RWOPS can only read from 2 locations:  From disk, or from
> memory.  So you'd have to set up a buffer in memory first, and build an RWOPS
> around it.  And for creating and using TCP connections, the SDL_net library
> should be useful.

You can roll your own RWops (it's really just an interface) that reads
from a network connection, but you need to take into account that:

1) Net lag could mean that your RWops won't have available data when you
need it and...
2) ...there's no way to see if you've got an EOF condition in a RWops...
3) ...so returning zero from a read will make programs think you're at EOF...
4) ...which means you can't do nonblocking i/o.

RWops really need to be extended for SDL 2.0.

This complicates things with SDL sound. You can make your RWops have some
extra functionality and make sure Sound_Decode() only gets called when
there's a big enough buffer...think of this as subclassing a RWops without
the benefit of C++. You app talks to the extra functionality of your RWops
implementation, SDL_sound only sees the basic read/write/seek/close

Remember that lots of the SDL_sound decoders want to seek around the
RWops, too, which makes things uglier.


More information about the sdlsound mailing list