CVS Update (driverlist + aRts + 1.1.7 prerelease)

The latest CVS snapshot is available:
http://www.libsdl.org/cvs.html

The audio directory has been completely reorganized to allow multiple
audio drivers to be shared between platforms. This means that if you
have custom project files (Darrell), you’ll just need to change the
directory the audio driver resides in. This also means that everyone
should test this snapshot on their platform of choice to make sure that
I didn’t break anything. It seems to work fine on Linux, Win32, and
MacOS, but I haven’t tested the other platforms yet.

Neil Stevens has contributed an Analog Realtime Synthesizer audio
driver. aRts is the audio daemon for KDE, in the way that ESD is
the audio daemon for GNOME. Thanks Neil!

And I’ve finally added API calls to list the available audio and
video drivers, along with a test program ‘listdrivers’ that will
show you the drivers available to SDL. Note that these functions
return the drivers that will actually be used in initialization,
not just the ones that are compiled in.

Akawaka, can you add documentation for the new API’s? They are
documented at the top of SDL_audio.h and SDL_video.h

This is very close to the final 1.1.7 release, so I would appreciate
it if people download this snapshot and let me know if there are any
known problems with it.

Enjoy! :slight_smile:
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

And I’ve finally added API calls to list the available audio and
video drivers, along with a test program ‘listdrivers’ that will
show you the drivers available to SDL. Note that these functions
return the drivers that will actually be used in initialization,
not just the ones that are compiled in.

Please don’t cast that API in stone. There are reasons to prefer a
more flexible interface. The form (FirstVideoDriver, NextVideoDriver)
isn’t very nice since it maintains a hidden state. Better solutions
would be to provide a callback enumeration on the form

EnumerateVideoDriver(void (*f)(something *, void *), void *)

or even simpler, just return a vector of the drivers to the user.

Orthogonally it would be nice to get driver capabilities, not just a
string (which is only good for user choices). A game would pick a driver
with the capabilities it needs, or offer hints to the user for driver
choice. Example:

SDL_DriverInfo **SDL_GetVideoDriverList(int kind)

returning a vector of pointers to structs

struct SDL_VideoDriverInfo {
char *name, *description;
int version;
SDL_VideoInfo *vinfo;
};

perhaps augmented with more information. Care should be taken to arrange
the structs in a way so that we can add capabilites without breaking
binary compatibility

[… about the firstdriver/nextdriver interface]

Please don’t cast that API in stone.

sigh I knew that would come up. The functions really should be
deprecated as 1.3 will have a completely different interface. And
yes, I knew that as soon as I allowed people to enumerate the drivers
people would want more information about them, but that won’t happen
until 1.3 either…

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

The functions really should be
deprecated as 1.3 will have a completely different interface.

“Here’s the new API you’ve been asking for. Now please don’t use it,
it will go away soon.”

:slight_smile:

The functions really should be
deprecated as 1.3 will have a completely different interface.

“Here’s the new API you’ve been asking for. Now please don’t use it,
it will go away soon.”

Exactly. :slight_smile:

No, not entirely true. These functions should remain in some sort of
backwards compatibility mode, I just don’t want to necessarily promise
any sort of additional functionality or that this will remain the best
API to use. It’s just there because people have been asking me for it
for months.

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

No, not entirely true. These functions should remain in some sort of
backwards compatibility mode, I just don’t want to necessarily promise

That sounds like a very bad idea. Do it right, or don’t do it at
all. I don’t thin we need to introduce a set of functions that we
know are going to change, and tell people to use them with the plan of
offering a backwards-compat. kludge. Those who need them can wait for
a proper API.

/me goes and ports forward his SDL gamma code cough cough

m.On Wed, Dec 13, 2000 at 07:31:00AM -0800, Sam Lantinga wrote:


Programmer “Ha ha.” “Ha ha.” "What are you laughing at?"
Loki Software "Just the horror of being alive."
http://lokigames.com/~briareos/ - Tony Millionaire

Wed, 13 Dec 2000 Mattias Engdeg?rd wrote:

