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

Commit b74a9004 authored by Andreas Huber's avatar Andreas Huber Committed by Android Git Automerger
Browse files

am 4cb8a163: am 1c730d33: Merge "ALooper::GetNowUs() now relies on systemTime...

am 4cb8a163: am 1c730d33: Merge "ALooper::GetNowUs() now relies on systemTime instead of gettimeofday." into jb-mr1-dev

* commit '4cb8a163':
  ALooper::GetNowUs() now relies on systemTime instead of gettimeofday.
parents d05ed53b 4cb8a163
Loading
Loading
Loading
Loading
+0 −8
Original line number Original line Diff line number Diff line
@@ -53,12 +53,6 @@ struct AudioSource : public MediaSource, public MediaBufferObserver {
    status_t dataCallback(const AudioRecord::Buffer& buffer);
    status_t dataCallback(const AudioRecord::Buffer& buffer);
    virtual void signalBufferReturned(MediaBuffer *buffer);
    virtual void signalBufferReturned(MediaBuffer *buffer);


    // If useLooperTime == true, buffers will carry absolute timestamps
    // as returned by ALooper::GetNowUs(), otherwise systemTime() is used
    // and buffers contain timestamps relative to start time.
    // The default is to _not_ use looper time.
    void setUseLooperTime(bool useLooperTime);

protected:
protected:
    virtual ~AudioSource();
    virtual ~AudioSource();


@@ -94,8 +88,6 @@ private:


    List<MediaBuffer * > mBuffersReceived;
    List<MediaBuffer * > mBuffersReceived;


    bool mUseLooperTime;

    void trackMaxAmplitude(int16_t *data, int nSamples);
    void trackMaxAmplitude(int16_t *data, int nSamples);


    // This is used to raise the volume from mute to the
    // This is used to raise the volume from mute to the
+0 −2
Original line number Original line Diff line number Diff line
@@ -41,8 +41,6 @@ public:
    virtual int64_t getRealTimeUs();
    virtual int64_t getRealTimeUs();


private:
private:
    static int64_t GetSystemTimeUs();

    int64_t mStartTimeUs;
    int64_t mStartTimeUs;
};
};


+3 −14
Original line number Original line Diff line number Diff line
@@ -54,9 +54,7 @@ AudioSource::AudioSource(
      mSampleRate(sampleRate),
      mSampleRate(sampleRate),
      mPrevSampleTimeUs(0),
      mPrevSampleTimeUs(0),
      mNumFramesReceived(0),
      mNumFramesReceived(0),
      mNumClientOwnedBuffers(0),
      mNumClientOwnedBuffers(0) {
      mUseLooperTime(false) {

    ALOGV("sampleRate: %d, channelCount: %d", sampleRate, channelCount);
    ALOGV("sampleRate: %d, channelCount: %d", sampleRate, channelCount);
    CHECK(channelCount == 1 || channelCount == 2);
    CHECK(channelCount == 1 || channelCount == 2);


@@ -102,12 +100,6 @@ status_t AudioSource::initCheck() const {
    return mInitCheck;
    return mInitCheck;
}
}


void AudioSource::setUseLooperTime(bool useLooperTime) {
    CHECK(!mStarted);

    mUseLooperTime = useLooperTime;
}

status_t AudioSource::start(MetaData *params) {
status_t AudioSource::start(MetaData *params) {
    Mutex::Autolock autoLock(mLock);
    Mutex::Autolock autoLock(mLock);
    if (mStarted) {
    if (mStarted) {
@@ -280,8 +272,7 @@ void AudioSource::signalBufferReturned(MediaBuffer *buffer) {
}
}


status_t AudioSource::dataCallback(const AudioRecord::Buffer& audioBuffer) {
status_t AudioSource::dataCallback(const AudioRecord::Buffer& audioBuffer) {
    int64_t timeUs =
    int64_t timeUs = systemTime() / 1000ll;
        mUseLooperTime ? ALooper::GetNowUs() : (systemTime() / 1000ll);


    ALOGV("dataCallbackTimestamp: %lld us", timeUs);
    ALOGV("dataCallbackTimestamp: %lld us", timeUs);
    Mutex::Autolock autoLock(mLock);
    Mutex::Autolock autoLock(mLock);
@@ -300,9 +291,7 @@ status_t AudioSource::dataCallback(const AudioRecord::Buffer& audioBuffer) {
    if (mNumFramesReceived == 0 && mPrevSampleTimeUs == 0) {
    if (mNumFramesReceived == 0 && mPrevSampleTimeUs == 0) {
        mInitialReadTimeUs = timeUs;
        mInitialReadTimeUs = timeUs;
        // Initial delay
        // Initial delay
        if (mUseLooperTime) {
        if (mStartTimeUs > 0) {
            mStartTimeUs = timeUs;
        } else if (mStartTimeUs > 0) {
            mStartTimeUs = timeUs - mStartTimeUs;
            mStartTimeUs = timeUs - mStartTimeUs;
        } else {
        } else {
            // Assume latency is constant.
            // Assume latency is constant.
+2 −8
Original line number Original line Diff line number Diff line
@@ -17,16 +17,10 @@
#include "include/ThrottledSource.h"
#include "include/ThrottledSource.h"


#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ALooper.h>


namespace android {
namespace android {


static int64_t getNowUs() {
    struct timeval tv;
    gettimeofday(&tv, NULL);

    return (int64_t)tv.tv_usec + tv.tv_sec * 1000000ll;
}

ThrottledSource::ThrottledSource(
ThrottledSource::ThrottledSource(
        const sp<DataSource> &source,
        const sp<DataSource> &source,
        int32_t bandwidthLimitBytesPerSecond)
        int32_t bandwidthLimitBytesPerSecond)
@@ -52,7 +46,7 @@ ssize_t ThrottledSource::readAt(off64_t offset, void *data, size_t size) {


    mTotalTransferred += n;
    mTotalTransferred += n;


    int64_t nowUs = getNowUs();
    int64_t nowUs = ALooper::GetNowUs();


    if (mStartTimeUs < 0) {
    if (mStartTimeUs < 0) {
        mStartTimeUs = nowUs;
        mStartTimeUs = nowUs;
+3 −10
Original line number Original line Diff line number Diff line
@@ -17,24 +17,17 @@
#include <stddef.h>
#include <stddef.h>
#include <sys/time.h>
#include <sys/time.h>


#include <media/stagefright/foundation/ALooper.h>
#include <media/stagefright/TimeSource.h>
#include <media/stagefright/TimeSource.h>


namespace android {
namespace android {


SystemTimeSource::SystemTimeSource()
SystemTimeSource::SystemTimeSource()
    : mStartTimeUs(GetSystemTimeUs()) {
    : mStartTimeUs(ALooper::GetNowUs()) {
}
}


int64_t SystemTimeSource::getRealTimeUs() {
int64_t SystemTimeSource::getRealTimeUs() {
    return GetSystemTimeUs() - mStartTimeUs;
    return ALooper::GetNowUs() - mStartTimeUs;
}

// static
int64_t SystemTimeSource::GetSystemTimeUs() {
    struct timeval tv;
    gettimeofday(&tv, NULL);

    return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
}
}


}  // namespace android
}  // namespace android
Loading