Rename CaptureThread message, callback method, handle success.

This commit is contained in:
Jared Boone 2016-06-21 12:05:55 -07:00
parent 81d4e59aeb
commit 264c19b312
3 changed files with 17 additions and 10 deletions

View File

@ -286,11 +286,11 @@ void RecordView::start() {
std::move(writer),
write_size, buffer_count,
[]() {
CaptureThreadErrorMessage message { };
CaptureThreadDoneMessage message { };
EventDispatcher::send_message(message);
},
[](File::Error error) {
CaptureThreadErrorMessage message { error.code() };
CaptureThreadDoneMessage message { error.code() };
EventDispatcher::send_message(message);
}
);
@ -353,8 +353,14 @@ void RecordView::update_status_display() {
}
}
void RecordView::handle_error(const File::Error error) {
void RecordView::handle_capture_thread_done(const File::Error error) {
stop();
if( error.code() ) {
handle_error(error);
}
}
void RecordView::handle_error(const File::Error error) {
if( on_error ) {
on_error(error.what());
}

View File

@ -69,6 +69,7 @@ private:
void on_tick_second();
void update_status_display();
void handle_capture_thread_done(const File::Error error);
void handle_error(const File::Error error);
const std::string filename_stem_pattern;
@ -107,10 +108,10 @@ private:
std::unique_ptr<CaptureThread> capture_thread;
MessageHandlerRegistration message_handler_capture_thread_error {
Message::ID::CaptureThreadError,
Message::ID::CaptureThreadDone,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const CaptureThreadErrorMessage*>(p);
this->handle_error(message.error);
const auto message = *reinterpret_cast<const CaptureThreadDoneMessage*>(p);
this->handle_capture_thread_done(message.error);
}
};
};

View File

@ -64,7 +64,7 @@ public:
SpectrumStreamingConfig = 15,
DisplaySleep = 16,
CaptureConfig = 17,
CaptureThreadError = 18,
CaptureThreadDone = 18,
MAX
};
@ -495,11 +495,11 @@ public:
CaptureConfig* const config;
};
class CaptureThreadErrorMessage : public Message {
class CaptureThreadDoneMessage : public Message {
public:
constexpr CaptureThreadErrorMessage(
constexpr CaptureThreadDoneMessage(
uint32_t error = 0
) : Message { ID::CaptureThreadError },
) : Message { ID::CaptureThreadDone },
error { error }
{
}