Mercurial > mplayer.hg
annotate libvo/vo_macosx.m @ 28076:dcfe2ea48fc1
Remove unused variable, fixes the warning:
libvo/vo_macosx.m:735: warning: unused variable 'lastTime'
author | diego |
---|---|
date | Mon, 08 Dec 2008 00:11:03 +0000 |
parents | ca9badc94740 |
children | 75925b6d0d51 |
rev | line source |
---|---|
15289 | 1 /* |
2 vo_macosx.m | |
3 by Nicolas Plourde <nicolasplourde@gmail.com> | |
4 | |
5 MPlayer Mac OSX video out module. | |
6 Copyright (c) Nicolas Plourde - 2005 | |
7 */ | |
8 | |
9 #import "vo_macosx.h" | |
16385 | 10 #include <sys/types.h> |
11 #include <sys/ipc.h> | |
28016
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
12 #include <sys/mman.h> |
27988 | 13 #include <CoreServices/CoreServices.h> |
14 //special workaround for Apple bug #6267445 | |
15 //(OSServices Power API disabled in OSServices.h for 64bit systems) | |
16 #ifndef __POWER__ | |
17 #include <CoreServices/../Frameworks/OSServices.framework/Headers/Power.h> | |
18 #endif | |
15289 | 19 |
20 //MPLAYER | |
21 #include "config.h" | |
22 #include "fastmemcpy.h" | |
23 #include "video_out.h" | |
24 #include "video_out_internal.h" | |
25 #include "aspect.h" | |
26 #include "mp_msg.h" | |
27 #include "m_option.h" | |
28075
ca9badc94740
#include appropriate headers instead of locally declaring function prototypes.
diego
parents:
28051
diff
changeset
|
28 #include "mp_fifo.h" |
ca9badc94740
#include appropriate headers instead of locally declaring function prototypes.
diego
parents:
28051
diff
changeset
|
29 #include "libvo/sub.h" |
15289 | 30 |
31 #include "input/input.h" | |
32 #include "input/mouse.h" | |
33 | |
34 #include "osdep/keycodes.h" | |
35 | |
36 //Cocoa | |
25157
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
37 NSDistantObject *mplayerosxProxy; |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
38 id <MPlayerOSXVOProto> mplayerosxProto; |
15611 | 39 MPlayerOpenGLView *mpGLView; |
15289 | 40 NSAutoreleasePool *autoreleasepool; |
41 OSType pixelFormat; | |
42 | |
16385 | 43 //shared memory |
28016
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
44 int shm_fd; |
16385 | 45 BOOL shared_buffer = false; |
46 | |
15728 | 47 //Screen |
48 int screen_id; | |
49 BOOL screen_force; | |
50 NSRect screen_frame; | |
51 NSScreen *screen_handle; | |
52 NSArray *screen_array; | |
15289 | 53 |
54 //image | |
55 unsigned char *image_data; | |
25180 | 56 // For double buffering |
57 static uint8_t image_page = 0; | |
58 static unsigned char *image_datas[2]; | |
59 | |
15289 | 60 static uint32_t image_width; |
61 static uint32_t image_height; | |
62 static uint32_t image_depth; | |
63 static uint32_t image_bytes; | |
64 static uint32_t image_format; | |
65 | |
66 //vo | |
67 static int isFullscreen; | |
15320 | 68 static int isOntop; |
15327 | 69 static int isRootwin; |
15289 | 70 extern float monitor_aspect; |
71 extern float movie_aspect; | |
72 static float old_movie_aspect; | |
25446 | 73 extern int enable_mouse_movements; |
15289 | 74 |
15731 | 75 static float winAlpha = 1; |
15289 | 76 static int int_pause = 0; |
77 | |
25179
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
78 static BOOL isLeopardOrLater; |
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
79 |
15289 | 80 static vo_info_t info = |
81 { | |
82 "Mac OSX Core Video", | |
83 "macosx", | |
84 "Nicolas Plourde <nicolas.plourde@gmail.com>", | |
85 "" | |
86 }; | |
87 | |
88 LIBVO_EXTERN(macosx) | |
89 | |
90 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) | |
91 { | |
92 switch (image_format) | |
93 { | |
94 case IMGFMT_RGB32: | |
95 vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*image_width+x0),4*image_width); | |
96 break; | |
97 case IMGFMT_YUY2: | |
98 vo_draw_alpha_yuy2(w,h,src,srca,stride,image_data + (x0 + y0 * image_width) * 2,image_width*2); | |
99 break; | |
100 } | |
101 } | |
102 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
103 static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
15289 | 104 { |
16385 | 105 |
15728 | 106 //init screen |
107 screen_array = [NSScreen screens]; | |
108 if(screen_id < [screen_array count]) | |
15289 | 109 { |
15728 | 110 screen_handle = [screen_array objectAtIndex:screen_id]; |
15289 | 111 } |
15728 | 112 else |
113 { | |
114 mp_msg(MSGT_VO, MSGL_FATAL, "Get device error: Device ID %d do not exist, falling back to main device.\n", screen_id); | |
115 screen_handle = [screen_array objectAtIndex:0]; | |
116 screen_id = 0; | |
117 } | |
118 screen_frame = [screen_handle frame]; | |
25414
5c03a9bdf220
Record screen size and display size in vo_ variables.
ulion
parents:
25413
diff
changeset
|
119 vo_screenwidth = screen_frame.size.width; |
5c03a9bdf220
Record screen size and display size in vo_ variables.
ulion
parents:
25413
diff
changeset
|
120 vo_screenheight = screen_frame.size.height; |
16385 | 121 |
15289 | 122 //misc mplayer setup |
123 image_width = width; | |
124 image_height = height; | |
125 switch (image_format) | |
126 { | |
127 case IMGFMT_BGR32: | |
128 case IMGFMT_RGB32: | |
129 image_depth = 32; | |
130 break; | |
16385 | 131 case IMGFMT_YUY2: |
15289 | 132 image_depth = 16; |
133 break; | |
134 } | |
135 image_bytes = (image_depth + 7) / 8; | |
16385 | 136 |
137 if(!shared_buffer) | |
138 { | |
25120
9b4ca4dc1294
Fix a memory leak when working in shared_buffer mode.
ulion
parents:
25114
diff
changeset
|
139 image_data = malloc(image_width*image_height*image_bytes); |
25180 | 140 image_datas[0] = image_data; |
141 if (vo_doublebuffering) | |
142 image_datas[1] = malloc(image_width*image_height*image_bytes); | |
143 image_page = 0; | |
25120
9b4ca4dc1294
Fix a memory leak when working in shared_buffer mode.
ulion
parents:
25114
diff
changeset
|
144 |
16385 | 145 monitor_aspect = (float)screen_frame.size.width/(float)screen_frame.size.height; |
146 | |
147 //set aspect | |
148 panscan_init(); | |
149 aspect_save_orig(width,height); | |
150 aspect_save_prescale(d_width,d_height); | |
151 aspect_save_screenres(screen_frame.size.width, screen_frame.size.height); | |
152 aspect((int *)&d_width,(int *)&d_height,A_NOZOOM); | |
153 | |
154 movie_aspect = (float)d_width/(float)d_height; | |
155 old_movie_aspect = movie_aspect; | |
15726 | 156 |
16385 | 157 vo_fs = flags & VOFLAG_FULLSCREEN; |
158 | |
159 //config OpenGL View | |
160 [mpGLView config]; | |
161 [mpGLView reshape]; | |
162 } | |
163 else | |
164 { | |
165 movie_aspect = (float)d_width/(float)d_height; | |
28016
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
166 |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
167 // create shared memory |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
168 shm_fd = shm_open("mplayerosx", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
169 if (shm_fd == -1) |
16385 | 170 { |
28016
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
171 mp_msg(MSGT_VO, MSGL_FATAL, |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
172 "vo_macosx: failed to open shared memory. Error: %s\n", strerror(errno)); |
16385 | 173 return 1; |
174 } | |
175 | |
28016
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
176 |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
177 if (ftruncate(shm_fd, image_width*image_height*image_bytes) == -1) |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
178 { |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
179 mp_msg(MSGT_VO, MSGL_FATAL, |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
180 "vo_macosx: failed to size shared memory, possibly already in use. Error: %s\n", strerror(errno)); |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
181 shm_unlink("mplayerosx"); |
16385 | 182 return 1; |
183 } | |
184 | |
28016
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
185 image_data = mmap(NULL, image_width*image_height*image_bytes, |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
186 PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
187 |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
188 if (image_data == MAP_FAILED) |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
189 { |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
190 mp_msg(MSGT_VO, MSGL_FATAL, |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
191 "vo_macosx: failed to map shared memory. Error: %s\n", strerror(errno)); |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
192 shm_unlink("mplayerosx"); |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
193 return 1; |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
194 } |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
195 |
16385 | 196 //connnect to mplayerosx |
197 mplayerosxProxy=[NSConnection rootProxyForConnectionWithRegisteredName:@"mplayerosx" host:nil]; | |
25157
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
198 if ([mplayerosxProxy conformsToProtocol:@protocol(MPlayerOSXVOProto)]) { |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
199 [mplayerosxProxy setProtocolForProxy:@protocol(MPlayerOSXVOProto)]; |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
200 mplayerosxProto = (id <MPlayerOSXVOProto>)mplayerosxProxy; |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
201 [mplayerosxProto startWithWidth: image_width withHeight: image_height withBytes: image_bytes withAspect:(int)(movie_aspect*100)]; |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
202 } |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
203 else { |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
204 [mplayerosxProxy release]; |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
205 mplayerosxProxy = nil; |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
206 mplayerosxProto = nil; |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
207 } |
16385 | 208 } |
15289 | 209 return 0; |
210 } | |
211 | |
212 static void check_events(void) | |
213 { | |
15611 | 214 [mpGLView check_events]; |
15289 | 215 } |
216 | |
217 static void draw_osd(void) | |
218 { | |
219 vo_draw_text(image_width, image_height, draw_alpha); | |
220 } | |
221 | |
222 static void flip_page(void) | |
223 { | |
16385 | 224 if(shared_buffer) |
25157
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
225 [mplayerosxProto render]; |
25114
bed4188998ca
Move the setCurrentTexture call into flip_page(), fix osd flicker problem.
ulion
parents:
25078
diff
changeset
|
226 else { |
bed4188998ca
Move the setCurrentTexture call into flip_page(), fix osd flicker problem.
ulion
parents:
25078
diff
changeset
|
227 [mpGLView setCurrentTexture]; |
16385 | 228 [mpGLView render]; |
25180 | 229 if (vo_doublebuffering) { |
230 image_page = 1 - image_page; | |
231 image_data = image_datas[image_page]; | |
232 } | |
25114
bed4188998ca
Move the setCurrentTexture call into flip_page(), fix osd flicker problem.
ulion
parents:
25078
diff
changeset
|
233 } |
15289 | 234 } |
235 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
236 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) |
15289 | 237 { |
238 return 0; | |
239 } | |
240 | |
241 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
242 static int draw_frame(uint8_t *src[]) |
15289 | 243 { |
244 switch (image_format) | |
245 { | |
246 case IMGFMT_BGR32: | |
247 case IMGFMT_RGB32: | |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23381
diff
changeset
|
248 fast_memcpy(image_data, src[0], image_width*image_height*image_bytes); |
15289 | 249 break; |
250 | |
251 case IMGFMT_YUY2: | |
252 memcpy_pic(image_data, src[0], image_width * 2, image_height, image_width * 2, image_width * 2); | |
253 break; | |
254 } | |
16385 | 255 |
15289 | 256 return 0; |
257 } | |
258 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
259 static int query_format(uint32_t format) |
15289 | 260 { |
261 image_format = format; | |
262 | |
263 switch(format) | |
264 { | |
265 case IMGFMT_YUY2: | |
266 pixelFormat = kYUVSPixelFormat; | |
267 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; | |
268 | |
269 case IMGFMT_RGB32: | |
270 case IMGFMT_BGR32: | |
271 pixelFormat = k32ARGBPixelFormat; | |
272 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; | |
273 } | |
274 return 0; | |
275 } | |
276 | |
277 static void uninit(void) | |
278 { | |
16385 | 279 if(shared_buffer) |
280 { | |
25157
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
281 [mplayerosxProto stop]; |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
282 mplayerosxProto = nil; |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
283 [mplayerosxProxy release]; |
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
284 mplayerosxProxy = nil; |
28016
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
285 |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
286 if (munmap(image_data, image_width*image_height*image_bytes) == -1) |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
287 mp_msg(MSGT_VO, MSGL_FATAL, "uninit: munmap failed. Error: %s\n", strerror(errno)); |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
288 |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
289 if (shm_unlink("mplayerosx") == -1) |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
290 mp_msg(MSGT_VO, MSGL_FATAL, "uninit: shm_unlink failed. Error: %s\n", strerror(errno)); |
3b8e66828e10
use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents:
28010
diff
changeset
|
291 |
16385 | 292 } |
293 | |
21551 | 294 SetSystemUIMode( kUIModeNormal, 0); |
295 CGDisplayShowCursor(kCGDirectMainDisplay); | |
296 | |
297 if(mpGLView) | |
298 { | |
25136 | 299 NSAutoreleasePool *finalPool; |
24742
0bef706332b5
Fix deallocate bug which sometimes causes a crash when reinitializing.
nplourde
parents:
24698
diff
changeset
|
300 mpGLView = nil; |
21551 | 301 [autoreleasepool release]; |
25136 | 302 finalPool = [[NSAutoreleasePool alloc] init]; |
25078
3efbdaab822f
Let NSApp handle events when uninit to fix the delay dealloc bug of mpGLView.
ulion
parents:
24965
diff
changeset
|
303 [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]; |
3efbdaab822f
Let NSApp handle events when uninit to fix the delay dealloc bug of mpGLView.
ulion
parents:
24965
diff
changeset
|
304 [finalPool release]; |
21551 | 305 } |
25121 | 306 if (!shared_buffer) |
307 { | |
25180 | 308 free(image_datas[0]); |
309 if (vo_doublebuffering) | |
310 free(image_datas[1]); | |
311 image_datas[0] = NULL; | |
312 image_datas[1] = NULL; | |
25121 | 313 image_data = NULL; |
314 } | |
15289 | 315 } |
316 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
317 static int preinit(const char *arg) |
15289 | 318 { |
319 int parse_err = 0; | |
320 | |
15728 | 321 if(arg) |
322 { | |
323 char *parse_pos = (char *)&arg[0]; | |
324 while (parse_pos[0] && !parse_err) | |
325 { | |
326 if (strncmp (parse_pos, "device_id=", 10) == 0) | |
327 { | |
328 parse_pos = &parse_pos[10]; | |
329 screen_id = strtol(parse_pos, &parse_pos, 0); | |
330 screen_force = YES; | |
331 } | |
16385 | 332 if (strncmp (parse_pos, "shared_buffer", 13) == 0) |
333 { | |
334 parse_pos = &parse_pos[13]; | |
335 shared_buffer = YES; | |
336 } | |
15728 | 337 if (parse_pos[0] == ':') parse_pos = &parse_pos[1]; |
338 else if (parse_pos[0]) parse_err = 1; | |
339 } | |
340 } | |
341 | |
15737
0c3939433cef
set nsapp and setup cocoa with NSApplicationLoad
nplourde
parents:
15736
diff
changeset
|
342 NSApplicationLoad(); |
15289 | 343 autoreleasepool = [[NSAutoreleasePool alloc] init]; |
15737
0c3939433cef
set nsapp and setup cocoa with NSApplicationLoad
nplourde
parents:
15736
diff
changeset
|
344 NSApp = [NSApplication sharedApplication]; |
25179
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
345 isLeopardOrLater = floor(NSAppKitVersionNumber) > 824; |
15726 | 346 |
16385 | 347 if(!shared_buffer) |
16144 | 348 { |
27397
d47744b95b78
Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents:
27394
diff
changeset
|
349 #if !defined (CONFIG_MACOSX_FINDER) || !defined (CONFIG_SDL) |
17358
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
350 //this chunk of code is heavily based off SDL_macosx.m from SDL |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
351 ProcessSerialNumber myProc, frProc; |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
352 Boolean sameProc; |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
353 |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
354 if (GetFrontProcess(&frProc) == noErr) |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
355 { |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
356 if (GetCurrentProcess(&myProc) == noErr) |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
357 { |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
358 if (SameProcess(&frProc, &myProc, &sameProc) == noErr && !sameProc) |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
359 { |
27988 | 360 TransformProcessType(&myProc, kProcessTransformToForegroundApplication); |
17358
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
361 } |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
362 SetFrontProcess(&myProc); |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
363 } |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
364 } |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
365 #endif |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
366 |
16385 | 367 if(!mpGLView) |
368 { | |
369 mpGLView = [[MPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat:[MPlayerOpenGLView defaultPixelFormat]]; | |
370 [mpGLView autorelease]; | |
371 } | |
372 | |
373 [mpGLView display]; | |
374 [mpGLView preinit]; | |
16144 | 375 } |
376 | |
15289 | 377 return 0; |
378 } | |
379 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
380 static int control(uint32_t request, void *data, ...) |
15289 | 381 { |
382 switch (request) | |
383 { | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
25468
diff
changeset
|
384 case VOCTRL_PAUSE: return int_pause = 1; |
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
25468
diff
changeset
|
385 case VOCTRL_RESUME: return int_pause = 0; |
15289 | 386 case VOCTRL_QUERY_FORMAT: return query_format(*((uint32_t*)data)); |
25157
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
387 case VOCTRL_ONTOP: vo_ontop = (!(vo_ontop)); if(!shared_buffer){ [mpGLView ontop]; } else { [mplayerosxProto ontop]; } return VO_TRUE; |
15611 | 388 case VOCTRL_ROOTWIN: vo_rootwin = (!(vo_rootwin)); [mpGLView rootwin]; return VO_TRUE; |
25157
cf3b6015735d
Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents:
25137
diff
changeset
|
389 case VOCTRL_FULLSCREEN: vo_fs = (!(vo_fs)); if(!shared_buffer){ [mpGLView fullscreen: NO]; } else { [mplayerosxProto toggleFullscreen]; } return VO_TRUE; |
15289 | 390 case VOCTRL_GET_PANSCAN: return VO_TRUE; |
15611 | 391 case VOCTRL_SET_PANSCAN: [mpGLView panscan]; return VO_TRUE; |
15289 | 392 } |
393 return VO_NOTIMPL; | |
394 } | |
395 | |
396 ////////////////////////////////////////////////////////////////////////// | |
397 // NSOpenGLView Subclass | |
398 ////////////////////////////////////////////////////////////////////////// | |
15611 | 399 @implementation MPlayerOpenGLView |
24076 | 400 - (void) preinit |
15289 | 401 { |
15726 | 402 //init menu |
403 [self initMenu]; | |
404 | |
405 //create window | |
15747
fbf14e1ab725
osx 10.3 dont like to have a window init with no size
nplourde
parents:
15737
diff
changeset
|
406 window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100) |
15726 | 407 styleMask:NSTitledWindowMask|NSTexturedBackgroundWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask |
408 backing:NSBackingStoreBuffered defer:NO]; | |
409 | |
16144 | 410 [window autorelease]; |
15726 | 411 [window setDelegate:mpGLView]; |
412 [window setContentView:mpGLView]; | |
413 [window setInitialFirstResponder:mpGLView]; | |
414 [window setAcceptsMouseMovedEvents:YES]; | |
415 [window setTitle:@"MPlayer - The Movie Player"]; | |
416 | |
417 isFullscreen = 0; | |
15855 | 418 winSizeMult = 1; |
15726 | 419 } |
420 | |
24076 | 421 - (void) config |
15726 | 422 { |
423 uint32_t d_width; | |
424 uint32_t d_height; | |
425 | |
25137 | 426 GLint swapInterval = 1; |
15726 | 427 |
428 NSRect frame; | |
15289 | 429 CVReturn error = kCVReturnSuccess; |
430 | |
15728 | 431 //config window |
15726 | 432 aspect((int *)&d_width, (int *)&d_height,A_NOZOOM); |
433 frame = NSMakeRect(0, 0, d_width, d_height); | |
434 [window setContentSize: frame.size]; | |
15570 | 435 |
15289 | 436 //create OpenGL Context |
437 glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil]; | |
15647 | 438 |
15289 | 439 [self setOpenGLContext:glContext]; |
15647 | 440 [glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; |
15289 | 441 [glContext setView:self]; |
442 [glContext makeCurrentContext]; | |
443 | |
25180 | 444 error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[0], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[0]); |
15289 | 445 if(error != kCVReturnSuccess) |
446 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create Pixel Buffer(%d)\n", error); | |
25180 | 447 if (vo_doublebuffering) { |
448 error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[1], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[1]); | |
449 if(error != kCVReturnSuccess) | |
450 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create Pixel Double Buffer(%d)\n", error); | |
451 } | |
15289 | 452 |
453 error = CVOpenGLTextureCacheCreate(NULL, 0, [glContext CGLContextObj], [[self pixelFormat] CGLPixelFormatObj], 0, &textureCache); | |
454 if(error != kCVReturnSuccess) | |
455 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture Cache(%d)\n", error); | |
456 | |
25180 | 457 error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture); |
15289 | 458 if(error != kCVReturnSuccess) |
459 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error); | |
460 | |
15728 | 461 //show window |
462 [window center]; | |
463 [window makeKeyAndOrderFront:mpGLView]; | |
464 | |
15726 | 465 if(vo_rootwin) |
466 [mpGLView rootwin]; | |
467 | |
468 if(vo_fs) | |
469 [mpGLView fullscreen: NO]; | |
470 | |
471 if(vo_ontop) | |
472 [mpGLView ontop]; | |
15289 | 473 } |
474 | |
475 /* | |
15570 | 476 Init Menu |
477 */ | |
478 - (void)initMenu | |
479 { | |
21395 | 480 NSMenu *menu, *aspectMenu; |
15570 | 481 NSMenuItem *menuItem; |
482 | |
483 [NSApp setMainMenu:[[NSMenu alloc] init]]; | |
484 | |
485 //Create Movie Menu | |
486 menu = [[NSMenu alloc] initWithTitle:@"Movie"]; | |
487 menuItem = [[NSMenuItem alloc] initWithTitle:@"Half Size" action:@selector(menuAction:) keyEquivalent:@"0"]; [menu addItem:menuItem]; | |
488 kHalfScreenCmd = menuItem; | |
489 menuItem = [[NSMenuItem alloc] initWithTitle:@"Normal Size" action:@selector(menuAction:) keyEquivalent:@"1"]; [menu addItem:menuItem]; | |
490 kNormalScreenCmd = menuItem; | |
491 menuItem = [[NSMenuItem alloc] initWithTitle:@"Double Size" action:@selector(menuAction:) keyEquivalent:@"2"]; [menu addItem:menuItem]; | |
492 kDoubleScreenCmd = menuItem; | |
493 menuItem = [[NSMenuItem alloc] initWithTitle:@"Full Size" action:@selector(menuAction:) keyEquivalent:@"f"]; [menu addItem:menuItem]; | |
494 kFullScreenCmd = menuItem; | |
15909 | 495 menuItem = (NSMenuItem *)[NSMenuItem separatorItem]; [menu addItem:menuItem]; |
15570 | 496 |
497 aspectMenu = [[NSMenu alloc] initWithTitle:@"Aspect Ratio"]; | |
498 menuItem = [[NSMenuItem alloc] initWithTitle:@"Keep" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
499 if(vo_keepaspect) [menuItem setState:NSOnState]; | |
500 kKeepAspectCmd = menuItem; | |
501 menuItem = [[NSMenuItem alloc] initWithTitle:@"Pan-Scan" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
502 if(vo_panscan) [menuItem setState:NSOnState]; | |
503 kPanScanCmd = menuItem; | |
15909 | 504 menuItem = (NSMenuItem *)[NSMenuItem separatorItem]; [aspectMenu addItem:menuItem]; |
15570 | 505 menuItem = [[NSMenuItem alloc] initWithTitle:@"Original" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; |
506 kAspectOrgCmd = menuItem; | |
507 menuItem = [[NSMenuItem alloc] initWithTitle:@"4:3" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
508 kAspectFullCmd = menuItem; | |
509 menuItem = [[NSMenuItem alloc] initWithTitle:@"16:9" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
510 kAspectWideCmd = menuItem; | |
511 menuItem = [[NSMenuItem alloc] initWithTitle:@"Aspect Ratio" action:nil keyEquivalent:@""]; | |
512 [menuItem setSubmenu:aspectMenu]; | |
513 [menu addItem:menuItem]; | |
514 [aspectMenu release]; | |
515 | |
516 //Add to menubar | |
517 menuItem = [[NSMenuItem alloc] initWithTitle:@"Movie" action:nil keyEquivalent:@""]; | |
518 [menuItem setSubmenu:menu]; | |
519 [[NSApp mainMenu] addItem:menuItem]; | |
520 | |
521 //Create Window Menu | |
522 menu = [[NSMenu alloc] initWithTitle:@"Window"]; | |
523 | |
524 menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [menu addItem:menuItem]; | |
525 menuItem = [[NSMenuItem alloc] initWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; [menu addItem:menuItem]; | |
526 | |
527 //Add to menubar | |
528 menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; | |
529 [menuItem setSubmenu:menu]; | |
530 [[NSApp mainMenu] addItem:menuItem]; | |
531 [NSApp setWindowsMenu:menu]; | |
532 | |
533 [menu release]; | |
534 [menuItem release]; | |
535 } | |
536 | |
537 /* | |
538 Menu Action | |
539 */ | |
540 - (void)menuAction:(id)sender | |
541 { | |
542 uint32_t d_width; | |
543 uint32_t d_height; | |
544 NSRect frame; | |
545 | |
546 aspect((int *)&d_width, (int *)&d_height,A_NOZOOM); | |
15731 | 547 |
548 if(sender == kQuitCmd) | |
549 { | |
550 mplayer_put_key(KEY_ESC); | |
551 } | |
15570 | 552 |
553 if(sender == kHalfScreenCmd) | |
554 { | |
555 if(isFullscreen) { | |
21546
253a1e98bfe3
vo_macosx.m disable window animation when going to fullscreen
nplourde
parents:
21395
diff
changeset
|
556 vo_fs = (!(vo_fs)); [self fullscreen:NO]; |
15570 | 557 } |
558 | |
15855 | 559 winSizeMult = 0.5; |
560 frame.size.width = (d_width*winSizeMult); | |
561 frame.size.height = ((d_width/movie_aspect)*winSizeMult); | |
15570 | 562 [window setContentSize: frame.size]; |
563 [self reshape]; | |
564 } | |
565 if(sender == kNormalScreenCmd) | |
566 { | |
567 if(isFullscreen) { | |
21546
253a1e98bfe3
vo_macosx.m disable window animation when going to fullscreen
nplourde
parents:
21395
diff
changeset
|
568 vo_fs = (!(vo_fs)); [self fullscreen:NO]; |
15570 | 569 } |
570 | |
15855 | 571 winSizeMult = 1; |
15570 | 572 frame.size.width = d_width; |
573 frame.size.height = d_width/movie_aspect; | |
574 [window setContentSize: frame.size]; | |
575 [self reshape]; | |
576 } | |
577 if(sender == kDoubleScreenCmd) | |
578 { | |
579 if(isFullscreen) { | |
21546
253a1e98bfe3
vo_macosx.m disable window animation when going to fullscreen
nplourde
parents:
21395
diff
changeset
|
580 vo_fs = (!(vo_fs)); [self fullscreen:NO]; |
15570 | 581 } |
582 | |
15855 | 583 winSizeMult = 2; |
584 frame.size.width = d_width*winSizeMult; | |
585 frame.size.height = (d_width/movie_aspect)*winSizeMult; | |
15570 | 586 [window setContentSize: frame.size]; |
587 [self reshape]; | |
588 } | |
589 if(sender == kFullScreenCmd) | |
590 { | |
591 vo_fs = (!(vo_fs)); | |
21546
253a1e98bfe3
vo_macosx.m disable window animation when going to fullscreen
nplourde
parents:
21395
diff
changeset
|
592 [self fullscreen:NO]; |
15570 | 593 } |
594 | |
595 if(sender == kKeepAspectCmd) | |
596 { | |
597 vo_keepaspect = (!(vo_keepaspect)); | |
598 if(vo_keepaspect) | |
599 [kKeepAspectCmd setState:NSOnState]; | |
600 else | |
601 [kKeepAspectCmd setState:NSOffState]; | |
15909 | 602 |
603 [self reshape]; | |
15570 | 604 } |
605 | |
606 if(sender == kPanScanCmd) | |
607 { | |
608 vo_panscan = (!(vo_panscan)); | |
609 if(vo_panscan) | |
610 [kPanScanCmd setState:NSOnState]; | |
611 else | |
612 [kPanScanCmd setState:NSOffState]; | |
15902
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
613 |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
614 [self panscan]; |
15570 | 615 } |
616 | |
617 if(sender == kAspectOrgCmd) | |
618 { | |
619 movie_aspect = old_movie_aspect; | |
15902
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
620 |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
621 if(isFullscreen) |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
622 { |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
623 [self reshape]; |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
624 } |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
625 else |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
626 { |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
627 frame.size.width = d_width*winSizeMult; |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
628 frame.size.height = (d_width/movie_aspect)*winSizeMult; |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
629 [window setContentSize: frame.size]; |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
630 [self reshape]; |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
631 } |
15570 | 632 } |
633 | |
634 if(sender == kAspectFullCmd) | |
635 { | |
636 movie_aspect = 4.0f/3.0f; | |
15882 | 637 |
638 if(isFullscreen) | |
639 { | |
640 [self reshape]; | |
641 } | |
642 else | |
643 { | |
644 frame.size.width = d_width*winSizeMult; | |
645 frame.size.height = (d_width/movie_aspect)*winSizeMult; | |
646 [window setContentSize: frame.size]; | |
647 [self reshape]; | |
648 } | |
15570 | 649 } |
650 | |
651 if(sender == kAspectWideCmd) | |
652 { | |
653 movie_aspect = 16.0f/9.0f; | |
15882 | 654 |
655 if(isFullscreen) | |
656 { | |
657 [self reshape]; | |
658 } | |
659 else | |
660 { | |
661 frame.size.width = d_width*winSizeMult; | |
662 frame.size.height = (d_width/movie_aspect)*winSizeMult; | |
663 [window setContentSize: frame.size]; | |
664 [self reshape]; | |
665 } | |
15570 | 666 } |
667 } | |
668 | |
669 /* | |
15289 | 670 Setup OpenGL |
671 */ | |
672 - (void)prepareOpenGL | |
673 { | |
15339 | 674 glEnable(GL_BLEND); |
15289 | 675 glDisable(GL_DEPTH_TEST); |
676 glDepthMask(GL_FALSE); | |
677 glDisable(GL_CULL_FACE); | |
678 [self reshape]; | |
679 } | |
680 | |
681 /* | |
682 reshape OpenGL viewport | |
683 */ | |
684 - (void)reshape | |
685 { | |
686 uint32_t d_width; | |
687 uint32_t d_height; | |
688 float aspectX; | |
689 float aspectY; | |
690 int padding = 0; | |
691 | |
692 NSRect frame = [self frame]; | |
693 | |
694 glViewport(0, 0, frame.size.width, frame.size.height); | |
695 glMatrixMode(GL_PROJECTION); | |
696 glLoadIdentity(); | |
697 glOrtho(0, frame.size.width, frame.size.height, 0, -1.0, 1.0); | |
698 glMatrixMode(GL_MODELVIEW); | |
699 glLoadIdentity(); | |
700 | |
15729 | 701 //set texture frame |
15289 | 702 if(vo_keepaspect) |
703 { | |
15571 | 704 aspect( (int *)&d_width, (int *)&d_height, A_NOZOOM); |
15289 | 705 d_height = ((float)d_width/movie_aspect); |
706 | |
707 aspectX = (float)((float)frame.size.width/(float)d_width); | |
708 aspectY = (float)((float)(frame.size.height)/(float)d_height); | |
709 | |
710 if((d_height*aspectX)>(frame.size.height)) | |
711 { | |
712 padding = (frame.size.width - d_width*aspectY)/2; | |
25424 | 713 textureFrame = NSMakeRect(padding, 0, d_width*aspectY, d_height*aspectY); |
15289 | 714 } |
715 else | |
716 { | |
717 padding = ((frame.size.height) - d_height*aspectX)/2; | |
25424 | 718 textureFrame = NSMakeRect(0, padding, d_width*aspectX, d_height*aspectX); |
15289 | 719 } |
720 } | |
721 else | |
722 { | |
15729 | 723 textureFrame = frame; |
15289 | 724 } |
25446 | 725 vo_dwidth = textureFrame.size.width; |
726 vo_dheight = textureFrame.size.height; | |
15289 | 727 } |
728 | |
729 /* | |
730 Render frame | |
731 */ | |
732 - (void) render | |
733 { | |
21395 | 734 int curTime; |
735 | |
15289 | 736 glClear(GL_COLOR_BUFFER_BIT); |
737 | |
738 glEnable(CVOpenGLTextureGetTarget(texture)); | |
739 glBindTexture(CVOpenGLTextureGetTarget(texture), CVOpenGLTextureGetName(texture)); | |
740 | |
741 glColor3f(1,1,1); | |
742 glBegin(GL_QUADS); | |
15729 | 743 glTexCoord2f(upperLeft[0], upperLeft[1]); glVertex2i( textureFrame.origin.x-(vo_panscan_x >> 1), textureFrame.origin.y-(vo_panscan_y >> 1)); |
25424 | 744 glTexCoord2f(lowerLeft[0], lowerLeft[1]); glVertex2i(textureFrame.origin.x-(vo_panscan_x >> 1), NSMaxY(textureFrame)+(vo_panscan_y >> 1)); |
745 glTexCoord2f(lowerRight[0], lowerRight[1]); glVertex2i(NSMaxX(textureFrame)+(vo_panscan_x >> 1), NSMaxY(textureFrame)+(vo_panscan_y >> 1)); | |
746 glTexCoord2f(upperRight[0], upperRight[1]); glVertex2i(NSMaxX(textureFrame)+(vo_panscan_x >> 1), textureFrame.origin.y-(vo_panscan_y >> 1)); | |
15289 | 747 glEnd(); |
15339 | 748 glDisable(CVOpenGLTextureGetTarget(texture)); |
749 | |
750 //render resize box | |
751 if(!isFullscreen) | |
752 { | |
753 NSRect frame = [self frame]; | |
754 | |
755 glBegin(GL_LINES); | |
756 glColor4f(0.2, 0.2, 0.2, 0.5); | |
757 glVertex2i(frame.size.width-1, frame.size.height-1); glVertex2i(frame.size.width-1, frame.size.height-1); | |
758 glVertex2i(frame.size.width-1, frame.size.height-5); glVertex2i(frame.size.width-5, frame.size.height-1); | |
759 glVertex2i(frame.size.width-1, frame.size.height-9); glVertex2i(frame.size.width-9, frame.size.height-1); | |
760 | |
761 glColor4f(0.4, 0.4, 0.4, 0.5); | |
762 glVertex2i(frame.size.width-1, frame.size.height-2); glVertex2i(frame.size.width-2, frame.size.height-1); | |
763 glVertex2i(frame.size.width-1, frame.size.height-6); glVertex2i(frame.size.width-6, frame.size.height-1); | |
764 glVertex2i(frame.size.width-1, frame.size.height-10); glVertex2i(frame.size.width-10, frame.size.height-1); | |
765 | |
766 glColor4f(0.6, 0.6, 0.6, 0.5); | |
767 glVertex2i(frame.size.width-1, frame.size.height-3); glVertex2i(frame.size.width-3, frame.size.height-1); | |
768 glVertex2i(frame.size.width-1, frame.size.height-7); glVertex2i(frame.size.width-7, frame.size.height-1); | |
769 glVertex2i(frame.size.width-1, frame.size.height-11); glVertex2i(frame.size.width-11, frame.size.height-1); | |
770 glEnd(); | |
771 } | |
15289 | 772 |
773 glFlush(); | |
774 | |
28010
0a0f63090e60
factorize mouse hiding and screensaver disabling code
gpoirier
parents:
28001
diff
changeset
|
775 curTime = TickCount()/60; |
0a0f63090e60
factorize mouse hiding and screensaver disabling code
gpoirier
parents:
28001
diff
changeset
|
776 |
28001 | 777 //auto hide mouse cursor (and future on-screen control?) |
15327 | 778 if(isFullscreen && !mouseHide && !isRootwin) |
15289 | 779 { |
28010
0a0f63090e60
factorize mouse hiding and screensaver disabling code
gpoirier
parents:
28001
diff
changeset
|
780 if( ((curTime - lastMouseHide) >= 5) || (lastMouseHide == 0) ) |
15289 | 781 { |
18057 | 782 CGDisplayHideCursor(kCGDirectMainDisplay); |
28010
0a0f63090e60
factorize mouse hiding and screensaver disabling code
gpoirier
parents:
28001
diff
changeset
|
783 mouseHide = TRUE; |
0a0f63090e60
factorize mouse hiding and screensaver disabling code
gpoirier
parents:
28001
diff
changeset
|
784 lastMouseHide = curTime; |
15289 | 785 } |
786 } | |
17546 | 787 |
17725 | 788 //update activity every 30 seconds to prevent |
17546 | 789 //screensaver from starting up. |
28010
0a0f63090e60
factorize mouse hiding and screensaver disabling code
gpoirier
parents:
28001
diff
changeset
|
790 if( ((curTime - lastScreensaverUpdate) >= 30) || (lastScreensaverUpdate == 0) ) |
17546 | 791 { |
792 UpdateSystemActivity(UsrActivity); | |
28010
0a0f63090e60
factorize mouse hiding and screensaver disabling code
gpoirier
parents:
28001
diff
changeset
|
793 lastScreensaverUpdate = curTime; |
17546 | 794 } |
15289 | 795 } |
796 | |
797 /* | |
798 Create OpenGL texture from current frame & set texco | |
799 */ | |
800 - (void) setCurrentTexture | |
801 { | |
802 CVReturn error = kCVReturnSuccess; | |
803 | |
25180 | 804 error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture); |
15289 | 805 if(error != kCVReturnSuccess) |
806 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error); | |
807 | |
808 CVOpenGLTextureGetCleanTexCoords(texture, lowerLeft, lowerRight, upperRight, upperLeft); | |
809 } | |
810 | |
811 /* | |
812 redraw win rect | |
813 */ | |
814 - (void) drawRect: (NSRect *) bounds | |
815 { | |
816 [self render]; | |
817 } | |
818 | |
819 /* | |
820 Toggle Fullscreen | |
821 */ | |
822 - (void) fullscreen: (BOOL) animate | |
823 { | |
824 static NSRect old_frame; | |
825 static NSRect old_view_frame; | |
15728 | 826 |
15573 | 827 panscan_calc(); |
828 | |
15289 | 829 //go fullscreen |
830 if(vo_fs) | |
831 { | |
15327 | 832 if(!isRootwin) |
833 { | |
15882 | 834 SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); |
18057 | 835 CGDisplayHideCursor(kCGDirectMainDisplay); |
15327 | 836 mouseHide = YES; |
837 } | |
15289 | 838 |
839 old_frame = [window frame]; //save main window size & position | |
25413 | 840 if(screen_force) |
841 screen_frame = [screen_handle frame]; | |
25414
5c03a9bdf220
Record screen size and display size in vo_ variables.
ulion
parents:
25413
diff
changeset
|
842 else { |
25413 | 843 screen_frame = [[window screen] frame]; |
25414
5c03a9bdf220
Record screen size and display size in vo_ variables.
ulion
parents:
25413
diff
changeset
|
844 vo_screenwidth = screen_frame.size.width; |
5c03a9bdf220
Record screen size and display size in vo_ variables.
ulion
parents:
25413
diff
changeset
|
845 vo_screenheight = screen_frame.size.height; |
5c03a9bdf220
Record screen size and display size in vo_ variables.
ulion
parents:
25413
diff
changeset
|
846 } |
25413 | 847 |
15728 | 848 [window setFrame:screen_frame display:YES animate:animate]; //zoom-in window with nice useless sfx |
15289 | 849 old_view_frame = [self bounds]; |
850 | |
851 //fix origin for multi screen setup | |
15728 | 852 screen_frame.origin.x = 0; |
853 screen_frame.origin.y = 0; | |
854 [self setFrame:screen_frame]; | |
15289 | 855 [self setNeedsDisplay:YES]; |
856 [window setHasShadow:NO]; | |
857 isFullscreen = 1; | |
858 } | |
859 else | |
15882 | 860 { |
15902
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
861 SetSystemUIMode( kUIModeNormal, 0); |
15882 | 862 |
15289 | 863 isFullscreen = 0; |
18057 | 864 CGDisplayShowCursor(kCGDirectMainDisplay); |
15289 | 865 mouseHide = NO; |
866 | |
867 //revert window to previous setting | |
868 [self setFrame:old_view_frame]; | |
869 [self setNeedsDisplay:YES]; | |
16081
72c352edce8f
restore window shadow when quitting fullscreen mode
nplourde
parents:
15909
diff
changeset
|
870 [window setHasShadow:YES]; |
15289 | 871 [window setFrame:old_frame display:YES animate:animate];//zoom-out window with nice useless sfx |
872 } | |
873 } | |
874 | |
875 /* | |
876 Toggle ontop | |
877 */ | |
878 - (void) ontop | |
879 { | |
15320 | 880 if(vo_ontop) |
881 { | |
882 [window setLevel:NSScreenSaverWindowLevel]; | |
883 isOntop = YES; | |
884 } | |
885 else | |
886 { | |
887 [window setLevel:NSNormalWindowLevel]; | |
888 isOntop = NO; | |
889 } | |
15289 | 890 } |
891 | |
892 /* | |
893 Toggle panscan | |
894 */ | |
895 - (void) panscan | |
896 { | |
15331 | 897 panscan_calc(); |
15289 | 898 } |
899 | |
900 /* | |
15327 | 901 Toggle rootwin |
902 */ | |
903 - (void) rootwin | |
904 { | |
905 if(vo_rootwin) | |
906 { | |
907 [window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey)]; | |
908 [window orderBack:self]; | |
909 isRootwin = YES; | |
910 } | |
911 else | |
912 { | |
913 [window setLevel:NSNormalWindowLevel]; | |
914 isRootwin = NO; | |
915 } | |
916 } | |
917 | |
918 /* | |
15289 | 919 Check event for new event |
920 */ | |
921 - (void) check_events | |
922 { | |
923 event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:0.0001] inMode:NSEventTrackingRunLoopMode dequeue:YES]; | |
25178 | 924 if (event == nil) |
925 return; | |
15289 | 926 [NSApp sendEvent:event]; |
25179
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
927 // Without SDL's bootstrap code (include SDL.h in mplayer.c), |
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
928 // on Leopard, we got trouble to get the play window auto focused |
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
929 // when app is actived. Following code fix this problem. |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26755
diff
changeset
|
930 #ifndef CONFIG_SDL |
25179
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
931 if (isLeopardOrLater && [event type] == NSAppKitDefined |
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
932 && [event subtype] == NSApplicationActivatedEventType) { |
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
933 [window makeMainWindow]; |
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
934 [window makeKeyAndOrderFront:mpGLView]; |
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
935 } |
6e8b40d412f0
Fix play window not get actived problem on Leopard.
ulion
parents:
25178
diff
changeset
|
936 #endif |
15289 | 937 } |
938 | |
939 /* | |
15731 | 940 From NSView, respond to key equivalents. |
941 */ | |
942 - (BOOL)performKeyEquivalent:(NSEvent *)theEvent | |
943 { | |
944 switch([theEvent keyCode]) | |
945 { | |
946 case 0x21: [window setAlphaValue: winAlpha-=0.05]; return YES; | |
947 case 0x1e: [window setAlphaValue: winAlpha+=0.05]; return YES; | |
948 } | |
949 return NO; | |
950 } | |
951 | |
952 /* | |
15289 | 953 Process key event |
954 */ | |
955 - (void) keyDown: (NSEvent *) theEvent | |
956 { | |
957 unsigned int key; | |
958 | |
959 switch([theEvent keyCode]) | |
960 { | |
961 case 0x34: | |
962 case 0x24: key = KEY_ENTER; break; | |
963 case 0x35: key = KEY_ESC; break; | |
964 case 0x33: key = KEY_BACKSPACE; break; | |
965 case 0x3A: key = KEY_BACKSPACE; break; | |
966 case 0x3B: key = KEY_BACKSPACE; break; | |
967 case 0x38: key = KEY_BACKSPACE; break; | |
968 case 0x7A: key = KEY_F+1; break; | |
969 case 0x78: key = KEY_F+2; break; | |
970 case 0x63: key = KEY_F+3; break; | |
971 case 0x76: key = KEY_F+4; break; | |
972 case 0x60: key = KEY_F+5; break; | |
973 case 0x61: key = KEY_F+6; break; | |
974 case 0x62: key = KEY_F+7; break; | |
975 case 0x64: key = KEY_F+8; break; | |
976 case 0x65: key = KEY_F+9; break; | |
977 case 0x6D: key = KEY_F+10; break; | |
978 case 0x67: key = KEY_F+11; break; | |
979 case 0x6F: key = KEY_F+12; break; | |
980 case 0x72: key = KEY_INSERT; break; | |
981 case 0x75: key = KEY_DELETE; break; | |
982 case 0x73: key = KEY_HOME; break; | |
983 case 0x77: key = KEY_END; break; | |
984 case 0x45: key = '+'; break; | |
985 case 0x4E: key = '-'; break; | |
986 case 0x30: key = KEY_TAB; break; | |
987 case 0x74: key = KEY_PAGE_UP; break; | |
988 case 0x79: key = KEY_PAGE_DOWN; break; | |
989 case 0x7B: key = KEY_LEFT; break; | |
990 case 0x7C: key = KEY_RIGHT; break; | |
991 case 0x7D: key = KEY_DOWN; break; | |
992 case 0x7E: key = KEY_UP; break; | |
993 case 0x43: key = '*'; break; | |
994 case 0x4B: key = '/'; break; | |
24107 | 995 case 0x4C: key = KEY_KPENTER; break; |
15289 | 996 case 0x41: key = KEY_KPDEC; break; |
997 case 0x52: key = KEY_KP0; break; | |
998 case 0x53: key = KEY_KP1; break; | |
999 case 0x54: key = KEY_KP2; break; | |
1000 case 0x55: key = KEY_KP3; break; | |
1001 case 0x56: key = KEY_KP4; break; | |
1002 case 0x57: key = KEY_KP5; break; | |
1003 case 0x58: key = KEY_KP6; break; | |
1004 case 0x59: key = KEY_KP7; break; | |
1005 case 0x5B: key = KEY_KP8; break; | |
1006 case 0x5C: key = KEY_KP9; break; | |
1007 default: key = *[[theEvent characters] UTF8String]; break; | |
1008 } | |
1009 mplayer_put_key(key); | |
1010 } | |
1011 | |
1012 /* | |
1013 Process mouse button event | |
1014 */ | |
1015 - (void) mouseMoved: (NSEvent *) theEvent | |
1016 { | |
15327 | 1017 if(isFullscreen && !isRootwin) |
15289 | 1018 { |
18057 | 1019 CGDisplayShowCursor(kCGDirectMainDisplay); |
15289 | 1020 mouseHide = NO; |
1021 } | |
25468
a77c438fedf7
Do not send mouse movements events in root win mode.
ulion
parents:
25446
diff
changeset
|
1022 if (enable_mouse_movements && !isRootwin) { |
25446 | 1023 NSPoint p =[self convertPoint:[theEvent locationInWindow] fromView:nil]; |
1024 if ([self mouse:p inRect:textureFrame]) { | |
1025 char cmdstr[40]; | |
1026 snprintf(cmdstr, sizeof(cmdstr), "set_mouse_pos %i %i", | |
1027 (int)(vo_fs ? p.x : (p.x - textureFrame.origin.x)), | |
1028 (int)(vo_fs ? [self frame].size.height - p.y: (NSMaxY(textureFrame) - p.y))); | |
1029 mp_input_queue_cmd(mp_input_parse_cmd(cmdstr)); | |
1030 } | |
1031 } | |
15289 | 1032 } |
1033 | |
1034 - (void) mouseDown: (NSEvent *) theEvent | |
1035 { | |
1036 [self mouseEvent: theEvent]; | |
1037 } | |
1038 | |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1039 - (void) mouseUp: (NSEvent *) theEvent |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1040 { |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1041 [self mouseEvent: theEvent]; |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1042 } |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1043 |
15289 | 1044 - (void) rightMouseDown: (NSEvent *) theEvent |
1045 { | |
1046 [self mouseEvent: theEvent]; | |
1047 } | |
1048 | |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1049 - (void) rightMouseUp: (NSEvent *) theEvent |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1050 { |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1051 [self mouseEvent: theEvent]; |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1052 } |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1053 |
15289 | 1054 - (void) otherMouseDown: (NSEvent *) theEvent |
1055 { | |
1056 [self mouseEvent: theEvent]; | |
1057 } | |
1058 | |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1059 - (void) otherMouseUp: (NSEvent *) theEvent |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1060 { |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1061 [self mouseEvent: theEvent]; |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1062 } |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1063 |
15289 | 1064 - (void) scrollWheel: (NSEvent *) theEvent |
1065 { | |
1066 if([theEvent deltaY] > 0) | |
1067 mplayer_put_key(MOUSE_BTN3); | |
1068 else | |
1069 mplayer_put_key(MOUSE_BTN4); | |
1070 } | |
1071 | |
1072 - (void) mouseEvent: (NSEvent *) theEvent | |
1073 { | |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1074 if ( [theEvent buttonNumber] >= 0 && [theEvent buttonNumber] <= 9 ) |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1075 { |
25422 | 1076 int buttonNumber = [theEvent buttonNumber]; |
1077 // Fix to mplayer defined button order: left, middle, right | |
1078 if (buttonNumber == 1) | |
1079 buttonNumber = 2; | |
25423 | 1080 else if (buttonNumber == 2) |
1081 buttonNumber = 1; | |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1082 switch([theEvent type]) |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1083 { |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1084 case NSLeftMouseDown: |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1085 case NSRightMouseDown: |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1086 case NSOtherMouseDown: |
25422 | 1087 mplayer_put_key((MOUSE_BTN0 + buttonNumber) | MP_KEY_DOWN); |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1088 break; |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1089 case NSLeftMouseUp: |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1090 case NSRightMouseUp: |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1091 case NSOtherMouseUp: |
25422 | 1092 mplayer_put_key(MOUSE_BTN0 + buttonNumber); |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1093 break; |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
1094 } |
15289 | 1095 } |
1096 } | |
1097 | |
1098 /* | |
1099 NSResponder | |
1100 */ | |
1101 - (BOOL) acceptsFirstResponder | |
1102 { | |
1103 return YES; | |
1104 } | |
1105 | |
1106 - (BOOL) becomeFirstResponder | |
1107 { | |
1108 return YES; | |
1109 } | |
1110 | |
1111 - (BOOL) resignFirstResponder | |
1112 { | |
1113 return YES; | |
1114 } | |
15325 | 1115 |
1116 - (void)windowWillClose:(NSNotification *)aNotification | |
1117 { | |
21551 | 1118 mpGLView = NULL; |
15325 | 1119 mplayer_put_key(KEY_ESC); |
1120 } | |
1121 @end |