diff options
Diffstat (limited to 'services/audioflinger/AudioFlinger.h')
-rw-r--r-- | services/audioflinger/AudioFlinger.h | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index bae18fd..ab4c567 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -55,6 +55,7 @@ #include "FastMixer.h" #include <media/nbaio/NBAIO.h> #include "AudioWatchdog.h" +#include "AudioMixer.h" #include <powermanager/IPowerManager.h> @@ -327,6 +328,30 @@ private: audio_devices_t devices); void purgeStaleEffects_l(); + // Set kEnableExtendedChannels to true to enable greater than stereo output + // for the MixerThread and device sink. Number of channels allowed is + // FCC_2 <= channels <= AudioMixer::MAX_NUM_CHANNELS. + static const bool kEnableExtendedChannels = false; + + // Returns true if channel mask is permitted for the PCM sink in the MixerThread + static inline bool isValidPcmSinkChannelMask(audio_channel_mask_t channelMask) { + switch (audio_channel_mask_get_representation(channelMask)) { + case AUDIO_CHANNEL_REPRESENTATION_POSITION: { + uint32_t channelCount = FCC_2; // stereo is default + if (kEnableExtendedChannels) { + channelCount = audio_channel_count_from_out_mask(channelMask); + if (channelCount > AudioMixer::MAX_NUM_CHANNELS) { + return false; + } + } + // check that channelMask is the "canonical" one we expect for the channelCount. + return channelMask == audio_channel_out_mask_from_count(channelCount); + } + default: + return false; + } + } + // Set kEnableExtendedPrecision to true to use extended precision in MixerThread static const bool kEnableExtendedPrecision = true; @@ -489,6 +514,18 @@ private: PlaybackThread *checkPlaybackThread_l(audio_io_handle_t output) const; MixerThread *checkMixerThread_l(audio_io_handle_t output) const; RecordThread *checkRecordThread_l(audio_io_handle_t input) const; + sp<RecordThread> openInput_l(audio_module_handle_t module, + audio_devices_t device, + struct audio_config *config, + audio_input_flags_t flags); + sp<PlaybackThread> openOutput_l(audio_module_handle_t module, + audio_devices_t device, + struct audio_config *config, + audio_output_flags_t flags); + + void closeOutputFinish(sp<PlaybackThread> thread); + void closeInputFinish(sp<RecordThread> thread); + // no range check, AudioFlinger::mLock held bool streamMute_l(audio_stream_type_t stream) const { return mStreamTypes[stream].mute; } @@ -530,10 +567,11 @@ private: AHWD_CAN_SET_MASTER_MUTE = 0x2, }; - AudioHwDevice(const char *moduleName, + AudioHwDevice(audio_module_handle_t handle, + const char *moduleName, audio_hw_device_t *hwDevice, Flags flags) - : mModuleName(strdup(moduleName)) + : mHandle(handle), mModuleName(strdup(moduleName)) , mHwDevice(hwDevice) , mFlags(flags) { } /*virtual*/ ~AudioHwDevice() { free((void *)mModuleName); } @@ -546,11 +584,13 @@ private: return (0 != (mFlags & AHWD_CAN_SET_MASTER_MUTE)); } + audio_module_handle_t handle() const { return mHandle; } const char *moduleName() const { return mModuleName; } audio_hw_device_t *hwDevice() const { return mHwDevice; } uint32_t version() const { return mHwDevice->common.version; } private: + const audio_module_handle_t mHandle; const char * const mModuleName; audio_hw_device_t * const mHwDevice; const Flags mFlags; @@ -669,7 +709,9 @@ private: // for use from destructor status_t closeOutput_nonvirtual(audio_io_handle_t output); + void closeOutputInternal_l(sp<PlaybackThread> thread); status_t closeInput_nonvirtual(audio_io_handle_t input); + void closeInputInternal_l(sp<RecordThread> thread); #ifdef TEE_SINK // all record threads serially share a common tee sink, which is re-created on format change |