Working with contexts

Updated: May 06, 2022

Contexts define media flows from an input to one or many outputs. You must create or open a context before you can play media content.

To create a context, call the mmr_context_create() function, passing in the mm-renderer connection handle. This function returns a context handle. You can use this handle to set parameters for the context, attach an input and one or more outputs, and issue playback commands.

You can create multiple contexts, as long as your application manages potentially conflicting playback situations (e.g., simultaneous requests to play two different tracks from the same CD).

If you don't specify the -o option when starting mm-renderer, you can open an existing context through mmr_context_open(). This function returns a different handle, through which you can access the context and perform all operations listed above.

To avoid memory leaks, you should close every handle of a context, by calling mmr_context_close(). When a context is no longer needed, you can explicitly destroy it by passing any of its handles to mmr_context_destroy().