* Register/add a decoder output callback function. * * The function will be called when a protocol decoder sends output back * to the PD controller (except for Python objects, which only go up the * stack). * * @param sess The output session in which to register the callback. * Must not be NULL. * @param output_type The output type this callback will receive. Only one *
| 378 | * @since 0.3.0 |
| 379 | */ |
| 380 | SRD_API int srd_pd_output_callback_add(struct srd_session *sess, |
| 381 | int output_type, srd_pd_output_callback cb, void *cb_data) |
| 382 | { |
| 383 | struct srd_pd_callback *pd_cb; |
| 384 | |
| 385 | if (!sess) |
| 386 | return SRD_ERR_ARG; |
| 387 | |
| 388 | srd_dbg("Registering new callback for output type %s.", |
| 389 | output_type_name(output_type)); |
| 390 | |
| 391 | pd_cb = malloc(sizeof(struct srd_pd_callback)); |
| 392 | if (pd_cb == NULL){ |
| 393 | srd_err("%s,ERROR:failed to alloc memory.", __func__); |
| 394 | return SRD_ERR; |
| 395 | } |
| 396 | memset(pd_cb, 0, sizeof(struct srd_pd_callback)); |
| 397 | |
| 398 | pd_cb->output_type = output_type; |
| 399 | pd_cb->cb = cb; |
| 400 | pd_cb->cb_data = cb_data; |
| 401 | sess->callbacks = g_slist_append(sess->callbacks, pd_cb); |
| 402 | |
| 403 | return SRD_OK; |
| 404 | } |
| 405 | |
| 406 | /** @private */ |
| 407 | SRD_PRIV struct srd_pd_callback *srd_pd_output_callback_find( |
no outgoing calls
no test coverage detected