WTF - Asserting the return value of a function causes it to not run?!
Some checks failed
Build / build-gentoo (push) Failing after 22s
Build / download-system-deps (push) Successful in 3m16s
Build / get-source-code (push) Successful in 12m8s
Build / build-appimage (push) Successful in 3m58s
Build / build-android (push) Failing after 2m59s
Build / build-windows (push) Failing after 7m22s

This commit is contained in:
Zachary Hall 2024-12-08 09:55:27 -08:00
parent 347c968b81
commit 27113f6443
18 changed files with 93 additions and 40 deletions

BIN
.genio Normal file

Binary file not shown.

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2024-11-10T21:49:56. --> <!-- Written by QtCreator 14.0.1, 2024-11-22T13:11:13. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
@ -86,7 +86,7 @@
<value type="bool" key="ClangTools.UseGlobalSettings">true</value> <value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ClangdSettings"> <valuemap type="QVariantMap" key="ClangdSettings">
<value type="bool" key="blockIndexing">true</value> <value type="bool" key="blockIndexing">false</value>
<value type="bool" key="useGlobalSettings">true</value> <value type="bool" key="useGlobalSettings">true</value>
</valuemap> </valuemap>
</valuemap> </valuemap>
@ -109,19 +109,19 @@
<value type="QString">CMAKE_CXX_COMPILER_LAUNCHER=ccache</value> <value type="QString">CMAKE_CXX_COMPILER_LAUNCHER=ccache</value>
<value type="QString">CMAKE_C_COMPILER_LAUNCHER=ccache</value> <value type="QString">CMAKE_C_COMPILER_LAUNCHER=ccache</value>
</valuelist> </valuelist>
<value type="QString" key="CMake.Initial.Parameters">-DBUILD_SOUNDTOUCH:BOOL=ON <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_C_FLAGS:STRING=-O2 -march=native -g
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=ON
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_C_FLAGS:STRING=-O2 -march=native -g
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DDISABLE_GTK_UI:BOOL=ON
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_CXX_FLAGS:STRING=-O2 -march=native -g -DCMAKE_CXX_FLAGS:STRING=-O2 -march=native -g
-DCMAKE_POLICY_DEFAULT_CMP0069:STRING=NEW</value> -DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=ON
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_POLICY_DEFAULT_CMP0069:STRING=NEW
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DBUILD_SOUNDTOUCH:BOOL=ON
-DDISABLE_GTK_UI:BOOL=ON
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/boot/home/Desktop/looper/build/default</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/boot/home/Desktop/looper/build/default</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
@ -222,19 +222,19 @@
<value type="QString">CMAKE_CXX_COMPILER_LAUNCHER=ccache</value> <value type="QString">CMAKE_CXX_COMPILER_LAUNCHER=ccache</value>
<value type="QString">CMAKE_C_COMPILER_LAUNCHER=ccache</value> <value type="QString">CMAKE_C_COMPILER_LAUNCHER=ccache</value>
</valuelist> </valuelist>
<value type="QString" key="CMake.Initial.Parameters">-DBUILD_SOUNDTOUCH:BOOL=ON <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_C_FLAGS:STRING=-O2 -march=native -g
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_C_FLAGS:STRING=-O2 -march=native -g
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DDISABLE_GTK_UI:BOOL=ON
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_CXX_FLAGS:STRING=-O2 -march=native -g -DCMAKE_CXX_FLAGS:STRING=-O2 -march=native -g
-DCMAKE_POLICY_DEFAULT_CMP0069:STRING=NEW</value> -DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_POLICY_DEFAULT_CMP0069:STRING=NEW
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DBUILD_SOUNDTOUCH:BOOL=ON
-DDISABLE_GTK_UI:BOOL=ON
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/boot/home/Desktop/looper/build/Fast_building_config_CMake_preset-RelWithDebInfo</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/boot/home/Desktop/looper/build/Fast_building_config_CMake_preset-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">

View file

