Browse Source

avoid going over same nodes unnecessarily to set playback latency

This needs more testing but fixes lags.

Fixes https://todo.sr.ht/~alextee/zrythm-bug/928 and
https://todo.sr.ht/~alextee/zrythm-bug/921.
libpanel_detach
Alexandros Theodotou 2 months ago
parent
commit
43e1fa769a
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 34
      inc/audio/graph_node.h
  2. 52
      inc/schemas/audio/port_connection.h
  3. 9
      inc/schemas/audio/port_connections_manager.h
  4. 3
      inc/schemas/gui/backend/timeline.h
  5. 5
      src/audio/graph.c
  6. 17
      src/audio/graph_node.c
  7. 2
      src/plugins/carla_native_plugin.c
  8. 20
      tests/integration/run_graph_with_latencies.c
  9. 20
      tests/plugins/carla_native_plugin.c

34
inc/audio/graph_node.h

@ -1,24 +1,11 @@ @@ -1,24 +1,11 @@
// SPDX-FileCopyrightText: © 2019-2021 Alexandros Theodotou <alex@zrythm.org>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
/*
* Copyright (C) 2019-2021 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
* Zrythm is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zrythm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* ---
*
* Copyright (C) 2017, 2019 Robin Gareus <robin@gareus.org>
*
* This program is free software: you can redistribute it and/or modify
@ -33,6 +20,10 @@ @@ -33,6 +20,10 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* ---
*/
/**
@ -202,13 +193,12 @@ graph_node_process ( @@ -202,13 +193,12 @@ graph_node_process (
EngineProcessTimeInfo time_nfo);
/**
* Returns the latency of only the given port,
* without adding the previous/next latencies.
* Returns the latency of only the given port, without adding
* the previous/next latencies.
*
* It returns the plugin's latency if plugin,
* otherwise 0.
* It returns the plugin's latency if plugin, otherwise 0.
*/
nframes_t
HOT nframes_t
graph_node_get_single_playback_latency (GraphNode * node);
/**

52
inc/schemas/audio/port_connection.h

@ -4,40 +4,44 @@ @@ -4,40 +4,44 @@
#ifndef __SCHEMAS_AUDIO_PORT_CONNECTION_H__
#define __SCHEMAS_AUDIO_PORT_CONNECTION_H__
#include "schemas/audio/port_identifier.h"
#include "utils/yaml.h"
#include "schemas/audio/port_identifier.h"
typedef struct PortConnection_v1
{
int schema_version;
int schema_version;
PortIdentifier_v1 * src_id;
PortIdentifier_v1 * dest_id;
float multiplier;
bool locked;
bool enabled;
float base_value;
float multiplier;
bool locked;
bool enabled;
float base_value;
} PortConnection_v1;
static const cyaml_schema_field_t port_connection_fields_schema_v1[] = {
YAML_FIELD_INT (PortConnection_v1, schema_version),
YAML_FIELD_MAPPING_PTR (
PortConnection_v1,
src_id,
port_identifier_fields_schema_v1),
YAML_FIELD_MAPPING_PTR (
PortConnection_v1,
dest_id,
port_identifier_fields_schema_v1),
YAML_FIELD_FLOAT (PortConnection_v1, multiplier),
YAML_FIELD_INT (PortConnection_v1, locked),
YAML_FIELD_INT (PortConnection_v1, enabled),
YAML_FIELD_FLOAT (PortConnection_v1, base_value),
CYAML_FIELD_END
};
static const cyaml_schema_field_t
port_connection_fields_schema_v1[] = {
YAML_FIELD_INT (PortConnection_v1, schema_version),
YAML_FIELD_MAPPING_PTR (
PortConnection_v1,
src_id,
port_identifier_fields_schema_v1),
YAML_FIELD_MAPPING_PTR (
PortConnection_v1,
dest_id,
port_identifier_fields_schema_v1),
YAML_FIELD_FLOAT (PortConnection_v1, multiplier),
YAML_FIELD_INT (PortConnection_v1, locked),
YAML_FIELD_INT (PortConnection_v1, enabled),
YAML_FIELD_FLOAT (PortConnection_v1, base_value),
CYAML_FIELD_END
};
static const cyaml_schema_value_t port_connection_schema_v1 = {
YAML_VALUE_PTR (PortConnection_v1, port_connection_fields_schema_v1),
YAML_VALUE_PTR (
PortConnection_v1,
port_connection_fields_schema_v1),
};
#endif

9
inc/schemas/audio/port_connections_manager.h

@ -4,15 +4,16 @@ @@ -4,15 +4,16 @@
#ifndef __SCHEMAS_AUDIO_PORT_CONNECTIONS_MANAGER_H__
#define __SCHEMAS_AUDIO_PORT_CONNECTIONS_MANAGER_H__
#include "schemas/audio/port_connection.h"
#include "utils/yaml.h"
#include "schemas/audio/port_connection.h"
typedef struct PortConnectionsManager_v1
{
int schema_version;
int schema_version;
PortConnection_v1 ** connections;
int num_connections;
size_t connections_size;
int num_connections;
size_t connections_size;
} PortConnectionsManager_v1;
static const cyaml_schema_field_t

3
inc/schemas/gui/backend/timeline.h

@ -4,9 +4,10 @@ @@ -4,9 +4,10 @@
#ifndef __SCHEMAS_GUI_BACKEND_TIMELINE_H__
#define __SCHEMAS_GUI_BACKEND_TIMELINE_H__
#include "schemas/gui/backend/editor_settings.h"
#include "utils/yaml.h"
#include "schemas/gui/backend/editor_settings.h"
typedef struct Timeline_v1
{
int schema_version;

5
src/audio/graph.c

@ -535,6 +535,7 @@ graph_update_latencies (Graph * self, bool use_setup_nodes) @@ -535,6 +535,7 @@ graph_update_latencies (Graph * self, bool use_setup_nodes)
use_setup_nodes ? self->setup_graph_nodes : self->graph_nodes;
GHashTableIter iter;
gpointer key, value;
g_debug ("setting all latencies to 0");
g_hash_table_iter_init (&iter, ht);
while (g_hash_table_iter_next (&iter, &key, &value))
{
@ -542,7 +543,10 @@ graph_update_latencies (Graph * self, bool use_setup_nodes) @@ -542,7 +543,10 @@ graph_update_latencies (Graph * self, bool use_setup_nodes)
n->playback_latency = 0;
n->route_playback_latency = 0;
}
g_debug ("done setting all latencies to 0");
g_debug (
"iterating over %u nodes...", g_hash_table_size (ht));
g_hash_table_iter_init (&iter, ht);
while (g_hash_table_iter_next (&iter, &key, &value))
{
@ -555,6 +559,7 @@ graph_update_latencies (Graph * self, bool use_setup_nodes) @@ -555,6 +559,7 @@ graph_update_latencies (Graph * self, bool use_setup_nodes)
n, n->playback_latency);
}
}
g_debug ("iterating done...");
g_message (
"Total latencies:\n"

17
src/audio/graph_node.c

@ -464,11 +464,10 @@ add_depends (GraphNode * self, GraphNode * src) @@ -464,11 +464,10 @@ add_depends (GraphNode * self, GraphNode * src)
}
/**
* Returns the latency of only the given port,
* without adding the previous/next latencies.
* Returns the latency of only the given port, without adding
* the previous/next latencies.
*
* It returns the plugin's latency if plugin,
* otherwise 0.
* It returns the plugin's latency if plugin, otherwise 0.
*/
nframes_t
graph_node_get_single_playback_latency (GraphNode * node)
@ -508,11 +507,17 @@ graph_node_set_route_playback_latency ( @@ -508,11 +507,17 @@ graph_node_set_route_playback_latency (
{
node->route_playback_latency = dest_latency;
}
else
{
/* assumed that parent nodes already have the previous
* latency set */
/* TODO double-check if this is OK to do, needs testing */
return;
}
GraphNode * parent;
for (int i = 0; i < node->init_refcount; i++)
{
parent = node->parentnodes[i];
GraphNode * parent = node->parentnodes[i];
graph_node_set_route_playback_latency (
parent, node->route_playback_latency);
#if 0

2
src/plugins/carla_native_plugin.c

@ -2186,7 +2186,7 @@ carla_native_plugin_set_param_value ( @@ -2186,7 +2186,7 @@ carla_native_plugin_set_param_value (
float cur_val = carla_get_current_parameter_value (
self->host_handle, 0, id);
if (!math_floats_equal (cur_val, val))
if (DEBUGGING && !math_floats_equal (cur_val, val))
{
g_debug (
"setting param %d value to %f", id, (double) val);

20
tests/integration/run_graph_with_latencies.c

@ -1,21 +1,5 @@ @@ -1,21 +1,5 @@
/*
* Copyright (C) 2020-2021 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
* Zrythm is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zrythm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-FileCopyrightText: © 2020-2021 Alexandros Theodotou <alex@zrythm.org>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
/* This test was written because of an issue with not
* post-processing nodes properly when no roll was

20
tests/plugins/carla_native_plugin.c

@ -1,21 +1,5 @@ @@ -1,21 +1,5 @@
/*
* Copyright (C) 2021-2022 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
* Zrythm is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zrythm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-FileCopyrightText: © 2021-2022 Alexandros Theodotou <alex@zrythm.org>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
#include "zrythm-test-config.h"

Loading…
Cancel
Save