Changeset e4ceccd32365e7199085f248fb09454d8e989054
- Timestamp:
- 27/07/04 18:20:32 (4 years ago)
- git-parent:
- Files:
-
- include/darwin_specific.h (modified) (2 diffs)
- modules/gui/macosx/intf.m (modified) (14 diffs)
- modules/gui/macosx/vout.h (modified) (1 diff)
- modules/gui/macosx/vout.m (modified) (15 diffs)
- src/interface/interface.c (modified) (7 diffs)
- src/libvlc.h (modified) (1 diff)
- src/misc/darwin_specific.m (modified) (1 diff)
- src/video_output/video_output.c (modified) (1 diff)
- src/vlc.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/darwin_specific.h
r6de15a6 re4ceccd 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001 VideoLAN 5 * $Id : darwin_specific.h,v 1.8 2004/01/25 18:17:08 zorglub Exp$5 * $Id$ 6 6 * 7 7 * Authors: Samuel Hocevar <sam@zoy.org> … … 21 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 22 22 *****************************************************************************/ 23 modules/gui/macosx/intf.m
rbf680e8 re4ceccd 70 70 p_intf->b_play = VLC_TRUE; 71 71 p_intf->pf_run = Run; 72 73 [[VLCMain sharedInstance] setIntf: p_intf];74 72 75 73 return( 0 ); … … 87 85 [p_intf->p_sys->o_sendport release]; 88 86 [p_intf->p_sys->o_pool release]; 89 87 90 88 free( p_intf->p_sys ); 91 89 } … … 100 98 * (???) --Meuuh */ 101 99 vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); 100 [[VLCMain sharedInstance] setIntf: p_intf]; 102 101 [NSBundle loadNibNamed: @"MainMenu" owner: NSApp]; 102 [NSApp run]; 103 [[VLCMain sharedInstance] terminate]; 103 104 } 104 105 … … 107 108 int i_ret = 0; 108 109 109 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];110 //NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; 110 111 111 112 if( [target respondsToSelector: @selector(performSelectorOnMainThread: … … 114 115 [target performSelectorOnMainThread: sel 115 116 withObject: [NSValue valueWithPointer: p_arg] 116 waitUntilDone: YES];117 waitUntilDone: NO]; 117 118 } 118 119 else if( NSApp != nil && [[VLCMain sharedInstance] respondsToSelector: @selector(getIntf)] ) … … 162 163 } 163 164 164 [o_pool release];165 //[o_pool release]; 165 166 166 167 return( i_ret ); … … 291 292 { 292 293 unsigned int i_key = 0; 293 intf_thread_t * p_intf = VLCIntf;294 294 playlist_t *p_playlist; 295 295 vlc_value_t val; … … 528 528 vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); 529 529 } 530 /* 530 531 531 - (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename 532 532 { … … 537 537 return( TRUE ); 538 538 } 539 */ 539 540 540 - (NSString *)localizedString:(char *)psz 541 541 { … … 638 638 639 639 val.i_int = 0; 640 p_hotkeys = VLCIntf->p_vlc->p_hotkeys;640 p_hotkeys = p_intf->p_vlc->p_hotkeys; 641 641 642 642 i_pressed_modifiers = [o_event modifierFlags]; … … 659 659 if( p_hotkeys[i].i_key == val.i_int ) 660 660 { 661 var_Set( VLCIntf->p_vlc, "key-pressed", val );661 var_Set( p_intf->p_vlc, "key-pressed", val ); 662 662 return YES; 663 663 } … … 697 697 { 698 698 NSDate * o_sleep_date; 699 /* new thread requires a new pool */ 699 700 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; 700 701 … … 810 811 if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] ) 811 812 { 812 [o_vout_wnd updateTitle];813 ;//[o_vout_wnd updateTitle]; 813 814 } 814 815 } … … 1135 1136 - (IBAction)timesliderUpdate:(id)sender 1136 1137 { 1137 intf_thread_t * p_intf;1138 1138 input_thread_t * p_input; 1139 1139 float f_updated; modules/gui/macosx/vout.h
r1b031a9 re4ceccd 76 76 77 77 /***************************************************************************** 78 * VLCVout interface79 *****************************************************************************/80 @interface VLCVout : NSObject81 {82 }83 84 - (void)createWindow:(NSValue *)o_value;85 - (void)destroyWindow:(NSValue *)o_value;86 87 @end88 89 /*****************************************************************************90 78 * vout_sys_t: MacOS X video output method descriptor 91 79 *****************************************************************************/ 92 80 struct vout_sys_t 93 81 { 94 int i_opengl; 95 82 NSAutoreleasePool *o_pool; 96 83 NSRect s_rect; 97 int b_pos_saved;98 84 VLCWindow * o_window; 99 85 86 int i_opengl; 87 int b_pos_saved; 88 100 89 vlc_bool_t b_mouse_moved; 101 90 mtime_t i_time_mouse_last_moved; modules/gui/macosx/vout.m
rbf680e8 re4ceccd 69 69 static void vout_Display ( vout_thread_t *, picture_t * ); 70 70 71 static int CoSendRequest ( vout_thread_t *, SEL );72 71 static int CoCreateWindow ( vout_thread_t * ); 73 72 static int CoDestroyWindow ( vout_thread_t * ); … … 120 119 } 121 120 121 p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init]; 122 122 p_vout->p_sys->b_mouse_moved = VLC_TRUE; 123 123 p_vout->p_sys->i_time_mouse_last_moved = mdate(); … … 160 160 free( p_vout->p_sys ); 161 161 return( 1 ); 162 } 162 } 163 163 164 164 /* Damn QT isn't thread safe. so keep a lock in the p_vlc object */ … … 169 169 170 170 vlc_mutex_unlock( &p_vout->p_vlc->quicktime_lock ); 171 171 172 if( err == noErr && p_vout->p_sys->img_dc != 0 ) 172 173 { … … 193 194 } 194 195 195 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];196 196 NSArray * o_screens = [NSScreen screens]; 197 197 if( [o_screens count] > 0 && var_Type( p_vout, "video-device" ) == 0 ) … … 237 237 var_Set( p_vout, "intf-change", val ); 238 238 } 239 [o_pool release];240 239 241 240 if( CoCreateWindow( p_vout ) ) … … 433 432 *****************************************************************************/ 434 433 void E_(CloseVideo) ( vlc_object_t *p_this ) 435 { 434 { 435 NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; 436 436 vout_thread_t * p_vout = (vout_thread_t *)p_this; 437 437 … … 458 458 } 459 459 460 [o_pool release]; 460 461 free( p_vout->p_sys ); 461 462 } … … 571 572 572 573 /***************************************************************************** 573 * CoSendRequest: send request to interface thread574 *****************************************************************************575 * Returns 0 on success, 1 otherwise576 *****************************************************************************/577 static int CoSendRequest( vout_thread_t *p_vout, SEL sel )578 {579 int i_ret = 0;580 vlc_value_t val;581 intf_thread_t * p_intf;582 583 VLCVout * o_vlv = [[VLCVout alloc] init];584 585 if( ( i_ret = ExecuteOnMainThread( o_vlv, sel, (void *)p_vout ) ) )586 {587 msg_Err( p_vout, "SendRequest: no way to communicate with mt" );588 }589 590 [o_vlv release];591 592 /*This makes this function dependant of the presence of a macosx593 interface. We do not check if this interface exists, since it has594 already been done before.*/595 596 /*p_intf = VLCIntf;597 598 val.b_bool = VLC_TRUE;599 var_Create(p_intf,"intf-change",VLC_VAR_BOOL);600 var_Set(p_intf, "intf-change",val);601 */602 return( i_ret );603 }604 605 /*****************************************************************************606 574 * CoCreateWindow: create new window 607 575 ***************************************************************************** … … 610 578 static int CoCreateWindow( vout_thread_t *p_vout ) 611 579 { 612 if( CoSendRequest( p_vout, @selector(createWindow:) ) ) 613 { 614 msg_Err( p_vout, "CoSendRequest (createWindow) failed" ); 615 return( 1 ); 580 vlc_value_t val; 581 VLCQTView * o_view; 582 NSScreen * o_screen; 583 vlc_bool_t b_main_screen; 584 NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; 585 586 p_vout->p_sys->o_window = [VLCWindow alloc]; 587 [p_vout->p_sys->o_window setReleasedWhenClosed: YES]; 588 589 if( var_Get( p_vout, "video-device", &val ) < 0 ) 590 { 591 o_screen = [NSScreen mainScreen]; 592 b_main_screen = 1; 593 } 594 else 595 { 596 NSArray *o_screens = [NSScreen screens]; 597 unsigned int i_index = val.i_int; 598 599 if( [o_screens count] < i_index ) 600 { 601 o_screen = [NSScreen mainScreen]; 602 b_main_screen = 1; 603 } 604 else 605 { 606 i_index--; 607 o_screen = [o_screens objectAtIndex: i_index]; 608 config_PutInt( p_vout, "macosx-vdev", i_index ); 609 b_main_screen = (i_index == 0); 610 } 611 } 612 613 if( p_vout->b_fullscreen ) 614 { 615 NSRect screen_rect = [o_screen frame]; 616 screen_rect.origin.x = screen_rect.origin.y = 0; 617 618 if ( b_main_screen && p_vout->p_sys->p_fullscreen_state == NULL ) 619 BeginFullScreen( &p_vout->p_sys->p_fullscreen_state, NULL, 0, 0, 620 NULL, NULL, fullScreenAllowEvents ); 621 622 [p_vout->p_sys->o_window 623 initWithContentRect: screen_rect 624 styleMask: NSBorderlessWindowMask 625 backing: NSBackingStoreBuffered 626 defer: NO screen: o_screen]; 627 628 [p_vout->p_sys->o_window setVout: p_vout]; 629 p_vout->p_sys->b_mouse_moved = YES; 630 p_vout->p_sys->i_time_mouse_last_moved = mdate(); 631 } 632 else 633 { 634 unsigned int i_stylemask = NSTitledWindowMask | 635 NSMiniaturizableWindowMask | 636 NSClosableWindowMask | 637 NSResizableWindowMask; 638 639 if ( p_vout->p_sys->p_fullscreen_state != NULL ) 640 EndFullScreen ( p_vout->p_sys->p_fullscreen_state, NULL ); 641 p_vout->p_sys->p_fullscreen_state = NULL; 642 643 [p_vout->p_sys->o_window 644 initWithContentRect: p_vout->p_sys->s_rect 645 styleMask: i_stylemask 646 backing: NSBackingStoreBuffered 647 defer: NO screen: o_screen]; 648 649 [p_vout->p_sys->o_window setVout: p_vout]; 650 [p_vout->p_sys->o_window setAlphaValue: config_GetFloat( p_vout, "macosx-opaqueness" )]; 651 652 if( config_GetInt( p_vout, "video-on-top" ) ) 653 { 654 [p_vout->p_sys->o_window setLevel: NSStatusWindowLevel]; 655 } 656 657 if( !p_vout->p_sys->b_pos_saved ) 658 { 659 [p_vout->p_sys->o_window center]; 660 } 661 } 662 663 if( !p_vout->p_sys->i_opengl ) 664 { 665 o_view = [[VLCQTView alloc] init]; 666 /* FIXME: [o_view setMenu:] */ 667 [p_vout->p_sys->o_window setContentView: o_view]; 668 [o_view autorelease]; 669 670 [o_view lockFocus]; 671 p_vout->p_sys->p_qdport = [o_view qdPort]; 672 [o_view unlockFocus]; 673 } 674 else 675 { 676 #define o_glview p_vout->p_sys->o_glview 677 o_glview = [[VLCGLView alloc] initWithFrame: p_vout->p_sys->s_rect vout: p_vout]; 678 [p_vout->p_sys->o_window setContentView: o_glview]; 679 [o_glview autorelease]; 680 #undef o_glview 616 681 } 617 682 618 return( 0 ); 683 [p_vout->p_sys->o_window updateTitle]; 684 [p_vout->p_sys->o_window makeKeyAndOrderFront: nil]; 685 686 [o_pool release]; 687 return( 0); 619 688 } 620 689 … … 626 695 static int CoDestroyWindow( vout_thread_t *p_vout ) 627 696 { 628 697 NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; 629 698 VLCHideMouse( p_vout, NO ); 630 699 631 if( CoSendRequest( p_vout, @selector(destroyWindow:) ) ) 632 { 633 msg_Err( p_vout, "CoSendRequest (destroyWindow) failed" ); 634 return( 1 ); 635 } 636 637 return( 0 ); 700 if( !p_vout->b_fullscreen ) 701 { 702 NSRect s_rect; 703 704 s_rect = [[p_vout->p_sys->o_window contentView] frame]; 705 p_vout->p_sys->s_rect.size = s_rect.size; 706 707 s_rect = [p_vout->p_sys->o_window frame]; 708 p_vout->p_sys->s_rect.origin = s_rect.origin; 709 710 p_vout->p_sys->b_pos_saved = YES; 711 } 712 713 p_vout->p_sys->p_qdport = nil; 714 [p_vout->p_sys->o_window close]; 715 p_vout->p_sys->o_window = nil; 716 [o_pool release]; 717 return 0; 638 718 } 639 719 … … 645 725 static int CoToggleFullscreen( vout_thread_t *p_vout ) 646 726 { 727 NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; 728 647 729 if( !p_vout->p_sys->i_opengl ) 648 730 { … … 685 767 } 686 768 769 [o_pool release]; 687 770 return( 0 ); 688 771 } … … 1014 1097 return( YES ); 1015 1098 } 1016 1099 /* 1017 1100 - (BOOL)performKeyEquivalent:(NSEvent *)o_event 1018 1101 { 1019 1102 return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event]; 1020 1103 } 1021 1104 */ 1022 1105 - (void)keyDown:(NSEvent *)o_event 1023 1106 { … … 1739 1822 1740 1823 @end 1741 1742 /*****************************************************************************1743 * VLCVout implementation1744 *****************************************************************************/1745 @implementation VLCVout1746 1747 - (void)createWindow:(NSValue *)o_value1748 {1749 vlc_value_t val;1750 VLCQTView * o_view;1751 NSScreen * o_screen;1752 vout_thread_t * p_vout;1753 vlc_bool_t b_main_screen;1754 1755 p_vout = (vout_thread_t *)[o_value pointerValue];1756 1757 p_vout->p_sys->o_window = [VLCWindow alloc];1758 [p_vout->p_sys->o_window setVout: p_vout];1759 [p_vout->p_sys->o_window setReleasedWhenClosed: YES];1760 1761 if( var_Get( p_vout, "video-device", &val ) < 0 )1762 {1763 o_screen = [NSScreen mainScreen];1764 b_main_screen = 1;1765 }1766 else1767 {1768 NSArray *o_screens = [NSScreen screens];1769 unsigned int i_index = val.i_int;1770 1771 if( [o_screens count] < i_index )1772 {1773 o_screen = [NSScreen mainScreen];1774 b_main_screen = 1;1775 }1776 else1777 {1778 i_index--;1779 o_screen = [o_screens objectAtIndex: i_index];1780 config_PutInt( p_vout, "macosx-vdev", i_index );1781 b_main_screen = (i_index == 0);1782 }1783 }1784 1785 if( p_vout->b_fullscreen )1786 {1787 NSRect screen_rect = [o_screen frame];1788 screen_rect.origin.x = screen_rect.origin.y = 0;1789 1790 if ( b_main_screen && p_vout->p_sys->p_fullscreen_state == NULL )1791 BeginFullScreen( &p_vout->p_sys->p_fullscreen_state, NULL, 0, 0,1792 NULL, NULL, fullScreenAllowEvents );1793 1794 [p_vout->p_sys->o_window1795 initWithContentRect: screen_rect1796 styleMask: NSBorderlessWindowMask1797 backing: NSBackingStoreBuffered1798 defer: NO screen: o_screen];1799 1800 //[p_vout->p_sys->o_window setLevel: NSPopUpMenuWindowLevel - 1];1801 p_vout->p_sys->b_mouse_moved = YES;1802 p_vout->p_sys->i_time_mouse_last_moved = mdate();1803 }1804 else1805 {1806 unsigned int i_stylemask = NSTitledWindowMask |1807 NSMiniaturizableWindowMask |1808 NSClosableWindowMask |1809 NSResizableWindowMask;1810 1811 if ( p_vout->p_sys->p_fullscreen_state != NULL )1812 EndFullScreen ( p_vout->p_sys->p_fullscreen_state, NULL );1813 p_vout->p_sys->p_fullscreen_state = NULL;1814 1815 [p_vout->p_sys->o_window1816 initWithContentRect: p_vout->p_sys->s_rect1817 styleMask: i_stylemask1818 backing: NSBackingStoreBuffered1819 defer: NO screen: o_screen];1820 1821 [p_vout->p_sys->o_window setAlphaValue: config_GetFloat( p_vout, "macosx-opaqueness" )];1822 1823 if( config_GetInt( p_vout, "video-on-top" ) )1824 {1825 [p_vout->p_sys->o_window setLevel: NSStatusWindowLevel];1826 }1827 1828 if( !p_vout->p_sys->b_pos_saved )1829 {1830 [p_vout->p_sys->o_window center];1831 }1832 }1833 1834 if( !p_vout->p_sys->i_opengl )1835 {1836 o_view = [[VLCQTView alloc] init];1837 /* FIXME: [o_view setMenu:] */1838 [p_vout->p_sys->o_window setContentView: o_view];1839 [o_view autorelease];1840 1841 [o_view lockFocus];1842 p_vout->p_sys->p_qdport = [o_view qdPort];1843 [o_view unlockFocus];1844 }1845 else1846 {1847 #define o_glview p_vout->p_sys->o_glview1848 o_glview = [[VLCGLView alloc] initWithFrame: p_vout->p_sys->s_rect vout: p_vout];1849 [p_vout->p_sys->o_window setContentView: o_glview];1850 [o_glview autorelease];1851 #undef o_glview1852 }1853 1854 [p_vout->p_sys->o_window updateTitle];1855 [p_vout->p_sys->o_window makeKeyAndOrderFront: nil];1856 1857 }1858 1859 - (void)destroyWindow:(NSValue *)o_value1860 {1861 vout_thread_t * p_vout;1862 1863 p_vout = (vout_thread_t *)[o_value pointerValue];1864 1865 if( !p_vout->b_fullscreen )1866 {1867 NSRect s_rect;1868 1869 s_rect = [[p_vout->p_sys->o_window contentView] frame];1870 p_vout->p_sys->s_rect.size = s_rect.size;1871 1872 s_rect = [p_vout->p_sys->o_window frame];1873 p_vout->p_sys->s_rect.origin = s_rect.origin;1874 1875 p_vout->p_sys->b_pos_saved = YES;1876 }1877 1878 p_vout->p_sys->p_qdport = nil;1879 [p_vout->p_sys->o_window close];1880 p_vout->p_sys->o_window = nil;1881 }1882 1883 @endsrc/interface/interface.c
rbf680e8 re4ceccd 61 61 vlc_value_t , vlc_value_t , void * ); 62 62 63 #ifdef SYS_DARWIN 64 /***************************************************************************** 65 * VLCApplication interface 66 *****************************************************************************/ 67 @interface VLCApplication : NSApplication 68 { 69 } 70 71 @end 72 #endif 73 63 74 /***************************************************************************** 64 75 * intf_Create: prepare interface before main loop … … 132 143 { 133 144 #ifdef SYS_DARWIN 145 NSAutoreleasePool * o_pool; 146 134 147 if( p_intf->b_block ) 135 148 { … … 144 157 } 145 158 146 if( p_intf->b_block && !strncmp( p_intf->p_module->psz_shortname, "macosx" , 6 ) ) 147 { 148 /* this is OSX, we are cheating :) 149 This is NOT I REPEAT NOT blocking since [NSApp run] is */ 150 p_intf->b_block = VLC_FALSE; 151 152 RunInterface( p_intf ); 153 p_intf->b_block = VLC_TRUE; 154 } 155 else if( p_intf->b_block && !strncmp( p_intf->p_vlc->psz_object_name, "clivlc", 6 ) ) 156 { 157 /* VLC OS X in cli mode ( no blocking [NSApp run] ) 158 this is equal to running in normal non-OSX primary intf mode */ 159 if( p_intf->b_block && strncmp( p_intf->p_module->psz_shortname, "clivlc", 6) ) 160 { 161 o_pool = [[NSAutoreleasePool alloc] init]; 162 [VLCApplication sharedApplication]; 163 } 164 165 if( p_intf->b_block && ( !strncmp( p_intf->p_module->psz_shortname, "macosx" , 6 ) || 166 !strncmp( p_intf->p_vlc->psz_object_name, "clivlc", 6 ) ) ) 167 { 168 /* VLC in normal primary interface mode */ 159 169 RunInterface( p_intf ); 160 170 p_intf->b_die = VLC_TRUE; … … 162 172 else 163 173 { 164 /* If anything else is the primary intf and we are not in cli mode, 165 then don't make it blocking ([NSApp run] will be blocking) 166 but run it in a seperate thread. */ 167 p_intf->b_block = VLC_FALSE; 174 /* Run the interface in a separate thread */ 175 if( vlc_thread_create( p_intf, "interface", RunInterface, 176 VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) 177 { 178 msg_Err( p_intf, "cannot spawn interface thread" ); 179 return VLC_EGENERIC; 180 } 181 182 if( p_intf->b_block ) 183 { 184 /* VLC in primary interface mode with a working macosx vout */ 185 [NSApp run]; 186 p_intf->b_die = VLC_TRUE; 187 } 188 } 168 189 #else 169 190 if( p_intf->b_block ) … … 184 205 else 185 206 { 186 #endif187 207 /* Run the interface in a separate thread */ 188 208 if( vlc_thread_create( p_intf, "interface", RunInterface, … … 193 213 } 194 214 } 215 #endif 195 216 196 217 return VLC_SUCCESS; … … 419 440 return VLC_SUCCESS; 420 441 } 442 443 #ifdef SYS_DARWIN 444 /***************************************************************************** 445 * VLCApplication implementation 446 *****************************************************************************/ 447 @implementation VLCApplication 448 449 - (void)stop: (id)sender 450 { 451 NSEvent *o_event; 452 NSAutoreleasePool *o_pool; 453 [super stop:sender]; 454 455 o_pool = [[NSAutoreleasePool alloc] init]; 456 /* send a dummy event to break out of the event loop */ 457 o_event = [NSEvent mouseEventWithType: NSLeftMouseDown 458 location: NSMakePoint( 1, 1 ) modifierFlags: 0 459 timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber] 460 context: [NSGraphicsContext currentContext] eventNumber: 1 461 clickCount: 1 pressure: 0.0]; 462 [NSApp postEvent: o_event atStart: YES]; 463 [o_pool release]; 464 } 465 466 - (void)terminate: (id)sender 467 { 468 if( [NSApp isRunning] ) 469 [NSApp stop:sender]; 470 [super terminate: sender]; 471 } 472 473 @end 474 #endif 475 src/libvlc.h
r7f29318 re4ceccd 1317 1317 { NULL, 0, 0 } 1318 1318 }; 1319 src/misc/darwin_specific.m
r25cd132 re4ceccd 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001-2004 VideoLAN 5 * $Id : darwin_specific.m,v 1.18 2004/01/06 12:02:06 zorglub Exp$5 * $Id$ 6 6 * 7 7 * Authors: Sam Hocevar <sam@zoy.org> src/video_output/video_output.c
r7c92855 re4ceccd 1100 1100 ***************************************************************************** 1101 1101 * This function is called when the thread ends after a sucessful 1102 * initialization. It frees all res sources allocated by InitThread.1102 * initialization. It frees all resources allocated by InitThread. 1103 1103 *****************************************************************************/ 1104 1104 static void EndThread( vout_thread_t *p_vout ) src/vlc.c
rbf680e8 re4ceccd 36 36 # include <time.h> /* time() */ 37 37 #endif 38 #ifdef HAVE_STRINGS_H39 # include <strings.h> /* strncmp() */40 #endif41 38 42 39 #include <vlc/vlc.h> 43 44 #ifdef SYS_DARWIN45 #include <Cocoa/Cocoa.h>46 #endif47 40 48 41 /***************************************************************************** … … 52 45 static void SigHandler ( int i_signal ); 53 46 #endif 54 55 #ifdef SYS_DARWIN56 /*****************************************************************************57 * VLCApplication interface58 *****************************************************************************/59 @interface VLCApplication : NSApplication60 {61 }62 63 @end64 65 /*****************************************************************************66 * VLCApplication implementation67 *****************************************************************************/68 @implementation VLCApplication69 70 - (void)stop: (id)sender71 {72 NSEvent *o_event;73 [super stop:sender];74 75 /* send a dummy event to break out of the event loop */76 o_event = [NSEvent mouseEventWithType: NSLeftMouseDown77 location: NSMakePoint( 1, 1 ) modifierFlags: 078 timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber]79 context: [NSGraphicsContext currentContext] eventNumber: 180 clickCount: 1 pressure: 0.0];81 [NSApp postEvent: o_event atStart: YES];82 }83 84 - (void)terminate: (id)sender85 {86 if( [NSApp isRunning] )87 [NSApp stop:sender];88 [super terminate: sender];89 }90 91 @end92 93 #endif /* SYS_DARWIN */94 47 95 48 /***************************************************************************** … … 151 104 } 152 105 153 #ifdef HAVE_STRINGS_H154 /* if first 3 chars of argv[0] are cli, then this is clivlc155 * We detect this specifically for Mac OS X, so you can launch vlc156 * from the commandline even if you are not logged in on the GUI */157 if( i_argc > 0 )158 {159 char *psz_temp;160 char *psz_program = psz_temp = ppsz_argv[0];161 while( *psz_temp )162 {163 if( *psz_temp == '/' ) psz_program = ++psz_temp;164 else ++psz_temp;165 }166 b_cli = !strncmp( psz_program, "cli", 3 );167 }168 #endif169 170 #ifdef SYS_DARWIN171 if( !b_cli )172 {173 [VLCApplication sharedApplication];174 }175 176 106 i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE ); 177 178 if( !b_cli )179 {180 /* This is a blocking call */181 [NSApp run];182 }183 #else184 i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE );185 #endif /* SYS_DARWIN */186 107 187 108 /* Finish the threads */ … … 190 111 /* Destroy the libvlc structure */ 191 112 VLC_Destroy( 0 ); 192 193 #ifdef SYS_DARWIN194 if( !b_cli )195 {196 [NSApp terminate:NULL];197 }198 #endif /* SYS_DARWIN */199 113 200 114 return i_ret;
