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
a97b09d7
authored
Dec 11, 2019
by
olly
Committed by
Oliver Woodman
Dec 11, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add WavHeader.samplesPerBlock (currently always == 1)
PiperOrigin-RevId: 284961417
parent
039ce8a9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
library/core/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeader.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeader.java
View file @
a97b09d7
...
@@ -33,6 +33,8 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -33,6 +33,8 @@ import com.google.android.exoplayer2.util.Util;
private
final
int
blockAlignment
;
private
final
int
blockAlignment
;
/** Bits per sample for the audio data. */
/** Bits per sample for the audio data. */
private
final
int
bitsPerSample
;
private
final
int
bitsPerSample
;
/** Number of samples in each block. */
private
final
int
samplesPerBlock
;
/** The PCM encoding. */
/** The PCM encoding. */
@C
.
PcmEncoding
private
final
int
encoding
;
@C
.
PcmEncoding
private
final
int
encoding
;
...
@@ -47,12 +49,14 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -47,12 +49,14 @@ import com.google.android.exoplayer2.util.Util;
int
averageBytesPerSecond
,
int
averageBytesPerSecond
,
int
blockAlignment
,
int
blockAlignment
,
int
bitsPerSample
,
int
bitsPerSample
,
int
samplesPerBlock
,
@C
.
PcmEncoding
int
encoding
)
{
@C
.
PcmEncoding
int
encoding
)
{
this
.
numChannels
=
numChannels
;
this
.
numChannels
=
numChannels
;
this
.
sampleRateHz
=
sampleRateHz
;
this
.
sampleRateHz
=
sampleRateHz
;
this
.
averageBytesPerSecond
=
averageBytesPerSecond
;
this
.
averageBytesPerSecond
=
averageBytesPerSecond
;
this
.
blockAlignment
=
blockAlignment
;
this
.
blockAlignment
=
blockAlignment
;
this
.
bitsPerSample
=
bitsPerSample
;
this
.
bitsPerSample
=
bitsPerSample
;
this
.
samplesPerBlock
=
samplesPerBlock
;
this
.
encoding
=
encoding
;
this
.
encoding
=
encoding
;
dataStartPosition
=
C
.
POSITION_UNSET
;
dataStartPosition
=
C
.
POSITION_UNSET
;
dataEndPosition
=
C
.
POSITION_UNSET
;
dataEndPosition
=
C
.
POSITION_UNSET
;
...
@@ -101,8 +105,8 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -101,8 +105,8 @@ import com.google.android.exoplayer2.util.Util;
@Override
@Override
public
long
getDurationUs
()
{
public
long
getDurationUs
()
{
long
num
Frame
s
=
(
dataEndPosition
-
dataStartPosition
)
/
blockAlignment
;
long
num
Block
s
=
(
dataEndPosition
-
dataStartPosition
)
/
blockAlignment
;
return
(
numFrames
*
C
.
MICROS_PER_SECOND
)
/
sampleRateHz
;
return
numBlocks
*
samplesPerBlock
*
C
.
MICROS_PER_SECOND
/
sampleRateHz
;
}
}
@Override
@Override
...
@@ -157,6 +161,11 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -157,6 +161,11 @@ import com.google.android.exoplayer2.util.Util;
return
numChannels
;
return
numChannels
;
}
}
/** Returns the number of samples in each block. */
public
int
getSamplesPerBlock
()
{
return
samplesPerBlock
;
}
/** Returns the PCM encoding. **/
/** Returns the PCM encoding. **/
public
@C
.
PcmEncoding
int
getEncoding
()
{
public
@C
.
PcmEncoding
int
getEncoding
()
{
return
encoding
;
return
encoding
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
View file @
a97b09d7
...
@@ -94,7 +94,13 @@ import java.io.IOException;
...
@@ -94,7 +94,13 @@ import java.io.IOException;
input
.
advancePeekPosition
((
int
)
chunkHeader
.
size
-
16
);
input
.
advancePeekPosition
((
int
)
chunkHeader
.
size
-
16
);
return
new
WavHeader
(
return
new
WavHeader
(
numChannels
,
sampleRateHz
,
averageBytesPerSecond
,
blockAlignment
,
bitsPerSample
,
encoding
);
numChannels
,
sampleRateHz
,
averageBytesPerSecond
,
blockAlignment
,
bitsPerSample
,
/* samplesPerBlock= */
1
,
encoding
);
}
}
/**
/**
...
@@ -182,7 +188,7 @@ import java.io.IOException;
...
@@ -182,7 +188,7 @@ import java.io.IOException;
*/
*/
public
static
ChunkHeader
peek
(
ExtractorInput
input
,
ParsableByteArray
scratch
)
public
static
ChunkHeader
peek
(
ExtractorInput
input
,
ParsableByteArray
scratch
)
throws
IOException
,
InterruptedException
{
throws
IOException
,
InterruptedException
{
input
.
peekFully
(
scratch
.
data
,
0
,
SIZE_IN_BYTES
);
input
.
peekFully
(
scratch
.
data
,
/* offset= */
0
,
/* length= */
SIZE_IN_BYTES
);
scratch
.
setPosition
(
0
);
scratch
.
setPosition
(
0
);
int
id
=
scratch
.
readInt
();
int
id
=
scratch
.
readInt
();
...
...
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