-
Notifications
You must be signed in to change notification settings - Fork 20
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
State store function allows null and duplicate keys #23
Comments
You are passing a zero (null) key for the object. This doesn't make sense, but I realize now that lilv does not check for that correctly. I will fix it to return an error in this case (no idea why you get this really odd result specifically, but that doesn't really matter). Also your "expected" output isn't syntactically valid. The blank node with the You don't need to (i.e. can't) construct an object atom for (almost) the whole state like this anyway. The way to store a bunch of properties for your state is to call the callback once for every property. Each call to the store callback corresponds to a property on your state object. This means you don't have to screw around with the forge as much. Drop the object construction and you should get sensible output. Building complex objects with a forge is only necessary when you have values for state properties that are complex objects. They should work fine, though, all POD atoms can round-trip to a serialization and back. |
The problem is that I can not save properties which will have generated URIs because there is no way to get the full list of URIs when deserializing the state. That's why I was forced to use objects and, surprise, found that they don't work, too. Then I rewrote the whole bunch of code to save keys as a long set of strings separated by the ':' character. |
You seem to be working with the misconception that the state API lets you save and load a single complete description (object) of the state. This is not how it works. You don't create one on save, and you don't get one on restore (one never even exists, actually, it's not implemented as an atom in lilv). The state extension lets you save properties explicitly, and load those properties explicitly. So do that. If you want to save and restore some complete object for whatever reason, then save and restore a property with that value. |
@drobilla , I understand how the LV2:State works. You don't understand what I want to finally get. |
Maybe I'm wrong in syntax but why I can not finally get the following TTL structure:
|
This code snippet:
Gives the following result:
Which actually is bad. |
This code snippet:
Yields to corrupted TTL file:
|
This snippet:
Also yields to corrupted TTL:
|
You pass the body of the atom, not the whole thing with a header (which is why you can pass a float directly, for example). Pass |
I've submitted the code snippet for the case you've described here: It's not working. |
Aaah, my failure. This snippet seems to be working:
Here's what I've expected:
|
That looks reasonable. Isn't lack of type safety fun?! Good C++ bindings would make this way less of a nightmare for C++ plugins, but unfortunately those aren't here yet... |
These C++ bindings are not necessary and, moreover, they will be inefficient. The lack of good examples is the main reason of failures. AFAIK nobody before me saved Atom objects into TTL files. |
This thread suggests otherwise.
Not necessarily, and in the case of state, a bit of wrapper overhead (if there was any) would be insignificant anyway.
Sure. I don't know about "the main reason", but an official example that does this would be good. |
When restoring the object's state from the LV2:State TTL file, the object becomes duplicated: Here's the part of the log (You can see duplications of 'plain/text' and 'Test text' in binary dump): The related code: |
Constructing URIs like this is pretty questionable, you'd probably be better off with a list if that's what your state is really like. Anyway, there is way too much going on here for me to tell, but I'd guess that your code is constructing it that way. You can use sratom to print atoms which might help clarify what is going on. |
Sadly, but I can not predict how many 3D objects there are in a 3D scene. And each object has it's own set of properties. And if some other plugin will use Key-Value Tree storage, then I actually have no information about what keys can be used. The only thing I can say that these keys will be compatible to OSC address.
In a binary dump which is taken by retrieve() is visible that Atom object is twice duplicated. The dump is logged directly after the buffer has been retrieved. |
I have no expirience with sratom, maybe you'll reproduce the case easier by trying to parse the original *.ttl file. |
This is very definitely not a problem with parsing the file. |
I think I can also ask @x42 because I'm trying all things in Ardour 5.12 and it is reproducible there. |
Loading that preset does not produce the "duplication" for me. |
Can not reproduce in jalv.gtk. In Ardour still reproducible. |
On 6/22/19 1:39 AM, Vladimir Sadovnikov wrote:
Can not reproduce in jalv.gtk. In Ardour still reproducible
That is strange, both jalv and Ardour just call
lilv_state_new_from_instance() and lilv_state_restore().
Can you check which version of liblilv you have on your system?
Ardour 5.12 binaries from ardour.org come with lilv 0.24.2, serd 0.28.0
and sord 0.16.0.
|
I am skeptical that Ardour is actually loading the same data. Are you positive? |
@x42 do I right understand that Ardour is using system lilv library if it is possible?
I can check the behaviour on another machine where I've found this. But it's not earlier than monday, so we need to wait a bit. |
Reproduced the problem. It's not a problem of Ardour or lilv. I forgot that for test purposes I've added unconditional save of a BLOB object to the code, so on each save I got additional one object in TTL file:
Sorry, my mistake |
The LV2_State_Store_Function does not analyze the type of the value.
Trying to submit an Atom:Object to it results into corrupted *.ttl file.
Code snippet:
The expected result:
The actual result:
According to specification:
Actually, we can not submit something more complicated than plain data types.
The text was updated successfully, but these errors were encountered: