Error management

The renderer API functions always receive a callback as parameter. These functions include a GError parameter that is set in case an error happened during the execution of the operation. Developers should provide callback functions and check for this error parameter to be able to handle error conditions properly. If the error parameter is NULL it means the operation was executed successfully.

There are certain errors that may happen after the callback has been called. For example, a call to mafw_renderer_play may have finished without error, but after some time the underlying playback engine may detect an error (corrupted data, connection lost in the case of streams, etc). Because of this, there is another channel for error communication, in the form of signals. Developers should also connect to the "error" signal to handle these errors properly.

Here is a small code snippet:

static void
error_cb(MafwExtension *extension, guint domain, guint code, gchar *message, 
         gpointer user_data)
{
        /* Error management code here */
}

static void 
assign_playlist_cb(MafwRenderer *renderer, gpointer user_data, const GError *error)
{
        if (error != NULL) {
                /* error management code here */
        }
}

static void
assign_playlist(MafwRenderer *renderer, MafwPlaylist *playlist)
{
        g_signal_connect(MAFW_EXTENSION(renderer), "error",
                         G_CALLBACK(error_cb), NULL);
     
        mafw_renderer_assign_playlist(renderer, playlist, assign_playlist_cb, NULL);
}