+class sound_backend
+{
+public:
+
+ sound_backend()
+ {
+ if (retain_count++ == 0)
+ {
+ al_device = alcOpenDevice(0);
+ al_context = alcCreateContext(al_device, 0);
+ if (!al_device || !al_context)
+ {
+ const char* error = alcGetString(al_device,
+ alcGetError(al_device));
+ log_error("audio subsystem initialization failure", error);
+ }
+ else
+ {
+ alcMakeContextCurrent(al_context);
+ log_info << "opened sound device `"
+ << alcGetString(al_device,
+ ALC_DEFAULT_DEVICE_SPECIFIER)
+ << "'" << std::endl;
+ }
+ }
+ }
+
+
+ sound_backend(const sound_backend& backend)
+ {
+ ++retain_count;
+ }
+
+ sound_backend& operator=(const sound_backend& backend)
+ {
+ ++retain_count;
+ return *this;
+ }
+
+ ~sound_backend()
+ {
+ if (--retain_count == 0)
+ {
+ alcMakeContextCurrent(0);
+ alcDestroyContext(al_context);
+ alcCloseDevice(al_device);
+ log_info("unloaded sound device ALSA");
+ }
+ }
+
+
+ static int retain_count;
+ static ALCdevice* al_device;
+ static ALCcontext* al_context;
+};
+
+int sound_backend::retain_count = 0;
+ALCdevice* sound_backend::al_device;
+ALCcontext* sound_backend::al_context;
+
+
+class sound_resource;
+typedef resource_handle<sound_resource> sound_handle;
+
+
+class sound_resource_loader