trimmer fix: notification handling
[babeltrace.git] / plugins / utils / trimmer / iterator.c
CommitLineData
cab3f160
JG
1/*
2 * iterator.c
3 *
4 * Babeltrace Trace Trimmer Iterator
5 *
6 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 *
8 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * SOFTWARE.
27 */
28
b2e0c907
PP
29#include <babeltrace/graph/notification-iterator.h>
30#include <babeltrace/graph/private-notification-iterator.h>
31#include <babeltrace/graph/notification.h>
32#include <babeltrace/graph/notification-event.h>
33#include <babeltrace/graph/notification-stream.h>
34#include <babeltrace/graph/notification-packet.h>
35#include <babeltrace/graph/component-filter.h>
36#include <babeltrace/graph/private-component-filter.h>
37#include <babeltrace/graph/private-port.h>
38#include <babeltrace/graph/private-connection.h>
39#include <babeltrace/graph/private-component.h>
44d3cbf0
JG
40#include <babeltrace/ctf-ir/event.h>
41#include <babeltrace/ctf-ir/stream.h>
42#include <babeltrace/ctf-ir/stream-class.h>
ac0c6bdd 43#include <babeltrace/ctf-ir/clock-class.h>
44d3cbf0
JG
44#include <babeltrace/ctf-ir/packet.h>
45#include <babeltrace/ctf-ir/trace.h>
72208f03 46#include <babeltrace/ctf-ir/fields.h>
44d3cbf0 47#include <assert.h>
8b0ce102 48#include <plugins-common.h>
44d3cbf0 49
19ce87a4
JD
50#include "trimmer.h"
51#include "iterator.h"
52#include "copy.h"
53
d3eb6e8f 54BT_HIDDEN
64cadc66 55void trimmer_iterator_finalize(struct bt_private_notification_iterator *it)
44d3cbf0
JG
56{
57 struct trimmer_iterator *it_data;
58
890882ef 59 it_data = bt_private_notification_iterator_get_user_data(it);
44d3cbf0
JG
60 assert(it_data);
61
99cdb69e 62 bt_put(it_data->input_iterator);
19ce87a4 63 g_hash_table_destroy(it_data->packet_map);
44d3cbf0
JG
64 g_free(it_data);
65}
cab3f160
JG
66
67BT_HIDDEN
d3eb6e8f 68enum bt_notification_iterator_status trimmer_iterator_init(
91457551
PP
69 struct bt_private_notification_iterator *iterator,
70 struct bt_private_port *port)
cab3f160 71{
d3eb6e8f
PP
72 enum bt_notification_iterator_status ret =
73 BT_NOTIFICATION_ITERATOR_STATUS_OK;
cab3f160 74 enum bt_notification_iterator_status it_ret;
890882ef
PP
75 struct bt_private_port *input_port = NULL;
76 struct bt_private_connection *connection = NULL;
91457551
PP
77 struct bt_private_component *component =
78 bt_private_notification_iterator_get_private_component(iterator);
44d3cbf0 79 struct trimmer_iterator *it_data = g_new0(struct trimmer_iterator, 1);
5fc02ebc
JD
80 static const enum bt_notification_type notif_types[] = {
81 BT_NOTIFICATION_TYPE_EVENT,
82 BT_NOTIFICATION_TYPE_STREAM_END,
83 BT_NOTIFICATION_TYPE_PACKET_BEGIN,
84 BT_NOTIFICATION_TYPE_PACKET_END,
85 BT_NOTIFICATION_TYPE_SENTINEL,
86 };
44d3cbf0
JG
87
88 if (!it_data) {
d3eb6e8f 89 ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
44d3cbf0
JG
90 goto end;
91 }
92
99cdb69e 93 /* Create a new iterator on the upstream component. */
b9d103be
PP
94 input_port = bt_private_component_filter_get_input_private_port_by_name(
95 component, "in");
99cdb69e 96 assert(input_port);
890882ef 97 connection = bt_private_port_get_private_connection(input_port);
99cdb69e
JG
98 assert(connection);
99
890882ef 100 it_data->input_iterator =
fa054faf 101 bt_private_connection_create_notification_iterator(connection,
5fc02ebc 102 notif_types);
99cdb69e
JG
103 if (!it_data->input_iterator) {
104 ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
105 goto end;
106 }
107
19ce87a4
JD
108 it_data->err = stderr;
109 it_data->packet_map = g_hash_table_new_full(g_direct_hash,
110 g_direct_equal, NULL, NULL);
111
890882ef
PP
112 it_ret = bt_private_notification_iterator_set_user_data(iterator,
113 it_data);
44d3cbf0
JG
114 if (it_ret) {
115 goto end;
116 }
cab3f160 117end:
91457551 118 bt_put(component);
99cdb69e
JG
119 bt_put(connection);
120 bt_put(input_port);
cab3f160
JG
121 return ret;
122}
123
528debdf
MD
124static
125int update_lazy_bound(struct trimmer_bound *bound, const char *name,
55595636 126 int64_t ts, bool *lazy_update)
528debdf
MD
127{
128 struct tm tm;
129 int64_t value;
130 time_t timeval;
131
55595636
MD
132 *lazy_update = false;
133
528debdf
MD
134 if (!bound->lazy) {
135 return 0;
136 }
137 tm.tm_isdst = -1;
138 timeval = ts / NSEC_PER_SEC;
139
140 if (bound->lazy_values.gmt) {
141 /* Get day, month, year. */
142 if (!gmtime_r(&timeval, &tm)) {
55595636 143 printf_error("Failure in gmtime_r()");
528debdf
MD
144 goto error;
145 }
146 tm.tm_sec = bound->lazy_values.ss;
147 tm.tm_min = bound->lazy_values.mm;
148 tm.tm_hour = bound->lazy_values.hh;
149 timeval = timegm(&tm);
150 if (timeval < 0) {
55595636
MD
151 printf_error("Failure in timegm(), incorrectly formatted %s timestamp",
152 name);
528debdf
MD
153 goto error;
154 }
155 } else {
156 /* Get day, month, year. */
157 if (!localtime_r(&timeval, &tm)) {
55595636 158 printf_error("Failure in localtime_r()");
528debdf
MD
159 goto error;
160 }
161 tm.tm_sec = bound->lazy_values.ss;
162 tm.tm_min = bound->lazy_values.mm;
163 tm.tm_hour = bound->lazy_values.hh;
164 timeval = mktime(&tm);
165 if (timeval < 0) {
55595636 166 printf_error("Failure in mktime(), incorrectly formatted %s timestamp",
528debdf
MD
167 name);
168 goto error;
169 }
170 }
171 value = (int64_t) timeval;
172 value *= NSEC_PER_SEC;
173 value += bound->lazy_values.ns;
174 bound->value = value;
175 bound->set = true;
176 bound->lazy = false;
55595636 177 *lazy_update = true;
528debdf
MD
178 return 0;
179
180error:
528debdf
MD
181 return -1;
182}
183
44d3cbf0 184static
19ce87a4
JD
185struct bt_notification *evaluate_event_notification(
186 struct bt_notification *notification,
187 struct trimmer_iterator *trim_it,
55595636
MD
188 struct trimmer_bound *begin, struct trimmer_bound *end,
189 bool *_event_in_range)
44d3cbf0 190{
72208f03
JG
191 int64_t ts;
192 int clock_ret;
19ce87a4 193 struct bt_ctf_event *event = NULL, *writer_event;
72208f03 194 bool in_range = true;
ac0c6bdd 195 struct bt_ctf_clock_class *clock_class = NULL;
72208f03 196 struct bt_ctf_trace *trace = NULL;
44d3cbf0 197 struct bt_ctf_stream *stream = NULL;
72208f03
JG
198 struct bt_ctf_stream_class *stream_class = NULL;
199 struct bt_ctf_clock_value *clock_value = NULL;
55595636 200 bool lazy_update = false;
19ce87a4
JD
201 struct bt_notification *new_notification = NULL;
202 struct bt_clock_class_priority_map *cc_prio_map;
44d3cbf0 203
72208f03
JG
204 event = bt_notification_event_get_event(notification);
205 assert(event);
19ce87a4
JD
206 cc_prio_map = bt_notification_event_get_clock_class_priority_map(
207 notification);
208 assert(cc_prio_map);
209 writer_event = trimmer_output_event(trim_it, event);
210 assert(writer_event);
211 new_notification = bt_notification_event_create(writer_event, cc_prio_map);
212 assert(new_notification);
213 bt_put(cc_prio_map);
44d3cbf0 214
72208f03
JG
215 stream = bt_ctf_event_get_stream(event);
216 assert(stream);
44d3cbf0 217
72208f03
JG
218 stream_class = bt_ctf_stream_get_class(stream);
219 assert(stream_class);
220
221 trace = bt_ctf_stream_class_get_trace(stream_class);
222 assert(trace);
223
224 /* FIXME multi-clock? */
9ac68eb1 225 clock_class = bt_ctf_trace_get_clock_class_by_index(trace, 0);
ac0c6bdd 226 if (!clock_class) {
72208f03 227 goto end;
44d3cbf0 228 }
44d3cbf0 229
ac0c6bdd 230 clock_value = bt_ctf_event_get_clock_value(event, clock_class);
72208f03 231 if (!clock_value) {
55595636 232 printf_error("Failed to retrieve clock value");
19ce87a4 233 goto error;
44d3cbf0 234 }
72208f03
JG
235
236 clock_ret = bt_ctf_clock_value_get_value_ns_from_epoch(
237 clock_value, &ts);
238 if (clock_ret) {
55595636 239 printf_error("Failed to retrieve clock value timestamp");
19ce87a4 240 goto error;
44d3cbf0 241 }
55595636 242 if (update_lazy_bound(begin, "begin", ts, &lazy_update)) {
528debdf
MD
243 goto end;
244 }
55595636 245 if (update_lazy_bound(end, "end", ts, &lazy_update)) {
528debdf
MD
246 goto end;
247 }
55595636
MD
248 if (lazy_update && begin->set && end->set) {
249 if (begin->value > end->value) {
250 printf_error("Unexpected: time range begin value is above end value");
19ce87a4 251 goto error;
55595636
MD
252 }
253 }
72208f03
JG
254 if (begin->set && ts < begin->value) {
255 in_range = false;
256 }
257 if (end->set && ts > end->value) {
258 in_range = false;
259 }
19ce87a4
JD
260
261 goto end;
262
263error:
264 BT_PUT(new_notification);
44d3cbf0 265end:
72208f03 266 bt_put(event);
19ce87a4 267 bt_put(writer_event);
ac0c6bdd 268 bt_put(clock_class);
72208f03
JG
269 bt_put(trace);
270 bt_put(stream);
271 bt_put(stream_class);
272 bt_put(clock_value);
55595636 273 *_event_in_range = in_range;
19ce87a4 274 return new_notification;
44d3cbf0
JG
275}
276
44d3cbf0 277static
72208f03 278int ns_from_integer_field(struct bt_ctf_field *integer, int64_t *ns)
44d3cbf0 279{
72208f03
JG
280 int ret = 0;
281 int is_signed;
282 uint64_t raw_clock_value;
283 struct bt_ctf_field_type *integer_type = NULL;
ac0c6bdd 284 struct bt_ctf_clock_class *clock_class = NULL;
44d3cbf0
JG
285 struct bt_ctf_clock_value *clock_value = NULL;
286
72208f03
JG
287 integer_type = bt_ctf_field_get_type(integer);
288 assert(integer_type);
ac0c6bdd
PP
289 clock_class = bt_ctf_field_type_integer_get_mapped_clock_class(
290 integer_type);
291 if (!clock_class) {
72208f03 292 ret = -1;
44d3cbf0
JG
293 goto end;
294 }
295
72208f03
JG
296 is_signed = bt_ctf_field_type_integer_get_signed(integer_type);
297 if (!is_signed) {
298 ret = bt_ctf_field_unsigned_integer_get_value(integer,
299 &raw_clock_value);
300 if (ret) {
44d3cbf0
JG
301 goto end;
302 }
72208f03
JG
303 } else {
304 /* Signed clock values are unsupported. */
305 goto end;
306 }
44d3cbf0 307
ac0c6bdd 308 clock_value = bt_ctf_clock_value_create(clock_class, raw_clock_value);
72208f03
JG
309 if (!clock_value) {
310 goto end;
311 }
44d3cbf0 312
72208f03
JG
313 ret = bt_ctf_clock_value_get_value_ns_from_epoch(clock_value, ns);
314end:
315 bt_put(integer_type);
ac0c6bdd 316 bt_put(clock_class);
72208f03
JG
317 bt_put(clock_value);
318 return ret;
319}
44d3cbf0 320
19ce87a4
JD
321static uint64_t ns_from_value(uint64_t frequency, uint64_t value)
322{
323 uint64_t ns;
324
325 if (frequency == NSEC_PER_SEC) {
326 ns = value;
327 } else {
328 ns = (uint64_t) ((1e9 * (double) value) / (double) frequency);
329 }
330
331 return ns;
332}
333
334/*
335 * timestamp minus the offset.
336 */
72208f03 337static
19ce87a4
JD
338int64_t get_raw_timestamp(struct bt_ctf_packet *writer_packet,
339 int64_t timestamp)
340{
341 struct bt_ctf_clock_class *writer_clock_class;
342 int64_t sec_offset, cycles_offset, ns;
343 struct bt_ctf_trace *writer_trace;
344 struct bt_ctf_stream *writer_stream;
345 struct bt_ctf_stream_class *writer_stream_class;
346 int ret;
347 uint64_t freq;
348
349 writer_stream = bt_ctf_packet_get_stream(writer_packet);
350 assert(writer_stream);
351
352 writer_stream_class = bt_ctf_stream_get_class(writer_stream);
353 assert(writer_stream_class);
354
355 writer_trace = bt_ctf_stream_class_get_trace(writer_stream_class);
356 assert(writer_trace);
357
358 /* FIXME multi-clock? */
9ac68eb1
PP
359 writer_clock_class = bt_ctf_trace_get_clock_class_by_index(
360 writer_trace, 0);
19ce87a4
JD
361 assert(writer_clock_class);
362
363 ret = bt_ctf_clock_class_get_offset_s(writer_clock_class, &sec_offset);
364 assert(!ret);
365 ns = sec_offset * NSEC_PER_SEC;
366
367 freq = bt_ctf_clock_class_get_frequency(writer_clock_class);
368 assert(freq != -1ULL);
369
370 ret = bt_ctf_clock_class_get_offset_cycles(writer_clock_class, &cycles_offset);
371 assert(!ret);
372
373 ns += ns_from_value(freq, cycles_offset);
374
375 bt_put(writer_clock_class);
376 bt_put(writer_trace);
377 bt_put(writer_stream_class);
378 bt_put(writer_stream);
379
380 return timestamp - ns;
381}
382
383static
384struct bt_notification *evaluate_packet_notification(
55595636 385 struct bt_notification *notification,
19ce87a4 386 struct trimmer_iterator *trim_it,
55595636
MD
387 struct trimmer_bound *begin, struct trimmer_bound *end,
388 bool *_packet_in_range)
72208f03 389{
72208f03
JG
390 int64_t begin_ns, pkt_begin_ns, end_ns, pkt_end_ns;
391 bool in_range = true;
19ce87a4 392 struct bt_ctf_packet *packet = NULL, *writer_packet = NULL;
72208f03
JG
393 struct bt_ctf_field *packet_context = NULL,
394 *timestamp_begin = NULL,
395 *timestamp_end = NULL;
19ce87a4
JD
396 struct bt_notification *new_notification = NULL;
397 enum bt_component_status ret;
398 bool lazy_update = false;
72208f03
JG
399
400 switch (bt_notification_get_type(notification)) {
401 case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
402 packet = bt_notification_packet_begin_get_packet(notification);
19ce87a4
JD
403 assert(packet);
404 writer_packet = trimmer_new_packet(trim_it, packet);
405 assert(writer_packet);
44d3cbf0 406 break;
72208f03
JG
407 case BT_NOTIFICATION_TYPE_PACKET_END:
408 packet = bt_notification_packet_end_get_packet(notification);
19ce87a4
JD
409 assert(packet);
410 writer_packet = trimmer_close_packet(trim_it, packet);
411 assert(writer_packet);
72208f03
JG
412 break;
413 default:
19ce87a4 414 goto end;
44d3cbf0 415 }
72208f03 416
19ce87a4 417 packet_context = bt_ctf_packet_get_context(writer_packet);
72208f03 418 if (!packet_context) {
19ce87a4 419 goto end_no_notif;
72208f03
JG
420 }
421
422 if (!bt_ctf_field_is_structure(packet_context)) {
19ce87a4 423 goto end_no_notif;
72208f03
JG
424 }
425
426 timestamp_begin = bt_ctf_field_structure_get_field(
427 packet_context, "timestamp_begin");
428 if (!timestamp_begin || !bt_ctf_field_is_integer(timestamp_begin)) {
19ce87a4 429 goto end_no_notif;
72208f03
JG
430 }
431 timestamp_end = bt_ctf_field_structure_get_field(
432 packet_context, "timestamp_end");
433 if (!timestamp_end || !bt_ctf_field_is_integer(timestamp_end)) {
19ce87a4 434 goto end_no_notif;
72208f03
JG
435 }
436
55595636 437 if (ns_from_integer_field(timestamp_begin, &pkt_begin_ns)) {
19ce87a4 438 goto end_no_notif;
72208f03 439 }
55595636 440 if (ns_from_integer_field(timestamp_end, &pkt_end_ns)) {
19ce87a4
JD
441 goto end_no_notif;
442 }
443
444 if (update_lazy_bound(begin, "begin", pkt_begin_ns, &lazy_update)) {
445 goto end_no_notif;
446 }
447 if (update_lazy_bound(end, "end", pkt_end_ns, &lazy_update)) {
448 goto end_no_notif;
449 }
450 if (lazy_update && begin->set && end->set) {
451 if (begin->value > end->value) {
452 printf_error("Unexpected: time range begin value is above end value");
453 goto end_no_notif;
454 }
72208f03
JG
455 }
456
457 begin_ns = begin->set ? begin->value : INT64_MIN;
458 end_ns = end->set ? end->value : INT64_MAX;
459
460 /*
461 * Accept if there is any overlap between the selected region and the
462 * packet.
463 */
464 in_range = (pkt_end_ns >= begin_ns) && (pkt_begin_ns <= end_ns);
19ce87a4
JD
465 if (!in_range) {
466 goto end_no_notif;
467 }
468
469 if (begin_ns > pkt_begin_ns) {
470 ret = update_packet_context_field(trim_it->err, writer_packet,
471 "timestamp_begin",
472 get_raw_timestamp(writer_packet, begin_ns));
473 assert(!ret);
474 }
475
476 if (end_ns < pkt_end_ns) {
477 ret = update_packet_context_field(trim_it->err, writer_packet,
478 "timestamp_end",
479 get_raw_timestamp(writer_packet, end_ns));
480 assert(!ret);
481 }
482
72208f03 483end:
19ce87a4
JD
484 switch (bt_notification_get_type(notification)) {
485 case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
486 new_notification = bt_notification_packet_begin_create(writer_packet);
487 assert(new_notification);
488 break;
489 case BT_NOTIFICATION_TYPE_PACKET_END:
490 new_notification = bt_notification_packet_end_create(writer_packet);
491 assert(new_notification);
492 break;
493 default:
494 break;
495 }
496end_no_notif:
55595636 497 *_packet_in_range = in_range;
72208f03 498 bt_put(packet);
19ce87a4 499 bt_put(writer_packet);
72208f03
JG
500 bt_put(packet_context);
501 bt_put(timestamp_begin);
502 bt_put(timestamp_end);
19ce87a4
JD
503 return new_notification;
504}
505
506static
507struct bt_notification *evaluate_stream_notification(
508 struct bt_notification *notification,
509 struct trimmer_iterator *trim_it)
510{
511 struct bt_ctf_stream *stream;
512
513 stream = bt_notification_stream_end_get_stream(notification);
514 assert(stream);
515
516 /* FIXME: useless copy */
517 return bt_notification_stream_end_create(stream);
72208f03
JG
518}
519
520/* Return true if the notification should be forwarded. */
521static
55595636 522enum bt_notification_iterator_status evaluate_notification(
19ce87a4
JD
523 struct bt_notification **notification,
524 struct trimmer_iterator *trim_it,
55595636
MD
525 struct trimmer_bound *begin, struct trimmer_bound *end,
526 bool *in_range)
72208f03 527{
72208f03 528 enum bt_notification_type type;
19ce87a4 529 struct bt_notification *new_notification = NULL;
72208f03 530
b61397c4 531 *in_range = true;
19ce87a4 532 type = bt_notification_get_type(*notification);
72208f03
JG
533 switch (type) {
534 case BT_NOTIFICATION_TYPE_EVENT:
19ce87a4
JD
535 new_notification = evaluate_event_notification(*notification,
536 trim_it, begin, end, in_range);
72208f03
JG
537 break;
538 case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
539 case BT_NOTIFICATION_TYPE_PACKET_END:
19ce87a4
JD
540 new_notification = evaluate_packet_notification(*notification,
541 trim_it, begin, end, in_range);
542 break;
543 case BT_NOTIFICATION_TYPE_STREAM_END:
544 new_notification = evaluate_stream_notification(*notification,
545 trim_it);
72208f03 546 break;
44d3cbf0 547 default:
5fc02ebc 548 puts("Unhandled notification type");
44d3cbf0
JG
549 break;
550 }
19ce87a4
JD
551 BT_PUT(*notification);
552 *notification = new_notification;
553
554 return BT_NOTIFICATION_ITERATOR_STATUS_OK;
cab3f160
JG
555}
556
557BT_HIDDEN
41a2b7ae 558struct bt_notification_iterator_next_return trimmer_iterator_next(
890882ef 559 struct bt_private_notification_iterator *iterator)
cab3f160 560{
44d3cbf0 561 struct trimmer_iterator *trim_it = NULL;
890882ef 562 struct bt_private_component *component = NULL;
44d3cbf0
JG
563 struct trimmer *trimmer = NULL;
564 struct bt_notification_iterator *source_it = NULL;
41a2b7ae
PP
565 struct bt_notification_iterator_next_return ret = {
566 .status = BT_NOTIFICATION_ITERATOR_STATUS_OK,
567 .notification = NULL,
568 };
72208f03 569 bool notification_in_range = false;
cab3f160 570
890882ef 571 trim_it = bt_private_notification_iterator_get_user_data(iterator);
44d3cbf0
JG
572 assert(trim_it);
573
890882ef
PP
574 component = bt_private_notification_iterator_get_private_component(
575 iterator);
44d3cbf0 576 assert(component);
890882ef 577 trimmer = bt_private_component_get_user_data(component);
44d3cbf0
JG
578 assert(trimmer);
579
99cdb69e
JG
580 source_it = trim_it->input_iterator;
581 assert(source_it);
44d3cbf0 582
72208f03 583 while (!notification_in_range) {
41a2b7ae
PP
584 ret.status = bt_notification_iterator_next(source_it);
585 if (ret.status != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
44d3cbf0
JG
586 goto end;
587 }
588
41a2b7ae 589 ret.notification = bt_notification_iterator_get_notification(
44d3cbf0 590 source_it);
41a2b7ae
PP
591 if (!ret.notification) {
592 ret.status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
44d3cbf0
JG
593 goto end;
594 }
595
19ce87a4 596 ret.status = evaluate_notification(&ret.notification, trim_it,
55595636
MD
597 &trimmer->begin, &trimmer->end,
598 &notification_in_range);
41a2b7ae 599 if (!notification_in_range) {
19ce87a4 600 BT_PUT(ret.notification);
44d3cbf0 601 }
6d5f6792 602
41a2b7ae 603 if (ret.status != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
6d5f6792
JG
604 break;
605 }
44d3cbf0 606 }
cab3f160 607end:
44d3cbf0 608 bt_put(component);
cab3f160
JG
609 return ret;
610}
611
612BT_HIDDEN
613enum bt_notification_iterator_status trimmer_iterator_seek_time(
890882ef
PP
614 struct bt_private_notification_iterator *iterator,
615 int64_t time)
cab3f160 616{
72b913fb 617 return BT_NOTIFICATION_ITERATOR_STATUS_OK;
cab3f160 618}
This page took 0.057434 seconds and 4 git commands to generate.