ossia / libossia

A modern C++, cross-environment distributed object model for creative coding and interaction scoring
https://ossia.io
GNU Lesser General Public License v3.0
204 stars 33 forks source link

[osc] crashfix when receiving an OSC message during the generic_device creation #836

Closed monsieurgustav closed 6 months ago

monsieurgustav commented 6 months ago

This code crashes if an OSC message is received between the osc_protocol creation and the generic_device creation. oscDevice = std::make_unique<ossia::net::generic_device>( std::make_unique<ossia::net::osc_protocol>("127.0.0.1", 9996, 9997, std::string("mydevice")), "P");

Another fix would be to call osc_protocol::update_receiver() only when the device is set, but I think it is less readable.

jcelerier commented 6 months ago

hey, sorry I completely forgot to check this.

jcelerier commented 6 months ago

btw I'd recommend to move towards the newer OSC protocol implementation : src/ossia/protocols/osc/osc_factory.hpp (check the examples a lot have been made with this) as it supports much more ways to do OSC I/O over a varied range of transports (websockets, serial port, etc). It's also more flexible (you can choose which OSC version you want to talk to / support) and allocates less (for "basic" OSC nodes with e.g. int, float, etc... types it will be much much much more optimized than was in the previous osc_protocol implementation)

jcelerier commented 6 months ago

and looking at the code, it already handled this case too :) I think I'll mark osc_protocol as deprecated

monsieurgustav commented 6 months ago

Thanks for the hint, I'll look into it! libossia works well but I feel sometimes lost in the code base... The entry point is not always obvious for all features. Here, the OSC setup is also quite different from the oscquery setup.

jcelerier commented 6 months ago

my goal is to migrate everything to the same kind of factory pattern to hide the build-time-consuming implementation details but it's taking a lot of time I hardly have sadly

monsieurgustav commented 6 months ago

Sure! :) If I knew the lib well, my first move would be to fill the doc, because it should be fast. Especially this page which is incredibly well made but half empty: https://ossia.io/ossia-docs/?cpp--14#remote-midi-device