Re: [Nautilus-list] Re: SOLUTION : Menu opening and others actions sooooo slow (5-10 secs) !
- From: John Harper <jsh pixelslut com>
- To: Seth Aaron Nickell <snickell stanford edu>
- Cc: S Stormacq aubay-si lu, nautilus-list lists eazel com
- Subject: Re: [Nautilus-list] Re: SOLUTION : Menu opening and others actions sooooo slow (5-10 secs) !
- Date: Fri, 31 Aug 2001 17:26:02 -0700
Seth Aaron Nickell writes:
|The third part of the problem is that nautilus keeps trying to initialize
|libesd, which is bad because if it fails it probably shouldn't try again (and
|it shouldn't do it a bunch anyway).
Is it worth doing something like the following?
John
Index: libnautilus-private/nautilus-sound.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-sound.c,v
retrieving revision 1.10
diff -u -p -r1.10 nautilus-sound.c
--- libnautilus-private/nautilus-sound.c 2001/07/10 16:38:59 1.10
+++ libnautilus-private/nautilus-sound.c 2001/09/01 00:21:28
@@ -33,6 +33,7 @@
# include <sys/wait.h>
# endif
#endif
+#include <time.h>
#include <esd.h>
#include <eel/eel-gconf-extensions.h>
@@ -41,6 +42,9 @@
/* Keep track of the sound playing process */
#define CURRENT_SOUND_STATE_KEY "/apps/nautilus/sound_state"
+/* Number of seconds between checking if sound can be played */
+#define SOUND_CHECK_INTERVAL 60
+
static gboolean
kill_sound_if_necessary (void)
{
@@ -102,21 +106,34 @@ nautilus_sound_register_sound (pid_t sou
gboolean
nautilus_sound_can_play_sound (void)
{
+ static gboolean last_result;
+ static time_t last_check_time;
+
int sound_process, open_result;
-
+ time_t current_time;
+
/* first see if there's already one in progress; if so, return true */
sound_process = eel_gconf_get_integer (CURRENT_SOUND_STATE_KEY);
if (sound_process > 0) {
return TRUE;
}
+
+ /* Only check once every SOUND_CHECK_INTERVAL seconds, since
+ * esd_open_sound () is an expensive call
+ */
+ current_time = time (NULL);
+ if (current_time >= last_check_time + SOUND_CHECK_INTERVAL) {
+ last_check_time = current_time;
- /* Now check and see if system has audio out capabilites */
- open_result = esd_open_sound (NULL);
- if (open_result == -1) {
- return FALSE;
- } else {
- esd_close (open_result);
- return TRUE;
+ /* Now check and see if system has audio out capabilites */
+ open_result = esd_open_sound (NULL);
+ if (open_result == -1) {
+ last_result = FALSE;
+ } else {
+ esd_close (open_result);
+ last_result = TRUE;
+ }
}
-}
+ return last_result;
+}
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]