And I’ve finally added API calls to list the available audio and
video drivers, along with a test program ‘listdrivers’ that will
show you the drivers available to SDL. Note that these functions
return the drivers that will actually be used in initialization,
not just the ones that are compiled in.

Please don’t cast that API in stone. There are reasons to prefer a
more flexible interface. The form (FirstVideoDriver, NextVideoDriver)
isn’t very nice since it maintains a hidden state.

Not if NextVideoDriver() does what many OSes have done before; takes a pointer
to your current object as an argument. Optionally, one could entirely eliminate
the FirstVideoDriver() call by using NextVideoDriver(NULL) instead.

Better solutions
would be to provide a callback enumeration on the form

EnumerateVideoDriver(void (*f)(something *, void *), void *)

I think callbacks are hacks in most cases… They are indeed nice where they’re
needed, but this doesn’t look like such a case.

or even simpler, just return a vector of the drivers to the user.

This is kinda’ nice though. However, it may appear less nice when considering
that an array cannot be dynamically resized. (OTOH, would that ever be needed?)
Another problem is that elements in a vector must be of fixed size, which means
that SDL cannot strap private things onto these device structs without breaking
the API on the binary level.

An array of pointers would be nice, though, but
if it’s a copy/“special thing” that’s generated by the SDL call, someone has to
delete the array as well.

Also, you need to know the size of the array…

Still, I think I’ve seen a few APIs use these kind of methods. It’s nice when
there are many objects, and applications may benefit from other traversing
orders than node by node, start->end. It’s also nice if speed is very
important. Other than that, it’s just messy, IMHO.

Orthogonally it would be nice to get driver capabilities, not just a
string (which is only good for user choices). A game would pick a driver
with the capabilities it needs, or offer hints to the user for driver
choice.

Yes, definitely! Preferably, most games should be able to figure out a
reasonable default choice at run time, rather than always asking the user.

Example:

SDL_DriverInfo **SDL_GetVideoDriverList(int kind)

returning a vector of pointers to structs

struct SDL_VideoDriverInfo {
char *name, *description;
int version;
SDL_VideoInfo *vinfo;
};

perhaps augmented with more information. Care should be taken to arrange
the structs in a way so that we can add capabilites without breaking
binary compatibility

Yep, and that’s where the usual node = GetFirst(); node = GetNext(node);
construct comes in handy. It would probably be nice to throw in a version code
in the struct as well, so that newer applications could potentially work with
older SDL libs, adapting at run time… (Not sure if that’s really useful here,
but it’s usually a good ide.)

//David

…- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' ..- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -’

Wed, 13 Dec 2000 Michael Vance wrote:> On Wed, Dec 13, 2000 at 07:31:00AM -0800, Sam Lantinga wrote:

No, not entirely true. These functions should remain in some sort of
backwards compatibility mode, I just don’t want to necessarily promise

That sounds like a very bad idea. Do it right, or don’t do it at
all. I don’t thin we need to introduce a set of functions that we
know are going to change, and tell people to use them with the plan of
offering a backwards-compat. kludge. Those who need them can wait for
a proper API.

Hmm… How about doing the GetFirst() + GetNext() function calls now, returning
pointers to structs that for now just have the name fields defined in the API
headers? That would make it possible to add the details later by just extending
the info struct. That’s even possible to do w/o breaking binary compatibility,
if that would be an issue.

//David

…- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' ..- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -’

This is kinda’ nice though. However, it may appear less nice when considering
that an array cannot be dynamically resized. (OTOH, would that ever be
needed?)
Another problem is that elements in a vector must be of fixed size, which
means
that SDL cannot strap private things onto these device structs without
breaking
the API on the binary level.

An array of pointers would be nice, though, but
if it’s a copy/“special thing” that’s generated by the SDL call, someone has
to
delete the array as well.

Also, you need to know the size of the array…

What about linked lists?

Proff–
Florian ‘Proff’ Schulze - @Florian_Schulze
Homepage: - http://proff.fly.to
PGP-Key available from - http://www.keyserver.net/en/

Hmm… How about doing the GetFirst() + GetNext() function calls now, returning
pointers to structs that for now just have the name fields defined in the API

