From 5439223b5633679edcc255651e7062046004d75d Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Tue, 24 May 2011 15:53:33 -0700 Subject: Use channel mask instead of channel count for track creation Record and playback objects (resp AudioRecord and AudioTrack) are created using a channel mask, but this information is lost in the mixer because only the channel count is known to AudioFlinger. A channel count can always be derived from a channel mask. The change consists in: - disambiguiting variable names for channel masks and counts - passing the mask information from the client to AudioFlinger and the mixer. - when using the DIRECT ouput, only verifying the format of the track is compatible with the output's for PCM. Change-Id: I50d87bfb7d7afcabdf5f12d4ab75ef3a54132c0e --- include/media/AudioRecord.h | 16 ++++++++-------- include/media/AudioTrack.h | 19 ++++++++++--------- include/media/IAudioFlinger.h | 10 +++++----- include/private/media/AudioTrackShared.h | 3 ++- 4 files changed, 25 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h index baab2e8..605680a 100644 --- a/include/media/AudioRecord.h +++ b/include/media/AudioRecord.h @@ -130,7 +130,7 @@ public: * sampleRate: Track sampling rate in Hz. * format: Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed * 16 bits per sample). - * channels: Channel mask: see audio_channels_t. + * channelMask: Channel mask: see audio_channels_t. * frameCount: Total size of track PCM buffer in frames. This defines the * latency of the track. * flags: A bitmask of acoustic values from enum record_flags. It enables @@ -151,7 +151,7 @@ public: AudioRecord(int inputSource, uint32_t sampleRate = 0, int format = 0, - uint32_t channels = AUDIO_CHANNEL_IN_MONO, + uint32_t channelMask = AUDIO_CHANNEL_IN_MONO, int frameCount = 0, uint32_t flags = 0, callback_t cbf = 0, @@ -177,7 +177,7 @@ public: status_t set(int inputSource = 0, uint32_t sampleRate = 0, int format = 0, - uint32_t channels = AUDIO_CHANNEL_IN_MONO, + uint32_t channelMask = AUDIO_CHANNEL_IN_MONO, int frameCount = 0, uint32_t flags = 0, callback_t cbf = 0, @@ -348,8 +348,8 @@ private: bool processAudioBuffer(const sp& thread); status_t openRecord_l(uint32_t sampleRate, - int format, - int channelCount, + uint32_t format, + uint32_t channelMask, int frameCount, uint32_t flags, audio_io_handle_t input); @@ -364,10 +364,10 @@ private: uint32_t mFrameCount; audio_track_cblk_t* mCblk; - uint8_t mFormat; + uint32_t mFormat; uint8_t mChannelCount; uint8_t mInputSource; - uint8_t mReserved; + uint8_t mReserved[2]; status_t mStatus; uint32_t mLatency; @@ -382,7 +382,7 @@ private: uint32_t mNewPosition; uint32_t mUpdatePeriod; uint32_t mFlags; - uint32_t mChannels; + uint32_t mChannelMask; audio_io_handle_t mInput; int mSessionId; }; diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h index de928da..df30e8c 100644 --- a/include/media/AudioTrack.h +++ b/include/media/AudioTrack.h @@ -69,8 +69,8 @@ public: MUTE = 0x00000001 }; uint32_t flags; - int channelCount; int format; + int channelCount; // will be removed in the future, do not use size_t frameCount; size_t size; union { @@ -129,7 +129,7 @@ public: * sampleRate: Track sampling rate in Hz. * format: Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed * 16 bits per sample). - * channels: Channel mask: see audio_channels_t. + * channelMask: Channel mask: see audio_channels_t. * frameCount: Total size of track PCM buffer in frames. This defines the * latency of the track. * flags: Reserved for future use. @@ -143,7 +143,7 @@ public: AudioTrack( int streamType, uint32_t sampleRate = 0, int format = 0, - int channels = 0, + int channelMask = 0, int frameCount = 0, uint32_t flags = 0, callback_t cbf = 0, @@ -163,7 +163,7 @@ public: AudioTrack( int streamType, uint32_t sampleRate = 0, int format = 0, - int channels = 0, + int channelMask = 0, const sp& sharedBuffer = 0, uint32_t flags = 0, callback_t cbf = 0, @@ -187,7 +187,7 @@ public: status_t set(int streamType =-1, uint32_t sampleRate = 0, int format = 0, - int channels = 0, + int channelMask = 0, int frameCount = 0, uint32_t flags = 0, callback_t cbf = 0, @@ -438,8 +438,8 @@ private: bool processAudioBuffer(const sp& thread); status_t createTrack_l(int streamType, uint32_t sampleRate, - int format, - int channelCount, + uint32_t format, + uint32_t channelMask, int frameCount, uint32_t flags, const sp& sharedBuffer, @@ -459,11 +459,12 @@ private: uint32_t mFrameCount; audio_track_cblk_t* mCblk; + uint32_t mFormat; uint8_t mStreamType; - uint8_t mFormat; uint8_t mChannelCount; uint8_t mMuted; - uint32_t mChannels; + uint8_t mReserved; + uint32_t mChannelMask; status_t mStatus; uint32_t mLatency; diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h index d8fdc27..4037c46 100644 --- a/include/media/IAudioFlinger.h +++ b/include/media/IAudioFlinger.h @@ -48,8 +48,8 @@ public: pid_t pid, int streamType, uint32_t sampleRate, - int format, - int channelCount, + uint32_t format, + uint32_t channelMask, int frameCount, uint32_t flags, const sp& sharedBuffer, @@ -61,8 +61,8 @@ public: pid_t pid, int input, uint32_t sampleRate, - int format, - int channelCount, + uint32_t format, + uint32_t channelMask, int frameCount, uint32_t flags, int *sessionId, @@ -73,7 +73,7 @@ public: */ virtual uint32_t sampleRate(int output) const = 0; virtual int channelCount(int output) const = 0; - virtual int format(int output) const = 0; + virtual uint32_t format(int output) const = 0; virtual size_t frameCount(int output) const = 0; virtual uint32_t latency(int output) const = 0; diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h index 1827c3e..072329d 100644 --- a/include/private/media/AudioTrackShared.h +++ b/include/private/media/AudioTrackShared.h @@ -82,7 +82,7 @@ struct audio_track_cblk_t // 16 bit because data is converted to 16 bit before being stored in buffer uint8_t frameSize; - uint8_t channelCount; + uint8_t pad1; uint16_t bufferTimeoutMs; // Maximum cumulated timeout before restarting audioflinger uint16_t waitTimeMs; // Cumulated wait time @@ -90,6 +90,7 @@ struct audio_track_cblk_t volatile int32_t flags; // Cache line boundary (32 bytes) + audio_track_cblk_t(); uint32_t stepUser(uint32_t frameCount); bool stepServer(uint32_t frameCount); -- cgit v1.1