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
d5829336
authored
Nov 23, 2020
by
olly
Committed by
Ian Baker
Nov 30, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove unused logic in SonicAudioProcessor
PiperOrigin-RevId: 343882631
parent
10bc77c1
Hide 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 @
d5829336
...
@@ -113,8 +113,11 @@ public final class DefaultAudioSink implements AudioSink {
...
@@ -113,8 +113,11 @@ public final class DefaultAudioSink implements AudioSink {
boolean
applySkipSilenceEnabled
(
boolean
skipSilenceEnabled
);
boolean
applySkipSilenceEnabled
(
boolean
skipSilenceEnabled
);
/**
/**
* Scales the specified playout duration to take into account speedup due to audio processing,
* Returns the media duration corresponding to the specified playout duration, taking speed
* returning an input media duration, in arbitrary units.
* 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
);
long
getMediaDuration
(
long
playoutDuration
);
...
@@ -173,9 +176,9 @@ public final class DefaultAudioSink implements AudioSink {
...
@@ -173,9 +176,9 @@ public final class DefaultAudioSink implements AudioSink {
@Override
@Override
public
PlaybackParameters
applyPlaybackParameters
(
PlaybackParameters
playbackParameters
)
{
public
PlaybackParameters
applyPlaybackParameters
(
PlaybackParameters
playbackParameters
)
{
float
speed
=
sonicAudioProcessor
.
setSpeed
(
playbackParameters
.
speed
);
sonicAudioProcessor
.
setSpeed
(
playbackParameters
.
speed
);
float
pitch
=
sonicAudioProcessor
.
setPitch
(
playbackParameters
.
pitch
);
sonicAudioProcessor
.
setPitch
(
playbackParameters
.
pitch
);
return
new
PlaybackParameters
(
speed
,
pitch
)
;
return
playbackParameters
;
}
}
@Override
@Override
...
@@ -186,7 +189,7 @@ public final class DefaultAudioSink implements AudioSink {
...
@@ -186,7 +189,7 @@ public final class DefaultAudioSink implements AudioSink {
@Override
@Override
public
long
getMediaDuration
(
long
playoutDuration
)
{
public
long
getMediaDuration
(
long
playoutDuration
)
{
return
sonicAudioProcessor
.
scaleDurationForSpeedup
(
playoutDuration
);
return
sonicAudioProcessor
.
getMediaDuration
(
playoutDuration
);
}
}
@Override
@Override
...
...
library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java
View file @
d5829336
...
@@ -36,10 +36,10 @@ public final class SonicAudioProcessor implements AudioProcessor {
...
@@ -36,10 +36,10 @@ public final class SonicAudioProcessor implements AudioProcessor {
private
static
final
float
CLOSE_THRESHOLD
=
0.01f
;
private
static
final
float
CLOSE_THRESHOLD
=
0.01f
;
/**
/**
* The minimum number of output bytes
at which the speedup is calculated using the input/output
* The minimum number of output bytes
required for duration scaling to be calculated using the
*
byte counts, rather than using the current playback parameters
speed.
*
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
int
pendingOutputSampleRate
;
private
float
speed
;
private
float
speed
;
...
@@ -74,35 +74,31 @@ public final class SonicAudioProcessor implements AudioProcessor {
...
@@ -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
* processor. The value returned by {@link #isActive()} may change, and the processor must be
* {@link #flush() flushed} before queueing more data.
* {@link #flush() flushed} before queueing more data.
*
*
* @param speed The requested new playback speed.
* @param speed The target playback speed.
* @return The actual new playback speed.
*/
*/
public
float
setSpeed
(
float
speed
)
{
public
void
setSpeed
(
float
speed
)
{
if
(
this
.
speed
!=
speed
)
{
if
(
this
.
speed
!=
speed
)
{
this
.
speed
=
speed
;
this
.
speed
=
speed
;
pendingSonicRecreation
=
true
;
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
* processor. The value returned by {@link #isActive()} may change, and the processor must be
* {@link #flush() flushed} before queueing more data.
* {@link #flush() flushed} before queueing more data.
*
*
* @param pitch The requested new pitch.
* @param pitch The target pitch.
* @return The actual new pitch.
*/
*/
public
float
setPitch
(
float
pitch
)
{
public
void
setPitch
(
float
pitch
)
{
if
(
this
.
pitch
!=
pitch
)
{
if
(
this
.
pitch
!=
pitch
)
{
this
.
pitch
=
pitch
;
this
.
pitch
=
pitch
;
pendingSonicRecreation
=
true
;
pendingSonicRecreation
=
true
;
}
}
return
pitch
;
}
}
/**
/**
...
@@ -118,23 +114,22 @@ public final class SonicAudioProcessor implements AudioProcessor {
...
@@ -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,
* Returns the
media duration corresponding to the specified playout duration, taking speed
*
in the same units as {@code duration}
.
*
adjustment into account
.
*
*
* @param duration The duration to scale taking into account speedup.
* @param playoutDuration The playout duration to scale.
* @return The specified duration scaled to take into account speedup, in the same units as
* @return The corresponding media duration, in the same units as {@code duration}.
* {@code duration}.
*/
*/
public
long
scaleDurationForSpeedup
(
long
d
uration
)
{
public
long
getMediaDuration
(
long
playoutD
uration
)
{
if
(
outputBytes
>=
MIN_BYTES_FOR_
SPEEDUP
_CALCULATION
)
{
if
(
outputBytes
>=
MIN_BYTES_FOR_
DURATION_SCALING
_CALCULATION
)
{
return
outputAudioFormat
.
sampleRate
==
inputAudioFormat
.
sampleRate
return
outputAudioFormat
.
sampleRate
==
inputAudioFormat
.
sampleRate
?
Util
.
scaleLargeTimestamp
(
d
uration
,
inputBytes
,
outputBytes
)
?
Util
.
scaleLargeTimestamp
(
playoutD
uration
,
inputBytes
,
outputBytes
)
:
Util
.
scaleLargeTimestamp
(
:
Util
.
scaleLargeTimestamp
(
d
uration
,
playoutD
uration
,
inputBytes
*
outputAudioFormat
.
sampleRate
,
inputBytes
*
outputAudioFormat
.
sampleRate
,
outputBytes
*
inputAudioFormat
.
sampleRate
);
outputBytes
*
inputAudioFormat
.
sampleRate
);
}
else
{
}
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