After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 748495 - libde265: No code to detect the number of CPUs on W32
libde265: No code to detect the number of CPUs on W32
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
unspecified
Other All
: Normal normal
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-04-26 21:01 UTC by LRN
Modified: 2015-04-28 15:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libde265: W32 thread count support (1.19 KB, patch)
2015-04-26 21:01 UTC, LRN
needs-work Details | Review
libde265: More elaborate W32 threadcount code from glib (1.65 KB, patch)
2015-04-27 14:13 UTC, LRN
none Details | Review

Description LRN 2015-04-26 21:01:16 UTC
Results in #warning "Don't know how to get number of CPU cores, will use the default thread count"
Comment 1 LRN 2015-04-26 21:01:21 UTC
Created attachment 302396 [details] [review]
libde265: W32 thread count support
Comment 2 Nicolas Dufresne (ndufresne) 2015-04-27 13:52:27 UTC
Review of attachment 302396 [details] [review]:

Kind of a sad moment, since we got g_get_num_processors() since glib 2.36, but GST depends on 2.32 :-( Interestingly the glib implementation is much more complex, I wonder if there is a reason for this. Would it be possible to ask Ryan ?


#ifdef G_OS_WIN32
  DWORD_PTR process_cpus;
  DWORD_PTR system_cpus;

  if (GetProcessAffinityMask (GetCurrentProcess (),
                              &process_cpus, &system_cpus))
    {
      unsigned int count;

      for (count = 0; process_cpus != 0; process_cpus >>= 1)
        if (process_cpus & 1)
          count++;

      if (count > 0)
        return count;
    }

::: ext/libde265/libde265-dec.c
@@ +43,3 @@
 #include <unistd.h>
 #endif
+#ifdef _WIN32

Most code I have been across uses G_OS_WIN32 for portability. Any reason this would not be right here ?
Comment 3 LRN 2015-04-27 14:13:58 UTC
Created attachment 302448 [details] [review]
libde265: More elaborate W32 threadcount code from glib

Imports code from glib. This is more correct than a simple GetSystemInfo().
Apply on top of attachment 302396 [details] [review].
Comment 4 Nicolas Dufresne (ndufresne) 2015-04-27 14:30:06 UTC
Attachment 302396 [details] pushed as 0a95a4e - libde265: W32 thread count support
Comment 5 Nicolas Dufresne (ndufresne) 2015-04-27 14:32:24 UTC
I've squashed the patches, fix the use of _WIN32 to be G_OS_WIN32 and fixed the indentation. Please make sure gst-indent works, and don't use git commit -n option in further patch submission.
Comment 6 Tim-Philipp Müller 2015-04-28 15:11:04 UTC
Refactored this a little so we can easily drop it when we bump glib requirement, let me know if it breaks anything on windows:

ommit c754b8526b32cffe397308567127313bf993c86d
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Tue Apr 28 16:06:47 2015 +0100

    de265dec: use g_get_num_processors() if available
    
    And provide home-made fallback for older GLib versions,
    so that we can later find these and remove them when
    we bump the GLib requirement (which is certainly going
    to happen before 2.0).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=748495


(On a side note, all this thread count autoconfig stuff looks highly dubious to me, as if nothing else is going on on the system..)