OpenAL device, buffer and context relationship
Asked Answered
H

1

9

I'm trying to create an object oriented model to wrap OpenAL and have a little problem understanding the devices, buffers and contexts.

From what I can see in the Programmer's Guide, there are multiple devices, each of which can have multiple contexts as well as multiple buffers. Each context has a listener, and the alListener*() functions all operate on the listener of the active context. (Meaning that I have to make another context active first if I wanted to change it's listener, if I got that right.) So far, so good. What irritates me though is that I need to pass a device to the alcCreateContext() function, but none to alGenBuffers().

How does this work then? When I open multiple devices, on which device are the buffers created? Are the buffers shared between all devices? What happens to the buffers if I close all open devices?

(Or is there something I missed?)

Hernardo answered 2/6, 2010 at 18:42 Comment(0)
H
4

Okay, problem solved. I asked the question here and the answer was

All the al* functions (rather than alc* functions) operate on the current context. So, alGenBuffer calls will operate on the current context and create Buffers that belong to the Context's Device (a Context can only have one Device).

Buffers created on one Device are not available on another Device.

A Device's Buffers will (probably) be automatically destroyed when you call alcCloseDevice.

So I will have to make an arbitrary context of that device active, then create the buffers, then make the old context active again. Or prevent creation of buffers altogether if the device is not active, meaning that none of it's contexts is active.

Hernardo answered 4/6, 2010 at 18:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.