[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: [PATCH] Kamera is too slow!
From: Szombathelyi "György" <gyurco () freemail ! hu>
Date: 2005-09-10 18:44:06
Message-ID: 200509102044.06594.gyurco () freemail ! hu
[Download RAW message or body]
Hi!
Sometimes I download images from my friend's Canon Powershot S1 digital camera
(PTP) with the kamera:/ kioslave. The problem is that the downloading of many
images is dead slow. I investigated why kamera is so slow, when gphoto can
read the images very fast. The conclusion:
- The gp_camera init is called twice for each image (one for stat() and one
for get()). This is the cause of the main part of the slowness.
- The gp_camera_folder_list_folders is called once for each image (in the
stat() function).
I attached a patch which solves these problems:
- The camera is not closed with every stat() and get() (This should be safe, I
didn't removed more closeCamera(), since it can cause locking problems).
- Modified the stat() function for probing an url for is it a file, not is it
dir first.
The patch is against the 3.5 branch.
May I commit?
____________________________________________________________________
Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu
["kamera.diff" (text/x-diff)]
Index: kamera/kioslave/kamera.cpp
===================================================================
--- kamera/kioslave/kamera.cpp (revision 458287)
+++ kamera/kioslave/kamera.cpp (working copy)
@@ -85,6 +85,7 @@
// attempt to initialize libgphoto2 and chosen camera (requires locking)
// (will init m_camera, since the m_camera's configuration is empty)
m_camera = 0;
+ m_init = false;
m_file = NULL;
m_config = new KSimpleConfig(KProtocolInfo::config("camera"));
m_context = gp_context_new();
@@ -102,10 +103,12 @@
// initializes the camera for usage - should be done before operations over the wire
bool KameraProtocol::openCamera(void) {
+ kdDebug(7123) << "openCamera: " << m_camera << endl;
if (!m_camera) {
reparseConfiguration();
- } else {
+ } else if (!m_init) {
int ret, tries = 15;
+ kdDebug(7123) << "gp_camera_init" << endl;
while (tries--) {
ret = gp_camera_init(m_camera, m_context);
@@ -118,6 +121,7 @@
return false;
}
}
+ m_init = true;
return true;
}
@@ -126,6 +130,7 @@
{
int gpr;
+ m_init = false;
if (!m_camera)
return;
@@ -288,7 +293,7 @@
finished();
gp_file_free(m_file);
m_file = NULL;
- closeCamera();
+// closeCamera();
}
// The KIO slave "stat" function.
@@ -349,6 +354,24 @@
// fprintf(stderr,"statRegular(%s)\n",url.path().latin1());
+ // Is "url" a file?
+ CameraFileInfo info;
+ gpr = gp_camera_file_get_info(m_camera, \
tocstr(fix_foldername(url.directory(false))), tocstr(url.fileName()), &info, \
m_context); + if ( gpr != GP_ERROR_FILE_NOT_FOUND ) { //maybe a directory
+ if (gpr != GP_OK) {
+ if (gpr == GP_ERROR_DIRECTORY_NOT_FOUND)
+ error(KIO::ERR_DOES_NOT_EXIST, url.path());
+ else
+ error(KIO::ERR_UNKNOWN, gp_result_as_string(gpr));
+ closeCamera();
+ return;
+ }
+ translateFileToUDS(entry, info, url.fileName());
+ statEntry(entry);
+ finished();
+ return;
+ }
+
// Is "url" a directory?
CameraList *dirList;
gp_list_new(&dirList);
@@ -361,6 +384,7 @@
else
error(KIO::ERR_UNKNOWN, gp_result_as_string(gpr));
gp_list_free(dirList);
+ kdDebug(7123) << "gp_camera_folder_list_folders error: " << \
gp_result_as_string(gpr) << endl; closeCamera();
return;
}
@@ -399,20 +423,6 @@
}
gp_list_free(dirList);
- // Is "url" a file?
- CameraFileInfo info;
- gpr = gp_camera_file_get_info(m_camera, \
tocstr(fix_foldername(url.directory(false))), tocstr(url.fileName()), &info, \
m_context);
- if (gpr != GP_OK) {
- if ((gpr == GP_ERROR_FILE_NOT_FOUND) || (gpr == GP_ERROR_DIRECTORY_NOT_FOUND))
- error(KIO::ERR_DOES_NOT_EXIST, url.path());
- else
- error(KIO::ERR_UNKNOWN, gp_result_as_string(gpr));
- closeCamera();
- return;
- }
- translateFileToUDS(entry, info, url.fileName());
- statEntry(entry);
- finished();
closeCamera();
}
@@ -442,7 +452,7 @@
finished();
}
}
- closeCamera();
+// closeCamera();
}
// The KIO slave "listDir" function.
Index: kamera/kioslave/kamera.h
===================================================================
--- kamera/kioslave/kamera.h (revision 458287)
+++ kamera/kioslave/kamera.h (working copy)
@@ -73,6 +73,7 @@
QString m_cfgPath;
int m_fileSize;
+ bool m_init;
CameraFile *m_file;
};
#endif
=
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscrib=
e <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic