[Openal] Verify device closed
Chris Robinson
chris.kcat at gmail.com
Fri Aug 14 12:45:56 PDT 2009
On Friday 14 August 2009 11:39:25 am David Guthrie wrote:
> I'm trying to verify that a device and a context are being closed/
> destroyed as part of a unit test. I can't seem to find a way that
> works on all implementations. The best I can tell with the context is
> to try to make it current and see if it returns NULL. It seems like I
> should get an error in that case, but I don't always, and trying to
> destroy it should fail because it's destroyed already.
The spec says that destroying a context can fail if it's the current context,
so calling
alcMakeContextCurrent(NULL);
and making sure it succeeds, guarantees the context will be destroyed. Some
implementations are lenient and will allow you to destroy the current context
(in which case the current context is implicitly changed), but that's the only
way it can fail.
> With the device, if I try to destroy the device again, it returns
> false in some implementations, but in others it crashes.
If alcCloseDevice returns ALC_TRUE, it's as good as gone and the pointer
should be treated as invalid.
I'm not sure there's a way to verify beyond that if devices/contexts are truly
destroyed, since the pointers are not necessarily invalid (there's nothing
stopping it from being statically allocated, or being part of a larger
structure that's kept longer) and passing invalid pointers to alc* functions
isn't safe.
Perhaps if anyone else has other ideas, they can speak up. But I think that's
the extent of it.
More information about the Openal
mailing list