Browse Source

Serialize primaryModule in Engine instead of relying on modules to do it themselves.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
6e8cb42e7b
2 changed files with 12 additions and 8 deletions
  1. +0
    -8
      src/core/AudioInterface.cpp
  2. +12
    -0
      src/engine/Engine.cpp

+ 0
- 8
src/core/AudioInterface.cpp View File

@@ -371,9 +371,6 @@ struct AudioInterface : Module {
json_t* rootJ = json_object();
json_object_set_new(rootJ, "audio", port.toJson());

if (isPrimary())
json_object_set_new(rootJ, "primary", json_boolean(true));

json_object_set_new(rootJ, "dcFilter", json_boolean(dcFilterEnabled));

return rootJ;
@@ -384,11 +381,6 @@ struct AudioInterface : Module {
if (audioJ)
port.fromJson(audioJ);

// For not, don't deserialize primary module state.
// json_t* primaryJ = json_object_get(rootJ, "primary");
// if (primaryJ)
// setPrimary();

json_t* dcFilterJ = json_object_get(rootJ, "dcFilter");
if (dcFilterJ)
dcFilterEnabled = json_boolean_value(dcFilterJ);


+ 12
- 0
src/engine/Engine.cpp View File

@@ -1137,6 +1137,11 @@ json_t* Engine::toJson() {
}
json_object_set_new(rootJ, "cables", cablesJ);

// primaryModule
if (internal->primaryModule) {
json_object_set_new(rootJ, "primaryModuleId", json_integer(internal->primaryModule->id));
}

return rootJ;
}

@@ -1219,6 +1224,13 @@ void Engine::fromJson(json_t* rootJ) {
continue;
}
}

// primaryModule
json_t* primaryModuleIdJ = json_object_get(rootJ, "primaryModuleId");
if (primaryModuleIdJ) {
Module* primaryModule = getModule(json_integer_value(primaryModuleIdJ));
setPrimaryModule(primaryModule);
}
}




Loading…
Cancel
Save