Closing context handles

Depending on mm-renderer's configuration, client applications may be allowed to obtain additional handles to existing contexts. These additional handles are called secondary context handles, whereas the context handle obtained from the mmr_context_create() function is called the primary context handle. In addition, mm-renderer's configuration may allow a context to exist after its primary handle has been closed. This is called an orphan context. When orphan contexts are allowed, secondary handles are also allowed. Secondary handles may be allowed when orphan contexts aren't.

mm-renderer's behavior in closing context handles is different depending on whether orphan contexts are allowed:

  • If orphan contexts are allowed, the only way to close the primary context handle without destroying the context is by explicitly calling mmr_context_close().
  • If orphan contexts aren't allowed, there's no way to close the primary handle without destroying the context. In this situation, calling mmr_context_close() using the primary context handle will not only close the context handle, but also stop playback, detach any inputs and outputs, and destroy the context. Because of this, it's important to ensure that any secondary context handles, if permitted, are properly closed.
  • Regardless of the configuration, if your application terminates unexpectedly or disconnects from mm-renderer without explicitly closing the primary context handle, the context is destroyed.

In all circumstances, it's important to properly close unneeded context handles to ensure that memory leaks don't occur.