mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Add CaptureThread success_callback.
This commit is contained in:
parent
4ffb05212e
commit
81d4e59aeb
@ -78,9 +78,11 @@ CaptureThread::CaptureThread(
|
||||
std::unique_ptr<Writer> writer,
|
||||
size_t write_size,
|
||||
size_t buffer_count,
|
||||
std::function<void()> success_callback,
|
||||
std::function<void(File::Error)> error_callback
|
||||
) : config { write_size, buffer_count },
|
||||
writer { std::move(writer) },
|
||||
success_callback { std::move(success_callback) },
|
||||
error_callback { std::move(error_callback) }
|
||||
{
|
||||
// Need significant stack for FATFS
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
std::unique_ptr<Writer> writer,
|
||||
size_t write_size,
|
||||
size_t buffer_count,
|
||||
std::function<void()> success_callback,
|
||||
std::function<void(File::Error)> error_callback
|
||||
);
|
||||
~CaptureThread();
|
||||
@ -60,6 +61,7 @@ private:
|
||||
|
||||
CaptureConfig config;
|
||||
std::unique_ptr<Writer> writer;
|
||||
std::function<void()> success_callback;
|
||||
std::function<void(File::Error)> error_callback;
|
||||
static Thread* thread;
|
||||
|
||||
@ -68,6 +70,10 @@ private:
|
||||
const auto error = obj->run();
|
||||
if( error.is_valid() && obj->error_callback ) {
|
||||
obj->error_callback(error.value());
|
||||
} else {
|
||||
if( obj->success_callback ) {
|
||||
obj->success_callback();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -285,6 +285,10 @@ void RecordView::start() {
|
||||
capture_thread = std::make_unique<CaptureThread>(
|
||||
std::move(writer),
|
||||
write_size, buffer_count,
|
||||
[]() {
|
||||
CaptureThreadErrorMessage message { };
|
||||
EventDispatcher::send_message(message);
|
||||
},
|
||||
[](File::Error error) {
|
||||
CaptureThreadErrorMessage message { error.code() };
|
||||
EventDispatcher::send_message(message);
|
||||
|
@ -498,7 +498,7 @@ public:
|
||||
class CaptureThreadErrorMessage : public Message {
|
||||
public:
|
||||
constexpr CaptureThreadErrorMessage(
|
||||
uint32_t error
|
||||
uint32_t error = 0
|
||||
) : Message { ID::CaptureThreadError },
|
||||
error { error }
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user