diff options
-rw-r--r-- | services/audioflinger/AudioMixer.cpp | 20 | ||||
-rw-r--r-- | services/audioflinger/AudioMixer.h | 16 |
2 files changed, 24 insertions, 12 deletions
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index 05fa3b9..100f289 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -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; + // delete the resampler + delete track.resampler; + track.resampler = NULL; 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) { diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h index a04fe95..9698d0c 100644 --- a/services/audioflinger/AudioMixer.h +++ b/services/audioflinger/AudioMixer.h @@ -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); |