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 ++-- media/libmediaplayerservice/MediaPlayerService.cpp | 12 ++++++------ media/libmediaplayerservice/MediaPlayerService.h | 12 ++++++------ 6 files changed, 32 insertions(+), 32 deletions(-) (limited to 'media') 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; diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index 487c433..ccfd95a 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -1149,7 +1149,7 @@ int Antagonizer::callbackThread(void* user) static size_t kDefaultHeapSize = 1024 * 1024; // 1MB -sp MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) +sp MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) { ALOGV("decode(%s)", url); sp mem; @@ -1197,7 +1197,7 @@ sp MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, i mem = new MemoryBase(cache->getHeap(), 0, cache->size()); *pSampleRate = cache->sampleRate(); *pNumChannels = cache->channelCount(); - *pFormat = (int)cache->format(); + *pFormat = cache->format(); ALOGV("return memory @ %p, sampleRate=%u, channelCount = %d, format = %d", mem->pointer(), *pSampleRate, *pNumChannels, *pFormat); Exit: @@ -1205,7 +1205,7 @@ Exit: return mem; } -sp MediaPlayerService::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) +sp MediaPlayerService::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 mem; @@ -1339,7 +1339,7 @@ status_t MediaPlayerService::AudioOutput::getPosition(uint32_t *position) } status_t MediaPlayerService::AudioOutput::open( - uint32_t sampleRate, int channelCount, int format, int bufferCount, + uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount, AudioCallback cb, void *cookie) { mCallback = cb; @@ -1611,7 +1611,7 @@ bool CallbackThread::threadLoop() { //////////////////////////////////////////////////////////////////////////////// status_t MediaPlayerService::AudioCache::open( - uint32_t sampleRate, int channelCount, int format, int bufferCount, + uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount, AudioCallback cb, void *cookie) { ALOGV("open(%u, %d, %d, %d)", sampleRate, channelCount, format, bufferCount); @@ -1621,7 +1621,7 @@ status_t MediaPlayerService::AudioCache::open( mSampleRate = sampleRate; mChannelCount = (uint16_t)channelCount; - mFormat = (uint16_t)format; + mFormat = format; mMsecsPerFrame = 1.e3 / (float) sampleRate; if (cb != NULL) { diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h index 04d9e28..66f245d 100644 --- a/media/libmediaplayerservice/MediaPlayerService.h +++ b/media/libmediaplayerservice/MediaPlayerService.h @@ -83,7 +83,7 @@ class MediaPlayerService : public BnMediaPlayerService virtual status_t open( uint32_t sampleRate, int channelCount, - int format, int bufferCount, + audio_format_t format, int bufferCount, AudioCallback cb, void *cookie); virtual void start(); @@ -139,7 +139,7 @@ class MediaPlayerService : public BnMediaPlayerService virtual int getSessionId(); virtual status_t open( - uint32_t sampleRate, int channelCount, int format, + uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount = 1, AudioCallback cb = NULL, void *cookie = NULL); @@ -152,7 +152,7 @@ class MediaPlayerService : public BnMediaPlayerService void setAudioStreamType(int streamType) {} void setVolume(float left, float right) {} uint32_t sampleRate() const { return mSampleRate; } - uint32_t format() const { return (uint32_t)mFormat; } + audio_format_t format() const { return mFormat; } size_t size() const { return mSize; } status_t wait(); @@ -170,7 +170,7 @@ class MediaPlayerService : public BnMediaPlayerService sp mHeap; float mMsecsPerFrame; uint16_t mChannelCount; - uint16_t mFormat; + audio_format_t mFormat; ssize_t mFrameCount; uint32_t mSampleRate; uint32_t mSize; @@ -190,8 +190,8 @@ public: virtual sp create(pid_t pid, const sp& client, int audioSessionId); - virtual sp decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat); - virtual sp decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat); + virtual sp decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat); + virtual sp decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat); virtual sp getOMX(); virtual status_t dump(int fd, const Vector& args); -- cgit v1.1