]> git.sesse.net Git - vlc/commitdiff
* src/misc/cpu.c: New altivec detection for Darwin. Using the correct
authorDerk-Jan Hartman <hartman@videolan.org>
Tue, 20 Jan 2004 15:34:44 +0000 (15:34 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Tue, 20 Jan 2004 15:34:44 +0000 (15:34 +0000)
  official method.
* modules/gui/macosx/playlist.m: Fix Add with options and no enqueue.
* modules/gui/macosx/applescript.m: PLAYLIST_GO fix

modules/gui/macosx/applescript.m
modules/gui/macosx/playlist.m
src/misc/cpu.c

index 47d427df9ec9685750120ab51f5576e8ffd1bce2..94f3651631dea42de6aecd9538d0763cd6d07258 100644 (file)
@@ -2,7 +2,7 @@
  * applescript.m: MacOS X AppleScript support
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: applescript.m,v 1.5 2004/01/05 13:07:03 zorglub Exp $
+ * $Id: applescript.m,v 1.6 2004/01/20 15:34:43 hartman Exp $
  *
  * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
  *
         {
             NSURL * o_url;
     
-            int i_mode = PLAYLIST_INSERT | PLAYLIST_GO;
+            int i_mode = PLAYLIST_INSERT;
             
             playlist_Add( p_playlist, [o_urlString fileSystemRepresentation],
-                          [o_urlString fileSystemRepresentation],
+                          [[o_urlString fileSystemRepresentation] lastPathComponent],
                           i_mode, PLAYLIST_END );
 
             o_url = [NSURL fileURLWithPath: o_urlString];
index 9bbc03bd88e5f987b81649bf210f408b8542ce05..8f90490fb44da09539facf00751f876ddfe7167f 100644 (file)
@@ -2,7 +2,7 @@
  * playlist.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2004 VideoLAN
- * $Id: playlist.m,v 1.53 2004/01/14 18:45:45 bigben Exp $
+ * $Id: playlist.m,v 1.54 2004/01/20 15:34:43 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Derk-Jan Hartman <hartman at videolan dot org>
@@ -423,7 +423,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
     {
         /* One item */
         NSDictionary *o_one_item;
-        int j, i_new_position = -1;
+        int j, i_new_id = -1;
         int i_mode = PLAYLIST_INSERT;
         BOOL b_rem = FALSE, b_dir = FALSE;
         NSString *o_uri, *o_name;
@@ -455,12 +455,9 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
             psz_dev[temp - psz_dev] = '\0';
             o_uri = [NSString stringWithCString: psz_dev ];
         }
-    
-        if (i_item == 0 && !b_enqueue)
-            i_mode |= PLAYLIST_GO;
         
         /* Add the item */
-        i_new_position = playlist_Add( p_playlist, [o_uri fileSystemRepresentation], 
+        i_new_id = playlist_Add( p_playlist, [o_uri fileSystemRepresentation], 
                       [o_name UTF8String], i_mode, 
                       i_position == -1 ? PLAYLIST_END : i_position + i_item);
         
@@ -469,10 +466,16 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
         {
             for( j = 0; j < [o_options count]; j++ )
             {
-                playlist_AddOption( p_playlist, i_new_position,
+                playlist_AddOption( p_playlist, i_new_id,
                  strdup( [[o_options objectAtIndex:j] UTF8String] ) );
             }
         }
+        
+        if( i_item == 0 && !b_enqueue )
+        {
+            playlist_Goto( p_playlist, playlist_GetPositionById( p_playlist, i_new_id ) );
+            playlist_Play( p_playlist );
+        }
     
         /* Recent documents menu */
         o_true_file = [NSURL fileURLWithPath: o_uri];
index 10e19cb4035b3f2564c9d0c9a9c01988ce437019..9c1ae608a367eb8eb71f9fabfe3ec8f96448e154 100644 (file)
@@ -2,7 +2,7 @@
  * cpu.c: CPU detection code
  *****************************************************************************
  * Copyright (C) 1998-2004 VideoLAN
- * $Id: cpu.c,v 1.12 2004/01/06 12:02:06 zorglub Exp $
+ * $Id: cpu.c,v 1.13 2004/01/20 15:34:44 hartman Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Christophe Massiot <massiot@via.ecp.fr>
 #endif
 
 #ifdef SYS_DARWIN
-#   include <mach/mach.h>                               /* AltiVec detection */
-#   include <mach/mach_error.h>       /* some day the header files||compiler *
-                                                       will define it for us */
-#   include <mach/bootstrap.h>
+#include <sys/sysctl.h>
 #endif
 
 #include "vlc_cpu.h"
@@ -70,34 +67,15 @@ uint32_t CPUCapabilities( void )
     volatile uint32_t i_capabilities = CPU_CAPABILITY_NONE;
 
 #if defined( SYS_DARWIN )
-    struct host_basic_info hi;
-    kern_return_t          ret;
-    host_name_port_t       host;
-
-    int i_size;
-    char *psz_name, *psz_subname;
+    int selectors[2] = { CTL_HW, HW_VECTORUNIT };
+    int i_has_altivec = 0;
+    size_t i_length = sizeof( i_has_altivec );
+    int i_error = sysctl( selectors, 2, &i_has_altivec, &i_length, NULL, 0);
 
     i_capabilities |= CPU_CAPABILITY_FPU;
 
-    /* Should 'never' fail? */
-    host = mach_host_self();
-
-    i_size = sizeof( hi ) / sizeof( int );
-    ret = host_info( host, HOST_BASIC_INFO, ( host_info_t )&hi, &i_size );
-
-    if( ret != KERN_SUCCESS )
-    {
-        fprintf( stderr, "error: couldn't get CPU information\n" );
-        return i_capabilities;
-    }
-
-    slot_name( hi.cpu_type, hi.cpu_subtype, &psz_name, &psz_subname );
-    /* FIXME: need better way to detect newer proccessors.
-     * could do strncmp(a,b,5), but that's real ugly */
-    if( !strcmp(psz_name, "ppc7400") || !strcmp(psz_name, "ppc7450") )
-    {
+    if( i_error == 0 && i_has_altivec != 0 )
         i_capabilities |= CPU_CAPABILITY_ALTIVEC;
-    }
 
     return i_capabilities;