Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix restoration of the plugin state #119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/nrepellent-adaptive.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ typedef struct URIs {

static void map_uris(LV2_URID_Map *map, URIs *uris, const char *uri) {
uris->plugin =
strcmp(uri, NOISEREPELLENT_ADAPTIVE_URI)
strcmp(uri, NOISEREPELLENT_ADAPTIVE_URI) == 0
? map->map(map->handle, NOISEREPELLENT_ADAPTIVE_URI)
: map->map(map->handle, NOISEREPELLENT_ADAPTIVE_STEREO_URI);
}
Expand Down
18 changes: 10 additions & 8 deletions plugins/nrepellent.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef struct State {
} State;

static void map_uris(LV2_URID_Map *map, URIs *uris, const char *uri) {
uris->plugin = strcmp(uri, NOISEREPELLENT_URI)
uris->plugin = strcmp(uri, NOISEREPELLENT_URI) == 0
? map->map(map->handle, NOISEREPELLENT_URI)
: map->map(map->handle, NOISEREPELLENT_STEREO_URI);
uris->atom_Int = map->map(map->handle, LV2_ATOM__Int);
Expand All @@ -61,7 +61,7 @@ static void map_uris(LV2_URID_Map *map, URIs *uris, const char *uri) {
}

static void map_state(LV2_URID_Map *map, State *state, const char *uri) {
if (!strcmp(uri, NOISEREPELLENT_URI)) {
if (strcmp(uri, NOISEREPELLENT_STEREO_URI) == 0) {
state->property_noise_profile_1 =
map->map(map->handle, NOISEREPELLENT_STEREO_URI "#noiseprofile");
state->property_noise_profile_2 =
Expand Down Expand Up @@ -409,17 +409,19 @@ static LV2_State_Status restore(LV2_Handle instance,
uint32_t type = 0U;
uint32_t valflags = 0U;

const uint32_t *fftsize = (const uint32_t *)retrieve(
const uint32_t *saved_fftsize = (const uint32_t *)retrieve(
handle, self->state.property_noise_profile_size, &size, &type, &valflags);
if (fftsize == NULL || type != self->uris.atom_Int) {
if (saved_fftsize == NULL || type != self->uris.atom_Int) {
return LV2_STATE_ERR_NO_PROPERTY;
}
const uint32_t fftsize = *saved_fftsize;

const uint32_t *averagedblocks = (const uint32_t *)retrieve(
const uint32_t *saved_averagedblocks = (const uint32_t *)retrieve(
handle, self->state.property_averaged_blocks, &size, &type, &valflags);
if (averagedblocks == NULL || type != self->uris.atom_Int) {
if (saved_averagedblocks == NULL || type != self->uris.atom_Int) {
return LV2_STATE_ERR_NO_PROPERTY;
}
const uint32_t averagedblocks = *saved_averagedblocks;

const void *saved_noise_profile_1 = retrieve(
handle, self->state.property_noise_profile_1, &size, &type, &valflags);
Expand All @@ -432,7 +434,7 @@ static LV2_State_Status restore(LV2_Handle instance,
sizeof(float) * self->profile_size);

specbleach_load_noise_profile(self->lib_instance_1, self->noise_profile_1,
*fftsize, *averagedblocks);
fftsize, averagedblocks);

if (strstr(self->plugin_uri, NOISEREPELLENT_STEREO_URI)) {
const void *saved_noise_profile_2 = retrieve(
Expand All @@ -446,7 +448,7 @@ static LV2_State_Status restore(LV2_Handle instance,
sizeof(float) * self->profile_size);

specbleach_load_noise_profile(self->lib_instance_2, self->noise_profile_2,
*fftsize, *averagedblocks);
fftsize, averagedblocks);
}

return LV2_STATE_SUCCESS;
Expand Down