Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
4f97b25a
Commit
4f97b25a
authored
Mar 25, 2005
by
Eric Petit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for thread-unsafe OpenGL implementations (OS X...)
parent
14106cb1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
5 deletions
+92
-5
include/video_output.h
include/video_output.h
+2
-0
modules/gui/macosx/voutgl.m
modules/gui/macosx/voutgl.m
+26
-5
modules/video_output/opengl.c
modules/video_output/opengl.c
+64
-0
No files found.
include/video_output.h
View file @
4f97b25a
...
@@ -103,6 +103,8 @@ struct vout_thread_t
...
@@ -103,6 +103,8 @@ struct vout_thread_t
void
(
*
pf_render
)
(
vout_thread_t
*
,
picture_t
*
);
void
(
*
pf_render
)
(
vout_thread_t
*
,
picture_t
*
);
void
(
*
pf_display
)
(
vout_thread_t
*
,
picture_t
*
);
void
(
*
pf_display
)
(
vout_thread_t
*
,
picture_t
*
);
void
(
*
pf_swap
)
(
vout_thread_t
*
);
/* OpenGL only */
void
(
*
pf_swap
)
(
vout_thread_t
*
);
/* OpenGL only */
int
(
*
pf_lock
)
(
vout_thread_t
*
);
/* OpenGL only */
void
(
*
pf_unlock
)
(
vout_thread_t
*
);
/* OpenGL only */
int
(
*
pf_control
)
(
vout_thread_t
*
,
int
,
va_list
);
int
(
*
pf_control
)
(
vout_thread_t
*
,
int
,
va_list
);
/**@}*/
/**@}*/
...
...
modules/gui/macosx/voutgl.m
View file @
4f97b25a
...
@@ -61,6 +61,7 @@ struct vout_sys_t
...
@@ -61,6 +61,7 @@ struct vout_sys_t
vlc_bool_t
b_saved_frame
;
vlc_bool_t
b_saved_frame
;
NSRect
s_frame
;
NSRect
s_frame
;
vlc_bool_t
b_got_frame
;
vlc_bool_t
b_got_frame
;
vlc_mutex_t
lock
;
};
};
/*****************************************************************************
/*****************************************************************************
...
@@ -72,6 +73,8 @@ static void End ( vout_thread_t * p_vout );
...
@@ -72,6 +73,8 @@ static void End ( vout_thread_t * p_vout );
static
int
Manage
(
vout_thread_t
*
p_vout
);
static
int
Manage
(
vout_thread_t
*
p_vout
);
static
int
Control
(
vout_thread_t
*
,
int
,
va_list
);
static
int
Control
(
vout_thread_t
*
,
int
,
va_list
);
static
void
Swap
(
vout_thread_t
*
p_vout
);
static
void
Swap
(
vout_thread_t
*
p_vout
);
static
int
Lock
(
vout_thread_t
*
p_vout
);
static
void
Unlock
(
vout_thread_t
*
p_vout
);
int
E_
(
OpenVideoGL
)
(
vlc_object_t
*
p_this
)
int
E_
(
OpenVideoGL
)
(
vlc_object_t
*
p_this
)
{
{
...
@@ -94,6 +97,7 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
...
@@ -94,6 +97,7 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
memset
(
p_vout
->
p_sys
,
0
,
sizeof
(
vout_sys_t
)
);
memset
(
p_vout
->
p_sys
,
0
,
sizeof
(
vout_sys_t
)
);
p_vout
->
p_sys
->
o_pool
=
[[
NSAutoreleasePool
alloc
]
init
];
p_vout
->
p_sys
->
o_pool
=
[[
NSAutoreleasePool
alloc
]
init
];
vlc_mutex_init
(
p_vout
,
&
p_vout
->
p_sys
->
lock
);
/* Spawn window */
/* Spawn window */
p_vout
->
p_sys
->
b_got_frame
=
VLC_FALSE
;
p_vout
->
p_sys
->
b_got_frame
=
VLC_FALSE
;
...
@@ -117,6 +121,8 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
...
@@ -117,6 +121,8 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
p_vout
->
pf_manage
=
Manage
;
p_vout
->
pf_manage
=
Manage
;
p_vout
->
pf_control
=
Control
;
p_vout
->
pf_control
=
Control
;
p_vout
->
pf_swap
=
Swap
;
p_vout
->
pf_swap
=
Swap
;
p_vout
->
pf_lock
=
Lock
;
p_vout
->
pf_unlock
=
Unlock
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -136,6 +142,7 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this )
...
@@ -136,6 +142,7 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this )
[
p_vout
->
p_sys
->
o_window
close
];
[
p_vout
->
p_sys
->
o_window
close
];
/* Clean up */
/* Clean up */
vlc_mutex_destroy
(
&
p_vout
->
p_sys
->
lock
);
[
o_pool
release
];
[
o_pool
release
];
free
(
p_vout
->
p_sys
);
free
(
p_vout
->
p_sys
);
}
}
...
@@ -220,11 +227,18 @@ static void Swap( vout_thread_t * p_vout )
...
@@ -220,11 +227,18 @@ static void Swap( vout_thread_t * p_vout )
{
{
p_vout
->
p_sys
->
b_got_frame
=
VLC_TRUE
;
p_vout
->
p_sys
->
b_got_frame
=
VLC_TRUE
;
[[
p_vout
->
p_sys
->
o_glview
openGLContext
]
makeCurrentContext
];
[[
p_vout
->
p_sys
->
o_glview
openGLContext
]
makeCurrentContext
];
if
(
[
p_vout
->
p_sys
->
o_glview
lockFocusIfCanDraw
]
)
glFlush
();
{
}
glFlush
();
[
p_vout
->
p_sys
->
o_glview
unlockFocus
];
static
int
Lock
(
vout_thread_t
*
p_vout
)
}
{
vlc_mutex_lock
(
&
p_vout
->
p_sys
->
lock
);
return
0
;
}
static
void
Unlock
(
vout_thread_t
*
p_vout
)
{
vlc_mutex_unlock
(
&
p_vout
->
p_sys
->
lock
);
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -296,8 +310,11 @@ static void Swap( vout_thread_t * p_vout )
...
@@ -296,8 +310,11 @@ static void Swap( vout_thread_t * p_vout )
x
=
bounds
.
size
.
width
;
x
=
bounds
.
size
.
width
;
y
=
bounds
.
size
.
width
*
VOUT_ASPECT_FACTOR
/
p_vout
->
render
.
i_aspect
;
y
=
bounds
.
size
.
width
*
VOUT_ASPECT_FACTOR
/
p_vout
->
render
.
i_aspect
;
}
}
Lock
(
p_vout
);
glViewport
(
(
bounds
.
size
.
width
-
x
)
/
2
,
glViewport
(
(
bounds
.
size
.
width
-
x
)
/
2
,
(
bounds
.
size
.
height
-
y
)
/
2
,
x
,
y
);
(
bounds
.
size
.
height
-
y
)
/
2
,
x
,
y
);
Unlock
(
p_vout
);
if
(
p_vout
->
p_sys
->
b_got_frame
)
if
(
p_vout
->
p_sys
->
b_got_frame
)
{
{
...
@@ -311,14 +328,18 @@ static void Swap( vout_thread_t * p_vout )
...
@@ -311,14 +328,18 @@ static void Swap( vout_thread_t * p_vout )
}
}
else
else
{
{
Lock
(
p_vout
);
glClear
(
GL_COLOR_BUFFER_BIT
);
glClear
(
GL_COLOR_BUFFER_BIT
);
Unlock
(
p_vout
);
}
}
}
}
-
(
void
)
drawRect
:
(
NSRect
)
rect
-
(
void
)
drawRect
:
(
NSRect
)
rect
{
{
[[
self
openGLContext
]
makeCurrentContext
];
[[
self
openGLContext
]
makeCurrentContext
];
Lock
(
p_vout
);
glFlush
();
glFlush
();
Unlock
(
p_vout
);
}
}
@end
@end
...
...
modules/video_output/opengl.c
View file @
4f97b25a
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*
*
* Authors: Cyril Deguet <asmax@videolan.org>
* Authors: Cyril Deguet <asmax@videolan.org>
* Gildas Bazin <gbazin@videolan.org>
* Gildas Bazin <gbazin@videolan.org>
* Eric Petit <titer@m0k.org>
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
...
@@ -310,6 +311,13 @@ static int Init( vout_thread_t *p_vout )
...
@@ -310,6 +311,13 @@ static int Init( vout_thread_t *p_vout )
I_OUTPUTPICTURES
=
1
;
I_OUTPUTPICTURES
=
1
;
if
(
p_sys
->
p_vout
->
pf_lock
&&
p_sys
->
p_vout
->
pf_lock
(
p_sys
->
p_vout
)
)
{
msg_Warn
(
p_vout
,
"could not lock OpenGL provider"
);
return
0
;
}
InitTextures
(
p_vout
);
InitTextures
(
p_vout
);
glDisable
(
GL_BLEND
);
glDisable
(
GL_BLEND
);
...
@@ -359,6 +367,11 @@ static int Init( vout_thread_t *p_vout )
...
@@ -359,6 +367,11 @@ static int Init( vout_thread_t *p_vout )
glTranslatef
(
0
.
0
,
0
.
0
,
-
5
.
0
);
glTranslatef
(
0
.
0
,
0
.
0
,
-
5
.
0
);
}
}
if
(
p_sys
->
p_vout
->
pf_unlock
)
{
p_sys
->
p_vout
->
pf_unlock
(
p_sys
->
p_vout
);
}
return
0
;
return
0
;
}
}
...
@@ -367,8 +380,22 @@ static int Init( vout_thread_t *p_vout )
...
@@ -367,8 +380,22 @@ static int Init( vout_thread_t *p_vout )
*****************************************************************************/
*****************************************************************************/
static
void
End
(
vout_thread_t
*
p_vout
)
static
void
End
(
vout_thread_t
*
p_vout
)
{
{
vout_sys_t
*
p_sys
=
p_vout
->
p_sys
;
if
(
p_sys
->
p_vout
->
pf_lock
&&
p_sys
->
p_vout
->
pf_lock
(
p_sys
->
p_vout
)
)
{
msg_Warn
(
p_vout
,
"could not lock OpenGL provider"
);
return
;
}
glFinish
();
glFinish
();
glFlush
();
glFlush
();
if
(
p_sys
->
p_vout
->
pf_unlock
)
{
p_sys
->
p_vout
->
pf_unlock
(
p_sys
->
p_vout
);
}
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -410,6 +437,13 @@ static int Manage( vout_thread_t *p_vout )
...
@@ -410,6 +437,13 @@ static int Manage( vout_thread_t *p_vout )
p_vout
->
i_changes
=
p_sys
->
p_vout
->
i_changes
;
p_vout
->
i_changes
=
p_sys
->
p_vout
->
i_changes
;
#ifdef SYS_DARWIN
#ifdef SYS_DARWIN
if
(
p_sys
->
p_vout
->
pf_lock
&&
p_sys
->
p_vout
->
pf_lock
(
p_sys
->
p_vout
)
)
{
msg_Warn
(
p_vout
,
"could not lock OpenGL provider"
);
return
i_ret
;
}
/* On OS X, we create the window and the GL view when entering
/* On OS X, we create the window and the GL view when entering
fullscreen - the textures have to be inited again */
fullscreen - the textures have to be inited again */
if
(
i_fullscreen_change
)
if
(
i_fullscreen_change
)
...
@@ -441,6 +475,11 @@ static int Manage( vout_thread_t *p_vout )
...
@@ -441,6 +475,11 @@ static int Manage( vout_thread_t *p_vout )
glTranslatef
(
0
.
0
,
0
.
0
,
-
5
.
0
);
glTranslatef
(
0
.
0
,
0
.
0
,
-
5
.
0
);
}
}
}
}
if
(
p_sys
->
p_vout
->
pf_unlock
)
{
p_sys
->
p_vout
->
pf_unlock
(
p_sys
->
p_vout
);
}
#endif
#endif
return
i_ret
;
return
i_ret
;
...
@@ -470,10 +509,18 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
...
@@ -470,10 +509,18 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
OS X, we first render, then reload the texture to be used next
OS X, we first render, then reload the texture to be used next
time. */
time. */
if
(
p_sys
->
p_vout
->
pf_lock
&&
p_sys
->
p_vout
->
pf_lock
(
p_sys
->
p_vout
)
)
{
msg_Warn
(
p_vout
,
"could not lock OpenGL provider"
);
return
;
}
#ifdef SYS_DARWIN
#ifdef SYS_DARWIN
int
i_new_index
;
int
i_new_index
;
i_new_index
=
(
p_sys
->
i_index
+
1
)
&
1
;
i_new_index
=
(
p_sys
->
i_index
+
1
)
&
1
;
/* Update the texture */
/* Update the texture */
glBindTexture
(
VLCGL_TARGET
,
p_sys
->
p_textures
[
i_new_index
]
);
glBindTexture
(
VLCGL_TARGET
,
p_sys
->
p_textures
[
i_new_index
]
);
glTexSubImage2D
(
VLCGL_TARGET
,
0
,
0
,
0
,
p_sys
->
i_tex_width
,
glTexSubImage2D
(
VLCGL_TARGET
,
0
,
0
,
0
,
p_sys
->
i_tex_width
,
...
@@ -493,6 +540,11 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
...
@@ -493,6 +540,11 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
p_vout
->
render
.
i_width
,
p_vout
->
render
.
i_height
,
p_vout
->
render
.
i_width
,
p_vout
->
render
.
i_height
,
VLCGL_RGB_FORMAT
,
VLCGL_RGB_TYPE
,
p_sys
->
pp_buffer
[
0
]
);
VLCGL_RGB_FORMAT
,
VLCGL_RGB_TYPE
,
p_sys
->
pp_buffer
[
0
]
);
#endif
#endif
if
(
p_sys
->
p_vout
->
pf_unlock
)
{
p_sys
->
p_vout
->
pf_unlock
(
p_sys
->
p_vout
);
}
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -517,6 +569,13 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
...
@@ -517,6 +569,13 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
OpenGL providers can call pf_display to force redraw. Currently,
OpenGL providers can call pf_display to force redraw. Currently,
the OS X provider uses it to get a smooth window resizing */
the OS X provider uses it to get a smooth window resizing */
if
(
p_sys
->
p_vout
->
pf_lock
&&
p_sys
->
p_vout
->
pf_lock
(
p_sys
->
p_vout
)
)
{
msg_Warn
(
p_vout
,
"could not lock OpenGL provider"
);
return
;
}
glClear
(
GL_COLOR_BUFFER_BIT
);
glClear
(
GL_COLOR_BUFFER_BIT
);
if
(
p_sys
->
i_effect
==
OPENGL_EFFECT_NONE
)
if
(
p_sys
->
i_effect
==
OPENGL_EFFECT_NONE
)
...
@@ -577,6 +636,11 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
...
@@ -577,6 +636,11 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
glDisable
(
VLCGL_TARGET
);
glDisable
(
VLCGL_TARGET
);
p_sys
->
p_vout
->
pf_swap
(
p_sys
->
p_vout
);
p_sys
->
p_vout
->
pf_swap
(
p_sys
->
p_vout
);
if
(
p_sys
->
p_vout
->
pf_unlock
)
{
p_sys
->
p_vout
->
pf_unlock
(
p_sys
->
p_vout
);
}
}
}
int
GetAlignedSize
(
int
i_size
)
int
GetAlignedSize
(
int
i_size
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment