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"?>
<!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>
<data>
<variable>EnvironmentId</variable>
@ -86,7 +86,7 @@
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
<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>
</valuemap>
</valuemap>
@ -109,19 +109,19 @@
<value type="QString">CMAKE_CXX_COMPILER_LAUNCHER=ccache</value>
<value type="QString">CMAKE_C_COMPILER_LAUNCHER=ccache</value>
</valuelist>
<value type="QString" key="CMake.Initial.Parameters">-DBUILD_SOUNDTOUCH:BOOL=ON
-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}
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_C_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>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.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_C_COMPILER_LAUNCHER=ccache</value>
</valuelist>
<value type="QString" key="CMake.Initial.Parameters">-DBUILD_SOUNDTOUCH:BOOL=ON
-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}
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_C_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>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.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_start = this->loop_pos;
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) \
{ \
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;
int16_t *ym_ptr = ym_buf.get_item_sized<int16_t>(needed_samples * 2);
YM_stream_update(ym_ptr, needed_samples);
assert(SDL_AudioStreamPut(fm_stream, ym_ptr, needed_samples * 2 * sizeof(int16_t)) == 0);
while (SDL_AudioStreamAvailable(fm_stream) < ((samples + 2) * sizeof(int16_t))) {
YM_stream_update(ym_ptr, 1);
assert(SDL_AudioStreamPut(fm_stream, ym_ptr, 2 * sizeof(int16_t)) == 0);
SDL_AudioStreamPut(fm_stream, ym_ptr, needed_samples * 2 * sizeof(int16_t));
while (SDL_AudioStreamAvailable(fm_stream) < (samples * sizeof(int16_t))) {
YM_stream_update(ym_ptr, 8);
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);
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);
layout->AddView(menu_bar);
BView *spacer = new BView("spacer", B_SUPPORTS_LAYOUT|B_FRAME_EVENTS);
spacer->SetExplicitPreferredSize(BSize(0, 0));
spacer->SetExplicitMinSize(BSize(0, 0));
layout->AddView(spacer);
BGroupView *top_row = new BGroupView(B_HORIZONTAL);
@ -314,7 +315,13 @@ void HaikuLooperWindow::Pulse() {
speed_slider->SetLabel(fmt::format("Speed: {:.02f}x", speed).c_str());
if (!tempo_clicked) tempo_slider->SetValueDouble(tempo);
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) {
InvalidateLayout(true);

View file

@ -63,4 +63,5 @@ AboutWindow::AboutWindow() {
mainLayout->addWidget(splitter);
setLayout(mainLayout);
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());
speed_slider->SetLabel(fmt::format("Speed: {:.02f}x", speed).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() {
labels_visible = false;
icons_visible = true;
this->layout()->setContentsMargins(QMargins(0, 0, 0, 0));
this->playback = playback;
this->root_layout = new QBoxLayout(QBoxLayout::TopToBottom);
QWidget *central_widget = new QWidget();
@ -164,4 +172,4 @@ void LooperWindow::update_label_setting(bool labels_visible, bool icons_visible)
buttons[i]->setIcon(emptyIcon);
}
}
}
}

View file

@ -60,6 +60,7 @@ PrefsWindow::PrefsWindow() {
btn_box->addWidget(apply_btn);
root_layout->addWidget(btn_view);
revert();
setWindowTitle("Looper Preferences");
}
void PrefsWindow::set_options_changed(bool changed) {
this->revert_btn->setEnabled(changed);
@ -92,4 +93,4 @@ void PrefsWindow::apply() {
else restart_warning->hide();
frontend_btn->setText(new_frontend.c_str());
update_label_setting();
}
}

View file

@ -1,5 +1,5 @@
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
{
"types" = "audio",

View file

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

View file

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

View file

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

View file

@ -6,12 +6,14 @@
#include "thirdparty/CLI11.hpp"
#include "data.h"
#include "license.hpp"
#include <SDL.h>
#include "assets/assets.h"
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
#ifdef __HAIKU__
#include <os/AppKit.h>
#include <image.h>
#endif
#include "web_functions.hpp"
using namespace Looper;
@ -243,7 +245,16 @@ int main(int argc, char **argv) {
size = GetModuleFileNameA(NULL, executable_path, size);
realloc(executable_path, size);
#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
executable_path = strdup(fs::canonical("/proc/self/exe").c_str());
#endif

View file

@ -83,4 +83,4 @@ namespace Looper::Options {
output.close();
#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() {
playback_ready.store(false);
// ====

View file

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

View file

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