* Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*/
-#define BT_COMP_LOG_SELF_COMP self_comp
-#define BT_LOG_OUTPUT_LEVEL log_level
+#define BT_COMP_LOG_SELF_COMP (pretty->self_comp)
+#define BT_LOG_OUTPUT_LEVEL (pretty->log_level)
#define BT_LOG_TAG "PLUGIN/SINK.TEXT.PRETTY"
#include "logging/comp-logging.h"
struct pretty_component *pretty;
bt_self_component *self_comp =
bt_self_component_sink_as_self_component(self_comp_sink);
- const bt_component *comp = bt_self_component_as_component(self_comp);
bt_self_component_port_input *in_port;
- bt_logging_level log_level = bt_component_get_logging_level(comp);
pretty = bt_self_component_get_data(self_comp);
BT_ASSERT(pretty);
bt_component_class_sink_consume_method_status pretty_consume(
bt_self_component_sink *comp)
{
- bt_component_class_sink_consume_method_status ret =
- BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
+ bt_component_class_sink_consume_method_status status;
bt_message_array_const msgs;
bt_message_iterator *it;
struct pretty_component *pretty = bt_self_component_get_data(
it = pretty->iterator;
next_status = bt_message_iterator_next(it,
&msgs, &count);
-
- switch (next_status) {
- case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK:
- break;
- case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR:
- case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN:
- ret = (int) next_status;
- goto end;
- case BT_MESSAGE_ITERATOR_NEXT_STATUS_END:
- ret = (int) next_status;
- BT_MESSAGE_ITERATOR_PUT_REF_AND_RESET(
- pretty->iterator);
- goto end;
- default:
- ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
+ if (next_status != BT_MESSAGE_ITERATOR_NEXT_STATUS_OK) {
+ status = (int) next_status;
goto end;
}
- BT_ASSERT_DBG(next_status == BT_MESSAGE_ITERATOR_NEXT_STATUS_OK);
-
for (i = 0; i < count; i++) {
- ret = (int) handle_message(pretty, msgs[i]);
- if (ret) {
+ status = (int) handle_message(pretty, msgs[i]);
+ if (status) {
goto end;
}
bt_message_put_ref(msgs[i]);
}
- return ret;
+ return status;
}
static
static
bt_component_class_initialize_method_status apply_params(
- struct pretty_component *pretty, const bt_value *params,
- bt_self_component *self_comp, bt_logging_level log_level)
+ struct pretty_component *pretty, const bt_value *params)
{
int ret;
const bt_value *value;
goto end;
} else if (validation_status == BT_PARAM_VALIDATION_STATUS_VALIDATION_ERROR) {
status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
- BT_COMP_LOGE_APPEND_CAUSE(self_comp, "%s", validate_error);
+ BT_COMP_LOGE_APPEND_CAUSE(pretty->self_comp, "%s", validate_error);
goto end;
}
goto error;
}
+ pretty->self_comp = self_comp;
+ pretty->log_level = log_level;
+
add_port_status = bt_self_component_sink_add_input_port(self_comp_sink,
in_port_name, NULL, NULL);
if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) {
pretty->delta_real_timestamp = -1ULL;
pretty->last_real_timestamp = -1ULL;
- status = apply_params(pretty, params, self_comp, log_level);
+ status = apply_params(pretty, params);
if (status != BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK) {
goto error;
}