Skip to content

Commit ab5d2a5

Browse files
committed
control_socket acquire: get the pointer from priv_data
Do not assume that (struct module) is first in the (struct control_state) anymore in particular and in any structure in general.
1 parent cda3d1b commit ab5d2a5

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

src/audio/filter/controlport_stats.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author Martin Piatka <[email protected]>
44
*/
55
/*
6-
* Copyright (c) 2022 CESNET, z. s. p. o.
6+
* Copyright (c) 2022-2025 CESNET
77
* All rights reserved.
88
*
99
* Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,9 @@
5555
struct state_controlport_stats{
5656
state_controlport_stats(struct module *mod) : mod(MODULE_CLASS_DATA, mod, this)
5757
{
58-
control = (control_state *) (get_module(get_root_module(mod), "control"));
58+
control = (control_state *) (get_module(get_root_module(mod),
59+
"control"))
60+
->priv_data;
5961
}
6062

6163
module_raii mod;

src/module.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ typedef void (*notify_t)(struct module *);
106106
struct module {
107107
enum module_class cls;
108108
notify_t new_message; ///< if set, notifies module that new message is in queue, receiver lock is hold during the call
109-
void *priv_data; ///< can be used to store state pointer for
110-
///< new_message(); uneeded otherwise
109+
void *priv_data; ///< optional; can be used to store state pointer for
110+
///< new_message() or to retreive the state from the
111+
///< module (control_socket)
111112
char name[128]; ///< optional name of the module. May be used for indexing.
112113

113114
struct module_priv_state *module_priv;

src/rtp/video_decoders.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ struct state_video_decoder
341341
mod.priv_data = this;
342342
mod.new_message = decoder_process_message;
343343
module_register(&mod, parent);
344-
control = (struct control_state *) get_module(get_root_module(parent), "control");
344+
control = (struct control_state *) get_module(
345+
get_root_module(parent), "control")
346+
->priv_data;
345347
}
346348
~state_video_decoder() {
347349
module_done(&mod);

src/transmit.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,10 @@ struct tx *tx_init(struct module *parent, unsigned mtu, enum tx_media_type media
264264

265265
tx->bitrate = bitrate;
266266

267-
if(parent)
268-
tx->control = (struct control_state *) get_module(get_root_module(parent), "control");
267+
if (parent) {
268+
tx->control = (struct control_state *) get_module(
269+
get_root_module(parent), "control")->priv_data;
270+
}
269271

270272
return tx;
271273
}

src/video_rxtx/ultragrid_rtp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author Martin Pulec <[email protected]>
44
*/
55
/*
6-
* Copyright (c) 2013-2023 CESNET z.s.p.o.
6+
* Copyright (c) 2013-2025 CESNET
77
* All rights reserved.
88
*
99
* Redistribution and use in source and binary forms, with or without
@@ -93,7 +93,7 @@ ultragrid_rtp_video_rxtx::ultragrid_rtp_video_rxtx(const map<string, param_u> &p
9393
}
9494

9595
m_control = (struct control_state *) get_module(
96-
get_root_module(m_common.parent), "control");
96+
get_root_module(m_common.parent), "control")->priv_data;
9797
}
9898

9999
ultragrid_rtp_video_rxtx::~ultragrid_rtp_video_rxtx()

0 commit comments

Comments
 (0)