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
diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp
index 40db37f..56dcf17 100644
--- a/media/jni/soundpool/SoundPool.cpp
+++ b/media/jni/soundpool/SoundPool.cpp
@@ -496,7 +496,7 @@
{
uint32_t sampleRate;
int numChannels;
- int format;
+ audio_format_t format;
sp<IMemory> p;
ALOGV("Start decode");
if (mUrl) {
diff --git a/media/jni/soundpool/SoundPool.h b/media/jni/soundpool/SoundPool.h
index 6010aac..1b91b3b 100644
--- a/media/jni/soundpool/SoundPool.h
+++ b/media/jni/soundpool/SoundPool.h
@@ -56,7 +56,7 @@
int sampleID() { return mSampleID; }
int numChannels() { return mNumChannels; }
int sampleRate() { return mSampleRate; }
- int format() { return mFormat; }
+ audio_format_t format() { return mFormat; }
size_t size() { return mSize; }
int state() { return mState; }
uint8_t* data() { return static_cast<uint8_t*>(mData->pointer()); }
@@ -65,7 +65,7 @@
sp<IMemory> getIMemory() { return mData; }
// hack
- void init(int numChannels, int sampleRate, int format, size_t size, sp<IMemory> data ) {
+ void init(int numChannels, int sampleRate, audio_format_t format, size_t size, sp<IMemory> data ) {
mNumChannels = numChannels; mSampleRate = sampleRate; mFormat = format; mSize = size; mData = data; }
private:
@@ -77,7 +77,7 @@
uint16_t mSampleRate;
uint8_t mState : 3;
uint8_t mNumChannels : 2;
- uint8_t mFormat : 2;
+ audio_format_t mFormat;
int mFd;
int64_t mOffset;
int64_t mLength;
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(
int streamType,
uint32_t sampleRate,
- int format,
+ audio_format_t format,
int channelMask,
int frameCount,
uint32_t flags,
@@ -104,7 +104,7 @@
AudioTrack::AudioTrack(
int streamType,
uint32_t sampleRate,
- int format,
+ audio_format_t format,
int channelMask,
const sp<IMemory>& sharedBuffer,
uint32_t flags,
@@ -142,7 +142,7 @@
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 @@
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 @@
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 @@
// create the IAudioTrack
status_t status = createTrack_l(streamType,
sampleRate,
- (uint32_t)format,
+ format,
(uint32_t)channelMask,
frameCount,
flags,
@@ -247,7 +247,7 @@
mStatus = NO_ERROR;
mStreamType = streamType;
- mFormat = (uint32_t)format;
+ mFormat = format;
mChannelMask = (uint32_t)channelMask;
mChannelCount = channelCount;
mSharedBuffer = sharedBuffer;
@@ -284,7 +284,7 @@
return mStreamType;
}
-int AudioTrack::format() const
+audio_format_t AudioTrack::format() const
{
return mFormat;
}
@@ -715,7 +715,7 @@
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 @@
return interface_cast<IMediaRecorder>(reply.readStrongBinder());
}
- virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+ virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
{
Parcel data, reply;
data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
@@ -86,11 +86,11 @@
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<IMemory>(reply.readStrongBinder());
}
- virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+ virtual sp<IMemory> 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 @@
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<IMemory>(reply.readStrongBinder());
}
@@ -148,11 +148,11 @@
const char* url = data.readCString();
uint32_t sampleRate;
int numChannels;
- int format;
+ audio_format_t format;
sp<IMemory> 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 @@
int64_t length = data.readInt64();
uint32_t sampleRate;
int numChannels;
- int format;
+ audio_format_t format;
sp<IMemory> 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 @@
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 @@
}
}
-/*static*/ sp<IMemory> MediaPlayer::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+/*static*/ sp<IMemory> MediaPlayer::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
{
ALOGV("decode(%s)", url);
sp<IMemory> p;
@@ -729,7 +729,7 @@
notify(MEDIA_ERROR, MEDIA_ERROR_SERVER_DIED, 0);
}
-/*static*/ sp<IMemory> MediaPlayer::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+/*static*/ sp<IMemory> 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<IMemory> 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 @@
static size_t kDefaultHeapSize = 1024 * 1024; // 1MB
-sp<IMemory> MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+sp<IMemory> MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
{
ALOGV("decode(%s)", url);
sp<MemoryBase> mem;
@@ -1197,7 +1197,7 @@
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 @@
return mem;
}
-sp<IMemory> MediaPlayerService::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+sp<IMemory> 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<MemoryBase> mem;
@@ -1339,7 +1339,7 @@
}
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 @@
////////////////////////////////////////////////////////////////////////////////
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 @@
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 @@
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 @@
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 @@
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 @@
sp<MemoryHeapBase> 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 @@
virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, int audioSessionId);
- virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
- virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
+ virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
+ virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
virtual sp<IOMX> getOMX();
virtual status_t dump(int fd, const Vector<String16>& args);