Working with contexts

Contexts define the flow of media content from an input to one or many outputs. You must configure a context before you can start playing media content.

To create a new context, call the function mmr_context_create(), passing in the mm-renderer connection handle. The creation operation returns a context handle (the primary handle), which you use to manipulate the context by setting parameters, attaching an input and one or more outputs, and issuing playback commands.

You can create multiple contexts, as long as your application manages potentially conflicting playback situations (for example, recording to an audio file while trying to play the same file).

The multimedia renderer doesn't allow contexts to exist after their primary handle is closed, but it does allow you to open existing contexts by calling mmr_context_open(). That is, additional (or secondary) context handles can be opened after the context is created.

Calling mmr_context_close() using the primary context handle not only closes that handle but also stops playback, detaches any input and outputs, and destroys the context. Also, if your application disconnects from mm-renderer or exits without disconnecting, any contexts created by the application are destroyed, regardless of whether or not you closed their handles. If your application is still running, it's important to close any remaining secondary handles of destroyed contexts to avoid memory leaks.

When a context is no longer needed, you can explicitly destroy it by passing the context handle to the mmr_context_destroy() function.

Last modified: 2014-06-24

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus