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/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;