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
f6671b3e
Commit
f6671b3e
authored
Aug 21, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist fetcher: use vlc_object_t instead of playlist_t
parent
d1bf94c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
23 deletions
+22
-23
src/playlist/engine.c
src/playlist/engine.c
+1
-1
src/playlist/fetcher.c
src/playlist/fetcher.c
+20
-21
src/playlist/fetcher.h
src/playlist/fetcher.h
+1
-1
No files found.
src/playlist/engine.c
View file @
f6671b3e
...
@@ -237,7 +237,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
...
@@ -237,7 +237,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
var_InheritBool
(
p_parent
,
"auto-preparse"
);
var_InheritBool
(
p_parent
,
"auto-preparse"
);
/* Fetcher */
/* Fetcher */
p
->
p_fetcher
=
playlist_fetcher_New
(
p_playlist
);
p
->
p_fetcher
=
playlist_fetcher_New
(
VLC_OBJECT
(
p_playlist
)
);
if
(
unlikely
(
p
->
p_fetcher
==
NULL
)
)
if
(
unlikely
(
p
->
p_fetcher
==
NULL
)
)
{
{
msg_Err
(
p_playlist
,
"cannot create fetcher"
);
msg_Err
(
p_playlist
,
"cannot create fetcher"
);
...
...
src/playlist/fetcher.c
View file @
f6671b3e
...
@@ -45,8 +45,7 @@
...
@@ -45,8 +45,7 @@
*****************************************************************************/
*****************************************************************************/
struct
playlist_fetcher_t
struct
playlist_fetcher_t
{
{
playlist_t
*
p_playlist
;
vlc_object_t
*
object
;
vlc_mutex_t
lock
;
vlc_mutex_t
lock
;
vlc_cond_t
wait
;
vlc_cond_t
wait
;
bool
b_live
;
bool
b_live
;
...
@@ -63,19 +62,19 @@ static void *Thread( void * );
...
@@ -63,19 +62,19 @@ static void *Thread( void * );
/*****************************************************************************
/*****************************************************************************
* Public functions
* Public functions
*****************************************************************************/
*****************************************************************************/
playlist_fetcher_t
*
playlist_fetcher_New
(
playlist_t
*
p_playlis
t
)
playlist_fetcher_t
*
playlist_fetcher_New
(
vlc_object_t
*
paren
t
)
{
{
playlist_fetcher_t
*
p_fetcher
=
malloc
(
sizeof
(
*
p_fetcher
)
);
playlist_fetcher_t
*
p_fetcher
=
malloc
(
sizeof
(
*
p_fetcher
)
);
if
(
!
p_fetcher
)
if
(
!
p_fetcher
)
return
NULL
;
return
NULL
;
p_fetcher
->
p_playlist
=
p_playlis
t
;
p_fetcher
->
object
=
paren
t
;
vlc_mutex_init
(
&
p_fetcher
->
lock
);
vlc_mutex_init
(
&
p_fetcher
->
lock
);
vlc_cond_init
(
&
p_fetcher
->
wait
);
vlc_cond_init
(
&
p_fetcher
->
wait
);
p_fetcher
->
b_live
=
false
;
p_fetcher
->
b_live
=
false
;
p_fetcher
->
i_waiting
=
0
;
p_fetcher
->
i_waiting
=
0
;
p_fetcher
->
pp_waiting
=
NULL
;
p_fetcher
->
pp_waiting
=
NULL
;
p_fetcher
->
i_art_policy
=
var_GetInteger
(
p
_playlis
t
,
"album-art"
);
p_fetcher
->
i_art_policy
=
var_GetInteger
(
p
aren
t
,
"album-art"
);
ARRAY_INIT
(
p_fetcher
->
albums
);
ARRAY_INIT
(
p_fetcher
->
albums
);
return
p_fetcher
;
return
p_fetcher
;
...
@@ -93,7 +92,7 @@ void playlist_fetcher_Push( playlist_fetcher_t *p_fetcher,
...
@@ -93,7 +92,7 @@ void playlist_fetcher_Push( playlist_fetcher_t *p_fetcher,
{
{
if
(
vlc_clone_detach
(
NULL
,
Thread
,
p_fetcher
,
if
(
vlc_clone_detach
(
NULL
,
Thread
,
p_fetcher
,
VLC_THREAD_PRIORITY_LOW
)
)
VLC_THREAD_PRIORITY_LOW
)
)
msg_Err
(
p_fetcher
->
p_playlis
t
,
msg_Err
(
p_fetcher
->
objec
t
,
"cannot spawn secondary preparse thread"
);
"cannot spawn secondary preparse thread"
);
else
else
p_fetcher
->
b_live
=
true
;
p_fetcher
->
b_live
=
true
;
...
@@ -153,7 +152,7 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
...
@@ -153,7 +152,7 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
if
(
!
strcmp
(
album
.
psz_artist
,
psz_artist
)
&&
if
(
!
strcmp
(
album
.
psz_artist
,
psz_artist
)
&&
!
strcmp
(
album
.
psz_album
,
psz_album
)
)
!
strcmp
(
album
.
psz_album
,
psz_album
)
)
{
{
msg_Dbg
(
p_fetcher
->
p_playlis
t
,
msg_Dbg
(
p_fetcher
->
objec
t
,
" %s - %s has already been searched"
,
" %s - %s has already been searched"
,
psz_artist
,
psz_album
);
psz_artist
,
psz_album
);
/* TODO-fenrir if we cache art filename too, we can go faster */
/* TODO-fenrir if we cache art filename too, we can go faster */
...
@@ -180,7 +179,7 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
...
@@ -180,7 +179,7 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
if
(
playlist_FindArtInCacheUsingItemUID
(
p_item
)
!=
VLC_SUCCESS
)
if
(
playlist_FindArtInCacheUsingItemUID
(
p_item
)
!=
VLC_SUCCESS
)
playlist_FindArtInCache
(
p_item
);
playlist_FindArtInCache
(
p_item
);
else
else
msg_Dbg
(
p_fetcher
->
p_playlis
t
,
"successfully retrieved arturl by uid"
);
msg_Dbg
(
p_fetcher
->
objec
t
,
"successfully retrieved arturl by uid"
);
char
*
psz_arturl
=
input_item_GetArtURL
(
p_item
);
char
*
psz_arturl
=
input_item_GetArtURL
(
p_item
);
if
(
psz_arturl
)
if
(
psz_arturl
)
...
@@ -203,8 +202,8 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
...
@@ -203,8 +202,8 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
psz_artist
=
input_item_GetArtist
(
p_item
);
psz_artist
=
input_item_GetArtist
(
p_item
);
if
(
psz_album
&&
psz_artist
)
if
(
psz_album
&&
psz_artist
)
{
{
msg_Dbg
(
p_fetcher
->
p_playlis
t
,
"searching art for %s - %s"
,
msg_Dbg
(
p_fetcher
->
objec
t
,
"searching art for %s - %s"
,
psz_artist
,
psz_album
);
psz_artist
,
psz_album
);
}
}
else
else
{
{
...
@@ -212,14 +211,14 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
...
@@ -212,14 +211,14 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
if
(
!
psz_title
)
if
(
!
psz_title
)
psz_title
=
input_item_GetName
(
p_item
);
psz_title
=
input_item_GetName
(
p_item
);
msg_Dbg
(
p_fetcher
->
p_playlis
t
,
"searching art for %s"
,
psz_title
);
msg_Dbg
(
p_fetcher
->
objec
t
,
"searching art for %s"
,
psz_title
);
free
(
psz_title
);
free
(
psz_title
);
}
}
/* Fetch the art url */
/* Fetch the art url */
i_ret
=
VLC_EGENERIC
;
i_ret
=
VLC_EGENERIC
;
vlc_object_t
*
p_parent
=
VLC_OBJECT
(
p_fetcher
->
p_playlist
)
;
vlc_object_t
*
p_parent
=
p_fetcher
->
object
;
art_finder_t
*
p_finder
=
art_finder_t
*
p_finder
=
vlc_custom_create
(
p_parent
,
sizeof
(
*
p_finder
),
"art finder"
);
vlc_custom_create
(
p_parent
,
sizeof
(
*
p_finder
),
"art finder"
);
if
(
p_finder
!=
NULL
)
if
(
p_finder
!=
NULL
)
...
@@ -271,7 +270,7 @@ static int DownloadArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
...
@@ -271,7 +270,7 @@ static int DownloadArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
if
(
!
strncmp
(
psz_arturl
,
"file://"
,
7
)
)
if
(
!
strncmp
(
psz_arturl
,
"file://"
,
7
)
)
{
{
msg_Dbg
(
p_fetcher
->
p_playlis
t
,
msg_Dbg
(
p_fetcher
->
objec
t
,
"Album art is local file, no need to cache"
);
"Album art is local file, no need to cache"
);
free
(
psz_arturl
);
free
(
psz_arturl
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
...
@@ -279,11 +278,11 @@ static int DownloadArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
...
@@ -279,11 +278,11 @@ static int DownloadArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
if
(
!
strncmp
(
psz_arturl
,
"APIC"
,
4
)
)
if
(
!
strncmp
(
psz_arturl
,
"APIC"
,
4
)
)
{
{
msg_Warn
(
p_fetcher
->
p_playlis
t
,
"APIC fetch not supported yet"
);
msg_Warn
(
p_fetcher
->
objec
t
,
"APIC fetch not supported yet"
);
goto
error
;
goto
error
;
}
}
stream_t
*
p_stream
=
stream_UrlNew
(
p_fetcher
->
p_playlis
t
,
psz_arturl
);
stream_t
*
p_stream
=
stream_UrlNew
(
p_fetcher
->
objec
t
,
psz_arturl
);
if
(
!
p_stream
)
if
(
!
p_stream
)
goto
error
;
goto
error
;
...
@@ -314,7 +313,7 @@ static int DownloadArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
...
@@ -314,7 +313,7 @@ static int DownloadArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
if
(
psz_type
&&
strlen
(
psz_type
)
>
5
)
if
(
psz_type
&&
strlen
(
psz_type
)
>
5
)
psz_type
=
NULL
;
/* remove extension if it's > to 4 characters */
psz_type
=
NULL
;
/* remove extension if it's > to 4 characters */
playlist_SaveArt
(
VLC_OBJECT
(
p_fetcher
->
p_playlist
)
,
p_item
,
playlist_SaveArt
(
p_fetcher
->
object
,
p_item
,
p_data
,
i_data
,
psz_type
);
p_data
,
i_data
,
psz_type
);
}
}
...
@@ -335,7 +334,7 @@ error:
...
@@ -335,7 +334,7 @@ error:
*/
*/
static
void
FetchMeta
(
playlist_fetcher_t
*
p_fetcher
,
input_item_t
*
p_item
)
static
void
FetchMeta
(
playlist_fetcher_t
*
p_fetcher
,
input_item_t
*
p_item
)
{
{
demux_meta_t
*
p_demux_meta
=
vlc_custom_create
(
p_fetcher
->
p_playlis
t
,
demux_meta_t
*
p_demux_meta
=
vlc_custom_create
(
p_fetcher
->
objec
t
,
sizeof
(
*
p_demux_meta
),
"demux meta"
);
sizeof
(
*
p_demux_meta
),
"demux meta"
);
if
(
!
p_demux_meta
)
if
(
!
p_demux_meta
)
return
;
return
;
...
@@ -352,7 +351,7 @@ static void FetchMeta( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
...
@@ -352,7 +351,7 @@ static void FetchMeta( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
static
void
*
Thread
(
void
*
p_data
)
static
void
*
Thread
(
void
*
p_data
)
{
{
playlist_fetcher_t
*
p_fetcher
=
p_data
;
playlist_fetcher_t
*
p_fetcher
=
p_data
;
playlist_t
*
p_playlist
=
p_fetcher
->
p_playlis
t
;
vlc_object_t
*
obj
=
p_fetcher
->
objec
t
;
for
(
;;
)
for
(
;;
)
{
{
...
@@ -389,13 +388,13 @@ static void *Thread( void *p_data )
...
@@ -389,13 +388,13 @@ static void *Thread( void *p_data )
char
*
psz_name
=
input_item_GetName
(
p_item
);
char
*
psz_name
=
input_item_GetName
(
p_item
);
if
(
!
i_ret
)
/* Art is now in cache */
if
(
!
i_ret
)
/* Art is now in cache */
{
{
PL_DEBUG
(
"found art for %s in cache"
,
psz_name
);
msg_Dbg
(
obj
,
"found art for %s in cache"
,
psz_name
);
input_item_SetArtFetched
(
p_item
,
true
);
input_item_SetArtFetched
(
p_item
,
true
);
var_SetAddress
(
p_playlist
,
"item-change"
,
p_item
);
var_SetAddress
(
obj
,
"item-change"
,
p_item
);
}
}
else
else
{
{
PL_DEBUG
(
"art not found for %s"
,
psz_name
);
msg_Dbg
(
obj
,
"art not found for %s"
,
psz_name
);
input_item_SetArtNotFound
(
p_item
,
true
);
input_item_SetArtNotFound
(
p_item
,
true
);
}
}
free
(
psz_name
);
free
(
psz_name
);
...
...
src/playlist/fetcher.h
View file @
f6671b3e
...
@@ -36,7 +36,7 @@ typedef struct playlist_fetcher_t playlist_fetcher_t;
...
@@ -36,7 +36,7 @@ typedef struct playlist_fetcher_t playlist_fetcher_t;
/**
/**
* This function creates the fetcher object and thread.
* This function creates the fetcher object and thread.
*/
*/
playlist_fetcher_t
*
playlist_fetcher_New
(
playlis
t_t
*
);
playlist_fetcher_t
*
playlist_fetcher_New
(
vlc_objec
t_t
*
);
/**
/**
* This function enqueues the provided item to be art fetched.
* This function enqueues the provided item to be art fetched.
...
...
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