openbsd-ports/audio/gtkpod/patches/patch-src_file_convert_c

55 lines
1.4 KiB
Plaintext

$OpenBSD: patch-src_file_convert_c,v 1.2 2009/03/06 20:44:24 ckuethe Exp $
--- src/file_convert.c.orig Sat Jan 17 22:52:32 2009
+++ src/file_convert.c Thu Feb 26 23:27:50 2009
@@ -33,6 +33,10 @@
# include <config.h>
#endif
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/wait.h>
#include "display_itdb.h"
#include "file_convert.h"
#include "info.h"
@@ -44,9 +48,6 @@
#include <glib/gstdio.h>
#include <signal.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/types.h>
-#include <sys/wait.h>
#include <unistd.h>
#undef DEBUG_CONV
@@ -645,6 +646,8 @@ static void conversion_prefs_changed (Conversion *conv
gboolean background_transfer;
gdouble maxsize;
GList *gl;
+ int mib[2], ncpus;
+ size_t len;
g_return_if_fail (conv);
@@ -666,13 +669,16 @@ static void conversion_prefs_changed (Conversion *conv
}
conv->max_threads_num = prefs_get_int (FILE_CONVERT_MAX_THREADS_NUM);
+ mib[0] = CTL_HW;
+ mib[1] = HW_NCPU;
+ len = sizeof(ncpus);
if (conv->max_threads_num == 0)
{ /* set to maximum available number of processors */
- conv->max_threads_num = sysconf (_SC_NPROCESSORS_ONLN);
- /* paranoia mode on */
- if (conv->max_threads_num <= 0)
- {
+ if ((sysctl(mib, 2, &ncpus, &len, NULL, 0) == -1) || (ncpus < 1)){
+ /* paranoia mode on */
conv->max_threads_num = 1;
+ } else {
+ conv->max_threads_num = ncpus;
}
}