Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
3842395a
Commit
3842395a
authored
Dec 22, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up/document a bit preparser code.
parent
0021e6aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
56 deletions
+125
-56
src/playlist/preparser.c
src/playlist/preparser.c
+101
-45
src/playlist/preparser.h
src/playlist/preparser.h
+24
-11
No files found.
src/playlist/preparser.c
View file @
3842395a
...
@@ -33,8 +33,27 @@
...
@@ -33,8 +33,27 @@
#include "preparser.h"
#include "preparser.h"
#include "../input/input_interface.h"
#include "../input/input_interface.h"
/*****************************************************************************
* Structures/definitions
*****************************************************************************/
struct
playlist_preparser_t
{
playlist_t
*
p_playlist
;
playlist_fetcher_t
*
p_fetcher
;
vlc_thread_t
thread
;
vlc_mutex_t
lock
;
vlc_cond_t
wait
;
input_item_t
**
pp_waiting
;
int
i_waiting
;
};
static
void
*
Thread
(
void
*
);
static
void
*
Thread
(
void
*
);
/*****************************************************************************
* Public functions
*****************************************************************************/
playlist_preparser_t
*
playlist_preparser_New
(
playlist_t
*
p_playlist
,
playlist_fetcher_t
*
p_fetcher
)
playlist_preparser_t
*
playlist_preparser_New
(
playlist_t
*
p_playlist
,
playlist_fetcher_t
*
p_fetcher
)
{
{
playlist_preparser_t
*
p_preparser
=
malloc
(
sizeof
(
*
p_preparser
)
);
playlist_preparser_t
*
p_preparser
=
malloc
(
sizeof
(
*
p_preparser
)
);
...
@@ -82,13 +101,84 @@ void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
...
@@ -82,13 +101,84 @@ void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
}
}
vlc_cond_destroy
(
&
p_preparser
->
wait
);
vlc_cond_destroy
(
&
p_preparser
->
wait
);
vlc_mutex_destroy
(
&
p_preparser
->
lock
);
vlc_mutex_destroy
(
&
p_preparser
->
lock
);
free
(
p_preparser
);
}
/*****************************************************************************
* Privates functions
*****************************************************************************/
/**
* This function preparses an item when needed.
*/
static
void
Preparse
(
playlist_t
*
p_playlist
,
input_item_t
*
p_item
)
{
vlc_mutex_lock
(
&
p_item
->
lock
);
int
i_type
=
p_item
->
i_type
;
vlc_mutex_unlock
(
&
p_item
->
lock
);
if
(
i_type
!=
ITEM_TYPE_FILE
)
return
;
stats_TimerStart
(
p_playlist
,
"Preparse run"
,
STATS_TIMER_PREPARSE
);
/* Do not preparse if it is already done (like by playing it) */
if
(
!
input_item_IsPreparsed
(
p_item
)
)
{
input_Preparse
(
p_playlist
,
p_item
);
input_item_SetPreparsed
(
p_item
,
true
);
var_SetInteger
(
p_playlist
,
"item-change"
,
p_item
->
i_id
);
}
stats_TimerStop
(
p_playlist
,
STATS_TIMER_PREPARSE
);
}
}
/**
* This function ask the fetcher object to fetch the art when needed
*/
static
void
Art
(
playlist_preparser_t
*
p_preparser
,
input_item_t
*
p_item
)
{
playlist_t
*
p_playlist
=
p_preparser
->
p_playlist
;
playlist_fetcher_t
*
p_fetcher
=
p_preparser
->
p_fetcher
;
bool
b_fetch
=
false
;
/* If we haven't retrieved enough meta, add to secondary queue
* which will run the "meta fetchers".
* This only checks for meta, not for art
* \todo don't do this for things we won't get meta for, like vids
*/
vlc_mutex_lock
(
&
p_item
->
lock
);
if
(
p_item
->
p_meta
)
{
const
char
*
psz_arturl
=
vlc_meta_Get
(
p_item
->
p_meta
,
vlc_meta_ArtworkURL
);
const
char
*
psz_name
=
vlc_meta_Get
(
p_item
->
p_meta
,
vlc_meta_Title
);
if
(
p_fetcher
&&
p_fetcher
->
i_art_policy
==
ALBUM_ART_ALL
&&
(
!
psz_arturl
||
strncmp
(
psz_arturl
,
"file://"
,
7
)
)
)
{
msg_Dbg
(
p_playlist
,
"meta ok for %s, need to fetch art"
,
psz_name
);
b_fetch
=
true
;
}
else
{
msg_Dbg
(
p_playlist
,
"no fetch required for %s (art currently %s)"
,
psz_name
,
psz_arturl
);
}
}
vlc_mutex_unlock
(
&
p_item
->
lock
);
if
(
b_fetch
)
playlist_fetcher_Push
(
p_fetcher
,
p_item
);
}
/**
* This function does the preparsing and issues the art fetching requests
*/
static
void
*
Thread
(
void
*
data
)
static
void
*
Thread
(
void
*
data
)
{
{
playlist_preparser_t
*
p_preparser
=
data
;
playlist_preparser_t
*
p_preparser
=
data
;
playlist_t
*
p_playlist
=
p_preparser
->
p_playlist
;
playlist_t
*
p_playlist
=
p_preparser
->
p_playlist
;
playlist_fetcher_t
*
p_fetcher
=
p_preparser
->
p_fetcher
;
for
(
;;
)
for
(
;;
)
{
{
...
@@ -108,53 +198,19 @@ static void *Thread( void *data )
...
@@ -108,53 +198,19 @@ static void *Thread( void *data )
if
(
!
p_current
)
if
(
!
p_current
)
continue
;
continue
;
int
canc
=
vlc_savecancel
();
int
canc
=
vlc_savecancel
();
{
PL_LOCK
;
Preparse
(
p_playlist
,
p_current
);
if
(
p_current
->
i_type
==
ITEM_TYPE_FILE
)
{
Art
(
p_preparser
,
p_current
);
stats_TimerStart
(
p_playlist
,
"Preparse run"
,
STATS_TIMER_PREPARSE
);
/* Do not preparse if it is already done (like by playing it) */
if
(
!
input_item_IsPreparsed
(
p_current
)
)
{
PL_UNLOCK
;
input_Preparse
(
p_playlist
,
p_current
);
PL_LOCK
;
}
stats_TimerStop
(
p_playlist
,
STATS_TIMER_PREPARSE
);
PL_UNLOCK
;
input_item_SetPreparsed
(
p_current
,
true
);
var_SetInteger
(
p_playlist
,
"item-change"
,
p_current
->
i_id
);
PL_LOCK
;
}
/* If we haven't retrieved enough meta, add to secondary queue
* which will run the "meta fetchers".
* This only checks for meta, not for art
* \todo don't do this for things we won't get meta for, like vids
*/
char
*
psz_arturl
=
input_item_GetArtURL
(
p_current
);
char
*
psz_name
=
input_item_GetName
(
p_current
);
if
(
p_fetcher
&&
p_fetcher
->
i_art_policy
==
ALBUM_ART_ALL
&&
(
!
psz_arturl
||
strncmp
(
psz_arturl
,
"file://"
,
7
)
)
)
{
msg_Dbg
(
p_playlist
,
"meta ok for %s, need to fetch art"
,
psz_name
);
playlist_fetcher_Push
(
p_fetcher
,
p_current
);
}
else
{
msg_Dbg
(
p_playlist
,
"no fetch required for %s (art currently %s)"
,
psz_name
,
psz_arturl
);
}
vlc_gc_decref
(
p_current
);
free
(
psz_name
);
free
(
psz_arturl
);
PL_UNLOCK
;
}
vlc_restorecancel
(
canc
);
vlc_restorecancel
(
canc
);
/* */
int
i_activity
=
var_GetInteger
(
p_playlist
,
"activity"
);
int
i_activity
=
var_GetInteger
(
p_playlist
,
"activity"
);
if
(
i_activity
<
0
)
i_activity
=
0
;
if
(
i_activity
<
0
)
i_activity
=
0
;
/* Sleep at least 1ms */
/* Sleep at least 1ms */
msleep
(
(
i_activity
+
1
)
*
1000
);
msleep
(
(
i_activity
+
1
)
*
1000
);
}
}
...
...
src/playlist/preparser.h
View file @
3842395a
...
@@ -25,20 +25,33 @@
...
@@ -25,20 +25,33 @@
#ifndef _PLAYLIST_PREPARSER_H
#ifndef _PLAYLIST_PREPARSER_H
#define _PLAYLIST_PREPARSER_H 1
#define _PLAYLIST_PREPARSER_H 1
typedef
struct
/**
{
* Preparser opaque structure.
playlist_t
*
p_playlist
;
*
playlist_fetcher_t
*
p_fetcher
;
* The preparser object will retreive the meta data of any given input item in
* an asynchronious way.
vlc_thread_t
thread
;
* It will also issue art fetching requests.
vlc_mutex_t
lock
;
*/
vlc_cond_t
wait
;
typedef
struct
playlist_preparser_t
playlist_preparser_t
;
input_item_t
**
pp_waiting
;
int
i_waiting
;
}
playlist_preparser_t
;
/**
* This function creates the preparser object and thread.
*/
playlist_preparser_t
*
playlist_preparser_New
(
playlist_t
*
,
playlist_fetcher_t
*
);
playlist_preparser_t
*
playlist_preparser_New
(
playlist_t
*
,
playlist_fetcher_t
*
);
/**
* This function enqueues the provided item to be preparsed.
*
* The input item is retained until the preparsing is done or until the
* preparser object is deleted.
*/
void
playlist_preparser_Push
(
playlist_preparser_t
*
,
input_item_t
*
);
void
playlist_preparser_Push
(
playlist_preparser_t
*
,
input_item_t
*
);
/**
* This function destroy the preparser object and thread.
*
* All pending input items will be released.
*/
void
playlist_preparser_Delete
(
playlist_preparser_t
*
);
void
playlist_preparser_Delete
(
playlist_preparser_t
*
);
#endif
#endif
...
...
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