Implement close command
This commit is contained in:
@@ -90,6 +90,9 @@ libmegapixels_load_file(libmegapixels_devconfig **config, const char *file);
|
||||
EXPORT int
|
||||
libmegapixels_open(libmegapixels_camera *camera);
|
||||
|
||||
EXPORT void
|
||||
libmegapixels_close(libmegapixels_camera *camera);
|
||||
|
||||
EXPORT unsigned int
|
||||
libmegapixels_select_mode(libmegapixels_camera *camera, libmegapixels_mode *mode);
|
||||
|
||||
|
@@ -169,6 +169,30 @@ libmegapixels_open(libmegapixels_camera *camera)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
libmegapixels_close(libmegapixels_camera *camera)
|
||||
{
|
||||
if (camera->media_fd != 0) {
|
||||
close(camera->media_fd);
|
||||
camera->media_fd = 0;
|
||||
}
|
||||
if (camera->sensor_fd != 0) {
|
||||
close(camera->sensor_fd);
|
||||
camera->sensor_fd = 0;
|
||||
}
|
||||
if (camera->video_fd != 0) {
|
||||
close(camera->video_fd);
|
||||
camera->video_fd = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < camera->num_handles; i++) {
|
||||
if (camera->handles[i]->fd != 0) {
|
||||
close(camera->handles[i]->fd);
|
||||
camera->handles[i]->fd = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
libmegapixels_select_mode(libmegapixels_camera *camera, libmegapixels_mode *mode)
|
||||
{
|
||||
|
Reference in New Issue
Block a user