Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
VLC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
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
Steve Lhomme
VLC
Commits
e5c14c90
Commit
e5c14c90
authored
May 30, 2017
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dshow: Use MTA and stop leaking thread context out of the module
Fix #16935
parent
22435a9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
11 deletions
+32
-11
modules/access/dshow/dshow.cpp
modules/access/dshow/dshow.cpp
+32
-11
No files found.
modules/access/dshow/dshow.cpp
View file @
e5c14c90
...
...
@@ -35,6 +35,7 @@
#include <list>
#include <string>
#include <assert.h>
#include <stdexcept>
#define VLC_MODULE_LICENSE VLC_LICENSE_GPL_2_PLUS
#include <vlc_common.h>
...
...
@@ -299,6 +300,18 @@ vlc_module_begin ()
vlc_module_end
()
struct
ComContext
{
ComContext
(
int
mode
)
{
if
(
FAILED
(
CoInitializeEx
(
NULL
,
mode
)
)
)
throw
std
::
runtime_error
(
"CoInitializeEx failed"
);
}
~
ComContext
()
{
CoUninitialize
();
}
};
/*****************************************************************************
* DirectShow elementary stream descriptor
...
...
@@ -392,10 +405,6 @@ static int CommonOpen( vlc_object_t *p_this, access_sys_t *p_sys,
bool
b_use_audio
=
true
;
bool
b_use_video
=
true
;
/* Initialize OLE/COM */
if
(
FAILED
(
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
))
)
vlc_assert_unreachable
();
var_Create
(
p_this
,
CFG_PREFIX
"config"
,
VLC_VAR_BOOL
|
VLC_VAR_DOINHERIT
);
var_Create
(
p_this
,
CFG_PREFIX
"tuner"
,
VLC_VAR_BOOL
|
VLC_VAR_DOINHERIT
);
psz_val
=
var_CreateGetString
(
p_this
,
CFG_PREFIX
"vdev"
);
...
...
@@ -665,6 +674,8 @@ static int DemuxOpen( vlc_object_t *p_this )
return
VLC_ENOMEM
;
p_demux
->
p_sys
=
(
demux_sys_t
*
)
p_sys
;
ComContext
ctx
(
COINIT_MULTITHREADED
);
if
(
CommonOpen
(
p_this
,
p_sys
,
true
)
!=
VLC_SUCCESS
)
{
CommonClose
(
p_this
,
p_sys
);
...
...
@@ -770,6 +781,8 @@ static int AccessOpen( vlc_object_t *p_this )
if
(
!
p_sys
)
return
VLC_ENOMEM
;
ComContext
ctx
(
COINIT_MULTITHREADED
);
if
(
CommonOpen
(
p_this
,
p_sys
,
false
)
!=
VLC_SUCCESS
)
{
CommonClose
(
p_this
,
p_sys
);
...
...
@@ -804,9 +817,6 @@ static void CommonClose( vlc_object_t *p_this, access_sys_t *p_sys )
DeleteDirectShowGraph
(
p_this
,
p_sys
);
/* Uninitialize OLE/COM */
CoUninitialize
();
vlc_delete_all
(
p_sys
->
pp_streams
);
vlc_mutex_destroy
(
&
p_sys
->
lock
);
...
...
@@ -823,6 +833,8 @@ static void AccessClose( vlc_object_t *p_this )
access_t
*
p_access
=
(
access_t
*
)
p_this
;
access_sys_t
*
p_sys
=
(
access_sys_t
*
)
p_access
->
p_sys
;
ComContext
ctx
(
COINIT_MULTITHREADED
);
/* Stop capturing stuff */
p_sys
->
p_control
->
Stop
();
...
...
@@ -837,6 +849,8 @@ static void DemuxClose( vlc_object_t *p_this )
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
access_sys_t
*
p_sys
=
(
access_sys_t
*
)
p_demux
->
p_sys
;
ComContext
ctx
(
COINIT_MULTITHREADED
);
/* Stop capturing stuff */
p_sys
->
p_control
->
Stop
();
...
...
@@ -1738,6 +1752,8 @@ static size_t EnumDeviceCaps( vlc_object_t *p_this, IBaseFilter *p_filter,
*****************************************************************************/
static
block_t
*
ReadCompressed
(
access_t
*
p_access
,
bool
*
eof
)
{
ComContext
ctx
(
COINIT_MULTITHREADED
);
access_sys_t
*
p_sys
=
(
access_sys_t
*
)
p_access
->
p_sys
;
/* There must be only 1 elementary stream to produce a valid stream
* of MPEG or DV data */
...
...
@@ -1783,6 +1799,8 @@ out:
****************************************************************************/
static
int
Demux
(
demux_t
*
p_demux
)
{
ComContext
ctx
(
COINIT_MULTITHREADED
);
access_sys_t
*
p_sys
=
(
access_sys_t
*
)
p_demux
->
p_sys
;
int
i_found_samples
;
...
...
@@ -2017,11 +2035,12 @@ static int FindDevices( vlc_object_t *p_this, const char *psz_name,
{
/* Find list of devices */
std
::
list
<
std
::
string
>
list_devices
;
if
(
SUCCEEDED
(
CoInitializeEx
(
NULL
,
COINIT_MULTITHREADED
))
||
SUCCEEDED
(
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
))
)
try
{
bool
b_audio
=
!
strcmp
(
psz_name
,
CFG_PREFIX
"adev"
);
ComContext
ctx
(
COINIT_MULTITHREADED
);
FindCaptureDevice
(
p_this
,
NULL
,
&
list_devices
,
b_audio
);
if
(
b_audio
)
...
...
@@ -2031,8 +2050,10 @@ static int FindDevices( vlc_object_t *p_this, const char *psz_name,
if
(
!
list_vdevs
.
empty
()
)
AppendAudioEnabledVDevs
(
p_this
,
list_devices
,
list_vdevs
);
}
CoUninitialize
();
}
catch
(
const
std
::
runtime_error
&
ex
)
{
msg_Err
(
p_this
,
"Failed fetch devices: %s"
,
ex
.
what
()
);
}
unsigned
count
=
2
+
list_devices
.
size
(),
i
=
2
;
...
...
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