Change NBAIO_Format from typedef to struct

This will make it easier to support arbitrary sample rates,
channel counts, and sample formats in NBAIO.

Change-Id: I5eda412648b094358f5eefc38300e9ec8a734cd3
diff --git a/include/media/nbaio/NBAIO.h b/include/media/nbaio/NBAIO.h
index 468508c..4150a09 100644
--- a/include/media/nbaio/NBAIO.h
+++ b/include/media/nbaio/NBAIO.h
@@ -52,7 +52,10 @@
 // the combinations that are actually needed within AudioFlinger.  If the list of combinations grows
 // too large, then this decision should be re-visited.
 // Sample rate and channel count are explicit, PCM interleaved 16-bit is assumed.
-typedef unsigned NBAIO_Format;
+struct NBAIO_Format {
+//private:
+    unsigned    mPacked;
+};
 
 extern const NBAIO_Format Format_Invalid;
 
diff --git a/media/libnbaio/NBAIO.cpp b/media/libnbaio/NBAIO.cpp
index 18e0252..f630236 100644
--- a/media/libnbaio/NBAIO.cpp
+++ b/media/libnbaio/NBAIO.cpp
@@ -58,7 +58,7 @@
     if (!Format_isValid(format)) {
         return 0;
     }
-    switch (format & Format_SR_Mask) {
+    switch (format.mPacked & Format_SR_Mask) {
     case Format_SR_8000:
         return 8000;
     case Format_SR_11025:
@@ -85,7 +85,7 @@
     if (!Format_isValid(format)) {
         return 0;
     }
-    switch (format & Format_C_Mask) {
+    switch (format.mPacked & Format_C_Mask) {
     case Format_C_1:
         return 1;
     case Format_C_2:
@@ -97,7 +97,7 @@
 
 NBAIO_Format Format_from_SR_C(unsigned sampleRate, unsigned channelCount)
 {
-    NBAIO_Format format;
+    unsigned format;
     switch (sampleRate) {
     case 8000:
         format = Format_SR_8000;
@@ -136,7 +136,9 @@
     default:
         return Format_Invalid;
     }
-    return format;
+    NBAIO_Format ret;
+    ret.mPacked = format;
+    return ret;
 }
 
 // This is a default implementation; it is expected that subclasses will optimize this.
@@ -237,12 +239,12 @@
 
 bool Format_isValid(const NBAIO_Format& format)
 {
-    return format != Format_Invalid;
+    return format.mPacked != Format_Invalid.mPacked;
 }
 
 bool Format_isEqual(const NBAIO_Format& format1, const NBAIO_Format& format2)
 {
-    return format1 == format2;
+    return format1.mPacked == format2.mPacked;
 }
 
 }   // namespace android