From: Jonathan W. <jw...@ph...> - 2007-08-20 23:39:49
|
Hi Pieter > >> The idea was that loadFromCache takes the ConfigRom and checks if there > >> is a directory named after the GUID. I thought that should be enough but > >> as you say it is not safe to do so. > > > > If all it did is check the ConfigRom then it would be fine. However, the > > fact that I got the "send oops" message from libiec61883 showed that > > somewhere an AVC command is being attempted. It's the AVC command which > > trips up non-AVC things like the MOTU. > > I would propose a slightly different approach to this probing + cache > loading: > : > If we put this is IAvDevice: > > IAvDevice::loadFromCache() { > return false; > } > > and put the current loadFromCache in the BeBoB class, we avoid this > situation. Agreed. At the time I'll admit I was after a quick fix so I could continue on some other tests I wanted to do. > It would be good though if we could eliminate all explicit references to > device types from the code, and let it be handled by the OO mechanisms. > There are some places where we can't avoid it, but currently that's only > getDriverForDevice(), and it would be nice to keep it that way. Sure. > I think the root of the problem is that the AvDevice is casted to a > BeBoB::AvDevice no matter whether it is one or not. Yes - as I mentioned, whatever reinterpret_cast was thought to be doing is clearly not happening. > This is IMHO due to the reinterpret_cast, that should be a dynamic_cast: > > "reinterpret_cast converts any pointer type to any other pointer type, > even of unrelated classes. The operation result is a simple binary copy > of the value from one pointer to the other. All pointer conversions are > allowed: neither the content pointed nor the pointer type itself is > checked." > > "dynamic_cast can be used only with pointers and references to objects. > Its purpose is to ensure that the result of the type conversion is a > valid complete object of the requested class." > > dynamic_cast sets the pointer to NULL when it fails, which is the > behavior we want. I agree - dynamic_cast is the behaviour implied by the code. Regards jonathan |