I only see three necessary functions:

  1. int SDL_NumVideoDrivers( void );
  2. const char* SDL_VideoDriverName( int driver );
  3. int SDL_SetVideoDriver( const char* driverName );

m.On Wed, Dec 13, 2000 at 09:21:45PM +0100, David Olofson wrote:


Programmer “Ha ha.” “Ha ha.” "What are you laughing at?"
Loki Software "Just the horror of being alive."
http://lokigames.com/~briareos/ - Tony Millionaire

The latest CVS snapshot is available:
http://www.libsdl.org/cvs.html

The audio directory has been completely reorganized to allow multiple
audio drivers to be shared between platforms. This means that if you
have custom project files (Darrell), you’ll just need to change the
directory the audio driver resides in. This also means that everyone
should test this snapshot on their platform of choice to make sure that
I didn’t break anything. It seems to work fine on Linux, Win32, and
MacOS, but I haven’t tested the other platforms yet.

OSS driver puts out static on my computer
(I disabled OSS and then just esd was active… that worked)
ESD works
ARTS doesn’t compile (SDL_artsaudio.c looking for SDL_dspaudio)

listed drivers:
audio
UNIX /dev/audio interface (audio)
OSS /dev/dsp standard audio (dsp)
OSS /dev/dsp DMA audio (dma)
Enlightenment Sound Daemon (esd)
video
SVGAlib (svgalib)

