How to define C++ mModule variable
Most people do not understand the knowledge points of this "C++ mModule variable definition" article, so the editor summarized the following contents, detailed contents, clear steps, and have a certain reference value. I hope you can get something after reading this article. Let's take a look at this "C++ mModule variable definition" article.
File CameraHardwareInterface.h
Status_t startPreview ()
{
ALOGV ("s (s)", _ _ FUNCTION__, mName.string ())
If (mDevice- > ops- > start_preview)
Return mDevice- > ops- > start_preview (mDevice)
Return INVALID_OPERATION
}
First
Private: camera_device_t * mDevice
Initialization assignment is performed in the method initialize
Status_t initialize (CameraModule * module) {
. . .
If (module- > getModuleApiVersion () > = CAMERA_MODULE_API_VERSION_2_3 & &
Info.device_version > CAMERA_DEVICE_API_VERSION_1_0) {
/ / Open higher version camera device as HAL1.0 device.
Rc = module- > openLegacy (mName.string ()
CAMERA_DEVICE_API_VERSION_1_0
(hw_device_t *) & mDevice)
} else {
Rc = module- > oCameraHardwareInterface.hpen (mName.string (), (hw_device_t * *) & mDevice)
/ / notice that the secondary pointer here, mDevice, should finally be intended to point to a structure.
}
. . .
}
Then come to the CameraModule.cpp file.
Int CameraModule::open (const char* id, struct hw_device_t** device) {
Int res
ATRACE_BEGIN ("camera_module- > open")
Res = filterOpenErrorCode (mModule- > common.methods- > open (& mModule- > common, id, device))
ATRACE_END ()
Return res
}
Here the mModule variable definition
Camera_module_t * mModule
As for the following common, it is actually an attribute of the camera_module_t structure
Typedef struct camera_module {
. . .
Hw_module_t common; / / here is not a pointer
. . .
}
Continue typedef struct hw_module_t {
. . .
Struct hw_module_methods_t* methods
. . .
}
Typedef struct hw_module_methods_t {
/ * * Open a specific device * /
Int (* open) (const struct hw_module_t* module, const char* id)
Struct hw_device_t** device)
} hw_module_methods_t
I can understand now.
MModule- > common.methods- > open (& mModule- > common, id, device)
Continue to device, which is the hw_device_t object instance
Typedef struct camera_device {
Hw_device_t common
Camera_device_ops_t * ops
Void * priv
} camera_device_t
Open is a pointer function that points to the camera_device_open method of QCamera2Factory
The above is about the content of this article on "how to define C++ mModule variables". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please follow the industry information channel.