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
cd0a888c
Commit
cd0a888c
authored
Sep 23, 2006
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the album art download thing to a separate proccess
parent
48f7e0b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
71 deletions
+96
-71
src/input/input.c
src/input/input.c
+96
-71
No files found.
src/input/input.c
View file @
cd0a888c
...
...
@@ -80,6 +80,8 @@ static void SlaveSeek( input_thread_t *p_input );
static
void
InputMetaUser
(
input_thread_t
*
p_input
);
int
input_DownloadAndCacheArt
(
vlc_object_t
*
p_parent
,
input_item_t
*
p_item
);
/*****************************************************************************
* This function creates a new input, and returns a pointer
* to its description. On error, it returns NULL.
...
...
@@ -235,8 +237,8 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
}
/**
* Initialize an input thread and run it. You will need to monitor the
thread to clean
* up after it is done
* Initialize an input thread and run it. You will need to monitor the
*
thread to clean
up after it is done
*
* \param p_parent a vlc_object
* \param p_item an input item
...
...
@@ -362,84 +364,20 @@ int __input_SecondaryPreparse( vlc_object_t *p_parent, input_item_t *p_item )
p_me
->
p_item
=
p_item
;
p_me
->
p_module
=
module_Need
(
p_me
,
"meta engine"
,
0
,
VLC_FALSE
);
if
(
!
p_me
->
p_module
)
{
msg_Err
(
p_parent
,
"no suitable meta engine module"
);
vlc_object_detach
(
p_me
);
vlc_object_destroy
(
p_me
);
return
VLC_EGENERIC
;
}
module_Unneed
(
p_me
,
p_me
->
p_module
);
if
(
p_item
->
p_meta
&&
p_item
->
p_meta
->
psz_arturl
&&
*
p_item
->
p_meta
->
psz_arturl
&&
strncmp
(
p_item
->
p_meta
->
psz_arturl
,
"file"
,
4
)
)
{
/* process album art */
#define MAX_PATH 10000
char
*
psz_artist
=
p_item
->
p_meta
->
psz_artist
;
char
*
psz_album
=
p_item
->
p_meta
->
psz_album
;
char
*
psz_type
=
strrchr
(
p_item
->
p_meta
->
psz_arturl
,
'.'
);
char
*
psz_filename
=
(
char
*
)
malloc
(
MAX_PATH
);
FILE
*
p_file
;
/* GRUIKKKKKKKKKK */
snprintf
(
psz_filename
,
MAX_PATH
,
"file://%s/"
CONFIG_DIR
,
p_parent
->
p_libvlc
->
psz_homedir
);
utf8_mkdir
(
psz_filename
+
7
);
snprintf
(
psz_filename
,
MAX_PATH
,
"file://%s/"
CONFIG_DIR
"/art"
,
p_parent
->
p_libvlc
->
psz_homedir
);
utf8_mkdir
(
psz_filename
+
7
);
snprintf
(
psz_filename
,
MAX_PATH
,
"file://%s/"
CONFIG_DIR
"/art/%s"
,
p_parent
->
p_libvlc
->
psz_homedir
,
psz_artist
);
utf8_mkdir
(
psz_filename
+
7
);
snprintf
(
psz_filename
,
MAX_PATH
,
"file://%s/"
CONFIG_DIR
"/art/%s/%s"
,
p_parent
->
p_libvlc
->
psz_homedir
,
psz_artist
,
psz_album
);
utf8_mkdir
(
psz_filename
+
7
);
snprintf
(
psz_filename
,
MAX_PATH
,
"file://%s/"
CONFIG_DIR
"/art/%s/%s/art%s"
,
p_parent
->
p_libvlc
->
psz_homedir
,
psz_artist
,
psz_album
,
psz_type
);
msg_Dbg
(
p_parent
,
"Saving album art to %s"
,
psz_filename
);
/* Check if file exists */
p_file
=
utf8_fopen
(
psz_filename
+
7
,
"r"
);
if
(
p_file
)
{
msg_Dbg
(
p_parent
,
"Album art %s already exists"
,
psz_filename
);
fclose
(
p_file
);
}
else
{
stream_t
*
p_stream
=
stream_UrlNew
(
p_parent
,
p_item
->
p_meta
->
psz_arturl
);
vlc_object_destroy
(
p_me
);
if
(
p_stream
)
{
void
*
p_buffer
=
malloc
(
1
<<
16
);
long
int
l_read
;
p_file
=
utf8_fopen
(
psz_filename
+
7
,
"w"
);
while
(
(
l_read
=
stream_Read
(
p_stream
,
p_buffer
,
1
<<
16
)
)
)
{
fwrite
(
p_buffer
,
l_read
,
1
,
p_file
);
}
free
(
p_buffer
);
fclose
(
p_file
);
stream_Delete
(
p_stream
);
msg_Dbg
(
p_parent
,
"Album art saved to %s
\n
"
,
psz_filename
);
free
(
p_item
->
p_meta
->
psz_arturl
);
p_item
->
p_meta
->
psz_arturl
=
strdup
(
psz_filename
);
}
}
free
(
psz_filename
);
}
input_DownloadAndCacheArt
(
p_parent
,
p_item
);
return
VLC_SUCCESS
;
}
...
...
@@ -2587,3 +2525,90 @@ vlc_bool_t input_AddSubtitles( input_thread_t *p_input, char *psz_subtitle,
return
VLC_TRUE
;
}
#define MAX_PATH 260
int
input_DownloadAndCacheArt
(
vlc_object_t
*
p_parent
,
input_item_t
*
p_item
)
{
char
*
psz_artist
;
char
*
psz_album
;
char
*
psz_type
;
char
*
psz_filename
;
int
i_status
=
VLC_EGENERIC
;
int
i_ret
;
if
(
!
p_item
->
p_meta
||
!
p_item
->
p_meta
->
psz_arturl
||
!*
p_item
->
p_meta
->
psz_arturl
)
{
return
VLC_EGENERIC
;
}
if
(
!
strncmp
(
p_item
->
p_meta
->
psz_arturl
,
"file"
,
4
)
)
{
return
VLC_SUCCESS
;
}
psz_artist
=
p_item
->
p_meta
->
psz_artist
;
psz_album
=
p_item
->
p_meta
->
psz_album
;
psz_type
=
strrchr
(
p_item
->
p_meta
->
psz_arturl
,
'.'
);
psz_filename
=
(
char
*
)
malloc
(
MAX_PATH
);
snprintf
(
psz_filename
,
MAX_PATH
,
"file://%s/"
CONFIG_DIR
"/art/%s/%s/art%s"
,
p_parent
->
p_libvlc
->
psz_homedir
,
psz_artist
,
psz_album
,
psz_type
);
msg_Dbg
(
p_parent
,
"Saving album art to %s"
,
psz_filename
);
/* Check if file exists */
i_ret
=
utf8_stat
(
psz_filename
+
7
,
NULL
);
if
(
i_ret
==
0
)
{
msg_Dbg
(
p_parent
,
"Album art %s already exists"
,
psz_filename
);
}
else
{
//if( i_ret == -1 && errno == ENOTDIR )
{
/* GRUIKKKKKKKKKK (make sure that all the directories exist) */
char
*
psz_dir
=
malloc
(
MAX_PATH
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s/"
CONFIG_DIR
,
p_parent
->
p_libvlc
->
psz_homedir
);
utf8_mkdir
(
psz_dir
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s/"
CONFIG_DIR
"/art"
,
p_parent
->
p_libvlc
->
psz_homedir
);
utf8_mkdir
(
psz_dir
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s/"
CONFIG_DIR
"/art/%s"
,
p_parent
->
p_libvlc
->
psz_homedir
,
psz_artist
);
utf8_mkdir
(
psz_dir
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s/"
CONFIG_DIR
"/art/%s/%s"
,
p_parent
->
p_libvlc
->
psz_homedir
,
psz_artist
,
psz_album
);
utf8_mkdir
(
psz_dir
);
free
(
psz_dir
);
}
stream_t
*
p_stream
=
stream_UrlNew
(
p_parent
,
p_item
->
p_meta
->
psz_arturl
);
if
(
p_stream
)
{
void
*
p_buffer
=
malloc
(
1
<<
16
);
long
int
l_read
;
FILE
*
p_file
=
utf8_fopen
(
psz_filename
+
7
,
"w"
);
while
(
(
l_read
=
stream_Read
(
p_stream
,
p_buffer
,
1
<<
16
)
)
)
{
fwrite
(
p_buffer
,
l_read
,
1
,
p_file
);
}
free
(
p_buffer
);
fclose
(
p_file
);
stream_Delete
(
p_stream
);
msg_Dbg
(
p_parent
,
"Album art saved to %s
\n
"
,
psz_filename
);
free
(
p_item
->
p_meta
->
psz_arturl
);
p_item
->
p_meta
->
psz_arturl
=
strdup
(
psz_filename
);
i_status
=
VLC_SUCCESS
;
}
}
free
(
psz_filename
);
return
i_status
;
}
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