Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8eca6bba authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "Accommodate the move of AudioPlaybackRate to system/audio.h"

parents 87bb9262 3784ab50
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@


#define AUDIO_PLAYER_H_
#define AUDIO_PLAYER_H_


#include <media/AudioResamplerPublic.h>
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MediaSource.h>
#include <media/MediaPlayerInterface.h>
#include <media/MediaPlayerInterface.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaBuffer.h>
@@ -25,7 +26,6 @@


namespace android {
namespace android {


struct AudioPlaybackRate;
class AudioTrack;
class AudioTrack;
struct AwesomePlayer;
struct AwesomePlayer;


+7 −58
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@


#include <stdint.h>
#include <stdint.h>
#include <math.h>
#include <math.h>
#include <system/audio.h>


namespace android {
namespace android {


@@ -37,68 +38,16 @@ namespace android {
// an int32_t of the phase increments, making the resulting sample rate inexact.
// an int32_t of the phase increments, making the resulting sample rate inexact.
#define AUDIO_RESAMPLER_UP_RATIO_MAX 65536
#define AUDIO_RESAMPLER_UP_RATIO_MAX 65536


// AUDIO_TIMESTRETCH_SPEED_MIN and AUDIO_TIMESTRETCH_SPEED_MAX define the min and max time stretch
// speeds supported by the system. These are enforced by the system and values outside this range
// will result in a runtime error.
// Depending on the AudioPlaybackRate::mStretchMode, the effective limits might be narrower than
// the ones specified here
// AUDIO_TIMESTRETCH_SPEED_MIN_DELTA is the minimum absolute speed difference that might trigger a
// parameter update
#define AUDIO_TIMESTRETCH_SPEED_MIN    0.01f
#define AUDIO_TIMESTRETCH_SPEED_MAX    20.0f
#define AUDIO_TIMESTRETCH_SPEED_NORMAL 1.0f
#define AUDIO_TIMESTRETCH_SPEED_MIN_DELTA 0.0001f

// AUDIO_TIMESTRETCH_PITCH_MIN and AUDIO_TIMESTRETCH_PITCH_MAX define the min and max time stretch
// pitch shifting supported by the system. These are not enforced by the system and values
// outside this range might result in a pitch different than the one requested.
// Depending on the AudioPlaybackRate::mStretchMode, the effective limits might be narrower than
// the ones specified here.
// AUDIO_TIMESTRETCH_PITCH_MIN_DELTA is the minimum absolute pitch difference that might trigger a
// parameter update
#define AUDIO_TIMESTRETCH_PITCH_MIN    0.25f
#define AUDIO_TIMESTRETCH_PITCH_MAX    4.0f
#define AUDIO_TIMESTRETCH_PITCH_NORMAL 1.0f
#define AUDIO_TIMESTRETCH_PITCH_MIN_DELTA 0.0001f


//Determines the current algorithm used for stretching
//Determines the current algorithm used for stretching
enum AudioTimestretchStretchMode : int32_t {
using AudioTimestretchStretchMode = ::audio_timestretch_stretch_mode_t;
    AUDIO_TIMESTRETCH_STRETCH_DEFAULT            = 0,
    AUDIO_TIMESTRETCH_STRETCH_SPEECH             = 1,
    //TODO: add more stretch modes/algorithms
};

//Limits for AUDIO_TIMESTRETCH_STRETCH_SPEECH mode
#define TIMESTRETCH_SONIC_SPEED_MIN 0.1f
#define TIMESTRETCH_SONIC_SPEED_MAX 6.0f


//Determines behavior of Timestretch if current algorithm can't perform
//Determines behavior of Timestretch if current algorithm can't perform
//with current parameters.
//with current parameters.
// FALLBACK_CUT_REPEAT: (internal only) for speed <1.0 will truncate frames
using AudioTimestretchFallbackMode = ::audio_timestretch_fallback_mode_t;
//    for speed > 1.0 will repeat frames

// FALLBACK_MUTE: will set all processed frames to zero
using AudioPlaybackRate = ::audio_playback_rate_t;
// FALLBACK_FAIL:  will stop program execution and log a fatal error

enum AudioTimestretchFallbackMode : int32_t {
static const AudioPlaybackRate AUDIO_PLAYBACK_RATE_DEFAULT = ::AUDIO_PLAYBACK_RATE_INITIALIZER;
    AUDIO_TIMESTRETCH_FALLBACK_CUT_REPEAT     = -1,
    AUDIO_TIMESTRETCH_FALLBACK_DEFAULT        = 0,
    AUDIO_TIMESTRETCH_FALLBACK_MUTE           = 1,
    AUDIO_TIMESTRETCH_FALLBACK_FAIL           = 2,
};

struct AudioPlaybackRate {
    float mSpeed;
    float mPitch;
    enum AudioTimestretchStretchMode  mStretchMode;
    enum AudioTimestretchFallbackMode mFallbackMode;
};

static const AudioPlaybackRate AUDIO_PLAYBACK_RATE_DEFAULT = {
        AUDIO_TIMESTRETCH_SPEED_NORMAL,
        AUDIO_TIMESTRETCH_PITCH_NORMAL,
        AUDIO_TIMESTRETCH_STRETCH_DEFAULT,
        AUDIO_TIMESTRETCH_FALLBACK_DEFAULT
};


static inline bool isAudioPlaybackRateEqual(const AudioPlaybackRate &pr1,
static inline bool isAudioPlaybackRateEqual(const AudioPlaybackRate &pr1,
        const AudioPlaybackRate &pr2) {
        const AudioPlaybackRate &pr2) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@
#include <utils/KeyedVector.h>
#include <utils/KeyedVector.h>
#include <system/audio.h>
#include <system/audio.h>


#include <media/AudioResamplerPublic.h>
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MediaSource.h>
#include <media/VolumeShaper.h>
#include <media/VolumeShaper.h>


@@ -38,7 +39,6 @@ class IDataSource;
struct IStreamSource;
struct IStreamSource;
class IGraphicBufferProducer;
class IGraphicBufferProducer;
struct IMediaHTTPService;
struct IMediaHTTPService;
struct AudioPlaybackRate;
struct AVSyncSettings;
struct AVSyncSettings;
struct BufferingSettings;
struct BufferingSettings;


+1 −1
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@
#include <utils/String8.h>
#include <utils/String8.h>
#include <utils/Vector.h>
#include <utils/Vector.h>


#include <media/AudioResamplerPublic.h>
#include <media/AudioSystem.h>
#include <media/AudioSystem.h>
#include <media/MediaPlayerInterface.h>
#include <media/MediaPlayerInterface.h>
#include <media/Metadata.h>
#include <media/Metadata.h>
@@ -36,7 +37,6 @@


namespace android {
namespace android {


struct AudioPlaybackRate;
class AudioTrack;
class AudioTrack;
struct AVSyncSettings;
struct AVSyncSettings;
class DeathNotifier;
class DeathNotifier;
+0 −1
Original line number Original line Diff line number Diff line
@@ -27,7 +27,6 @@ namespace android {


struct ABuffer;
struct ABuffer;
struct AMessage;
struct AMessage;
struct AudioPlaybackRate;
struct AVSyncSettings;
struct AVSyncSettings;
class IDataSource;
class IDataSource;
struct MediaClock;
struct MediaClock;