Skip to content

Commit 3a14465

Browse files
no more optional
1 parent 52895b7 commit 3a14465

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

‎src/capture_source.cpp‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "livekit/capture_source.h"
1818

19-
#include <optional>
2019
#include <stdexcept>
2120

2221
#include "capture.pb.h"
@@ -217,14 +216,14 @@ DeviceFormatRequest DeviceFormatRequest::closest(DeviceFormat format) {
217216
DeviceFormatRequest DeviceFormatRequest::highestFramerate(HighestFramerateConstraint constraint) {
218217
DeviceFormatRequest request;
219218
request.kind_ = Kind::HighestFramerate;
220-
request.highest_framerate_ = std::move(constraint);
219+
request.highest_framerate_ = constraint;
221220
return request;
222221
}
223222

224223
DeviceFormatRequest DeviceFormatRequest::highestResolution(HighestResolutionConstraint constraint) {
225224
DeviceFormatRequest request;
226225
request.kind_ = Kind::HighestResolution;
227-
request.highest_resolution_ = std::move(constraint);
226+
request.highest_resolution_ = constraint;
228227
return request;
229228
}
230229

@@ -306,16 +305,16 @@ std::future<std::vector<CaptureDeviceInfo>> CaptureSource::listDevices() {
306305
// the capture feature rejects it outright). Report that through the returned
307306
// future so every failure reaches the caller as a CaptureSourceError from
308307
// exactly one place, as documented.
309-
std::optional<std::future<proto::CaptureDeviceList>> devices;
308+
std::future<proto::CaptureDeviceList> devices;
310309
try {
311-
devices.emplace(FfiClient::instance().listCaptureDevicesAsync());
310+
devices = FfiClient::instance().listCaptureDevicesAsync();
312311
} catch (const std::exception& e) {
313312
return readyCaptureError<std::vector<CaptureDeviceInfo>>(e);
314313
}
315314

316315
// Map the FFI payload onto the public type once the callback resolves. A
317316
// helper thread keeps the returned future's wait semantics standard.
318-
return std::async(std::launch::async, [devices = std::move(*devices)]() mutable {
317+
return std::async(std::launch::async, [devices = std::move(devices)]() mutable {
319318
try {
320319
const proto::CaptureDeviceList list = devices.get();
321320
std::vector<CaptureDeviceInfo> out;
@@ -335,16 +334,16 @@ std::future<std::vector<CaptureDeviceInfo>> CaptureSource::listDevices() {
335334
std::future<std::shared_ptr<CaptureSource>> CaptureSource::createFromRequest(proto::NewCaptureSourceRequest request) {
336335
// See listDevices(): a synchronous send failure is delivered through the
337336
// future rather than thrown from the factory.
338-
std::optional<std::future<proto::OwnedCaptureSource>> owned;
337+
std::future<proto::OwnedCaptureSource> owned;
339338
try {
340-
owned.emplace(FfiClient::instance().newCaptureSourceAsync(std::move(request)));
339+
owned = FfiClient::instance().newCaptureSourceAsync(std::move(request));
341340
} catch (const std::exception& e) {
342341
return readyCaptureError<std::shared_ptr<CaptureSource>>(e);
343342
}
344343

345344
// Map the FFI payload onto a wrapper once the callback resolves. A helper
346345
// thread keeps the returned future's wait semantics standard.
347-
return std::async(std::launch::async, [owned = std::move(*owned)]() mutable {
346+
return std::async(std::launch::async, [owned = std::move(owned)]() mutable {
348347
try {
349348
return fromOwned(owned.get());
350349
} catch (const CaptureSourceError&) {

0 commit comments

Comments
 (0)