annotate libvo/vo_corevideo.m @ 36427:960593201c48

Revise German translation of some help messages. Translate 'seek' as 'positionieren'.
author ib
date Fri, 29 Nov 2013 00:26:17 +0000
parents f51965824a2b
children daae52791ca3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
1 /*
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
2 * CoreVideo video output driver
28836
93652f17d567 cosmetics: Reformat file header.
diego
parents: 28446
diff changeset
3 * Copyright (c) 2005 Nicolas Plourde <nicolasplourde@gmail.com>
93652f17d567 cosmetics: Reformat file header.
diego
parents: 28446
diff changeset
4 *
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
5 * This file is part of MPlayer.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
6 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
7 * MPlayer is free software; you can redistribute it and/or modify
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
8 * it under the terms of the GNU General Public License as published by
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
10 * (at your option) any later version.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
11 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
12 * MPlayer is distributed in the hope that it will be useful,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
15 * GNU General Public License for more details.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
16 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
17 * You should have received a copy of the GNU General Public License along
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
18 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
20 */
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28306
diff changeset
21
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
22 #import "vo_corevideo.h"
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
23 #include <sys/types.h>
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
24 #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
25 #include <sys/mman.h>
28077
75925b6d0d51 Add missing unistd.h #include, fixes the warning:
diego
parents: 28076
diff changeset
26 #include <unistd.h>
27988
84bad10e6d8d Allow vo_macosx to be compiled in 64-bits mode:
gpoirier
parents: 27397
diff changeset
27 #include <CoreServices/CoreServices.h>
84bad10e6d8d Allow vo_macosx to be compiled in 64-bits mode:
gpoirier
parents: 27397
diff changeset
28 //special workaround for Apple bug #6267445
84bad10e6d8d Allow vo_macosx to be compiled in 64-bits mode:
gpoirier
parents: 27397
diff changeset
29 //(OSServices Power API disabled in OSServices.h for 64bit systems)
84bad10e6d8d Allow vo_macosx to be compiled in 64-bits mode:
gpoirier
parents: 27397
diff changeset
30 #ifndef __POWER__
84bad10e6d8d Allow vo_macosx to be compiled in 64-bits mode:
gpoirier
parents: 27397
diff changeset
31 #include <CoreServices/../Frameworks/OSServices.framework/Headers/Power.h>
84bad10e6d8d Allow vo_macosx to be compiled in 64-bits mode:
gpoirier
parents: 27397
diff changeset
32 #endif
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
33
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
34 //MPLAYER
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
35 #include "config.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
36 #include "fastmemcpy.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
37 #include "video_out.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
38 #include "video_out_internal.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
39 #include "aspect.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
40 #include "mp_msg.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
41 #include "m_option.h"
28075
ca9badc94740 #include appropriate headers instead of locally declaring function prototypes.
diego
parents: 28051
diff changeset
42 #include "mp_fifo.h"
32471
ba766479d931 vo_corevideo.m: change path for sub.h.
cigaes
parents: 31760
diff changeset
43 #include "sub/sub.h"
28130
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
44 #include "subopt-helper.h"
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
45
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
46 #include "input/input.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
47 #include "input/mouse.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
48
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
49 #include "osdep/keycodes.h"
29533
9c8f8e375823 Reuse the osx_common convert_key function to convert OSX keycodes to MPlayer
reimar
parents: 29272
diff changeset
50 #include "osx_common.h"
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
51
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
52 //Cocoa
35065
9aa803767e6a Add missing "static" to global variables.
reimar
parents: 35057
diff changeset
53 static NSDistantObject *mplayerosxProxy;
9aa803767e6a Add missing "static" to global variables.
reimar
parents: 35057
diff changeset
54 static id <MPlayerOSXVOProto> mplayerosxProto;
9aa803767e6a Add missing "static" to global variables.
reimar
parents: 35057
diff changeset
55 static MPlayerOpenGLView *mpGLView;
9aa803767e6a Add missing "static" to global variables.
reimar
parents: 35057
diff changeset
56 static NSAutoreleasePool *autoreleasepool;
9aa803767e6a Add missing "static" to global variables.
reimar
parents: 35057
diff changeset
57 static OSType pixelFormat;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
58
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
59 //shared memory
35065
9aa803767e6a Add missing "static" to global variables.
reimar
parents: 35057
diff changeset
60 static BOOL shared_buffer = false;
28180
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
61 #define DEFAULT_BUFFER_NAME "mplayerosx"
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
62 static char *buffer_name;
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
63
15728
caa1d0aeffd5 device_id flag force fullscreen device
nplourde
parents: 15727
diff changeset
64 //Screen
35065
9aa803767e6a Add missing "static" to global variables.
reimar
parents: 35057
diff changeset
65 static int screen_id = -1;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
66
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
67 //image
35065
9aa803767e6a Add missing "static" to global variables.
reimar
parents: 35057
diff changeset
68 static unsigned char *image_data;
25180
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
69 // For double buffering
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
70 static uint8_t image_page = 0;
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
71 static unsigned char *image_datas[2];
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
72
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
73 static uint32_t image_width;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
74 static uint32_t image_height;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
75 static uint32_t image_bytes;
34878
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
76 static uint32_t image_stride;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
77 static uint32_t image_format;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
78
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
79 static vo_info_t info =
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
80 {
28837
e5171567fe6c cosmetics: spelling fixes
diego
parents: 28836
diff changeset
81 "Mac OS X Core Video",
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
82 "corevideo",
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
83 "Nicolas Plourde <nicolas.plourde@gmail.com>",
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
84 ""
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
85 };
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
86
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
87 LIBVO_EXTERN(corevideo)
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
88
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
89 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
90 {
34876
c5f89bf5b952 corevideo: Reduce code duplication in OSD rendering code.
reimar
parents: 34875
diff changeset
91 unsigned char *dst = image_data + image_bytes * (y0 * image_width + x0);
35128
9ca71ecd9f48 corevideo: simplify draw_alpha function.
reimar
parents: 35127
diff changeset
92 vo_draw_alpha_func draw = vo_get_draw_alpha(image_format);
9ca71ecd9f48 corevideo: simplify draw_alpha function.
reimar
parents: 35127
diff changeset
93 if (!draw) return;
9ca71ecd9f48 corevideo: simplify draw_alpha function.
reimar
parents: 35127
diff changeset
94 draw(w,h,src,srca,stride,dst,image_stride);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
95 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
96
29573
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
97 static void free_file_specific(void)
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
98 {
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
99 if(shared_buffer)
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
100 {
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
101 [mplayerosxProto stop];
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
102 mplayerosxProto = nil;
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
103 [mplayerosxProxy release];
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
104 mplayerosxProxy = nil;
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
105
34878
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
106 if (munmap(image_data, image_height*image_stride) == -1)
29573
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
107 mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: munmap failed. Error: %s\n", strerror(errno));
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
108
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
109 if (shm_unlink(buffer_name) == -1)
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
110 mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: shm_unlink failed. Error: %s\n", strerror(errno));
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
111 } else {
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
112 free(image_datas[0]);
34875
444a6a469743 Remove unnecessary if, free can be called unconditionally.
reimar
parents: 34825
diff changeset
113 free(image_datas[1]);
29573
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
114 image_datas[0] = NULL;
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
115 image_datas[1] = NULL;
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
116 image_data = NULL;
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
117 }
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
118 }
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
119
35150
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
120 static void update_screen_info_shared_buffer(void)
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
121 {
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
122 NSRect rc = [[NSScreen mainScreen] frame];
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
123 vo_screenwidth = rc.size.width;
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
124 vo_screenheight = rc.size.height;
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
125 xinerama_x = rc.origin.x;
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
126 xinerama_y = rc.origin.y;
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
127 aspect_save_screenres(vo_screenwidth, vo_screenheight);
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
128 }
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
129
29564
4ae3d2d7946e Use MPlayer's standard aspect handling functions in corevideo
reimar
parents: 29533
diff changeset
130 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)
4ae3d2d7946e Use MPlayer's standard aspect handling functions in corevideo
reimar
parents: 29533
diff changeset
131 {
29573
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
132 free_file_specific();
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
133
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
134 //misc mplayer setup
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
135 image_width = width;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
136 image_height = height;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
137 switch (image_format)
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
138 {
30974
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
139 case IMGFMT_RGB24:
34825
5ed9693f8071 Remove pointless global variables.
reimar
parents: 34299
diff changeset
140 image_bytes = 3;
30974
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
141 break;
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
142 case IMGFMT_ARGB:
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
143 case IMGFMT_BGRA:
34825
5ed9693f8071 Remove pointless global variables.
reimar
parents: 34299
diff changeset
144 image_bytes = 4;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
145 break;
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
146 case IMGFMT_YUY2:
35019
c879d6314c11 corevideo: Support also support UYVY.
reimar
parents: 34878
diff changeset
147 case IMGFMT_UYVY:
34825
5ed9693f8071 Remove pointless global variables.
reimar
parents: 34299
diff changeset
148 image_bytes = 2;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
149 break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
150 }
34878
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
151 // should be aligned, but that would break the shared buffer
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
152 image_stride = image_width * image_bytes;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
153
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
154 if(!shared_buffer)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
155 {
34878
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
156 image_data = malloc(image_height*image_stride);
25180
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
157 image_datas[0] = image_data;
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
158 if (vo_doublebuffering)
34878
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
159 image_datas[1] = malloc(image_height*image_stride);
25180
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
160 image_page = 0;
25120
9b4ca4dc1294 Fix a memory leak when working in shared_buffer mode.
ulion
parents: 25114
diff changeset
161
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
162 //config OpenGL View
36267
f51965824a2b Fix missing selector name warnings
upsuper
parents: 36232
diff changeset
163 [mpGLView configWidth:d_width height:d_height flags:flags];
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
164 [mpGLView reshape];
35146
c17eeb84bec7 vo corevideo: Use stringWithUTF8String
al
parents: 35128
diff changeset
165 [[mpGLView window] setTitle:[NSString stringWithUTF8String:vo_wintitle ? vo_wintitle : title]];
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
166 }
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
167 else
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
168 {
29567
349de9bdfcce Make shm_fd a local variable and close it when we need it no longer, thus
reimar
parents: 29566
diff changeset
169 int shm_fd;
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
170 mp_msg(MSGT_VO, MSGL_INFO, "[vo_corevideo] writing output to a shared buffer "
29170
9d40283d9a5d Unify error message output and update error messages.
diego
parents: 29137
diff changeset
171 "named \"%s\"\n",buffer_name);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
172
28016
3b8e66828e10 use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents: 28010
diff changeset
173 // create shared memory
28180
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
174 shm_fd = shm_open(buffer_name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
28016
3b8e66828e10 use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents: 28010
diff changeset
175 if (shm_fd == -1)
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
176 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
177 mp_msg(MSGT_VO, MSGL_FATAL,
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
178 "[vo_corevideo] failed to open shared memory. Error: %s\n", strerror(errno));
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
179 return 1;
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
180 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
181
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
182
34878
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
183 if (ftruncate(shm_fd, image_height*image_stride) == -1)
28016
3b8e66828e10 use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents: 28010
diff changeset
184 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
185 mp_msg(MSGT_VO, MSGL_FATAL,
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
186 "[vo_corevideo] failed to size shared memory, possibly already in use. Error: %s\n", strerror(errno));
29567
349de9bdfcce Make shm_fd a local variable and close it when we need it no longer, thus
reimar
parents: 29566
diff changeset
187 close(shm_fd);
28180
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
188 shm_unlink(buffer_name);
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
189 return 1;
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
190 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
191
34878
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
192 image_data = mmap(NULL, image_height*image_stride,
28016
3b8e66828e10 use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents: 28010
diff changeset
193 PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
29567
349de9bdfcce Make shm_fd a local variable and close it when we need it no longer, thus
reimar
parents: 29566
diff changeset
194 close(shm_fd);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
195
28016
3b8e66828e10 use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents: 28010
diff changeset
196 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
197 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
198 mp_msg(MSGT_VO, MSGL_FATAL,
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
199 "[vo_corevideo] failed to map shared memory. Error: %s\n", strerror(errno));
28180
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
200 shm_unlink(buffer_name);
28016
3b8e66828e10 use mmap instead of shmat for MPlayerOSX, patch by Adrian Stutz<adrian@sttz.ch>
nplourde
parents: 28010
diff changeset
201 return 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
202 }
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
203
28837
e5171567fe6c cosmetics: spelling fixes
diego
parents: 28836
diff changeset
204 //connect to mplayerosx
35146
c17eeb84bec7 vo corevideo: Use stringWithUTF8String
al
parents: 35128
diff changeset
205 mplayerosxProxy=[NSConnection rootProxyForConnectionWithRegisteredName:[NSString stringWithUTF8String:buffer_name] host:nil];
25157
cf3b6015735d Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents: 25137
diff changeset
206 if ([mplayerosxProxy conformsToProtocol:@protocol(MPlayerOSXVOProto)]) {
cf3b6015735d Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents: 25137
diff changeset
207 [mplayerosxProxy setProtocolForProxy:@protocol(MPlayerOSXVOProto)];
cf3b6015735d Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents: 25137
diff changeset
208 mplayerosxProto = (id <MPlayerOSXVOProto>)mplayerosxProxy;
29564
4ae3d2d7946e Use MPlayer's standard aspect handling functions in corevideo
reimar
parents: 29533
diff changeset
209 [mplayerosxProto startWithWidth: image_width withHeight: image_height withBytes: image_bytes withAspect:d_width*100/d_height];
25157
cf3b6015735d Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents: 25137
diff changeset
210 }
cf3b6015735d Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents: 25137
diff changeset
211 else {
cf3b6015735d Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents: 25137
diff changeset
212 [mplayerosxProxy release];
cf3b6015735d Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents: 25137
diff changeset
213 mplayerosxProxy = nil;
cf3b6015735d Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents: 25137
diff changeset
214 mplayerosxProto = nil;
cf3b6015735d Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents: 25137
diff changeset
215 }
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
216 }
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
217 return 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
218 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
219
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
220 static void check_events(void)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
221 {
29272
c95bad660986 When used with shared_buffer, there's no need for a NSApp object, which causes MPlayer to be marked as unresponsive.
adrian
parents: 29271
diff changeset
222 if (mpGLView)
c95bad660986 When used with shared_buffer, there's no need for a NSApp object, which causes MPlayer to be marked as unresponsive.
adrian
parents: 29271
diff changeset
223 [mpGLView check_events];
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
224 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
225
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
226 static void draw_osd(void)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
227 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
228 vo_draw_text(image_width, image_height, draw_alpha);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
229 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
230
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
231 static void flip_page(void)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
232 {
29271
82b6fbc72099 When used with shared_buffer, autorelease in each flip_page so objects don't accumulate until exit.
adrian
parents: 29263
diff changeset
233 if(shared_buffer) {
82b6fbc72099 When used with shared_buffer, autorelease in each flip_page so objects don't accumulate until exit.
adrian
parents: 29263
diff changeset
234 NSAutoreleasePool *pool = [NSAutoreleasePool new];
25157
cf3b6015735d Set protocol for the vo proxy used in shared-buffer mode.
ulion
parents: 25137
diff changeset
235 [mplayerosxProto render];
29271
82b6fbc72099 When used with shared_buffer, autorelease in each flip_page so objects don't accumulate until exit.
adrian
parents: 29263
diff changeset
236 [pool release];
82b6fbc72099 When used with shared_buffer, autorelease in each flip_page so objects don't accumulate until exit.
adrian
parents: 29263
diff changeset
237 } else {
25114
bed4188998ca Move the setCurrentTexture call into flip_page(), fix osd flicker problem.
ulion
parents: 25078
diff changeset
238 [mpGLView setCurrentTexture];
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
239 [mpGLView render];
25180
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
240 if (vo_doublebuffering) {
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
241 image_page = 1 - image_page;
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
242 image_data = image_datas[image_page];
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
243 }
25114
bed4188998ca Move the setCurrentTexture call into flip_page(), fix osd flicker problem.
ulion
parents: 25078
diff changeset
244 }
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
245 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
246
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 16145
diff changeset
247 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
248 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
249 return 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
250 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
251
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
252
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 16145
diff changeset
253 static int draw_frame(uint8_t *src[])
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
254 {
30972
886527159cae Implement VOCTRL_DRAW_IMAGE instead of the deprecated draw_frame, avoiding
reimar
parents: 30922
diff changeset
255 return 0;
886527159cae Implement VOCTRL_DRAW_IMAGE instead of the deprecated draw_frame, avoiding
reimar
parents: 30922
diff changeset
256 }
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
257
30972
886527159cae Implement VOCTRL_DRAW_IMAGE instead of the deprecated draw_frame, avoiding
reimar
parents: 30922
diff changeset
258 static uint32_t draw_image(mp_image_t *mpi)
886527159cae Implement VOCTRL_DRAW_IMAGE instead of the deprecated draw_frame, avoiding
reimar
parents: 30922
diff changeset
259 {
35057
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
260 if (!(mpi->flags & MP_IMGFLAG_DIRECT))
34878
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
261 memcpy_pic(image_data, mpi->planes[0], image_width*image_bytes, image_height, image_stride, mpi->stride[0]);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
262
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
263 return 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
264 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
265
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 16145
diff changeset
266 static int query_format(uint32_t format)
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
267 {
30974
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
268 const int supportflags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
269 image_format = format;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
270
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
271 switch(format)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
272 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
273 case IMGFMT_YUY2:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
274 pixelFormat = kYUVSPixelFormat;
30974
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
275 return supportflags;
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
276
35019
c879d6314c11 corevideo: Support also support UYVY.
reimar
parents: 34878
diff changeset
277 case IMGFMT_UYVY:
c879d6314c11 corevideo: Support also support UYVY.
reimar
parents: 34878
diff changeset
278 pixelFormat = k2vuyPixelFormat;
c879d6314c11 corevideo: Support also support UYVY.
reimar
parents: 34878
diff changeset
279 return supportflags;
c879d6314c11 corevideo: Support also support UYVY.
reimar
parents: 34878
diff changeset
280
30974
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
281 case IMGFMT_RGB24:
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
282 pixelFormat = k24RGBPixelFormat;
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
283 return supportflags;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
284
30974
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
285 case IMGFMT_ARGB:
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
286 pixelFormat = k32ARGBPixelFormat;
30974
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
287 return supportflags;
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
288
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
289 case IMGFMT_BGRA:
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
290 pixelFormat = k32BGRAPixelFormat;
bd964ca1f6fa Fix RGB support for corevideo: corevideo can only support
reimar
parents: 30973
diff changeset
291 return supportflags;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
292 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
293 return 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
294 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
295
35057
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
296 static int get_image(mp_image_t *mpi)
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
297 {
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
298 if (!(mpi->flags & (MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_ACCEPT_WIDTH)) ||
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
299 (mpi->type != MP_IMGTYPE_TEMP && mpi->type != MP_IMGTYPE_STATIC))
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
300 return VO_FALSE;
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
301
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
302 // mpi should not be planar format here
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
303 mpi->planes[0] = image_data;
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
304 mpi->stride[0] = image_stride;
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
305 mpi->flags |= MP_IMGFLAG_DIRECT;
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
306 mpi->flags &= ~MP_IMGFLAG_DRAW_CALLBACK;
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
307 return VO_TRUE;
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
308 }
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
309
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
310 static void uninit(void)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
311 {
21551
c35115c05c64 vo_macosx, fix crash when closing window
nplourde
parents: 21546
diff changeset
312 SetSystemUIMode( kUIModeNormal, 0);
c35115c05c64 vo_macosx, fix crash when closing window
nplourde
parents: 21546
diff changeset
313 CGDisplayShowCursor(kCGDirectMainDisplay);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
314
29573
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
315 free_file_specific();
2b14be337eaf Fix some of the major memleaks of vo_corevideo with -fixed-vo
reimar
parents: 29567
diff changeset
316
21551
c35115c05c64 vo_macosx, fix crash when closing window
nplourde
parents: 21546
diff changeset
317 if(mpGLView)
c35115c05c64 vo_macosx, fix crash when closing window
nplourde
parents: 21546
diff changeset
318 {
25136
e029d2fcd20f Fix warning:
ulion
parents: 25121
diff changeset
319 NSAutoreleasePool *finalPool;
24742
0bef706332b5 Fix deallocate bug which sometimes causes a crash when reinitializing.
nplourde
parents: 24698
diff changeset
320 mpGLView = nil;
21551
c35115c05c64 vo_macosx, fix crash when closing window
nplourde
parents: 21546
diff changeset
321 [autoreleasepool release];
25136
e029d2fcd20f Fix warning:
ulion
parents: 25121
diff changeset
322 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
323 [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
324 [finalPool release];
21551
c35115c05c64 vo_macosx, fix crash when closing window
nplourde
parents: 21546
diff changeset
325 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
326
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32471
diff changeset
327 free(buffer_name);
28180
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
328 buffer_name = NULL;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
329 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
330
29603
4c81686ad728 Subopt parser subopts should now be const.
reimar
parents: 29575
diff changeset
331 static const opt_t subopts[] = {
28306
19cf626f188a fix device_id option after r28165
gpoirier
parents: 28204
diff changeset
332 {"device_id", OPT_ARG_INT, &screen_id, NULL},
28130
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
333 {"shared_buffer", OPT_ARG_BOOL, &shared_buffer, NULL},
28180
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
334 {"buffer_name", OPT_ARG_MSTRZ,&buffer_name, NULL},
28130
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
335 {NULL}
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
336 };
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
337
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 16145
diff changeset
338 static int preinit(const char *arg)
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
339 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
340
28130
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
341 // set defaults
28306
19cf626f188a fix device_id option after r28165
gpoirier
parents: 28204
diff changeset
342 screen_id = -1;
28130
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
343 shared_buffer = false;
28204
ec9c4610f10f Fix deinit problem due to r28215
gpoirier
parents: 28180
diff changeset
344 buffer_name = NULL;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
345
28130
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
346 if (subopt_parse(arg, subopts) != 0) {
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
347 mp_msg(MSGT_VO, MSGL_FATAL,
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
348 "\n-vo corevideo command line help:\n"
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
349 "Example: mplayer -vo corevideo:device_id=1:shared_buffer:buffer_name=mybuff\n"
28130
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
350 "\nOptions:\n"
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
351 " device_id=<0-...>\n"
35074
3fb18ad99003 Deprecate corevideo device_id in favour of -xineramascreen.
reimar
parents: 35073
diff changeset
352 " DEPRECATED, use -xineramascreen instead.\n"
28837
e5171567fe6c cosmetics: spelling fixes
diego
parents: 28836
diff changeset
353 " Set screen device ID for fullscreen.\n"
28130
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
354 " shared_buffer\n"
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
355 " Write output to a shared memory buffer instead of displaying it.\n"
28180
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
356 " buffer_name=<name>\n"
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
357 " Name of the shared buffer created with shm_open() as well as\n"
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
358 " the name of the NSConnection MPlayer will try to open.\n"
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
359 " Setting buffer_name implicitly enables shared_buffer.\n"
28130
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
360 "\n" );
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
361 return -1;
b5898cb411da Replace vo_macosx's custom options parsing with a subopt_parse()-based one
gpoirier
parents: 28077
diff changeset
362 }
15728
caa1d0aeffd5 device_id flag force fullscreen device
nplourde
parents: 15727
diff changeset
363
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
364 autoreleasepool = [[NSAutoreleasePool alloc] init];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
365
35074
3fb18ad99003 Deprecate corevideo device_id in favour of -xineramascreen.
reimar
parents: 35073
diff changeset
366 if (screen_id != -1)
3fb18ad99003 Deprecate corevideo device_id in favour of -xineramascreen.
reimar
parents: 35073
diff changeset
367 xinerama_screen = screen_id;
3fb18ad99003 Deprecate corevideo device_id in favour of -xineramascreen.
reimar
parents: 35073
diff changeset
368
28204
ec9c4610f10f Fix deinit problem due to r28215
gpoirier
parents: 28180
diff changeset
369 if (!buffer_name)
ec9c4610f10f Fix deinit problem due to r28215
gpoirier
parents: 28180
diff changeset
370 buffer_name = strdup(DEFAULT_BUFFER_NAME);
ec9c4610f10f Fix deinit problem due to r28215
gpoirier
parents: 28180
diff changeset
371 else
28180
781ef511a767 Add an option to vo_macosx to set a custom buffer_name.
gpoirier
parents: 28130
diff changeset
372 shared_buffer = true;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
373
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
374 if(!shared_buffer)
16144
6ea7c0735fce properly release window
nplourde
parents: 16081
diff changeset
375 {
16385
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
376 if(!mpGLView)
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
377 {
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
378 mpGLView = [[MPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat:[MPlayerOpenGLView defaultPixelFormat]];
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
379 [mpGLView autorelease];
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
380 }
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
381 [mpGLView display];
35b310d35aa0 mplayer osx shared video buffer
nplourde
parents: 16171
diff changeset
382 [mpGLView preinit];
16144
6ea7c0735fce properly release window
nplourde
parents: 16081
diff changeset
383 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
384
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
385 return 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
386 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
387
33330
ad12e6080ed1 Fix compilation for OSX due to r33392 - control() vaarg removal.
iive
parents: 32537
diff changeset
388 static int control(uint32_t request, void *data)
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
389 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
390 switch (request)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
391 {
30972
886527159cae Implement VOCTRL_DRAW_IMAGE instead of the deprecated draw_frame, avoiding
reimar
parents: 30922
diff changeset
392 case VOCTRL_DRAW_IMAGE: return draw_image(data);
31737
38999f9d3c7e Remove yet more useless ()
reimar
parents: 31736
diff changeset
393 case VOCTRL_QUERY_FORMAT: return query_format(*(uint32_t*)data);
35057
08f284d173f6 Support -dr for -vo corevideo.
reimar
parents: 35019
diff changeset
394 case VOCTRL_GET_IMAGE: return get_image(data);
31737
38999f9d3c7e Remove yet more useless ()
reimar
parents: 31736
diff changeset
395 case VOCTRL_ONTOP: vo_ontop = !vo_ontop; if(!shared_buffer){ [mpGLView ontop]; } else { [mplayerosxProto ontop]; } return VO_TRUE;
38999f9d3c7e Remove yet more useless ()
reimar
parents: 31736
diff changeset
396 case VOCTRL_ROOTWIN: vo_rootwin = !vo_rootwin; [mpGLView rootwin]; return VO_TRUE;
38999f9d3c7e Remove yet more useless ()
reimar
parents: 31736
diff changeset
397 case VOCTRL_FULLSCREEN: vo_fs = !vo_fs; if(!shared_buffer){ [mpGLView fullscreen: NO]; } else { [mplayerosxProto toggleFullscreen]; } return VO_TRUE;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
398 case VOCTRL_GET_PANSCAN: return VO_TRUE;
35069
90a2e4fedfab Remove pointless one-line function.
reimar
parents: 35066
diff changeset
399 case VOCTRL_SET_PANSCAN: panscan_calc(); return VO_TRUE;
35150
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
400 case VOCTRL_UPDATE_SCREENINFO:
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
401 if (shared_buffer)
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
402 update_screen_info_shared_buffer();
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
403 else
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
404 [mpGLView update_screen_info];
4683218a0324 vo corevideo: VOCTRL_UPDATE_SCREENINFO: Fix shared_buffer case
al
parents: 35146
diff changeset
405 return VO_TRUE;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
406 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
407 return VO_NOTIMPL;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
408 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
409
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
410 //////////////////////////////////////////////////////////////////////////
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
411 // NSOpenGLView Subclass
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
412 //////////////////////////////////////////////////////////////////////////
15611
2f77a2da1d82 Function name cleanup
nplourde
parents: 15610
diff changeset
413 @implementation MPlayerOpenGLView
24076
7ac48ed8c394 Functions that do not return a value must be void
reimar
parents: 24074
diff changeset
414 - (void) preinit
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
415 {
29566
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
416 CVReturn error;
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
417
35086
8848682f4035 Split out an objective-C common OS X layer, to be reused by -vo gl.
reimar
parents: 35085
diff changeset
418 [super preinit];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
419
35086
8848682f4035 Split out an objective-C common OS X layer, to be reused by -vo gl.
reimar
parents: 35085
diff changeset
420 error = CVOpenGLTextureCacheCreate(NULL, 0, [[self openGLContext] CGLContextObj], [[self pixelFormat] CGLPixelFormatObj], 0, &textureCache);
29566
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
421 if(error != kCVReturnSuccess)
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
422 mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture Cache(%d)\n", error);
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
423 }
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
424
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
425 - (void) releaseVideoSpecific
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
426 {
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
427 CVPixelBufferRelease(frameBuffers[0]);
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
428 frameBuffers[0] = NULL;
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
429 CVPixelBufferRelease(frameBuffers[1]);
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
430 frameBuffers[1] = NULL;
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
431 CVOpenGLTextureRelease(texture);
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
432 texture = NULL;
15726
25ee208c6da9 do not realloc window while playing playlist
nplourde
parents: 15657
diff changeset
433 }
25ee208c6da9 do not realloc window while playing playlist
nplourde
parents: 15657
diff changeset
434
29574
0aa36133f638 Add a dealloc function to corevideo to reduce the memleaks from
reimar
parents: 29573
diff changeset
435 - (void) dealloc
0aa36133f638 Add a dealloc function to corevideo to reduce the memleaks from
reimar
parents: 29573
diff changeset
436 {
0aa36133f638 Add a dealloc function to corevideo to reduce the memleaks from
reimar
parents: 29573
diff changeset
437 [self releaseVideoSpecific];
0aa36133f638 Add a dealloc function to corevideo to reduce the memleaks from
reimar
parents: 29573
diff changeset
438 CVOpenGLTextureCacheRelease(textureCache);
0aa36133f638 Add a dealloc function to corevideo to reduce the memleaks from
reimar
parents: 29573
diff changeset
439 textureCache = NULL;
0aa36133f638 Add a dealloc function to corevideo to reduce the memleaks from
reimar
parents: 29573
diff changeset
440 [super dealloc];
0aa36133f638 Add a dealloc function to corevideo to reduce the memleaks from
reimar
parents: 29573
diff changeset
441 }
0aa36133f638 Add a dealloc function to corevideo to reduce the memleaks from
reimar
parents: 29573
diff changeset
442
36267
f51965824a2b Fix missing selector name warnings
upsuper
parents: 36232
diff changeset
443 - (void) configWidth:(uint32_t)width height:(uint32_t)height flags:(uint32_t)flags
15726
25ee208c6da9 do not realloc window while playing playlist
nplourde
parents: 15657
diff changeset
444 {
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
445 CVReturn error = kCVReturnSuccess;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
446
36267
f51965824a2b Fix missing selector name warnings
upsuper
parents: 36232
diff changeset
447 [super configWidth:width height:height flags:flags];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
448
29566
b128ce47771d Reduce vo_corevideo memleaks by initializing static context etc. only once
reimar
parents: 29564
diff changeset
449 [self releaseVideoSpecific];
34878
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
450 error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[0], image_stride, NULL, NULL, NULL, &frameBuffers[0]);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
451 if(error != kCVReturnSuccess)
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
452 mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Buffer(%d)\n", error);
25180
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
453 if (vo_doublebuffering) {
34878
3e6cfa2053bf Add a separate stride variable to make it easier to optimize later (e.g. align stride).
reimar
parents: 34876
diff changeset
454 error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[1], image_stride, NULL, NULL, NULL, &frameBuffers[1]);
25180
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
455 if(error != kCVReturnSuccess)
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
456 mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Double Buffer(%d)\n", error);
25180
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
457 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
458
25180
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
459 error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
460 if(error != kCVReturnSuccess)
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
461 mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture(%d)\n", error);
15570
f197f4a60b20 create menu
nplourde
parents: 15339
diff changeset
462 }
f197f4a60b20 create menu
nplourde
parents: 15339
diff changeset
463
f197f4a60b20 create menu
nplourde
parents: 15339
diff changeset
464 /*
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
465 Setup OpenGL
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
466 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
467 - (void)prepareOpenGL
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
468 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
469 glEnable(GL_BLEND);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
470 glDisable(GL_DEPTH_TEST);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
471 glDepthMask(GL_FALSE);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
472 glDisable(GL_CULL_FACE);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
473 [self reshape];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
474 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
475
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
476 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
477 reshape OpenGL viewport
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
478 */
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
479 - (void)reshape
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
480 {
31739
923b5da53f65 Declare variables with proper types to avoid dangerous pointer casts.
reimar
parents: 31738
diff changeset
481 int d_width, d_height;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
482
35091
9fcfc9c5f038 gl OSX backend: Detect and pass on resize events
reimar
parents: 35090
diff changeset
483 [super reshape];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
484
35090
bfc7f38d3008 Minor code simplification.
reimar
parents: 35086
diff changeset
485 glViewport(0, 0, vo_dwidth, vo_dheight);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
486 glMatrixMode(GL_PROJECTION);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
487 glLoadIdentity();
35090
bfc7f38d3008 Minor code simplification.
reimar
parents: 35086
diff changeset
488 glOrtho(0, vo_dwidth, vo_dheight, 0, -1.0, 1.0);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
489 glMatrixMode(GL_MODELVIEW);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
490 glLoadIdentity();
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
491
35090
bfc7f38d3008 Minor code simplification.
reimar
parents: 35086
diff changeset
492 d_width = vo_dwidth;
bfc7f38d3008 Minor code simplification.
reimar
parents: 35086
diff changeset
493 d_height = vo_dheight;
15729
55aaeb7b6aae new texture frame
nplourde
parents: 15728
diff changeset
494 //set texture frame
35127
dd8ebdd08791 Use aspect_scaling() function also for vo_corevideo.
reimar
parents: 35091
diff changeset
495 if(aspect_scaling())
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
496 {
31739
923b5da53f65 Declare variables with proper types to avoid dangerous pointer casts.
reimar
parents: 31738
diff changeset
497 aspect(&d_width, &d_height, A_WINZOOM);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
498 }
35090
bfc7f38d3008 Minor code simplification.
reimar
parents: 35086
diff changeset
499 textureFrame = NSMakeRect((vo_dwidth - d_width) / 2, (vo_dheight - d_height) / 2, d_width, d_height);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
500 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
501
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
502 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
503 Render frame
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
504 */
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
505 - (void) render
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
506 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
507 glClear(GL_COLOR_BUFFER_BIT);
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
508
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
509 glEnable(CVOpenGLTextureGetTarget(texture));
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
510 glBindTexture(CVOpenGLTextureGetTarget(texture), CVOpenGLTextureGetName(texture));
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
511
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
512 glColor3f(1,1,1);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
513 glBegin(GL_QUADS);
15729
55aaeb7b6aae new texture frame
nplourde
parents: 15728
diff changeset
514 glTexCoord2f(upperLeft[0], upperLeft[1]); glVertex2i( textureFrame.origin.x-(vo_panscan_x >> 1), textureFrame.origin.y-(vo_panscan_y >> 1));
25424
cf72b0793c67 Use NSMakeRect and NSRect in correct way:
ulion
parents: 25423
diff changeset
515 glTexCoord2f(lowerLeft[0], lowerLeft[1]); glVertex2i(textureFrame.origin.x-(vo_panscan_x >> 1), NSMaxY(textureFrame)+(vo_panscan_y >> 1));
cf72b0793c67 Use NSMakeRect and NSRect in correct way:
ulion
parents: 25423
diff changeset
516 glTexCoord2f(lowerRight[0], lowerRight[1]); glVertex2i(NSMaxX(textureFrame)+(vo_panscan_x >> 1), NSMaxY(textureFrame)+(vo_panscan_y >> 1));
cf72b0793c67 Use NSMakeRect and NSRect in correct way:
ulion
parents: 25423
diff changeset
517 glTexCoord2f(upperRight[0], upperRight[1]); glVertex2i(NSMaxX(textureFrame)+(vo_panscan_x >> 1), textureFrame.origin.y-(vo_panscan_y >> 1));
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
518 glEnd();
15339
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
519 glDisable(CVOpenGLTextureGetTarget(texture));
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
520
15339
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
521 //render resize box
35082
6d8be70115a8 Remove local variables that (except for very brief moments before
reimar
parents: 35081
diff changeset
522 if(!vo_fs)
15339
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
523 {
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
524 NSRect frame = [self frame];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
525
15339
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
526 glBegin(GL_LINES);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
527 glColor4f(0.2, 0.2, 0.2, 0.5);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
528 glVertex2i(frame.size.width-1, frame.size.height-1); glVertex2i(frame.size.width-1, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
529 glVertex2i(frame.size.width-1, frame.size.height-5); glVertex2i(frame.size.width-5, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
530 glVertex2i(frame.size.width-1, frame.size.height-9); glVertex2i(frame.size.width-9, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
531
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
532 glColor4f(0.4, 0.4, 0.4, 0.5);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
533 glVertex2i(frame.size.width-1, frame.size.height-2); glVertex2i(frame.size.width-2, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
534 glVertex2i(frame.size.width-1, frame.size.height-6); glVertex2i(frame.size.width-6, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
535 glVertex2i(frame.size.width-1, frame.size.height-10); glVertex2i(frame.size.width-10, frame.size.height-1);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
536
15339
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
537 glColor4f(0.6, 0.6, 0.6, 0.5);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
538 glVertex2i(frame.size.width-1, frame.size.height-3); glVertex2i(frame.size.width-3, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
539 glVertex2i(frame.size.width-1, frame.size.height-7); glVertex2i(frame.size.width-7, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
540 glVertex2i(frame.size.width-1, frame.size.height-11); glVertex2i(frame.size.width-11, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
541 glEnd();
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
542 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
543
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
544 glFlush();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
545 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
546
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
547 /*
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
548 Create OpenGL texture from current frame & set texco
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
549 */
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
550 - (void) setCurrentTexture
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
551 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
552 CVReturn error = kCVReturnSuccess;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
553
29137
0f6fc0df2c23 fix a memory leak leading to ~80 bytes being leaked at each call to flip_page.
gpoirier
parents: 28837
diff changeset
554 CVOpenGLTextureRelease(texture);
25180
48fe4b6e3bab Support double buffering, fix osd flicker.
ulion
parents: 25179
diff changeset
555 error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
556 if(error != kCVReturnSuccess)
29210
779281d8cd80 Rename macosx video output driver to corevideo.
diego
parents: 29177
diff changeset
557 mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture(%d)\n", error);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
558
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
559 CVOpenGLTextureGetCleanTexCoords(texture, lowerLeft, lowerRight, upperRight, upperLeft);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
560 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
561
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
562 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
563 redraw win rect
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29210
diff changeset
564 */
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
565 - (void) drawRect: (NSRect *) bounds
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
566 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
567 [self render];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
568 }
15325
5bd11a72dc58 close button exit mplayer with esc key
nplourde
parents: 15320
diff changeset
569 @end