summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioMixer.h
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-03-26 18:46:00 -0700
committerAndy Hung <hunga@google.com>2015-04-08 23:31:22 -0700
commit857d5a20a956ef61b64ae07b018ecc2f1eb0a503 (patch)
tree6b0e743b3c7f027aff568ac842c629291d1d4207 /services/audioflinger/AudioMixer.h
parentf129b03fa583d4cc26fd9c9171b8fb3b0ed8d4f4 (diff)
downloadframeworks_av-857d5a20a956ef61b64ae07b018ecc2f1eb0a503.zip
frameworks_av-857d5a20a956ef61b64ae07b018ecc2f1eb0a503.tar.gz
frameworks_av-857d5a20a956ef61b64ae07b018ecc2f1eb0a503.tar.bz2
Factor out buffer provider code from AudioMixer
In preparation for playback rate support and timestretching. Bug: 19196501 Change-Id: I435accb852d32110dd0b3a9917488522c567ba80
Diffstat (limited to 'services/audioflinger/AudioMixer.h')
-rw-r--r--services/audioflinger/AudioMixer.h115
1 files changed, 4 insertions, 111 deletions
diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h
index 381036b..e283b83 100644
--- a/services/audioflinger/AudioMixer.h
+++ b/services/audioflinger/AudioMixer.h
@@ -29,6 +29,7 @@
#include <utils/threads.h>
#include "AudioResampler.h"
+#include "BufferProviders.h"
// FIXME This is actually unity gain, which might not be max in future, expressed in U.12
#define MAX_GAIN_INT AudioMixer::UNITY_GAIN_INT
@@ -159,7 +160,6 @@ private:
struct state_t;
struct track_t;
- class CopyBufferProvider;
typedef void (*hook_t)(track_t* t, int32_t* output, size_t numOutFrames, int32_t* temp,
int32_t* aux);
@@ -225,11 +225,10 @@ private:
* the downmixer requirements to the mixer engine input requirements.
*/
AudioBufferProvider* mInputBufferProvider; // externally provided buffer provider.
- CopyBufferProvider* mReformatBufferProvider; // provider wrapper for reformatting.
- CopyBufferProvider* downmixerBufferProvider; // wrapper for channel conversion.
- CopyBufferProvider* mPostDownmixReformatBufferProvider;
+ PassthruBufferProvider* mReformatBufferProvider; // provider wrapper for reformatting.
+ PassthruBufferProvider* downmixerBufferProvider; // wrapper for channel conversion.
+ PassthruBufferProvider* mPostDownmixReformatBufferProvider;
- // 16-byte boundary
int32_t sessionId;
audio_format_t mMixerFormat; // output mix format: AUDIO_FORMAT_PCM_(FLOAT|16_BIT)
@@ -282,112 +281,6 @@ private:
track_t tracks[MAX_NUM_TRACKS] __attribute__((aligned(32)));
};
- // Base AudioBufferProvider class used for DownMixerBufferProvider, RemixBufferProvider,
- // and ReformatBufferProvider.
- // It handles a private buffer for use in converting format or channel masks from the
- // input data to a form acceptable by the mixer.
- // TODO: Make a ResamplerBufferProvider when integers are entirely removed from the
- // processing pipeline.
- class CopyBufferProvider : public AudioBufferProvider {
- public:
- // Use a private buffer of bufferFrameCount frames (each frame is outputFrameSize bytes).
- // If bufferFrameCount is 0, no private buffer is created and in-place modification of
- // the upstream buffer provider's buffers is performed by copyFrames().
- CopyBufferProvider(size_t inputFrameSize, size_t outputFrameSize,
- size_t bufferFrameCount);
- virtual ~CopyBufferProvider();
-
- // Overrides AudioBufferProvider methods
- virtual status_t getNextBuffer(Buffer* buffer, int64_t pts);
- virtual void releaseBuffer(Buffer* buffer);
-
- // Other public methods
-
- // call this to release the buffer to the upstream provider.
- // treat it as an audio discontinuity for future samples.
- virtual void reset();
-
- // this function should be supplied by the derived class. It converts
- // #frames in the *src pointer to the *dst pointer. It is public because
- // some providers will allow this to work on arbitrary buffers outside
- // of the internal buffers.
- virtual void copyFrames(void *dst, const void *src, size_t frames) = 0;
-
- // set the upstream buffer provider. Consider calling "reset" before this function.
- void setBufferProvider(AudioBufferProvider *p) {
- mTrackBufferProvider = p;
- }
-
- protected:
- AudioBufferProvider* mTrackBufferProvider;
- const size_t mInputFrameSize;
- const size_t mOutputFrameSize;
- private:
- AudioBufferProvider::Buffer mBuffer;
- const size_t mLocalBufferFrameCount;
- void* mLocalBufferData;
- size_t mConsumed;
- };
-
- // DownmixerBufferProvider wraps a track AudioBufferProvider to provide
- // position dependent downmixing by an Audio Effect.
- class DownmixerBufferProvider : public CopyBufferProvider {
- public:
- DownmixerBufferProvider(audio_channel_mask_t inputChannelMask,
- audio_channel_mask_t outputChannelMask, audio_format_t format,
- uint32_t sampleRate, int32_t sessionId, size_t bufferFrameCount);
- virtual ~DownmixerBufferProvider();
- virtual void copyFrames(void *dst, const void *src, size_t frames);
- bool isValid() const { return mDownmixHandle != NULL; }
-
- static status_t init();
- static bool isMultichannelCapable() { return sIsMultichannelCapable; }
-
- protected:
- effect_handle_t mDownmixHandle;
- effect_config_t mDownmixConfig;
-
- // effect descriptor for the downmixer used by the mixer
- static effect_descriptor_t sDwnmFxDesc;
- // indicates whether a downmix effect has been found and is usable by this mixer
- static bool sIsMultichannelCapable;
- // FIXME: should we allow effects outside of the framework?
- // We need to here. A special ioId that must be <= -2 so it does not map to a session.
- static const int32_t SESSION_ID_INVALID_AND_IGNORED = -2;
- };
-
- // RemixBufferProvider wraps a track AudioBufferProvider to perform an
- // upmix or downmix to the proper channel count and mask.
- class RemixBufferProvider : public CopyBufferProvider {
- public:
- RemixBufferProvider(audio_channel_mask_t inputChannelMask,
- audio_channel_mask_t outputChannelMask, audio_format_t format,
- size_t bufferFrameCount);
- virtual void copyFrames(void *dst, const void *src, size_t frames);
-
- protected:
- const audio_format_t mFormat;
- const size_t mSampleSize;
- const size_t mInputChannels;
- const size_t mOutputChannels;
- int8_t mIdxAry[sizeof(uint32_t)*8]; // 32 bits => channel indices
- };
-
- // ReformatBufferProvider wraps a track AudioBufferProvider to convert the input data
- // to an acceptable mixer input format type.
- class ReformatBufferProvider : public CopyBufferProvider {
- public:
- ReformatBufferProvider(int32_t channels,
- audio_format_t inputFormat, audio_format_t outputFormat,
- size_t bufferFrameCount);
- virtual void copyFrames(void *dst, const void *src, size_t frames);
-
- protected:
- const int32_t mChannels;
- const audio_format_t mInputFormat;
- const audio_format_t mOutputFormat;
- };
-
// bitmask of allocated track names, where bit 0 corresponds to TRACK0 etc.
uint32_t mTrackNames;