mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-01-06 00:56:13 +00:00
Use session_t destructor to ensure the context and hwdevice are always destroyed in the correct order.
This commit is contained in:
parent
a31c6c4cd0
commit
6fca2c593c
@ -324,9 +324,14 @@ struct encoder_t {
|
|||||||
class session_t {
|
class session_t {
|
||||||
public:
|
public:
|
||||||
session_t() = default;
|
session_t() = default;
|
||||||
session_t(ctx_t &&ctx, std::shared_ptr<platf::hwdevice_t> &&device, int inject) : device { std::move(device) }, ctx { std::move(ctx) }, inject { inject } {}
|
session_t(ctx_t &&ctx, std::shared_ptr<platf::hwdevice_t> &&device, int inject) : ctx { std::move(ctx) }, device { std::move(device) }, inject { inject } {}
|
||||||
|
|
||||||
session_t(session_t &&other) noexcept = default;
|
session_t(session_t &&other) noexcept = default;
|
||||||
|
~session_t() {
|
||||||
|
// Order matters here because the context relies on the hwdevice still being valid
|
||||||
|
ctx.reset();
|
||||||
|
device.reset();
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure objects are destroyed in the correct order
|
// Ensure objects are destroyed in the correct order
|
||||||
session_t &operator=(session_t &&other) {
|
session_t &operator=(session_t &&other) {
|
||||||
@ -341,8 +346,8 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<platf::hwdevice_t> device;
|
|
||||||
ctx_t ctx;
|
ctx_t ctx;
|
||||||
|
std::shared_ptr<platf::hwdevice_t> device;
|
||||||
|
|
||||||
std::vector<packet_raw_t::replace_t> replacements;
|
std::vector<packet_raw_t::replace_t> replacements;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user