@ -140,7 +140,7 @@ void ZsmBackend::load(const char *filename) {
loop_end = length; loop_end = length;
loop_start = this->loop_pos; loop_start = this->loop_pos;
fm_stream = SDL_NewAudioStream(AUDIO_S16SYS, 2, YM_FREQ, AUDIO_S16SYS, 2, PSG_FREQ); fm_stream = SDL_NewAudioStream(AUDIO_S16SYS, 2, YM_FREQ, AUDIO_S16SYS, 2, PSG_FREQ);
DEBUG.writefln("fm_stream: %ld -> %ld", YM_FREQ, PSG_FREQ); DEBUG.writefln("fm_stream: %ld -> %ld (Is null: %s)", YM_FREQ, PSG_FREQ, fm_stream == NULL ? "true" : "false");
#define _PROPERTY(name, type, default_value) \ #define _PROPERTY(name, type, default_value) \
{ \ { \
std::string type_str = #type; \ std::string type_str = #type; \
@ -456,10 +456,10 @@ void ZsmBackend::audio_step(size_t samples) {
size_t needed_samples = ((size_t)std::floor(samples * ratio)) / 2; size_t needed_samples = ((size_t)std::floor(samples * ratio)) / 2;
int16_t *ym_ptr = ym_buf.get_item_sized<int16_t>(needed_samples * 2); int16_t *ym_ptr = ym_buf.get_item_sized<int16_t>(needed_samples * 2);
YM_stream_update(ym_ptr, needed_samples); YM_stream_update(ym_ptr, needed_samples);
assert(SDL_AudioStreamPut(fm_stream, ym_ptr, needed_samples * 2 * sizeof(int16_t)) == 0); SDL_AudioStreamPut(fm_stream, ym_ptr, needed_samples * 2 * sizeof(int16_t));
while (SDL_AudioStreamAvailable(fm_stream) < ((samples + 2) * sizeof(int16_t))) { while (SDL_AudioStreamAvailable(fm_stream) < (samples * sizeof(int16_t))) {
YM_stream_update(ym_ptr, 1); YM_stream_update(ym_ptr, 8);
assert(SDL_AudioStreamPut(fm_stream, ym_ptr, 2 * sizeof(int16_t)) == 0); SDL_AudioStreamPut(fm_stream, ym_ptr, 8 * 2 * sizeof(int16_t));
} }
int16_t *ym_resample_ptr = ym_resample_buf.get_item_sized<int16_t>(samples); int16_t *ym_resample_ptr = ym_resample_buf.get_item_sized<int16_t>(samples);
ssize_t ym_resample_len = SDL_AudioStreamGet(fm_stream, ym_resample_ptr, (samples + 2) * sizeof(int16_t)); ssize_t ym_resample_len = SDL_AudioStreamGet(fm_stream, ym_resample_ptr, (samples + 2) * sizeof(int16_t));

View file

@ -94,6 +94,7 @@ HaikuLooperWindow::HaikuLooperWindow(Playback *playback) : BWindow(BRect(100, 10
menu_bar->AddItem(help_menu); menu_bar->AddItem(help_menu);
layout->AddView(menu_bar); layout->AddView(menu_bar);
BView *spacer = new BView("spacer", B_SUPPORTS_LAYOUT|B_FRAME_EVENTS); BView *spacer = new BView("spacer", B_SUPPORTS_LAYOUT|B_FRAME_EVENTS);
spacer->SetExplicitPreferredSize(BSize(0, 0));
spacer->SetExplicitMinSize(BSize(0, 0)); spacer->SetExplicitMinSize(BSize(0, 0));
layout->AddView(spacer); layout->AddView(spacer);
BGroupView *top_row = new BGroupView(B_HORIZONTAL); BGroupView *top_row = new BGroupView(B_HORIZONTAL);
@ -315,6 +316,12 @@ void HaikuLooperWindow::Pulse() {
if (!tempo_clicked) tempo_slider->SetValueDouble(tempo); if (!tempo_clicked) tempo_slider->SetValueDouble(tempo);
tempo_slider->SetLabel(fmt::format("Tempo: {:.02f}x", tempo).c_str()); tempo_slider->SetLabel(fmt::format("Tempo: {:.02f}x", tempo).c_str());
UpdateIfNeeded(); UpdateIfNeeded();
auto title = playback->get_current_title();
if (title.has_value()) {
SetTitle(fmt::format("{} - Looper", title.value()).c_str());
} else {
SetTitle("Looper");
}
} }
void HaikuLooperWindow::FrameResized(float newWidth, float newHeight) { void HaikuLooperWindow::FrameResized(float newWidth, float newHeight) {
InvalidateLayout(true); InvalidateLayout(true);

View file

@ -63,4 +63,5 @@ AboutWindow::AboutWindow() {
mainLayout->addWidget(splitter); mainLayout->addWidget(splitter);
setLayout(mainLayout); setLayout(mainLayout);
license_list->clicked(license_list->model()->index(0, 0)); license_list->clicked(license_list->model()->index(0, 0));
setWindowTitle("About Looper");
} }

View file

@ -32,10 +32,18 @@ void LooperWindow::Pulse() {
pitch_slider->SetLabel(fmt::format("Pitch {:.02f}x", pitch).c_str()); pitch_slider->SetLabel(fmt::format("Pitch {:.02f}x", pitch).c_str());
speed_slider->SetLabel(fmt::format("Speed: {:.02f}x", speed).c_str()); speed_slider->SetLabel(fmt::format("Speed: {:.02f}x", speed).c_str());
tempo_slider->SetLabel(fmt::format("Tempo: {:.02f}x", tempo).c_str()); tempo_slider->SetLabel(fmt::format("Tempo: {:.02f}x", tempo).c_str());
if (playback->handle_signals(PlaybackSignalFileChanged|PlaybackSignalStarted|PlaybackSignalStopped)) {
if (playback->IsStopped()) {
setWindowTitle("Looper");
} else {
setWindowTitle(fmt::format("{} - Looper", playback->get_current_title().value_or(fs::path(playback->get_current_file().value_or("")).stem().string())).c_str());
}
}
} }
LooperWindow::LooperWindow(Playback *playback) : QMainWindow() { LooperWindow::LooperWindow(Playback *playback) : QMainWindow() {
labels_visible = false; labels_visible = false;
icons_visible = true; icons_visible = true;
this->layout()->setContentsMargins(QMargins(0, 0, 0, 0));
this->playback = playback; this->playback = playback;
this->root_layout = new QBoxLayout(QBoxLayout::TopToBottom); this->root_layout = new QBoxLayout(QBoxLayout::TopToBottom);
QWidget *central_widget = new QWidget(); QWidget *central_widget = new QWidget();

View file

@ -60,6 +60,7 @@ PrefsWindow::PrefsWindow() {
btn_box->addWidget(apply_btn); btn_box->addWidget(apply_btn);
root_layout->addWidget(btn_view); root_layout->addWidget(btn_view);
revert(); revert();
setWindowTitle("Looper Preferences");
} }
void PrefsWindow::set_options_changed(bool changed) { void PrefsWindow::set_options_changed(bool changed) {
this->revert_btn->setEnabled(changed); this->revert_btn->setEnabled(changed);

View file

@ -1,5 +1,5 @@
resource app_signature "application/x-vnd.com.complecwaft.Looper"; resource app_signature "application/x-vnd.com.complecwaft.Looper";
resource app_flags B_EXCLUSIVE_LAUNCH; resource app_flags B_MULTIPLE_LAUNCH;
resource file_types message resource file_types message
{ {
"types" = "audio", "types" = "audio",

View file

@ -14,6 +14,7 @@ enum PropertyId {
BackendName = 9; BackendName = 9;
PlaybackRate = 10; PlaybackRate = 10;
LengthProperty = 11; LengthProperty = 11;
PriorityProperty = 12;
}; };
message StringProperty { message StringProperty {
string value = 506; string value = 506;

View file

@ -13,6 +13,12 @@ message RenderResponse {
uint64 len = 302; uint64 len = 302;
bytes data = 303; bytes data = 303;
}; };
message Ping {
bytes data = 1;
};
message Pong {
bytes data = 1;
};
message LogMessage { message LogMessage {
uint64 timespec = 6000; uint64 timespec = 6000;
uint32 level = 6001; uint32 level = 6001;
@ -45,6 +51,8 @@ message RPCCall {
QuitCmd quit = 6; QuitCmd quit = 6;
InitCommand init = 7; InitCommand init = 7;
GetPropertyListCommand get_property_list = 8; GetPropertyListCommand get_property_list = 8;
Ping = 9;
Pong = 10;
}; };
}; };
message PropertyList { message PropertyList {
@ -59,5 +67,7 @@ message RPCResponse {
ResetResponse reset = 5; ResetResponse reset = 5;
ErrorResponse err = 6; ErrorResponse err = 6;
PropertyList property_list = 7; PropertyList property_list = 7;
Ping = 8;
Pong = 9;
}; };
}; };

View file

@ -218,6 +218,7 @@ namespace Looper::Log {
std::recursive_mutex log_stream_mutex; std::recursive_mutex log_stream_mutex;
void init_logging_custom(log_stream_creation_function_t fn) { void init_logging_custom(log_stream_creation_function_t fn) {
std::lock_guard<std::recursive_mutex> guard(log_stream_mutex); std::lock_guard<std::recursive_mutex> guard(log_stream_mutex);
make_log_stream(-2, fn);
make_log_stream(-1, fn); make_log_stream(-1, fn);
make_log_stream(0, fn); make_log_stream(0, fn);
make_log_stream(1, fn); make_log_stream(1, fn);
@ -228,6 +229,7 @@ namespace Looper::Log {
} }
void pop_log_streams() { void pop_log_streams() {
std::lock_guard<std::recursive_mutex> guard(log_stream_mutex); std::lock_guard<std::recursive_mutex> guard(log_stream_mutex);
pop_log_stream(-2);
pop_log_stream(-1); pop_log_stream(-1);
pop_log_stream(0); pop_log_stream(0);
pop_log_stream(1); pop_log_stream(1);

View file

@ -6,12 +6,14 @@
#include "thirdparty/CLI11.hpp" #include "thirdparty/CLI11.hpp"
#include "data.h" #include "data.h"
#include "license.hpp" #include "license.hpp"
#include <SDL.h>
#include "assets/assets.h" #include "assets/assets.h"
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
#include <emscripten.h> #include <emscripten.h>
#endif #endif
#ifdef __HAIKU__ #ifdef __HAIKU__
#include <os/AppKit.h> #include <os/AppKit.h>
#include <image.h>
#endif #endif
#include "web_functions.hpp" #include "web_functions.hpp"
using namespace Looper; using namespace Looper;
@ -243,7 +245,16 @@ int main(int argc, char **argv) {
size = GetModuleFileNameA(NULL, executable_path, size); size = GetModuleFileNameA(NULL, executable_path, size);
realloc(executable_path, size); realloc(executable_path, size);
#elif defined(__HAIKU__) #elif defined(__HAIKU__)
executable_path = strdup(fs::canonical(argv[0]).c_str()); {
int32 cookie = 0;
image_info info;
while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
if (info.type == B_APP_IMAGE) {
executable_path = strdup(info.name);
break;
}
}
}
#else #else
executable_path = strdup(fs::canonical("/proc/self/exe").c_str()); executable_path = strdup(fs::canonical("/proc/self/exe").c_str());
#endif #endif

View file

@ -387,6 +387,11 @@ void PlaybackInstance::LoopFunction() {
} }
} }
void PlaybackInstance::Render(std::string opath) {
output_file_mutex.lock();
output_file = opath;
output_file_mutex.unlock();
}
void PlaybackInstance::DeinitLoopFunction() { void PlaybackInstance::DeinitLoopFunction() {
playback_ready.store(false); playback_ready.store(false);
// ==== // ====

View file

@ -220,6 +220,8 @@ class Playback {
virtual std::vector<Property> get_property_list() { virtual std::vector<Property> get_property_list() {
return {}; return {};
} }
inline virtual void Render(std::string path) { }
static Playback *Create(bool *daemon_found, bool daemon = false); static Playback *Create(bool *daemon_found, bool daemon = false);
}; };
@ -294,6 +296,8 @@ private:
float prev_pitch, prev_speed, prev_tempo; float prev_pitch, prev_speed, prev_tempo;
FILE_TYPE *file; FILE_TYPE *file;
bool initial_render = false; bool initial_render = false;
std::mutex output_file_mutex;
std::optional<std::string> output_file;
inline void wait(std::function<bool()> fn) { inline void wait(std::function<bool()> fn) {
while (!fn()) { while (!fn()) {
#ifdef NO_THREADS #ifdef NO_THREADS
@ -338,6 +342,7 @@ public:
std::optional<google::protobuf::Any> get_property(std::string path) override; std::optional<google::protobuf::Any> get_property(std::string path) override;
std::optional<google::protobuf::Any> reset_property(std::string path) override; std::optional<google::protobuf::Any> reset_property(std::string path) override;
std::vector<Property> get_property_list() override; std::vector<Property> get_property_list() override;
void Render(std::string opath) override;
float volume; float volume;
float speed; float speed;
float tempo; float tempo;

View file

@ -396,6 +396,7 @@ PlaybackProcess::PlaybackProcess(PlaybackProcess *parent) {
DEBUG.writeln("Host process address: (in-process)"); DEBUG.writeln("Host process address: (in-process)");
} }
PlaybackProcess::PlaybackProcess(std::vector<std::string> args) { PlaybackProcess::PlaybackProcess(std::vector<std::string> args) {
SDL_InitSubSystem(SDL_INIT_AUDIO);
done = false; done = false;
is_playback_process = true; is_playback_process = true;
Looper::Log::init_logging(); Looper::Log::init_logging();
@ -528,6 +529,7 @@ void PlaybackProcess::run_playback_process() {
int looper_run_playback_process(std::vector<std::string> args) { int looper_run_playback_process(std::vector<std::string> args) {
auto proc = PlaybackProcess(args); auto proc = PlaybackProcess(args);
proc.run_playback_process(); proc.run_playback_process();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
return 0; return 0;
} }
PropertyData PlaybackProcess::get_property(PropertyId property, std::optional<uint64_t> idx) { PropertyData PlaybackProcess::get_property(PropertyId property, std::optional<uint64_t> idx) {

@ -1 +1 @@
Subproject commit 0379bf3a5d52d8542aec1874677c9df5ff9ba5f9 Subproject commit 720da57baba83b3b1829e20133575e57aa1a8a4f

@ -1 +1 @@
Subproject commit 6dae7eb4a5c3a169f3e298392bff4680224aa94a Subproject commit d144031940543e15423a25ae5a8a74141044862f