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
eb1210d4
authored
Nov 14, 2014
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make sampleQueue thread safe
parent
6b123590
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
library/src/main/java/com/google/android/exoplayer/hls/TsExtractor.java
library/src/main/java/com/google/android/exoplayer/hls/TsExtractor.java
View file @
eb1210d4
...
@@ -32,9 +32,9 @@ import android.util.SparseArray;
...
@@ -32,9 +32,9 @@ import android.util.SparseArray;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Queue
;
import
java.util.Queue
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
/**
/**
* Facilitates the extraction of data from the MPEG-2 TS container format.
* Facilitates the extraction of data from the MPEG-2 TS container format.
...
@@ -144,10 +144,10 @@ public final class TsExtractor {
...
@@ -144,10 +144,10 @@ public final class TsExtractor {
public
boolean
getSample
(
int
track
,
SampleHolder
out
)
{
public
boolean
getSample
(
int
track
,
SampleHolder
out
)
{
Assertions
.
checkState
(
prepared
);
Assertions
.
checkState
(
prepared
);
Queue
<
Sample
>
queue
=
pesPayloadReaders
.
valueAt
(
track
).
sampleQueue
;
Queue
<
Sample
>
queue
=
pesPayloadReaders
.
valueAt
(
track
).
sampleQueue
;
if
(
queue
.
isEmpty
())
{
Sample
sample
=
queue
.
poll
();
if
(
sample
==
null
)
{
return
false
;
return
false
;
}
}
Sample
sample
=
queue
.
remove
();
convert
(
sample
,
out
);
convert
(
sample
,
out
);
samplePool
.
recycle
(
sample
);
samplePool
.
recycle
(
sample
);
return
true
;
return
true
;
...
@@ -473,14 +473,14 @@ public final class TsExtractor {
...
@@ -473,14 +473,14 @@ public final class TsExtractor {
*/
*/
private
abstract
class
PesPayloadReader
{
private
abstract
class
PesPayloadReader
{
public
final
LinkedList
<
Sample
>
sampleQueue
;
public
final
ConcurrentLinkedQueue
<
Sample
>
sampleQueue
;
private
MediaFormat
mediaFormat
;
private
MediaFormat
mediaFormat
;
private
boolean
foundFirstKeyframe
;
private
boolean
foundFirstKeyframe
;
private
boolean
foundLastKeyframe
;
private
boolean
foundLastKeyframe
;
protected
PesPayloadReader
()
{
protected
PesPayloadReader
()
{
this
.
sampleQueue
=
new
LinkedList
<
Sample
>();
this
.
sampleQueue
=
new
ConcurrentLinkedQueue
<
Sample
>();
}
}
public
boolean
hasMediaFormat
()
{
public
boolean
hasMediaFormat
()
{
...
@@ -498,8 +498,10 @@ public final class TsExtractor {
...
@@ -498,8 +498,10 @@ public final class TsExtractor {
public
abstract
void
read
(
BitArray
pesBuffer
,
int
pesPayloadSize
,
long
pesTimeUs
);
public
abstract
void
read
(
BitArray
pesBuffer
,
int
pesPayloadSize
,
long
pesTimeUs
);
public
void
clear
()
{
public
void
clear
()
{
while
(!
sampleQueue
.
isEmpty
())
{
Sample
toRecycle
=
sampleQueue
.
poll
();
samplePool
.
recycle
(
sampleQueue
.
remove
());
while
(
toRecycle
!=
null
)
{
samplePool
.
recycle
(
toRecycle
);
toRecycle
=
sampleQueue
.
poll
();
}
}
}
}
...
...
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