refactor: simplify test_gui.c by removing direct JACK dependencies
Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
40
test_gui.c
40
test_gui.c
@@ -1,53 +1,21 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <jack/jack.h>
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
static jack_client_t *client = NULL;
|
|
||||||
static float *buffer = NULL;
|
|
||||||
static int buffer_size = 0;
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* create JACK client */
|
Engine engine;
|
||||||
const char *client_name = "jack_looper_gui_test";
|
const char *client_name = "jack_looper_gui_test";
|
||||||
jack_options_t options = JackNullOption;
|
|
||||||
jack_status_t status;
|
|
||||||
|
|
||||||
client = jack_client_open(client_name, options, &status);
|
if (engine_init(&engine, client_name) != 0) {
|
||||||
if (client == NULL) {
|
|
||||||
fprintf(stderr, "jack_client_open() failed, status = 0x%2.0x\n", status);
|
|
||||||
if (status & JackServerFailed) {
|
|
||||||
fprintf(stderr, "Unable to connect to JACK server\n");
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate audio buffer */
|
|
||||||
buffer_size = 4096;
|
|
||||||
buffer = calloc(buffer_size, sizeof(float));
|
|
||||||
if (!buffer) {
|
|
||||||
fprintf(stderr, "Failed to allocate audio buffer\n");
|
|
||||||
jack_client_close(client);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize engine */
|
|
||||||
if (engine_init(client, buffer, buffer_size) != 0) {
|
|
||||||
fprintf(stderr, "Failed to initialize engine\n");
|
fprintf(stderr, "Failed to initialize engine\n");
|
||||||
free(buffer);
|
|
||||||
jack_client_close(client);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* run GUI */
|
int ret = gui_main(&engine);
|
||||||
int ret = gui_main(client, buffer, buffer_size);
|
|
||||||
|
|
||||||
/* cleanup */
|
engine_cleanup(&engine);
|
||||||
engine_cleanup(g_engine);
|
|
||||||
free(buffer);
|
|
||||||
jack_client_close(client);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user