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
3ec5ad1d
authored
Nov 23, 2020
by
olly
Committed by
kim-vde
Nov 24, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove unused logic in SonicAudioProcessor
PiperOrigin-RevId: 343882631
parent
05f6d248
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
29 deletions
library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java
library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java
library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java
View file @
3ec5ad1d
...
...
@@ -112,8 +112,11 @@ public final class DefaultAudioSink implements AudioSink {
boolean
applySkipSilenceEnabled
(
boolean
skipSilenceEnabled
);
/**
* Scales the specified playout duration to take into account speedup due to audio processing,
* returning an input media duration, in arbitrary units.
* Returns the media duration corresponding to the specified playout duration, taking speed
* adjustment due to audio processing into account.
*
* @param playoutDuration The playout duration to scale.
* @return The corresponding media duration, in the same units as {@code duration}.
*/
long
getMediaDuration
(
long
playoutDuration
);
...
...
@@ -172,9 +175,9 @@ public final class DefaultAudioSink implements AudioSink {
@Override
public
PlaybackParameters
applyPlaybackParameters
(
PlaybackParameters
playbackParameters
)
{
float
speed
=
sonicAudioProcessor
.
setSpeed
(
playbackParameters
.
speed
);
float
pitch
=
sonicAudioProcessor
.
setPitch
(
playbackParameters
.
pitch
);
return
new
PlaybackParameters
(
speed
,
pitch
)
;
sonicAudioProcessor
.
setSpeed
(
playbackParameters
.
speed
);
sonicAudioProcessor
.
setPitch
(
playbackParameters
.
pitch
);
return
playbackParameters
;
}
@Override
...
...
@@ -185,7 +188,7 @@ public final class DefaultAudioSink implements AudioSink {
@Override
public
long
getMediaDuration
(
long
playoutDuration
)
{
return
sonicAudioProcessor
.
scaleDurationForSpeedup
(
playoutDuration
);
return
sonicAudioProcessor
.
getMediaDuration
(
playoutDuration
);
}
@Override
...
...
library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java
View file @
3ec5ad1d
...
...
@@ -36,10 +36,10 @@ public final class SonicAudioProcessor implements AudioProcessor {
private
static
final
float
CLOSE_THRESHOLD
=
0.0001f
;
/**
* The minimum number of output bytes
at which the speedup is calculated using the input/output
*
byte counts, rather than using the current playback parameters
speed.
* The minimum number of output bytes
required for duration scaling to be calculated using the
*
input and output byte counts, rather than using the current playback
speed.
*/
private
static
final
int
MIN_BYTES_FOR_
SPEEDUP
_CALCULATION
=
1024
;
private
static
final
int
MIN_BYTES_FOR_
DURATION_SCALING
_CALCULATION
=
1024
;
private
int
pendingOutputSampleRate
;
private
float
speed
;
...
...
@@ -74,35 +74,31 @@ public final class SonicAudioProcessor implements AudioProcessor {
}
/**
* Sets the playback speed. This method may only be called after draining data through the
* Sets the
target
playback speed. This method may only be called after draining data through the
* processor. The value returned by {@link #isActive()} may change, and the processor must be
* {@link #flush() flushed} before queueing more data.
*
* @param speed The requested new playback speed.
* @return The actual new playback speed.
* @param speed The target playback speed.
*/
public
float
setSpeed
(
float
speed
)
{
public
void
setSpeed
(
float
speed
)
{
if
(
this
.
speed
!=
speed
)
{
this
.
speed
=
speed
;
pendingSonicRecreation
=
true
;
}
return
speed
;
}
/**
* Sets the playback pitch. This method may only be called after draining data through the
* Sets the
target
playback pitch. This method may only be called after draining data through the
* processor. The value returned by {@link #isActive()} may change, and the processor must be
* {@link #flush() flushed} before queueing more data.
*
* @param pitch The requested new pitch.
* @return The actual new pitch.
* @param pitch The target pitch.
*/
public
float
setPitch
(
float
pitch
)
{
public
void
setPitch
(
float
pitch
)
{
if
(
this
.
pitch
!=
pitch
)
{
this
.
pitch
=
pitch
;
pendingSonicRecreation
=
true
;
}
return
pitch
;
}
/**
...
...
@@ -118,23 +114,22 @@ public final class SonicAudioProcessor implements AudioProcessor {
}
/**
* Returns the
specified duration scaled to take into account the speedup factor of this instance,
*
in the same units as {@code duration}
.
* Returns the
media duration corresponding to the specified playout duration, taking speed
*
adjustment into account
.
*
* @param duration The duration to scale taking into account speedup.
* @return The specified duration scaled to take into account speedup, in the same units as
* {@code duration}.
* @param playoutDuration The playout duration to scale.
* @return The corresponding media duration, in the same units as {@code duration}.
*/
public
long
scaleDurationForSpeedup
(
long
d
uration
)
{
if
(
outputBytes
>=
MIN_BYTES_FOR_
SPEEDUP
_CALCULATION
)
{
public
long
getMediaDuration
(
long
playoutD
uration
)
{
if
(
outputBytes
>=
MIN_BYTES_FOR_
DURATION_SCALING
_CALCULATION
)
{
return
outputAudioFormat
.
sampleRate
==
inputAudioFormat
.
sampleRate
?
Util
.
scaleLargeTimestamp
(
d
uration
,
inputBytes
,
outputBytes
)
?
Util
.
scaleLargeTimestamp
(
playoutD
uration
,
inputBytes
,
outputBytes
)
:
Util
.
scaleLargeTimestamp
(
d
uration
,
playoutD
uration
,
inputBytes
*
outputAudioFormat
.
sampleRate
,
outputBytes
*
inputAudioFormat
.
sampleRate
);
}
else
{
return
(
long
)
((
double
)
speed
*
d
uration
);
return
(
long
)
((
double
)
speed
*
playoutD
uration
);
}
}
...
...
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