Closing context handles
Depending on the mm-renderer configuration, client applications
may be allowed to obtain additional handles to existing contexts. This configuration setting
determines the behavior of mm-renderer when closing context handles.
Handles obtained by opening existing contexts are called secondary context handles,
whereas the handle obtained by creating a context is called the primary context handle.
In addition, the 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; however, secondary handles may
be allowed when orphan contexts aren't. For further clarification, see the descriptions of the
-c and -o options for the
mm-renderer command-line.
The behavior of mm-renderer in closing context handles depends on
your orphan context policy:
- If orphan contexts are allowed, the only way to close the primary context handle
without destroying the context is by 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 case, calling
mmr_context_close() with the primary handle
is equivalent to calling
mmr_context_destroy() because
mm-renderer will
not only close the context handle but will also stop playback, detach any inputs and
outputs, and destroy the context. Therefore, you must ensure that any
secondary 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 handle, the context is destroyed.
Note: In all circumstances, it's important to properly close unneeded context handles to
prevent memory leaks.