From 5df26c89c52ed58a96fc1bce64d6e49d69b655ee Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Fri, 8 Feb 2019 17:36:38 -0500 Subject: [PATCH] lib: add stream activity beginning/end messages Those new messages are meant to indicate the beginning and end of the activity of a given stream, with optional clock snapshots. Eventually all stream messages except stream beginning/end messages must be "between" stream activity beginning and end messages. The purpose of such messages is to indicate where tracing activity starts and stops, for example when the LTTng `start` and `stop` commands are executed (not supported by LTTng as of this date). This information can be important for some filters and sinks to acknowledge the real beginning and end of a stream, for example: [------------############################------#######-------------] ^ stream activity beginning stream activity end ^ ^^^^^^^^^^^^ tracing, but no activity ^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ activity We also plan to make flt.utils.trimmer remove those messages for a given stream and "inject" its own stream activity messages to emulate a potentially reduced stream activity, depending on the message intersection between the requested time range to keep and the stream's time range. You can use the following functions to set the message's default clock snapshot: * bt_message_stream_activity_beginning_set_default_clock_snapshot() * bt_message_stream_activity_end_set_default_clock_snapshot() and borrow it with: * bt_message_stream_activity_beginning_borrow_default_clock_snapshot_const() * bt_message_stream_activity_end_borrow_default_clock_snapshot_const() The message's stream's class must have a defined default clock class in order to use the setting functions. When you set a stream activity message's default clock snapshot, the clock snapshot's state within this message is `BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN`. The other possible states are: `BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN` (default): It is not possible to know the exact time of this stream activity message at the source level. `BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE`: The stream is considered to have always existed (for a stream activity beginning message) or to exist forever (for a stream activity end message). A stream activity message with such a default clock snapshot state must either immediately follow a stream beginning message or immediately precede a stream end message. You can set an explicit default clock snapshot state with: * bt_message_stream_activity_beginning_set_default_clock_snapshot_state() * bt_message_stream_activity_end_set_default_clock_snapshot_state() bt_message_stream_activity_beginning_borrow_default_clock_snapshot_const() and bt_message_stream_activity_end_borrow_default_clock_snapshot_const() return the default clock snapshot's state. Also in this patch: refactor the packet beginning/end and stream beginning/end messages to avoid code duplication, and put the functions in their own header file. Signed-off-by: Philippe Proulx --- include/Makefile.am | 15 +- include/babeltrace/babeltrace.h | 14 +- include/babeltrace/graph/message-const.h | 14 +- include/babeltrace/graph/message-internal.h | 4 + ...nst.h => message-packet-beginning-const.h} | 9 +- ...ge-packet.h => message-packet-beginning.h} | 14 +- .../graph/message-packet-end-const.h | 41 +++ include/babeltrace/graph/message-packet-end.h | 46 +++ .../graph/message-packet-internal.h | 14 +- .../message-stream-activity-beginning-const.h | 48 ++++ .../graph/message-stream-activity-beginning.h | 54 ++++ .../graph/message-stream-activity-const.h | 40 +++ .../graph/message-stream-activity-end-const.h | 48 ++++ .../graph/message-stream-activity-end.h | 54 ++++ .../graph/message-stream-activity-internal.h | 55 ++++ ...nst.h => message-stream-beginning-const.h} | 9 +- ...ge-stream.h => message-stream-beginning.h} | 14 +- .../graph/message-stream-end-const.h | 44 +++ include/babeltrace/graph/message-stream-end.h | 46 +++ .../graph/message-stream-internal.h | 9 +- lib/graph/graph.c | 4 +- lib/graph/iterator.c | 10 +- lib/graph/message/Makefile.am | 3 +- lib/graph/message/message.c | 2 +- lib/graph/message/packet.c | 231 ++++++--------- lib/graph/message/stream-activity.c | 270 ++++++++++++++++++ lib/graph/message/stream.c | 127 ++++---- lib/lib-logging.c | 44 +-- 28 files changed, 975 insertions(+), 308 deletions(-) rename include/babeltrace/graph/{message-packet-const.h => message-packet-beginning-const.h} (85%) rename include/babeltrace/graph/{message-packet.h => message-packet-beginning.h} (82%) create mode 100644 include/babeltrace/graph/message-packet-end-const.h create mode 100644 include/babeltrace/graph/message-packet-end.h create mode 100644 include/babeltrace/graph/message-stream-activity-beginning-const.h create mode 100644 include/babeltrace/graph/message-stream-activity-beginning.h create mode 100644 include/babeltrace/graph/message-stream-activity-const.h create mode 100644 include/babeltrace/graph/message-stream-activity-end-const.h create mode 100644 include/babeltrace/graph/message-stream-activity-end.h create mode 100644 include/babeltrace/graph/message-stream-activity-internal.h rename include/babeltrace/graph/{message-stream-const.h => message-stream-beginning-const.h} (86%) rename include/babeltrace/graph/{message-stream.h => message-stream-beginning.h} (82%) create mode 100644 include/babeltrace/graph/message-stream-end-const.h create mode 100644 include/babeltrace/graph/message-stream-end.h create mode 100644 lib/graph/message/stream-activity.c diff --git a/include/Makefile.am b/include/Makefile.am index c3393e17..4ed311a8 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -173,10 +173,17 @@ babeltracegraphinclude_HEADERS = \ babeltrace/graph/message-inactivity-const.h \ babeltrace/graph/message-inactivity.h \ babeltrace/graph/message-iterator-const.h \ - babeltrace/graph/message-packet-const.h \ - babeltrace/graph/message-packet.h \ - babeltrace/graph/message-stream-const.h \ - babeltrace/graph/message-stream.h \ + babeltrace/graph/message-packet-beginning-const.h \ + babeltrace/graph/message-packet-beginning.h \ + babeltrace/graph/message-packet-end-const.h \ + babeltrace/graph/message-packet-end.h \ + babeltrace/graph/message-stream-activity-beginning.h \ + babeltrace/graph/message-stream-activity-const.h \ + babeltrace/graph/message-stream-activity-end.h \ + babeltrace/graph/message-stream-beginning-const.h \ + babeltrace/graph/message-stream-beginning.h \ + babeltrace/graph/message-stream-end-const.h \ + babeltrace/graph/message-stream-end.h \ babeltrace/graph/port-const.h \ babeltrace/graph/port-input-const.h \ babeltrace/graph/port-output-const.h \ diff --git a/include/babeltrace/babeltrace.h b/include/babeltrace/babeltrace.h index 36d42258..253bd960 100644 --- a/include/babeltrace/babeltrace.h +++ b/include/babeltrace/babeltrace.h @@ -115,10 +115,16 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/include/babeltrace/graph/message-const.h b/include/babeltrace/graph/message-const.h index d445e5f7..5085192a 100644 --- a/include/babeltrace/graph/message-const.h +++ b/include/babeltrace/graph/message-const.h @@ -35,12 +35,14 @@ extern "C" { * Message types. Unhandled message types should be ignored. */ typedef enum bt_message_type { - BT_MESSAGE_TYPE_EVENT = 0, - BT_MESSAGE_TYPE_INACTIVITY = 1, - BT_MESSAGE_TYPE_STREAM_BEGINNING = 2, - BT_MESSAGE_TYPE_STREAM_END = 3, - BT_MESSAGE_TYPE_PACKET_BEGINNING = 4, - BT_MESSAGE_TYPE_PACKET_END = 5, + BT_MESSAGE_TYPE_EVENT = 0, + BT_MESSAGE_TYPE_INACTIVITY = 1, + BT_MESSAGE_TYPE_STREAM_BEGINNING = 2, + BT_MESSAGE_TYPE_STREAM_END = 3, + BT_MESSAGE_TYPE_PACKET_BEGINNING = 4, + BT_MESSAGE_TYPE_PACKET_END = 5, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING = 6, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_END = 7, } bt_message_type; /** diff --git a/include/babeltrace/graph/message-internal.h b/include/babeltrace/graph/message-internal.h index 96740024..8c17ef9e 100644 --- a/include/babeltrace/graph/message-internal.h +++ b/include/babeltrace/graph/message-internal.h @@ -124,6 +124,10 @@ const char *bt_message_type_string(enum bt_message_type type) return "BT_MESSAGE_TYPE_PACKET_BEGINNING"; case BT_MESSAGE_TYPE_PACKET_END: return "BT_MESSAGE_TYPE_PACKET_END"; + case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING: + return "BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING"; + case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END: + return "BT_MESSAGE_TYPE_STREAM_ACTIVITY_END"; default: return "(unknown)"; } diff --git a/include/babeltrace/graph/message-packet-const.h b/include/babeltrace/graph/message-packet-beginning-const.h similarity index 85% rename from include/babeltrace/graph/message-packet-const.h rename to include/babeltrace/graph/message-packet-beginning-const.h index 997b39ef..78067113 100644 --- a/include/babeltrace/graph/message-packet-const.h +++ b/include/babeltrace/graph/message-packet-beginning-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_CONST_H -#define BABELTRACE_GRAPH_MESSAGE_PACKET_CONST_H +#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_CONST_H /* * Copyright 2017-2018 Philippe Proulx @@ -34,11 +34,8 @@ extern "C" { extern const bt_packet *bt_message_packet_beginning_borrow_packet_const( const bt_message *message); -extern const bt_packet *bt_message_packet_end_borrow_packet_const( - const bt_message *message); - #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_CONST_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_CONST_H */ diff --git a/include/babeltrace/graph/message-packet.h b/include/babeltrace/graph/message-packet-beginning.h similarity index 82% rename from include/babeltrace/graph/message-packet.h rename to include/babeltrace/graph/message-packet-beginning.h index 0ee0f6dc..e7d42546 100644 --- a/include/babeltrace/graph/message-packet.h +++ b/include/babeltrace/graph/message-packet-beginning.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_H -#define BABELTRACE_GRAPH_MESSAGE_PACKET_H +#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_H +#define BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_H /* * Copyright 2017-2018 Philippe Proulx @@ -36,19 +36,11 @@ bt_message *bt_message_packet_beginning_create( bt_self_message_iterator *message_iterator, bt_packet *packet); -extern -bt_message *bt_message_packet_end_create( - bt_self_message_iterator *message_iterator, - bt_packet *packet); - extern bt_packet *bt_message_packet_beginning_borrow_packet( bt_message *message); -extern bt_packet *bt_message_packet_end_borrow_packet( - bt_message *message); - #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_H */ diff --git a/include/babeltrace/graph/message-packet-end-const.h b/include/babeltrace/graph/message-packet-end-const.h new file mode 100644 index 00000000..8da580fb --- /dev/null +++ b/include/babeltrace/graph/message-packet-end-const.h @@ -0,0 +1,41 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_END_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_PACKET_END_CONST_H + +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2016 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* For bt_message, bt_packet */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern const bt_packet *bt_message_packet_end_borrow_packet_const( + const bt_message *message); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_END_CONST_H */ diff --git a/include/babeltrace/graph/message-packet-end.h b/include/babeltrace/graph/message-packet-end.h new file mode 100644 index 00000000..12cf0fc7 --- /dev/null +++ b/include/babeltrace/graph/message-packet-end.h @@ -0,0 +1,46 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_END_H +#define BABELTRACE_GRAPH_MESSAGE_PACKET_END_H + +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2016 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* For bt_message, bt_self_message_iterator, bt_packet */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern +bt_message *bt_message_packet_end_create( + bt_self_message_iterator *message_iterator, + bt_packet *packet); + +extern bt_packet *bt_message_packet_end_borrow_packet( + bt_message *message); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_END_H */ diff --git a/include/babeltrace/graph/message-packet-internal.h b/include/babeltrace/graph/message-packet-internal.h index 5a60e006..e34adf65 100644 --- a/include/babeltrace/graph/message-packet-internal.h +++ b/include/babeltrace/graph/message-packet-internal.h @@ -29,15 +29,13 @@ #include #include -struct bt_message_packet_beginning { +struct bt_message_packet { struct bt_message parent; struct bt_packet *packet; }; -struct bt_message_packet_end { - struct bt_message parent; - struct bt_packet *packet; -}; +BT_HIDDEN +void bt_message_packet_destroy(struct bt_message *msg); BT_HIDDEN struct bt_message *bt_message_packet_beginning_new( @@ -45,16 +43,10 @@ struct bt_message *bt_message_packet_beginning_new( BT_HIDDEN void bt_message_packet_beginning_recycle(struct bt_message *msg); -BT_HIDDEN -void bt_message_packet_beginning_destroy(struct bt_message *msg); - BT_HIDDEN struct bt_message *bt_message_packet_end_new(struct bt_graph *graph); BT_HIDDEN void bt_message_packet_end_recycle(struct bt_message *msg); -BT_HIDDEN -void bt_message_packet_end_destroy(struct bt_message *msg); - #endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_INTERNAL_H */ diff --git a/include/babeltrace/graph/message-stream-activity-beginning-const.h b/include/babeltrace/graph/message-stream-activity-beginning-const.h new file mode 100644 index 00000000..919b1185 --- /dev/null +++ b/include/babeltrace/graph/message-stream-activity-beginning-const.h @@ -0,0 +1,48 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_CONST_H + +/* + * Copyright 2019 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* For bt_message, bt_clock_snapshot, bt_stream */ +#include + +/* For bt_message_stream_activity_clock_snapshot_state */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern bt_message_stream_activity_clock_snapshot_state +bt_message_stream_activity_beginning_borrow_default_clock_snapshot_const( + const bt_message *msg, const bt_clock_snapshot **snapshot); + +extern const bt_stream * +bt_message_stream_activity_beginning_borrow_stream_const( + const bt_message *message); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_CONST_H */ diff --git a/include/babeltrace/graph/message-stream-activity-beginning.h b/include/babeltrace/graph/message-stream-activity-beginning.h new file mode 100644 index 00000000..2449a728 --- /dev/null +++ b/include/babeltrace/graph/message-stream-activity-beginning.h @@ -0,0 +1,54 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_H + +/* + * Copyright 2019 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* For bt_message, bt_self_message_iterator, bt_stream */ +#include + +/* For bt_message_stream_activity_clock_snapshot_state */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern bt_message *bt_message_stream_activity_beginning_create( + bt_self_message_iterator *message_iterator, + bt_stream *stream); + +extern bt_stream *bt_message_stream_activity_beginning_borrow_stream( + bt_message *message); + +extern void bt_message_stream_activity_beginning_set_default_clock_snapshot_state( + bt_message *msg, + bt_message_stream_activity_clock_snapshot_state state); + +extern void bt_message_stream_activity_beginning_set_default_clock_snapshot( + bt_message *msg, uint64_t raw_value); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_H */ diff --git a/include/babeltrace/graph/message-stream-activity-const.h b/include/babeltrace/graph/message-stream-activity-const.h new file mode 100644 index 00000000..b84e27b1 --- /dev/null +++ b/include/babeltrace/graph/message-stream-activity-const.h @@ -0,0 +1,40 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_CONST_H + +/* + * Copyright 2019 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum bt_message_stream_activity_clock_snapshot_state { + BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN, + BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN, + BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE, +} bt_message_stream_activity_clock_snapshot_state; + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_CONST_H */ diff --git a/include/babeltrace/graph/message-stream-activity-end-const.h b/include/babeltrace/graph/message-stream-activity-end-const.h new file mode 100644 index 00000000..d10540a2 --- /dev/null +++ b/include/babeltrace/graph/message-stream-activity-end-const.h @@ -0,0 +1,48 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_CONST_H + +/* + * Copyright 2019 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* For bt_message, bt_clock_snapshot, bt_stream */ +#include + +/* For bt_message_stream_activity_clock_snapshot_state */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern bt_message_stream_activity_clock_snapshot_state +bt_message_stream_activity_end_borrow_default_clock_snapshot_const( + const bt_message *msg, const bt_clock_snapshot **snapshot); + +extern const bt_stream * +bt_message_stream_activity_end_borrow_stream_const( + const bt_message *message); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_CONST_H */ diff --git a/include/babeltrace/graph/message-stream-activity-end.h b/include/babeltrace/graph/message-stream-activity-end.h new file mode 100644 index 00000000..7836745e --- /dev/null +++ b/include/babeltrace/graph/message-stream-activity-end.h @@ -0,0 +1,54 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_H + +/* + * Copyright 2019 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* For bt_message, bt_self_message_iterator, bt_stream */ +#include + +/* For bt_message_stream_activity_clock_snapshot_state */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern bt_message *bt_message_stream_activity_end_create( + bt_self_message_iterator *message_iterator, + bt_stream *stream); + +extern void bt_message_stream_activity_end_set_default_clock_snapshot_state( + bt_message *msg, + bt_message_stream_activity_clock_snapshot_state state); + +extern void bt_message_stream_activity_end_set_default_clock_snapshot( + bt_message *msg, uint64_t raw_value); + +extern bt_stream *bt_message_stream_activity_end_borrow_stream( + bt_message *message); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_H */ diff --git a/include/babeltrace/graph/message-stream-activity-internal.h b/include/babeltrace/graph/message-stream-activity-internal.h new file mode 100644 index 00000000..d90409d4 --- /dev/null +++ b/include/babeltrace/graph/message-stream-activity-internal.h @@ -0,0 +1,55 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_INTERNAL_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_INTERNAL_H + +/* + * Copyright 2019 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include + +struct bt_message_stream_activity { + struct bt_message parent; + struct bt_stream *stream; + struct bt_clock_snapshot *default_cs; + enum bt_message_stream_activity_clock_snapshot_state default_cs_state; +}; + +static inline +const char *bt_message_stream_activity_clock_snapshot_state_string( + enum bt_message_stream_activity_clock_snapshot_state state) +{ + switch (state) { + case BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN: + return "BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN"; + case BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN: + return "BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN"; + case BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE: + return "BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE"; + default: + return "(unknown)"; + } +} + +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_INTERNAL_H */ diff --git a/include/babeltrace/graph/message-stream-const.h b/include/babeltrace/graph/message-stream-beginning-const.h similarity index 86% rename from include/babeltrace/graph/message-stream-const.h rename to include/babeltrace/graph/message-stream-beginning-const.h index fbac5962..09960f77 100644 --- a/include/babeltrace/graph/message-stream-const.h +++ b/include/babeltrace/graph/message-stream-beginning-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_CONST_H -#define BABELTRACE_GRAPH_MESSAGE_STREAM_CONST_H +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_CONST_H /* * Copyright 2017-2018 Philippe Proulx @@ -37,11 +37,8 @@ extern "C" { extern const bt_stream *bt_message_stream_beginning_borrow_stream_const( const bt_message *message); -extern const bt_stream *bt_message_stream_end_borrow_stream_const( - const bt_message *message); - #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_CONST_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_CONST_H */ diff --git a/include/babeltrace/graph/message-stream.h b/include/babeltrace/graph/message-stream-beginning.h similarity index 82% rename from include/babeltrace/graph/message-stream.h rename to include/babeltrace/graph/message-stream-beginning.h index e12b9090..339c819e 100644 --- a/include/babeltrace/graph/message-stream.h +++ b/include/babeltrace/graph/message-stream-beginning.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_H -#define BABELTRACE_GRAPH_MESSAGE_STREAM_H +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_H /* * Copyright 2017-2018 Philippe Proulx @@ -36,19 +36,11 @@ bt_message *bt_message_stream_beginning_create( bt_self_message_iterator *message_iterator, bt_stream *stream); -extern -bt_message *bt_message_stream_end_create( - bt_self_message_iterator *message_iterator, - bt_stream *stream); - extern bt_stream *bt_message_stream_beginning_borrow_stream( bt_message *message); -extern bt_stream *bt_message_stream_end_borrow_stream( - bt_message *message); - #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_H */ diff --git a/include/babeltrace/graph/message-stream-end-const.h b/include/babeltrace/graph/message-stream-end-const.h new file mode 100644 index 00000000..1ee0a47b --- /dev/null +++ b/include/babeltrace/graph/message-stream-end-const.h @@ -0,0 +1,44 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_END_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_END_H + +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2016 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* For bt_message, bt_clock_snapshot, bt_stream */ +#include + +/* For bt_clock_snapshot_state */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern const bt_stream *bt_message_stream_end_borrow_stream_const( + const bt_message *message); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_END_H */ diff --git a/include/babeltrace/graph/message-stream-end.h b/include/babeltrace/graph/message-stream-end.h new file mode 100644 index 00000000..a9865d42 --- /dev/null +++ b/include/babeltrace/graph/message-stream-end.h @@ -0,0 +1,46 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_END_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_END_H + +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2016 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* For bt_message, bt_self_message_iterator, bt_stream */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern +bt_message *bt_message_stream_end_create( + bt_self_message_iterator *message_iterator, + bt_stream *stream); + +extern bt_stream *bt_message_stream_end_borrow_stream( + bt_message *message); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_END_H */ diff --git a/include/babeltrace/graph/message-stream-internal.h b/include/babeltrace/graph/message-stream-internal.h index 36e4580c..8cdcdda0 100644 --- a/include/babeltrace/graph/message-stream-internal.h +++ b/include/babeltrace/graph/message-stream-internal.h @@ -25,17 +25,12 @@ */ #include -#include +#include #include #include #include -struct bt_message_stream_beginning { - struct bt_message parent; - struct bt_stream *stream; -}; - -struct bt_message_stream_end { +struct bt_message_stream { struct bt_message parent; struct bt_stream *stream; }; diff --git a/lib/graph/graph.c b/lib/graph/graph.c index f0a919f6..d5fc0b6b 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -233,14 +233,14 @@ static void destroy_message_packet_begin(struct bt_message *msg, struct bt_graph *graph) { - bt_message_packet_beginning_destroy(msg); + bt_message_packet_destroy(msg); } static void destroy_message_packet_end(struct bt_message *msg, struct bt_graph *graph) { - bt_message_packet_end_destroy(msg); + bt_message_packet_destroy(msg); } static diff --git a/lib/graph/iterator.c b/lib/graph/iterator.c index 9fc612cc..a0da4e66 100644 --- a/lib/graph/iterator.c +++ b/lib/graph/iterator.c @@ -48,9 +48,11 @@ #include #include #include -#include +#include +#include #include -#include +#include +#include #include #include #include @@ -1002,7 +1004,7 @@ int get_message_ns_from_origin(const struct bt_message *msg, goto end; case BT_MESSAGE_TYPE_PACKET_BEGINNING: { - const struct bt_message_packet_beginning *pkt_msg = + const struct bt_message_packet *pkt_msg = (const void *) msg; clk_snapshot = pkt_msg->packet->default_beginning_cs; @@ -1010,7 +1012,7 @@ int get_message_ns_from_origin(const struct bt_message *msg, } case BT_MESSAGE_TYPE_PACKET_END: { - const struct bt_message_packet_end *pkt_msg = + const struct bt_message_packet *pkt_msg = (const void *) msg; clk_snapshot = pkt_msg->packet->default_end_cs; diff --git a/lib/graph/message/Makefile.am b/lib/graph/message/Makefile.am index d111f5b8..20f6a000 100644 --- a/lib/graph/message/Makefile.am +++ b/lib/graph/message/Makefile.am @@ -5,4 +5,5 @@ libgraph_message_la_SOURCES = \ packet.c \ event.c \ stream.c \ - inactivity.c + inactivity.c \ + stream-activity.c diff --git a/lib/graph/message/message.c b/lib/graph/message/message.c index 545d67cb..f258eb1e 100644 --- a/lib/graph/message/message.c +++ b/lib/graph/message/message.c @@ -36,7 +36,7 @@ void bt_message_init(struct bt_message *message, bt_object_release_func release, struct bt_graph *graph) { - BT_ASSERT(type >= 0 && type <= BT_MESSAGE_TYPE_PACKET_END); + BT_ASSERT(type >= 0 && type <= BT_MESSAGE_TYPE_STREAM_ACTIVITY_END); message->type = type; bt_object_init_shared(&message->base, release); message->graph = graph; diff --git a/lib/graph/message/packet.c b/lib/graph/message/packet.c index 22894c9b..32ce5698 100644 --- a/lib/graph/message/packet.c +++ b/lib/graph/message/packet.c @@ -31,29 +31,29 @@ #include #include #include -#include -#include +#include +#include +#include +#include #include #include #include #include #include -BT_HIDDEN -struct bt_message *bt_message_packet_beginning_new(struct bt_graph *graph) +static inline +struct bt_message *new_packet_message(struct bt_graph *graph, + enum bt_message_type type, bt_object_release_func recycle_func) { - struct bt_message_packet_beginning *message; + struct bt_message_packet *message; - message = g_new0(struct bt_message_packet_beginning, 1); + message = g_new0(struct bt_message_packet, 1); if (!message) { - BT_LOGE_STR("Failed to allocate one packet beginning message."); + BT_LOGE_STR("Failed to allocate one packet message."); goto error; } - bt_message_init(&message->parent, - BT_MESSAGE_TYPE_PACKET_BEGINNING, - (bt_object_release_func) bt_message_packet_beginning_recycle, - graph); + bt_message_init(&message->parent, type, recycle_func, graph); goto end; error: @@ -63,27 +63,39 @@ end: return (void *) message; } -struct bt_message *bt_message_packet_beginning_create( - struct bt_self_message_iterator *self_msg_iter, - struct bt_packet *packet) +BT_HIDDEN +struct bt_message *bt_message_packet_beginning_new(struct bt_graph *graph) { - struct bt_self_component_port_input_message_iterator *msg_iter = - (void *) self_msg_iter; - struct bt_message_packet_beginning *message = NULL; + return new_packet_message(graph, BT_MESSAGE_TYPE_PACKET_BEGINNING, + (bt_object_release_func) bt_message_packet_beginning_recycle); +} + +BT_HIDDEN +struct bt_message *bt_message_packet_end_new(struct bt_graph *graph) +{ + return new_packet_message(graph, BT_MESSAGE_TYPE_PACKET_END, + (bt_object_release_func) bt_message_packet_end_recycle); +} + +static inline +struct bt_message *bt_message_packet_create( + struct bt_self_component_port_input_message_iterator *msg_iter, + struct bt_packet *packet, struct bt_object_pool *pool) +{ + struct bt_message_packet *message = NULL; struct bt_stream *stream; struct bt_stream_class *stream_class; - BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + BT_ASSERT(msg_iter); BT_ASSERT_PRE_NON_NULL(packet, "Packet"); stream = bt_packet_borrow_stream(packet); BT_ASSERT(stream); stream_class = bt_stream_borrow_class(stream); BT_ASSERT(stream_class); - BT_LIB_LOGD("Creating packet beginning message object: " + BT_LIB_LOGD("Creating packet message object: " "%![packet-]+a, %![stream-]+s, %![sc-]+S", packet, stream, stream_class); - message = (void *) bt_message_create_from_pool( - &msg_iter->graph->packet_begin_msg_pool, msg_iter->graph); + message = (void *) bt_message_create_from_pool(pool, msg_iter->graph); if (!message) { /* bt_message_create_from_pool() logs errors */ goto end; @@ -94,7 +106,7 @@ struct bt_message *bt_message_packet_beginning_create( bt_object_get_no_null_check_no_parent_check( &message->packet->base); bt_packet_set_is_frozen(packet, true); - BT_LIB_LOGD("Created packet beginning message object: " + BT_LIB_LOGD("Created packet message object: " "%![msg-]+n, %![packet-]+a, %![stream-]+s, %![sc-]+S", message, packet, stream, stream_class); goto end; @@ -103,164 +115,107 @@ end: return (void *) message; } -BT_HIDDEN -void bt_message_packet_beginning_destroy(struct bt_message *msg) +struct bt_message *bt_message_packet_beginning_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_packet *packet) { - struct bt_message_packet_beginning *packet_begin_msg = (void *) msg; + struct bt_self_component_port_input_message_iterator *msg_iter = + (void *) self_msg_iter; - BT_LIB_LOGD("Destroying packet beginning message: %!+n", msg); - BT_LIB_LOGD("Putting packet: %!+a", packet_begin_msg->packet); - BT_OBJECT_PUT_REF_AND_RESET(packet_begin_msg->packet); - g_free(msg); + BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + return bt_message_packet_create(msg_iter, packet, + &msg_iter->graph->packet_begin_msg_pool); } -BT_HIDDEN -void bt_message_packet_beginning_recycle(struct bt_message *msg) +struct bt_message *bt_message_packet_end_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_packet *packet) { - struct bt_message_packet_beginning *packet_begin_msg = (void *) msg; - struct bt_graph *graph; - - BT_ASSERT(packet_begin_msg); - - if (unlikely(!msg->graph)) { - bt_message_packet_beginning_destroy(msg); - return; - } + struct bt_self_component_port_input_message_iterator *msg_iter = + (void *) self_msg_iter; - BT_LIB_LOGD("Recycling packet beginning message: %!+n", msg); - bt_message_reset(msg); - bt_object_put_no_null_check(&packet_begin_msg->packet->base); - packet_begin_msg->packet = NULL; - graph = msg->graph; - msg->graph = NULL; - bt_object_pool_recycle_object(&graph->packet_begin_msg_pool, msg); + BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + return bt_message_packet_create(msg_iter, packet, + &msg_iter->graph->packet_end_msg_pool); } -struct bt_packet *bt_message_packet_beginning_borrow_packet( - struct bt_message *message) +BT_HIDDEN +void bt_message_packet_destroy(struct bt_message *msg) { - struct bt_message_packet_beginning *packet_begin; + struct bt_message_packet *packet_msg = (void *) msg; - BT_ASSERT_PRE_NON_NULL(message, "Message"); - BT_ASSERT_PRE_MSG_IS_TYPE(message, - BT_MESSAGE_TYPE_PACKET_BEGINNING); - packet_begin = (void *) message; - return packet_begin->packet; + BT_LIB_LOGD("Destroying packet message: %!+n", msg); + BT_LIB_LOGD("Putting packet: %!+a", packet_msg->packet); + BT_OBJECT_PUT_REF_AND_RESET(packet_msg->packet); + g_free(msg); } -const struct bt_packet *bt_message_packet_beginning_borrow_packet_const( - const struct bt_message *message) +static inline +void recycle_packet_message(struct bt_message *msg, struct bt_object_pool *pool) { - return bt_message_packet_beginning_borrow_packet( - (void *) message); + struct bt_message_packet *packet_msg = (void *) msg; + + BT_LIB_LOGD("Recycling packet message: %!+n", msg); + bt_message_reset(msg); + bt_object_put_no_null_check(&packet_msg->packet->base); + packet_msg->packet = NULL; + msg->graph = NULL; + bt_object_pool_recycle_object(pool, msg); } BT_HIDDEN -struct bt_message *bt_message_packet_end_new(struct bt_graph *graph) +void bt_message_packet_beginning_recycle(struct bt_message *msg) { - struct bt_message_packet_end *message; + BT_ASSERT(msg); - message = g_new0(struct bt_message_packet_end, 1); - if (!message) { - BT_LOGE_STR("Failed to allocate one packet end message."); - goto error; + if (unlikely(!msg->graph)) { + bt_message_packet_destroy(msg); + return; } - bt_message_init(&message->parent, - BT_MESSAGE_TYPE_PACKET_END, - (bt_object_release_func) bt_message_packet_end_recycle, - graph); - goto end; - -error: - BT_OBJECT_PUT_REF_AND_RESET(message); - -end: - return (void *) message; + recycle_packet_message(msg, &msg->graph->packet_begin_msg_pool); } -struct bt_message *bt_message_packet_end_create( - struct bt_self_message_iterator *self_msg_iter, - struct bt_packet *packet) +BT_HIDDEN +void bt_message_packet_end_recycle(struct bt_message *msg) { - struct bt_self_component_port_input_message_iterator *msg_iter = - (void *) self_msg_iter; - struct bt_message_packet_end *message = NULL; - struct bt_stream *stream; - struct bt_stream_class *stream_class; + BT_ASSERT(msg); - BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); - BT_ASSERT_PRE_NON_NULL(packet, "Packet"); - stream = bt_packet_borrow_stream(packet); - BT_ASSERT(stream); - stream_class = bt_stream_borrow_class(stream); - BT_ASSERT(stream_class); - BT_LIB_LOGD("Creating packet end message object: " - "%![packet-]+a, %![stream-]+s, %![sc-]+S", - packet, stream, stream_class); - message = (void *) bt_message_create_from_pool( - &msg_iter->graph->packet_end_msg_pool, msg_iter->graph); - if (!message) { - /* bt_message_create_from_pool() logs errors */ - goto end; + if (unlikely(!msg->graph)) { + bt_message_packet_destroy(msg); + return; } - BT_ASSERT(!message->packet); - message->packet = packet; - bt_object_get_no_null_check_no_parent_check( - &message->packet->base); - bt_packet_set_is_frozen(packet, true); - BT_LIB_LOGD("Created packet end message object: " - "%![msg-]+n, %![packet-]+a, %![stream-]+s, %![sc-]+S", - message, packet, stream, stream_class); - goto end; - -end: - return (void *) message; + recycle_packet_message(msg, &msg->graph->packet_end_msg_pool); } -BT_HIDDEN -void bt_message_packet_end_destroy(struct bt_message *msg) +struct bt_packet *bt_message_packet_beginning_borrow_packet( + struct bt_message *message) { - struct bt_message_packet_end *packet_end_msg = (void *) msg; + struct bt_message_packet *packet_msg = (void *) message; - BT_LIB_LOGD("Destroying packet end message: %!+n", msg); - BT_LIB_LOGD("Putting packet: %!+a", packet_end_msg->packet); - BT_OBJECT_PUT_REF_AND_RESET(packet_end_msg->packet); - g_free(msg); + BT_ASSERT_PRE_NON_NULL(message, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(message, + BT_MESSAGE_TYPE_PACKET_BEGINNING); + return packet_msg->packet; } -BT_HIDDEN -void bt_message_packet_end_recycle(struct bt_message *msg) +const struct bt_packet *bt_message_packet_beginning_borrow_packet_const( + const struct bt_message *message) { - struct bt_message_packet_end *packet_end_msg = (void *) msg; - struct bt_graph *graph; - - BT_ASSERT(packet_end_msg); - - if (!msg->graph) { - bt_message_packet_end_destroy(msg); - return; - } - - BT_LIB_LOGD("Recycling packet end message: %!+n", msg); - bt_message_reset(msg); - BT_OBJECT_PUT_REF_AND_RESET(packet_end_msg->packet); - graph = msg->graph; - msg->graph = NULL; - bt_object_pool_recycle_object(&graph->packet_end_msg_pool, msg); + return bt_message_packet_beginning_borrow_packet( + (void *) message); } struct bt_packet *bt_message_packet_end_borrow_packet( struct bt_message *message) { - struct bt_message_packet_end *packet_end; + struct bt_message_packet *packet_msg = (void *) message; BT_ASSERT_PRE_NON_NULL(message, "Message"); BT_ASSERT_PRE_MSG_IS_TYPE(message, BT_MESSAGE_TYPE_PACKET_END); - packet_end = (void *) message; - return packet_end->packet; + return packet_msg->packet; } const struct bt_packet *bt_message_packet_end_borrow_packet_const( diff --git a/lib/graph/message/stream-activity.c b/lib/graph/message/stream-activity.c new file mode 100644 index 00000000..79f4319e --- /dev/null +++ b/lib/graph/message/stream-activity.c @@ -0,0 +1,270 @@ +/* + * Copyright 2019 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_TAG "MSG-STREAM-ACTIVITY" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static +void destroy_stream_activity_message(struct bt_object *obj) +{ + struct bt_message_stream_activity *message = (void *) obj; + + BT_LIB_LOGD("Destroying stream activity message: %!+n", message); + BT_LIB_LOGD("Putting stream: %!+s", message->stream); + BT_OBJECT_PUT_REF_AND_RESET(message->stream); + + if (message->default_cs) { + bt_clock_snapshot_recycle(message->default_cs); + } + + g_free(message); +} + +static inline +struct bt_message *create_stream_activity_message( + struct bt_self_message_iterator *self_msg_iter, + struct bt_stream *stream, enum bt_message_type type) +{ + struct bt_message_stream_activity *message; + struct bt_stream_class *stream_class; + + BT_ASSERT_PRE_NON_NULL(self_msg_iter, "Message iterator"); + BT_ASSERT_PRE_NON_NULL(stream, "Stream"); + stream_class = bt_stream_borrow_class(stream); + BT_ASSERT(stream_class); + BT_LIB_LOGD("Creating stream activity message object: " + "type=%s, %![stream-]+s, %![sc-]+S", + bt_message_type_string(type), stream, stream_class); + message = g_new0(struct bt_message_stream_activity, 1); + if (!message) { + BT_LOGE_STR("Failed to allocate one stream activity message."); + goto error; + } + + bt_message_init(&message->parent, type, + destroy_stream_activity_message, NULL); + message->stream = stream; + bt_object_get_no_null_check(message->stream); + + if (stream_class->default_clock_class) { + message->default_cs = bt_clock_snapshot_create( + stream_class->default_clock_class); + if (!message->default_cs) { + goto error; + } + } + + message->default_cs_state = + BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN; + BT_LIB_LOGD("Created stream activity message object: " + "%![msg-]+n, %![stream-]+s, %![sc-]+S", message, + stream, stream_class); + + return (void *) &message->parent; + +error: + return NULL; +} + +struct bt_message *bt_message_stream_activity_beginning_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_stream *stream) +{ + return create_stream_activity_message(self_msg_iter, stream, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING); +} + +struct bt_message *bt_message_stream_activity_end_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_stream *stream) +{ + return create_stream_activity_message(self_msg_iter, stream, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_END); +} + +static inline +struct bt_stream *borrow_stream_activity_message_stream( + struct bt_message *message) +{ + struct bt_message_stream_activity *stream_act_msg = (void *) message; + + BT_ASSERT(message); + return stream_act_msg->stream; +} + +struct bt_stream *bt_message_stream_activity_beginning_borrow_stream( + struct bt_message *message) +{ + BT_ASSERT_PRE_NON_NULL(message, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(message, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING); + return borrow_stream_activity_message_stream(message); +} + +struct bt_stream *bt_message_stream_activity_end_borrow_stream( + struct bt_message *message) +{ + BT_ASSERT_PRE_NON_NULL(message, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(message, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_END); + return borrow_stream_activity_message_stream(message); +} + +const struct bt_stream *bt_message_stream_activity_beginning_borrow_stream_const( + const struct bt_message *message) +{ + return bt_message_stream_activity_beginning_borrow_stream( + (void *) message); +} + +const struct bt_stream *bt_message_stream_activity_end_borrow_stream_const( + const struct bt_message *message) +{ + return bt_message_stream_activity_end_borrow_stream((void *) message); +} + +static inline +void set_stream_activity_message_default_clock_snapshot( + struct bt_message *msg, uint64_t value_cycles) +{ + struct bt_message_stream_activity *stream_act_msg = (void *) msg; + struct bt_stream_class *sc; + + BT_ASSERT(msg); + BT_ASSERT_PRE_HOT(msg, "Message", ": %!+n", msg); + sc = stream_act_msg->stream->class; + BT_ASSERT(sc); + BT_ASSERT_PRE(sc->default_clock_class, + "Message's stream's class has no default clock class: " + "%![msg-]+n, %![sc-]+S", msg, sc); + bt_clock_snapshot_set_raw_value(stream_act_msg->default_cs, + value_cycles); + stream_act_msg->default_cs_state = + BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN; + BT_LIB_LOGV("Set stream activity message's default clock snapshot: " + "%![msg-]+n, value=%" PRIu64, msg, value_cycles); +} + +void bt_message_stream_activity_beginning_set_default_clock_snapshot( + struct bt_message *msg, uint64_t raw_value) +{ + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING); + set_stream_activity_message_default_clock_snapshot(msg, raw_value); +} + +void bt_message_stream_activity_end_set_default_clock_snapshot( + struct bt_message *msg, uint64_t raw_value) +{ + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_END); + set_stream_activity_message_default_clock_snapshot(msg, raw_value); +} + +static inline +enum bt_message_stream_activity_clock_snapshot_state +borrow_stream_activity_message_default_clock_snapshot_const( + const bt_message *msg, const bt_clock_snapshot **snapshot) +{ + const struct bt_message_stream_activity *stream_act_msg = + (const void *) msg; + + BT_ASSERT_PRE_NON_NULL(snapshot, "Clock snapshot (output)"); + *snapshot = stream_act_msg->default_cs; + return stream_act_msg->default_cs_state; +} + +enum bt_message_stream_activity_clock_snapshot_state +bt_message_stream_activity_beginning_borrow_default_clock_snapshot_const( + const bt_message *msg, const bt_clock_snapshot **snapshot) +{ + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING); + return borrow_stream_activity_message_default_clock_snapshot_const(msg, + snapshot); +} + +enum bt_message_stream_activity_clock_snapshot_state +bt_message_stream_activity_end_borrow_default_clock_snapshot_const( + const bt_message *msg, const bt_clock_snapshot **snapshot) +{ + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_ACTIVITY_END); + return borrow_stream_activity_message_default_clock_snapshot_const(msg, + snapshot); +} + +static inline +void set_stream_activity_message_default_clock_snapshot_state( + struct bt_message *msg, + enum bt_message_stream_activity_clock_snapshot_state state) +{ + struct bt_message_stream_activity *stream_act_msg = (void *) msg; + + BT_ASSERT(msg); + BT_ASSERT_PRE_HOT(msg, "Message", ": %!+n", msg); + BT_ASSERT_PRE(state != BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN, + "Invalid clock snapshot state: %![msg-]+n, state=%s", + msg, + bt_message_stream_activity_clock_snapshot_state_string(state)); + stream_act_msg->default_cs_state = state; + BT_LIB_LOGV("Set stream activity message's default clock snapshot state: " + "%![msg-]+n, state=%s", msg, + bt_message_stream_activity_clock_snapshot_state_string(state)); +} + +void bt_message_stream_activity_beginning_set_default_clock_snapshot_state( + struct bt_message *msg, + enum bt_message_stream_activity_clock_snapshot_state state) +{ + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING); + set_stream_activity_message_default_clock_snapshot_state(msg, state); +} + +void bt_message_stream_activity_end_set_default_clock_snapshot_state( + struct bt_message *msg, + enum bt_message_stream_activity_clock_snapshot_state state) +{ + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, + BT_MESSAGE_TYPE_STREAM_ACTIVITY_END); + set_stream_activity_message_default_clock_snapshot_state(msg, state); +} diff --git a/lib/graph/message/stream.c b/lib/graph/message/stream.c index 0d6f374c..212e6482 100644 --- a/lib/graph/message/stream.c +++ b/lib/graph/message/stream.c @@ -30,132 +30,100 @@ #include #include #include -#include -#include +#include +#include +#include +#include #include #include #include static -void bt_message_stream_end_destroy(struct bt_object *obj) +void destroy_stream_message(struct bt_object *obj) { - struct bt_message_stream_end *message = - (struct bt_message_stream_end *) obj; + struct bt_message_stream *message = (void *) obj; - BT_LIB_LOGD("Destroying stream end message: %!+n", - message); + BT_LIB_LOGD("Destroying stream message: %!+n", message); BT_LIB_LOGD("Putting stream: %!+s", message->stream); BT_OBJECT_PUT_REF_AND_RESET(message->stream); g_free(message); } -struct bt_message *bt_message_stream_end_create( +static inline +struct bt_message *create_stream_message( struct bt_self_message_iterator *self_msg_iter, - struct bt_stream *stream) + struct bt_stream *stream, enum bt_message_type type) { - struct bt_message_stream_end *message; + struct bt_message_stream *message; struct bt_stream_class *stream_class; BT_ASSERT_PRE_NON_NULL(self_msg_iter, "Message iterator"); BT_ASSERT_PRE_NON_NULL(stream, "Stream"); stream_class = bt_stream_borrow_class(stream); BT_ASSERT(stream_class); - BT_LIB_LOGD("Creating stream end message object: " - "%![stream-]+s, %![sc-]+S", stream, stream_class); - message = g_new0(struct bt_message_stream_end, 1); + BT_LIB_LOGD("Creating stream message object: " + "type=%s, %![stream-]+s, %![sc-]+S", + bt_message_type_string(type), stream, stream_class); + message = g_new0(struct bt_message_stream, 1); if (!message) { - BT_LOGE_STR("Failed to allocate one stream end message."); + BT_LOGE_STR("Failed to allocate one stream message."); goto error; } - bt_message_init(&message->parent, - BT_MESSAGE_TYPE_STREAM_END, - bt_message_stream_end_destroy, NULL); + bt_message_init(&message->parent, type, + destroy_stream_message, NULL); message->stream = stream; bt_object_get_no_null_check(message->stream); - BT_LIB_LOGD("Created stream end message object: " + BT_LIB_LOGD("Created stream message object: " "%![msg-]+n, %![stream-]+s, %![sc-]+S", message, stream, stream_class); return (void *) &message->parent; + error: return NULL; } -struct bt_stream *bt_message_stream_end_borrow_stream( - struct bt_message *message) +struct bt_message *bt_message_stream_beginning_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_stream *stream) { - struct bt_message_stream_end *stream_end; - - BT_ASSERT_PRE_NON_NULL(message, "Message"); - BT_ASSERT_PRE_MSG_IS_TYPE(message, - BT_MESSAGE_TYPE_STREAM_END); - stream_end = (void *) message; - return stream_end->stream; + return create_stream_message(self_msg_iter, stream, + BT_MESSAGE_TYPE_STREAM_BEGINNING); } -const struct bt_stream *bt_message_stream_end_borrow_stream_const( - const struct bt_message *message) +struct bt_message *bt_message_stream_end_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_stream *stream) { - return bt_message_stream_end_borrow_stream( - (void *) message); + return create_stream_message(self_msg_iter, stream, + BT_MESSAGE_TYPE_STREAM_END); } -static -void bt_message_stream_beginning_destroy(struct bt_object *obj) +static inline +struct bt_stream *borrow_stream_message_stream(struct bt_message *message) { - struct bt_message_stream_beginning *message = - (struct bt_message_stream_beginning *) obj; + struct bt_message_stream *stream_msg; - BT_LIB_LOGD("Destroying stream beginning message: %!+n", - message); - BT_LIB_LOGD("Putting stream: %!+s", message->stream); - BT_OBJECT_PUT_REF_AND_RESET(message->stream); - g_free(message); + BT_ASSERT(message); + stream_msg = (void *) message; + return stream_msg->stream; } -struct bt_message *bt_message_stream_beginning_create( - struct bt_self_message_iterator *self_msg_iter, - struct bt_stream *stream) +struct bt_stream *bt_message_stream_beginning_borrow_stream( + struct bt_message *message) { - struct bt_message_stream_beginning *message; - struct bt_stream_class *stream_class; - - BT_ASSERT_PRE_NON_NULL(self_msg_iter, "Message iterator"); - BT_ASSERT_PRE_NON_NULL(stream, "Stream"); - stream_class = bt_stream_borrow_class(stream); - BT_ASSERT(stream_class); - BT_LIB_LOGD("Creating stream beginning message object: " - "%![stream-]+s, %![sc-]+S", stream, stream_class); - message = g_new0(struct bt_message_stream_beginning, 1); - if (!message) { - BT_LOGE_STR("Failed to allocate one stream beginning message."); - goto error; - } - - bt_message_init(&message->parent, - BT_MESSAGE_TYPE_STREAM_BEGINNING, - bt_message_stream_beginning_destroy, NULL); - message->stream = stream; - bt_object_get_no_null_check(message->stream); - BT_LIB_LOGD("Created stream beginning message object: " - "%![msg-]+n, %![stream-]+s, %![sc-]+S", message, - stream, stream_class); - return (void *) &message->parent; -error: - return NULL; + BT_ASSERT_PRE_NON_NULL(message, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(message, BT_MESSAGE_TYPE_STREAM_BEGINNING); + return borrow_stream_message_stream(message); } -struct bt_stream *bt_message_stream_beginning_borrow_stream( +struct bt_stream *bt_message_stream_end_borrow_stream( struct bt_message *message) { - struct bt_message_stream_beginning *stream_begin; - BT_ASSERT_PRE_NON_NULL(message, "Message"); - BT_ASSERT_PRE_MSG_IS_TYPE(message, - BT_MESSAGE_TYPE_STREAM_BEGINNING); - stream_begin = (void *) message; - return stream_begin->stream; + BT_ASSERT_PRE_MSG_IS_TYPE(message, BT_MESSAGE_TYPE_STREAM_END); + return borrow_stream_message_stream(message); } const struct bt_stream *bt_message_stream_beginning_borrow_stream_const( @@ -164,3 +132,10 @@ const struct bt_stream *bt_message_stream_beginning_borrow_stream_const( return bt_message_stream_beginning_borrow_stream( (void *) message); } + +const struct bt_stream *bt_message_stream_end_borrow_stream_const( + const struct bt_message *message) +{ + return bt_message_stream_end_borrow_stream( + (void *) message); +} diff --git a/lib/lib-logging.c b/lib/lib-logging.c index 017f2540..096428e1 100644 --- a/lib/lib-logging.c +++ b/lib/lib-logging.c @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -908,55 +909,58 @@ static inline void format_message(char **buf_ch, bool extended, if (msg_event->event) { SET_TMP_PREFIX("event-"); - format_event(buf_ch, true, tmp_prefix, msg_event->event); + format_event(buf_ch, true, tmp_prefix, + msg_event->event); } break; } case BT_MESSAGE_TYPE_STREAM_BEGINNING: + case BT_MESSAGE_TYPE_STREAM_END: { - const struct bt_message_stream_beginning *msg_stream = - (const void *) msg; + const struct bt_message_stream *msg_stream = (const void *) msg; if (msg_stream->stream) { SET_TMP_PREFIX("stream-"); - format_stream(buf_ch, true, tmp_prefix, msg_stream->stream); + format_stream(buf_ch, true, tmp_prefix, + msg_stream->stream); } break; } - case BT_MESSAGE_TYPE_STREAM_END: + case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING: + case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END: { - const struct bt_message_stream_end *msg_stream = + const struct bt_message_stream_activity *msg_stream_activity = (const void *) msg; - if (msg_stream->stream) { + if (msg_stream_activity->stream) { SET_TMP_PREFIX("stream-"); - format_stream(buf_ch, true, tmp_prefix, msg_stream->stream); + format_stream(buf_ch, true, tmp_prefix, + msg_stream_activity->stream); } - break; - } - case BT_MESSAGE_TYPE_PACKET_BEGINNING: - { - const struct bt_message_packet_beginning *msg_packet = - (const void *) msg; + BUF_APPEND(", %sdefault-cs-state=%s", + PRFIELD(bt_message_stream_activity_clock_snapshot_state_string( + msg_stream_activity->default_cs_state))); - if (msg_packet->packet) { - SET_TMP_PREFIX("packet-"); - format_packet(buf_ch, true, tmp_prefix, msg_packet->packet); + if (msg_stream_activity->default_cs) { + SET_TMP_PREFIX("default-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + msg_stream_activity->default_cs); } break; } + case BT_MESSAGE_TYPE_PACKET_BEGINNING: case BT_MESSAGE_TYPE_PACKET_END: { - const struct bt_message_packet_end *msg_packet = - (const void *) msg; + const struct bt_message_packet *msg_packet = (const void *) msg; if (msg_packet->packet) { SET_TMP_PREFIX("packet-"); - format_packet(buf_ch, true, tmp_prefix, msg_packet->packet); + format_packet(buf_ch, true, tmp_prefix, + msg_packet->packet); } break; -- 2.34.1