Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
c7d87dd2
Commit
c7d87dd2
authored
Jul 10, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libvlc_media_parse: thread-safety
parent
4d21a276
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
47 deletions
+41
-47
src/control/media.c
src/control/media.c
+41
-46
src/control/media_internal.h
src/control/media_internal.h
+0
-1
No files found.
src/control/media.c
View file @
c7d87dd2
...
...
@@ -226,21 +226,6 @@ static void uninstall_input_item_observer( libvlc_media_t *p_md )
p_md
);
}
/**************************************************************************
* Preparse if not already done (Private)
**************************************************************************/
static
void
preparse_if_needed
(
libvlc_media_t
*
p_md
)
{
/* XXX: need some locking here */
if
(
!
p_md
->
has_asked_preparse
)
{
playlist_PreparseEnqueue
(
libvlc_priv
(
p_md
->
p_libvlc_instance
->
p_libvlc_int
)
->
p_playlist
,
p_md
->
p_input_item
);
p_md
->
has_asked_preparse
=
true
;
}
}
/**************************************************************************
* Create a new media descriptor object from an input_item
* (libvlc internal)
...
...
@@ -467,24 +452,8 @@ libvlc_media_get_mrl( libvlc_media_t * p_md )
char
*
libvlc_media_get_meta
(
libvlc_media_t
*
p_md
,
libvlc_meta_t
e_meta
)
{
char
*
psz_meta
;
assert
(
p_md
);
/* XXX: locking */
preparse_if_needed
(
p_md
);
psz_meta
=
input_item_GetMeta
(
p_md
->
p_input_item
,
char
*
psz_meta
=
input_item_GetMeta
(
p_md
->
p_input_item
,
libvlc_to_vlc_meta
[
e_meta
]
);
if
(
e_meta
==
libvlc_meta_ArtworkURL
&&
!
psz_meta
&&
!
p_md
->
has_asked_art
)
{
p_md
->
has_asked_art
=
true
;
playlist_AskForArtEnqueue
(
libvlc_priv
(
p_md
->
p_libvlc_instance
->
p_libvlc_int
)
->
p_playlist
,
p_md
->
p_input_item
);
}
/* Should be integrated in core */
if
(
psz_meta
==
NULL
&&
e_meta
==
libvlc_meta_Title
&&
p_md
->
p_input_item
->
psz_name
!=
NULL
)
...
...
@@ -614,49 +583,75 @@ libvlc_media_get_duration( libvlc_media_t * p_md )
return
-
1
;
}
preparse_if_needed
(
p_md
);
if
(
!
input_item_IsPreparsed
(
p_md
->
p_input_item
))
return
-
1
;
return
from_mtime
(
input_item_GetDuration
(
p_md
->
p_input_item
));
}
static
int
media_parse
(
libvlc_media_t
*
media
)
{
/* TODO: fetcher and parser independent of playlist */
playlist_t
*
playlist
=
libvlc_priv
(
media
->
p_libvlc_instance
->
p_libvlc_int
)
->
p_playlist
;
/* TODO: Fetch art on need basis. But how not to break compatibility? */
playlist_AskForArtEnqueue
(
playlist
,
media
->
p_input_item
);
return
playlist_PreparseEnqueue
(
playlist
,
media
->
p_input_item
);
}
/**************************************************************************
* Parse the media.
* Parse the media
and wait
.
**************************************************************************/
void
libvlc_media_parse
(
libvlc_media_t
*
media
)
{
preparse_if_needed
(
media
);
vlc_mutex_lock
(
&
media
->
parsed_lock
);
if
(
!
media
->
has_asked_preparse
)
{
media
->
has_asked_preparse
=
true
;
vlc_mutex_unlock
(
&
media
->
parsed_lock
);
if
(
media_parse
(
media
))
/* Parse failed: do not wait! */
return
;
vlc_mutex_lock
(
&
media
->
parsed_lock
);
}
while
(
!
media
->
is_parsed
)
vlc_cond_wait
(
&
media
->
parsed_cond
,
&
media
->
parsed_lock
);
vlc_mutex_unlock
(
&
media
->
parsed_lock
);
}
/**************************************************************************
* Parse the media.
* Parse the media
but do not wait
.
**************************************************************************/
void
libvlc_media_parse_async
(
libvlc_media_t
*
media
)
{
preparse_if_needed
(
media
);
bool
needed
;
vlc_mutex_lock
(
&
media
->
parsed_lock
);
needed
=
media
->
has_asked_preparse
;
media
->
has_asked_preparse
=
true
;
vlc_mutex_unlock
(
&
media
->
parsed_lock
);
if
(
needed
)
media_parse
(
media
);
}
/**************************************************************************
* Get parsed status for media object.
**************************************************************************/
int
libvlc_media_is_parsed
(
libvlc_media_t
*
p_md
)
libvlc_media_is_parsed
(
libvlc_media_t
*
media
)
{
assert
(
p_md
)
;
bool
parsed
;
if
(
!
p_md
->
p_input_item
)
return
false
;
return
input_item_IsPreparsed
(
p_md
->
p_input_item
)
;
vlc_mutex_lock
(
&
media
->
parsed_lock
);
parsed
=
media
->
is_parsed
;
vlc_mutex_unlock
(
&
media
->
parsed_lock
);
return
parsed
;
}
/**************************************************************************
...
...
src/control/media_internal.h
View file @
c7d87dd2
...
...
@@ -46,7 +46,6 @@ struct libvlc_media_t
bool
is_parsed
;
bool
has_asked_preparse
;
bool
has_asked_art
;
};
/* Media Descriptor */
...
...
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