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

Commit 4e2293f2 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

AudioMixer new cmd: remove sample rate converter

Add a new command REMOVE to remove any sample rate converter
   on a track, without having to delete the track name.
Add comments.
Remove some dead code.
Fix whitespace and comparison to NULL.

Change-Id: Id55a23ab5ee673189e99675b4e6fa5df7b617987
parent 99a80e10
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -327,15 +327,9 @@ void AudioMixer::deleteTrackName(int name)
        track.enabled = false;
        invalidateState(1<<name);
    }
    if (track.resampler != NULL) {
    // delete the resampler
    delete track.resampler;
    track.resampler = NULL;
        track.sampleRate = mSampleRate;
        invalidateState(1<<name);
    }
    track.volumeInc[0] = 0;
    track.volumeInc[1] = 0;
    mTrackNames &= ~(1<<name);
}

@@ -439,6 +433,12 @@ void AudioMixer::setParameter(int name, int target, int param, void *value)
            track.resetResampler();
            invalidateState(1 << name);
            break;
        case REMOVE:
            delete track.resampler;
            track.resampler = NULL;
            track.sampleRate = mSampleRate;
            invalidateState(1 << name);
            break;
        default:
            LOG_FATAL("bad param");
        }
@@ -499,7 +499,7 @@ void AudioMixer::setParameter(int name, int target, int param, void *value)

bool AudioMixer::track_t::setResampler(uint32_t value, uint32_t devSampleRate)
{
    if (value!=devSampleRate || resampler) {
    if (value != devSampleRate || resampler != NULL) {
        if (sampleRate != value) {
            sampleRate = value;
            if (resampler == NULL) {
+14 −2
Original line number Diff line number Diff line
@@ -70,8 +70,17 @@ public:
        AUX_BUFFER      = 0x4003,
        DOWNMIX_TYPE    = 0X4004,
        // for target RESAMPLE
        SAMPLE_RATE     = 0x4100,
        RESET           = 0x4101,
        SAMPLE_RATE     = 0x4100, // Configure sample rate conversion on this track name;
                                  // parameter 'value' is the new sample rate in Hz.
                                  // Only creates a sample rate converter the first time that
                                  // the track sample rate is different from the mix sample rate.
                                  // If the new sample rate is the same as the mix sample rate,
                                  // and a sample rate converter already exists,
                                  // then the sample rate converter remains present but is a no-op.
        RESET           = 0x4101, // Reset sample rate converter without changing sample rate.
                                  // This clears out the resampler's input buffer.
        REMOVE          = 0x4102, // Remove the sample rate converter on this track name;
                                  // the track is restored to the mix sample rate.
        // for target RAMP_VOLUME and VOLUME (8 channels max)
        VOLUME0         = 0x4200,
        VOLUME1         = 0x4201,
@@ -237,7 +246,10 @@ private:
    // indicates whether a downmix effect has been found and is usable by this mixer
    static bool                isMultichannelCapable;

    // Call after changing either the enabled status of a track, or parameters of an enabled track.
    // OK to call more often than that, but unnecessary.
    void invalidateState(uint32_t mask);

    static status_t prepareTrackForDownmix(track_t* pTrack, int trackNum);

    static void track__genericResample(track_t* t, int32_t* out, size_t numFrames, int32_t* temp, int32_t* aux);