mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-25 07:19:28 -05:00
Check for filesystem errors in RecordView.
This commit is contained in:
parent
92d75fa46d
commit
9dc12fca3c
@ -235,6 +235,10 @@ void RecordView::start() {
|
||||
};
|
||||
|
||||
if( writer ) {
|
||||
const auto error = writer->error();
|
||||
if( error.is_valid() ) {
|
||||
report_error(error.value().what());
|
||||
} else {
|
||||
text_record_filename.set(filename_stem);
|
||||
button_record.set_bitmap(&bitmap_stop);
|
||||
capture_thread = std::make_unique<CaptureThread>(
|
||||
@ -242,6 +246,9 @@ void RecordView::start() {
|
||||
write_size, buffer_count
|
||||
);
|
||||
}
|
||||
} else {
|
||||
report_error("file type");
|
||||
}
|
||||
}
|
||||
|
||||
void RecordView::stop() {
|
||||
@ -259,6 +266,10 @@ void RecordView::write_metadata_file(const std::string& filename) {
|
||||
|
||||
void RecordView::on_tick_second() {
|
||||
if( is_active() ) {
|
||||
const auto error = capture_thread->error();
|
||||
if( error.is_valid() ) {
|
||||
report_error(error.value());
|
||||
}
|
||||
const auto dropped_percent = std::min(99U, capture_thread->state().dropped_percent());
|
||||
const auto s = to_string_dec_uint(dropped_percent, 2, ' ') + "\%";
|
||||
text_record_dropped.set(s);
|
||||
@ -280,4 +291,10 @@ void RecordView::on_tick_second() {
|
||||
}
|
||||
}
|
||||
|
||||
void RecordView::report_error(const std::string& message) {
|
||||
if( on_error ) {
|
||||
on_error(message);
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
@ -37,6 +37,8 @@ namespace ui {
|
||||
|
||||
class RecordView : public View {
|
||||
public:
|
||||
std::function<void(std::string)> on_error;
|
||||
|
||||
enum FileType {
|
||||
RawS16 = 2,
|
||||
WAV = 3,
|
||||
@ -71,6 +73,8 @@ private:
|
||||
|
||||
void on_tick_second();
|
||||
|
||||
void report_error(const std::string& message);
|
||||
|
||||
const std::string filename_stem_pattern;
|
||||
const FileType file_type;
|
||||
const size_t write_size;
|
||||
|
Loading…
Reference in New Issue
Block a user