my platform:
linux 2.4-pre11
glibc 2.1 (is there a reason to go to 2.2?)
gcc-2.95-3 (plus associated tools)
(more or less 7.2 Mandrake :slight_smile:
Creative SB-16 audiocard (original ISA series with DSP chip)
my 3dfx broke last night (fan failed) so S3-ViRGE video
(I’m used to fb/3dfx - S3/svga’s quite a drop…)On Tue, 12 Dec 2000, Sam Lantinga wrote:


Teunis of Northurrokheim, of the Free Company of Northurrok
Humbly Proud Member of the Musketeers of m’lady Ovidia of Vingaard.

Member in purple standing of the Mad Poet’s Society.
Trying to bring truth from beauty is Winterlion.
find at this winterlions’ page

Hmm… How about doing the GetFirst() + GetNext() function calls now, returning
pointers to structs that for now just have the name fields defined in the API

I only see three necessary functions:

  1. int SDL_NumVideoDrivers( void );
  2. const char* SDL_VideoDriverName( int driver );
  3. int SDL_SetVideoDriver( const char* driverName );

or (I have this innate distrust of using “const char*”)

int SDL_NumDriverClasses(void);
const char* SDL_DriverClassName(int driverclass);
int SDL_NumDrivers(int driverclass);
const char* SDL_DriverName(int driverclass, int driver);
int SDL_SetDriverFor(int driverclass, int driver);

that way you can vary the number of types of drivers as well…
(or just cut the “driverclass” references and use “Sound”, “Video”,
“Joystick”, “Input”, “WM”, …)
(prolly just a better idea to have a fixed set of basic drivers :slight_smile:
#define VIDEO 1
#define SOUND 2
#define INPUT 3

(maybe an "enum"s better :slight_smile:

I like the idea though…
G’day, eh? :slight_smile:
- TeunisOn Wed, 13 Dec 2000, Michael Vance wrote:

On Wed, Dec 13, 2000 at 09:21:45PM +0100, David Olofson wrote:


Teunis of Northurrokheim, of the Free Company of Northurrok
Humbly Proud Member of the Musketeers of m’lady Ovidia of Vingaard.

Member in purple standing of the Mad Poet’s Society.
Trying to bring truth from beauty is Winterlion.
find at this winterlions’ page

This is very close to the final 1.1.7 release, so I would
appreciate it if people download this snapshot and let me know if there
are any
known problems with it.

The only problem I’ve had with the 1.1.7 CVS I downloaded (today) was minor.
On my development system (Win2k with DirectX8), SDL compiled fine but would
error at SDL_Init() every time. It turns out it was erroring at
DirectInputCreate();

The quick fix is just to define DIRECTINPUT_VERSION to an older interface
before including <dinput.h>.

For example, in video/windx5/directx.h:

#ifdef GNUC
#define NONAMELESSUNION
#endif

#define DIRECTINPUT_VERSION 0x0700 // Use older interface

#include <ddraw.h>
#include <dsound.h>
#include <dinput.h>

Using DInput 7 seems to work fine, but I guess 0x0500 is the safe choice
since that’s what the original code was targetted at, I believe?

Hmm… How about doing the GetFirst() + GetNext() function calls now, returning
pointers to structs that for now just have the name fields defined in the API

I only see three necessary functions:

  1. int SDL_NumVideoDrivers( void );
  2. const char* SDL_VideoDriverName( int driver );
  3. int SDL_SetVideoDriver( const char* driverName );

That what CVS releases and development branches are for. :slight_smile:

Thanks for the suggestion. I’m more than happy to do it that way,
but the current code lists only available drivers (instead of all of
the drivers compiled in), and lists them in order of preference.

FYI, all sorts of wild ideas are flying through my head about what
to do for SDL 2.0, as sort of a “now I can do it right” release.
This would of course involve lots of API improvements and large
backward incompatibilities. Maybe the whole driver listing API
should wait until then…

Comments?

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software> On Wed, Dec 13, 2000 at 09:21:45PM +0100, David Olofson wrote:

What about linked lists?

no need?
code could be done something like this (portable?? i believe??)
then user could either loop through pointers until NULL, or
use and index and loop while index < number of drivers.

this way nothing needs to be allocated, freed, or messed with.
the array of drivers is built from the list of defined video
drivers that are already defined in the makefiles.

although i’d prefer adding a “drivername” field to SDL_VideoInfo
and getting pointers to those instead of just driver names.

and then people will likely want SDL_ListModes to take one
of these video drivers…

whew, 1.3 a ways off then, eh? :]

static const char* driverlist[] =
{
#ifdef DRIVER1
"driver1",
#endif
#ifdef DRIVER2
"driver2",
#endif
#ifdef DRIVER3
"driver3",
#endif
NULL
};

static const int numdrivers = sizeof(driverlist[0])/sizeof(driverlist) -
1;

const char** SDL_GetDrivers()
{
return driverlist;
}

int SDL_GetNumDrivers()
{
return numdrivers;
}

What about linked lists?

no need?
code could be done something like this (portable?? i believe??)
then user could either loop through pointers until NULL, or
use and index and loop while index < number of drivers.

this way nothing needs to be allocated, freed, or messed with.
the array of drivers is built from the list of defined video
drivers that are already defined in the makefiles.

although i’d prefer adding a “drivername” field to SDL_VideoInfo
and getting pointers to those instead of just driver names.

and then people will likely want SDL_ListModes to take one
of these video drivers…

whew, 1.3 a ways off then, eh? :]

[clip]

While this is a fine idea - it’s actually inferior to current system g
Mostly because current system only lists -available- drivers…
say, if esd is running, only esd sound driver will be listed.
if in fbcon, both fbcon and svgalib video will be available, but X will
not.
if in Windows, lotsa fixed stuff will be available that doesn’t change.
(so this’d make sense for platforms like that)

G’day, eh? :slight_smile:
- TeunisOn Wed, 13 Dec 2000, Pete J Shinners wrote:

My only worry is that this system takes the driver choice away from the user.
The only way a user has of disabling a certain driver is by not compiling it
in. While this might be fine for people who compile SDL themselves, its not
that great for people who use precompiled libs or for people shipping
precompiled SDL’s with software (e.g. you:). Some drivers that may seem
superior,such as DGA or fbcon, are often buggy.

The only solution I can think of is an OpenAL-style configuration file(which
would be a problem to implement on all platforms). But it all seems like
overkill. At the moment the most you’ll have is three possible video drivers
(fbcon, svgalib and ggi or x11, dga and ggi). With such a limited choice it
seems rather pointless implementing an entire configuration system. However,
at the same time I wouldn’t like SDL using the DGA driver and crashing X and
having no way to stop it.

BTW. Sam, The string returned in descbuf in SDL_VideoDriverDesc(…) isn’t null
terminated. Dunno if thats intended or not.On Wed, Dec 13, 2000 at 04:44:59PM -0800, Sam Lantinga wrote:

I only see three necessary functions:

  1. int SDL_NumVideoDrivers( void );
  2. const char* SDL_VideoDriverName( int driver );
  3. int SDL_SetVideoDriver( const char* driverName );

That what CVS releases and development branches are for. :slight_smile:

Thanks for the suggestion. I’m more than happy to do it that way,
but the current code lists only available drivers (instead of all of
the drivers compiled in), and lists them in order of preference.

FYI, all sorts of wild ideas are flying through my head about what
to do for SDL 2.0, as sort of a “now I can do it right” release.
This would of course involve lots of API improvements and large
backward incompatibilities. Maybe the whole driver listing API
should wait until then…

Martin

Bother, said Pooh as his torpedoes missed the Death Star’s weak spot.

#ifdef GNUC
#define NONAMELESSUNION
#endif

#define DIRECTINPUT_VERSION 0x0700 // Use older interface

#include <ddraw.h>
#include <dsound.h>
#include <dinput.h>

Using DInput 7 seems to work fine, but I guess 0x0500 is the safe choice
since that’s what the original code was targetted at, I believe?

I think what’s happening is that when you download directX8 your
DIRECTINPUT_VERSION
(along with other VERSION constants) are defined to be 0x0800. SDL loads
Dinput.DLL
and calls GetProcAddress on the DLL for the pointer to the DirectInputCreate
function…

The problem is that there is a new version of Dinput.DLL for DirectX8 called
Dinput8.DLL.
I think the reason why they named it different is that the functions in
DInput8.dll is NOT backward-compatible
with the functions in Dinput.DLL. So when SDL loads Dinput.DLL it’s really
loading the functions
for pre-DirectX8… DIRECTINPUT_VERSION constant, however, says that you’re
using DirectX v8.0.
So the function obviously chokes back and informs you that since you’re
using v8 of DX you shouldn’t
be loading Dinput.DLL but Dinpu8.dll

To fix this, I guess you’d have to detect for 0x0800 version of
DIRECTINPUT_VERSION
and load Dinput8.dll in that case, get the functio pointer to the NEW
version of the function
(which is called DirectInput8Create ) and when you call DinputCreate from
SDL make sure you
pass in the extra arguments that are required for v8 of DirectX. It may
sound convoluted, but
it’s really not that bad.

slim

My only worry is that this system takes the driver choice away from the user.

What system?

The only way a user has of disabling a certain driver is by not compiling it
in. While this might be fine for people who compile SDL themselves, its not
that great for people who use precompiled libs or for people shipping
precompiled SDL’s with software (e.g. you:). Some drivers that may seem
superior,such as DGA or fbcon, are often buggy.

I’m confused. I’m assuming that this API is only used in special cases
where the application knows for absolute fact that it is in a certain
environment and requires a particular driver. Perhaps this kind of API
shouldn’t be exposed at all at this point, and leave the current
environment variable system in place until a more complete driver
capability and selection API can be designed.

BTW. Sam, The string returned in descbuf in SDL_VideoDriverDesc(…) isn’t null
terminated. Dunno if thats intended or not.

Nope. strncpy() doesn’t seem to have consistent behavior. On Linux,
the destination string is supposed to be padded with nulls, but I guess
that’s not true for all platforms.

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

My only worry is that this system takes the driver choice away from the user.

What system?
Driver selection API.

I’m confused. I’m assuming that this API is only used in special cases
where the application knows for absolute fact that it is in a certain
environment and requires a particular driver. Perhaps this kind of API
shouldn’t be exposed at all at this point, and leave the current
environment variable system in place until a more complete driver
capability and selection API can be designed.
As long as the system isn’t abused then it should be fine and its a lot better
than people using setenv(“SDL_VIDEODRIVER”, “blah”). However, maybe the
SDL_VIDEODRIVER environment variable should still be respected? If its set
then the only video driver reported is what it specifies.On Wed, Dec 13, 2000 at 07:52:30PM -0800, Sam Lantinga wrote:


Martin

Bother, said Pooh, noticing he’d deleted his source code.