From e1c3962e268ffc12bfd1bd9ea84da1f135f36960 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Wed, 4 Jan 2012 09:36:37 -0800 Subject: Use audio_format_t consistently Was int, uint32_t, uint16_t, and uint8_t with 2-bit bitfield. Also replace 0 by AUDIO_FORMAT_DEFAULT and replace 1 by AUDIO_FORMAT_PCM_16_BIT. Change-Id: Ia8804f53f1725669e368857d5bb2044917e17975 --- media/libmedia/AudioTrack.cpp | 18 +++++++++--------- media/libmedia/IMediaPlayerService.cpp | 16 ++++++++-------- media/libmedia/JetPlayer.cpp | 2 +- media/libmedia/mediaplayer.cpp | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'media/libmedia') diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index e0c6ca5..607ca5b 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -85,7 +85,7 @@ AudioTrack::AudioTrack() AudioTrack::AudioTrack( int streamType, uint32_t sampleRate, - int format, + audio_format_t format, int channelMask, int frameCount, uint32_t flags, @@ -104,7 +104,7 @@ AudioTrack::AudioTrack( AudioTrack::AudioTrack( int streamType, uint32_t sampleRate, - int format, + audio_format_t format, int channelMask, const sp& sharedBuffer, uint32_t flags, @@ -142,7 +142,7 @@ AudioTrack::~AudioTrack() status_t AudioTrack::set( int streamType, uint32_t sampleRate, - int format, + audio_format_t format, int channelMask, int frameCount, uint32_t flags, @@ -179,7 +179,7 @@ status_t AudioTrack::set( sampleRate = afSampleRate; } // these below should probably come from the audioFlinger too... - if (format == 0) { + if (format == AUDIO_FORMAT_DEFAULT) { format = AUDIO_FORMAT_PCM_16_BIT; } if (channelMask == 0) { @@ -205,7 +205,7 @@ status_t AudioTrack::set( audio_io_handle_t output = AudioSystem::getOutput( (audio_stream_type_t)streamType, - sampleRate,format, channelMask, + sampleRate, format, channelMask, (audio_policy_output_flags_t)flags); if (output == 0) { @@ -224,7 +224,7 @@ status_t AudioTrack::set( // create the IAudioTrack status_t status = createTrack_l(streamType, sampleRate, - (uint32_t)format, + format, (uint32_t)channelMask, frameCount, flags, @@ -247,7 +247,7 @@ status_t AudioTrack::set( mStatus = NO_ERROR; mStreamType = streamType; - mFormat = (uint32_t)format; + mFormat = format; mChannelMask = (uint32_t)channelMask; mChannelCount = channelCount; mSharedBuffer = sharedBuffer; @@ -284,7 +284,7 @@ int AudioTrack::streamType() const return mStreamType; } -int AudioTrack::format() const +audio_format_t AudioTrack::format() const { return mFormat; } @@ -715,7 +715,7 @@ status_t AudioTrack::attachAuxEffect(int effectId) status_t AudioTrack::createTrack_l( int streamType, uint32_t sampleRate, - uint32_t format, + audio_format_t format, uint32_t channelMask, int frameCount, uint32_t flags, diff --git a/media/libmedia/IMediaPlayerService.cpp b/media/libmedia/IMediaPlayerService.cpp index 8e4dd04..f5b5cbd 100644 --- a/media/libmedia/IMediaPlayerService.cpp +++ b/media/libmedia/IMediaPlayerService.cpp @@ -78,7 +78,7 @@ public: return interface_cast(reply.readStrongBinder()); } - virtual sp decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) + virtual sp decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) { Parcel data, reply; data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); @@ -86,11 +86,11 @@ public: remote()->transact(DECODE_URL, data, &reply); *pSampleRate = uint32_t(reply.readInt32()); *pNumChannels = reply.readInt32(); - *pFormat = reply.readInt32(); + *pFormat = (audio_format_t) reply.readInt32(); return interface_cast(reply.readStrongBinder()); } - virtual sp decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) + virtual sp decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) { Parcel data, reply; data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); @@ -100,7 +100,7 @@ public: remote()->transact(DECODE_FD, data, &reply); *pSampleRate = uint32_t(reply.readInt32()); *pNumChannels = reply.readInt32(); - *pFormat = reply.readInt32(); + *pFormat = (audio_format_t) reply.readInt32(); return interface_cast(reply.readStrongBinder()); } @@ -148,11 +148,11 @@ status_t BnMediaPlayerService::onTransact( const char* url = data.readCString(); uint32_t sampleRate; int numChannels; - int format; + audio_format_t format; sp player = decode(url, &sampleRate, &numChannels, &format); reply->writeInt32(sampleRate); reply->writeInt32(numChannels); - reply->writeInt32(format); + reply->writeInt32((int32_t) format); reply->writeStrongBinder(player->asBinder()); return NO_ERROR; } break; @@ -163,11 +163,11 @@ status_t BnMediaPlayerService::onTransact( int64_t length = data.readInt64(); uint32_t sampleRate; int numChannels; - int format; + audio_format_t format; sp player = decode(fd, offset, length, &sampleRate, &numChannels, &format); reply->writeInt32(sampleRate); reply->writeInt32(numChannels); - reply->writeInt32(format); + reply->writeInt32((int32_t) format); reply->writeStrongBinder(player->asBinder()); return NO_ERROR; } break; diff --git a/media/libmedia/JetPlayer.cpp b/media/libmedia/JetPlayer.cpp index afa84b7..25c4898 100644 --- a/media/libmedia/JetPlayer.cpp +++ b/media/libmedia/JetPlayer.cpp @@ -91,7 +91,7 @@ int JetPlayer::init() mAudioTrack = new AudioTrack(); mAudioTrack->set(AUDIO_STREAM_MUSIC, //TODO parametrize this pLibConfig->sampleRate, - 1, // format = PCM 16bits per sample, + AUDIO_FORMAT_PCM_16_BIT, (pLibConfig->numChannels == 2) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO, mTrackBufferSize, 0); diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp index 695c4a8..92f3eb9 100644 --- a/media/libmedia/mediaplayer.cpp +++ b/media/libmedia/mediaplayer.cpp @@ -709,7 +709,7 @@ void MediaPlayer::notify(int msg, int ext1, int ext2, const Parcel *obj) } } -/*static*/ sp MediaPlayer::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) +/*static*/ sp MediaPlayer::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) { ALOGV("decode(%s)", url); sp p; @@ -729,7 +729,7 @@ void MediaPlayer::died() notify(MEDIA_ERROR, MEDIA_ERROR_SERVER_DIED, 0); } -/*static*/ sp MediaPlayer::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) +/*static*/ sp MediaPlayer::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) { ALOGV("decode(%d, %lld, %lld)", fd, offset, length); sp p; -- cgit v1.1