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
16454068
Commit
16454068
authored
Feb 02, 2006
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use VLC threads instead of wxWidgets threads.
(i just had to find the suxor thread exemple in video_output.c :p )
parent
ca3c860f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
71 deletions
+89
-71
modules/gui/wxwidgets/dialogs/updatevlc.cpp
modules/gui/wxwidgets/dialogs/updatevlc.cpp
+3
-28
src/misc/update.c
src/misc/update.c
+86
-43
No files found.
modules/gui/wxwidgets/dialogs/updatevlc.cpp
View file @
16454068
...
...
@@ -26,7 +26,6 @@
*****************************************************************************/
#include "updatevlc.hpp"
#include <wx/imaglist.h>
#include <wx/thread.h>
#include "bitmaps/update_ascii.xpm"
#include "bitmaps/update_binary.xpm"
...
...
@@ -168,26 +167,6 @@ void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
}
}
class
DownloadThread
:
public
wxThread
{
public:
DownloadThread
(
update_iterator_t
*
p_uit
,
char
*
psz_dest
)
:
p_uit
(
p_uit
),
psz_dest
(
psz_dest
)
{
Create
();
Run
();
};
ExitCode
Entry
()
{
update_download
(
p_uit
,
psz_dest
);
update_iterator_Delete
(
p_uit
);
LocaleFree
(
psz_dest
);
return
0
;
};
update_iterator_t
*
p_uit
;
char
*
psz_dest
;
};
void
UpdateVLC
::
OnChooseItem
(
wxListEvent
&
event
)
{
update_iterator_t
*
p_uit
=
update_iterator_New
(
p_u
);
...
...
@@ -213,14 +192,10 @@ void UpdateVLC::OnChooseItem( wxListEvent& event )
{
char
*
psz_dest
=
ToLocale
(
filedialog
->
GetPath
().
mb_str
()
);
/* Launch the download process in a new thread so it doesn't
* block the interface */
new
DownloadThread
(
p_uit
,
psz_dest
);
update_download
(
p_uit
,
psz_dest
);
LocaleFree
(
psz_dest
);
}
else
{
update_iterator_Delete
(
p_uit
);
}
delete
filedialog
;
}
}
src/misc/update.c
View file @
16454068
...
...
@@ -1181,7 +1181,20 @@ unsigned int update_iterator_Action( update_iterator_t *p_uit, int i_action )
}
/**
* Download the file selected by the update iterator
* Object to launch download thread in a different object
*/
typedef
struct
{
VLC_COMMON_MEMBERS
char
*
psz_dest
;
//< Download destination
char
*
psz_src
;
//< Download source
char
*
psz_status
;
//< Download status displayed in progress dialog
}
download_thread_t
;
void
update_download_for_real
(
download_thread_t
*
p_this
);
/**
* Download the file selected by the update iterator. This function will
* launch the download in a new thread (downloads can be long)
*
* \param p_uit update iterator
* \param psz_dest destination file path
...
...
@@ -1189,9 +1202,32 @@ unsigned int update_iterator_Action( update_iterator_t *p_uit, int i_action )
*/
void
update_download
(
update_iterator_t
*
p_uit
,
char
*
psz_dest
)
{
char
*
psz_src
=
p_uit
->
file
.
psz_url
;
download_thread_t
*
p_dt
=
vlc_object_create
(
p_uit
->
p_u
->
p_vlc
,
sizeof
(
download_thread_t
)
);
p_dt
->
psz_dest
=
strdup
(
psz_dest
);
p_dt
->
psz_src
=
strdup
(
p_uit
->
file
.
psz_url
);
asprintf
(
&
p_dt
->
psz_status
,
"%s - %s (%s)
\n
Source: %s
\n
Destination: %s"
,
p_uit
->
file
.
psz_description
,
p_uit
->
release
.
psz_version
,
p_uit
->
release
.
psz_svn_revision
,
p_uit
->
file
.
psz_url
,
psz_dest
);
vlc_thread_create
(
p_dt
,
"download thread"
,
update_download_for_real
,
VLC_THREAD_PRIORITY_LOW
,
VLC_FALSE
);
}
/**
* The true download function.
*
* \param p_this the download_thread_t object
* \return nothing
*/
void
update_download_for_real
(
download_thread_t
*
p_this
)
{
char
*
psz_dest
=
p_this
->
psz_dest
;
char
*
psz_src
=
p_this
->
psz_src
;
stream_t
*
p_stream
;
vlc_t
*
p_vlc
=
p_
uit
->
p_u
->
p_vlc
;
vlc_t
*
p_vlc
=
p_
this
->
p_vlc
;
FILE
*
p_file
=
NULL
;
void
*
p_buffer
;
...
...
@@ -1202,32 +1238,31 @@ void update_download( update_iterator_t *p_uit, char *psz_dest )
int
i_size
;
int
i_done
=
0
;
vlc_thread_ready
(
p_this
);
p_stream
=
stream_UrlNew
(
p_vlc
,
psz_src
);
if
(
!
p_stream
)
{
msg_Err
(
p_vlc
,
"Failed to open %s for reading"
,
psz_src
);
return
;
}
else
{
p_file
=
fopen
(
psz_dest
,
"w"
);
if
(
!
p_file
)
{
msg_Err
(
p_vlc
,
"Failed to open %s for writing"
,
psz_dest
);
return
;
}
else
{
i_size
=
(
int
)(
stream_Size
(
p_stream
)
/
(
1
<<
10
));
p_buffer
=
(
void
*
)
malloc
(
1
<<
10
);
asprintf
(
&
psz_status
,
"%s - %s (%s)
\n
"
"Source: %s
\n
"
"Destination: %s
\n
"
"Downloading... %.1f%% done"
,
p_uit
->
file
.
psz_description
,
p_uit
->
release
.
psz_version
,
p_uit
->
release
.
psz_svn_revision
,
p_uit
->
file
.
psz_url
,
psz_dest
,
0
.
0
);
i_progress
=
intf_UserProgress
(
p_vlc
,
"Downloading..."
,
psz_status
,
0
.
0
);
asprintf
(
&
psz_status
,
"%s
\n
Downloading... %.1f%% done"
,
p_this
->
psz_status
,
0
.
0
);
i_progress
=
intf_UserProgress
(
p_vlc
,
"Downloading..."
,
psz_status
,
0
.
0
);
while
(
stream_Read
(
p_stream
,
p_buffer
,
1
<<
10
)
)
{
...
...
@@ -1238,19 +1273,27 @@ void update_download( update_iterator_t *p_uit, char *psz_dest )
i_done
++
;
free
(
psz_status
);
f_progress
=
100
.
0
*
(
float
)
i_done
/
(
float
)
i_size
;
asprintf
(
&
psz_status
,
"%s - %s (%s)
\n
"
"Source: %s
\n
"
"Destination: %s
\n
"
"Downloading... %.1f%% done"
,
p_uit
->
file
.
psz_description
,
p_uit
->
release
.
psz_version
,
p_uit
->
release
.
psz_svn_revision
,
p_uit
->
file
.
psz_url
,
psz_dest
,
f_progress
);
intf_UserProgressUpdate
(
p_vlc
,
i_progress
,
psz_status
,
f_progress
);
asprintf
(
&
psz_status
,
"%s
\n
Downloading... %.1f%% done"
,
p_this
->
psz_status
,
f_progress
);
intf_UserProgressUpdate
(
p_vlc
,
i_progress
,
psz_status
,
f_progress
);
}
free
(
p_buffer
);
free
(
psz_status
);
fclose
(
p_file
);
stream_Delete
(
p_stream
);
}
}
free
(
p_this
->
psz_dest
);
free
(
p_this
->
psz_src
);
free
(
p_this
->
psz_status
);
#ifdef WIN32
CloseHandle
(
p_this
->
thread_id
);
#endif
vlc_object_destroy
(
p_this
);
}
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