mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-30 09:37:53 -04:00
Formatted code (#1007)
* Updated style * Updated files * fixed new line * Updated spacing * File fix WIP * Updated to clang 13 * updated comment style * Removed old comment code
This commit is contained in:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -25,66 +25,65 @@
|
|||
#include "buffer_exchange.hpp"
|
||||
|
||||
struct BasebandCapture {
|
||||
BasebandCapture(CaptureConfig* const config) {
|
||||
baseband::capture_start(config);
|
||||
}
|
||||
BasebandCapture(CaptureConfig* const config) {
|
||||
baseband::capture_start(config);
|
||||
}
|
||||
|
||||
~BasebandCapture() {
|
||||
baseband::capture_stop();
|
||||
}
|
||||
~BasebandCapture() {
|
||||
baseband::capture_stop();
|
||||
}
|
||||
};
|
||||
|
||||
// CaptureThread //////////////////////////////////////////////////////////
|
||||
|
||||
CaptureThread::CaptureThread(
|
||||
std::unique_ptr<stream::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
|
||||
thread = chThdCreateFromHeap(NULL, 1024, NORMALPRIO + 10, CaptureThread::static_fn, this);
|
||||
std::unique_ptr<stream::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
|
||||
thread = chThdCreateFromHeap(NULL, 1024, NORMALPRIO + 10, CaptureThread::static_fn, this);
|
||||
}
|
||||
|
||||
CaptureThread::~CaptureThread() {
|
||||
if( thread ) {
|
||||
chThdTerminate(thread);
|
||||
chThdWait(thread);
|
||||
thread = nullptr;
|
||||
}
|
||||
if (thread) {
|
||||
chThdTerminate(thread);
|
||||
chThdWait(thread);
|
||||
thread = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
msg_t CaptureThread::static_fn(void* arg) {
|
||||
auto obj = static_cast<CaptureThread*>(arg);
|
||||
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;
|
||||
auto obj = static_cast<CaptureThread*>(arg);
|
||||
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;
|
||||
}
|
||||
|
||||
Optional<File::Error> CaptureThread::run() {
|
||||
BasebandCapture capture { &config };
|
||||
BufferExchange buffers { &config };
|
||||
BasebandCapture capture{&config};
|
||||
BufferExchange buffers{&config};
|
||||
|
||||
while( !chThdShouldTerminate() ) {
|
||||
auto buffer = buffers.get();
|
||||
auto write_result = writer->write(buffer->data(), buffer->size());
|
||||
if( write_result.is_error() ) {
|
||||
return write_result.error();
|
||||
}
|
||||
buffer->empty();
|
||||
buffers.put(buffer);
|
||||
}
|
||||
while (!chThdShouldTerminate()) {
|
||||
auto buffer = buffers.get();
|
||||
auto write_result = writer->write(buffer->data(), buffer->size());
|
||||
if (write_result.is_error()) {
|
||||
return write_result.error();
|
||||
}
|
||||
buffer->empty();
|
||||
buffers.put(buffer);
|
||||
}
|
||||
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue