Updated: May 06, 2022

Destroy a context


#include <mm/renderer.h>
int mmr_context_destroy(mmr_context_t *ctxt)


A context handle




Destroy the context that the handle refers to and close the handle. Implicitly stop any playback and detach any input or outputs. If any other handles to this context still exist, attempts to use them will fail. At this point, you should close those handles, either explicitly through an API call or implicitly by disconnecting from mm-renderer or terminating the process.

Note: Calling mmr_context_destroy() is the best way to destroy a context because this function cleans it up properly, ensuring that handle memory is returned and playback is stopped and so, the hardware isn't left in a bad state. But if this function isn't called, a context is destroyed when:
  • mmr_context_close() is called with the primary handle and mm-renderer was run with command-line options that disallow orphans
  • mmr_disconnect() is called by a process that has the primary handle
  • the process that has the primary handle terminates


Zero on success, -1 on failure (check errno). The handle becomes invalid either way.