Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
63db847b
authored
Apr 23, 2020
by
olly
Committed by
Ian Baker
Apr 27, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make download progress updates thread safe
Issue: #5978 PiperOrigin-RevId: 308076851
parent
25f17acd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadManager.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadProgress.java
library/core/src/main/java/com/google/android/exoplayer2/offline/Downloader.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadManager.java
View file @
63db847b
...
...
@@ -734,7 +734,7 @@ public final class DownloadManager {
break
;
case
MSG_CONTENT_LENGTH_CHANGED:
task
=
(
Task
)
message
.
obj
;
onContentLengthChanged
(
task
);
onContentLengthChanged
(
task
,
Util
.
toLong
(
message
.
arg1
,
message
.
arg2
)
);
return
;
// No need to post back to mainHandler.
case
MSG_UPDATE_PROGRESS:
updateProgress
();
...
...
@@ -1030,9 +1030,8 @@ public final class DownloadManager {
// Task event processing.
private
void
onContentLengthChanged
(
Task
task
)
{
private
void
onContentLengthChanged
(
Task
task
,
long
contentLength
)
{
String
downloadId
=
task
.
request
.
id
;
long
contentLength
=
task
.
contentLength
;
Download
download
=
Assertions
.
checkNotNull
(
getDownload
(
downloadId
,
/* loadFromIndex= */
false
));
if
(
contentLength
==
download
.
contentLength
||
contentLength
==
C
.
LENGTH_UNSET
)
{
...
...
@@ -1325,7 +1324,13 @@ public final class DownloadManager {
this
.
contentLength
=
contentLength
;
@Nullable
Handler
internalHandler
=
this
.
internalHandler
;
if
(
internalHandler
!=
null
)
{
internalHandler
.
obtainMessage
(
MSG_CONTENT_LENGTH_CHANGED
,
this
).
sendToTarget
();
internalHandler
.
obtainMessage
(
MSG_CONTENT_LENGTH_CHANGED
,
(
int
)
(
contentLength
>>
32
),
(
int
)
contentLength
,
this
)
.
sendToTarget
();
}
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadProgress.java
View file @
63db847b
...
...
@@ -21,8 +21,8 @@ import com.google.android.exoplayer2.C;
public
class
DownloadProgress
{
/** The number of bytes that have been downloaded. */
public
long
bytesDownloaded
;
public
volatile
long
bytesDownloaded
;
/** The percentage that has been downloaded, or {@link C#PERCENTAGE_UNSET} if unknown. */
public
float
percentDownloaded
;
public
volatile
float
percentDownloaded
;
}
library/core/src/main/java/com/google/android/exoplayer2/offline/Downloader.java
View file @
63db847b
...
...
@@ -28,6 +28,10 @@ public interface Downloader {
/**
* Called when progress is made during a download operation.
*
* <p>May be called directly from {@link #download}, or from any other thread used by the
* downloader. In all cases, {@link #download} is guaranteed not to return until after the last
* call to {@link #onProgress} has finished executing.
*
* @param contentLength The length of the content in bytes, or {@link C#LENGTH_UNSET} if
* unknown.
* @param bytesDownloaded The number of bytes that have been downloaded.
...
...
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