diff options
| author | Eric Laurent <elaurent@google.com> | 2011-06-23 08:08:06 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-06-23 08:08:06 -0700 |
| commit | 9661a3aecd39cca95bd07253c52b99521409c147 (patch) | |
| tree | 6901834d6c2970974d762825492ccb9744cfc2f9 | |
| parent | 535164e9d9649a83d4d63829f3389f2bea339fe1 (diff) | |
| parent | da382248758eacd9f91d6f0a50dff3f021791c24 (diff) | |
| download | system_core-9661a3aecd39cca95bd07253c52b99521409c147.tar.gz system_core-9661a3aecd39cca95bd07253c52b99521409c147.tar.bz2 system_core-9661a3aecd39cca95bd07253c52b99521409c147.zip | |
Merge "Fixed some audio helper functions"
| -rw-r--r-- | include/system/audio.h | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/include/system/audio.h b/include/system/audio.h index 32945007..2e261ceb 100644 --- a/include/system/audio.h +++ b/include/system/audio.h @@ -369,6 +369,10 @@ static inline bool audio_is_valid_format(uint32_t format) { switch (format & AUDIO_FORMAT_MAIN_MASK) { case AUDIO_FORMAT_PCM: + if (format != AUDIO_FORMAT_PCM_16_BIT && + format != AUDIO_FORMAT_PCM_8_BIT) { + return false; + } case AUDIO_FORMAT_MP3: case AUDIO_FORMAT_AMR_NB: case AUDIO_FORMAT_AMR_WB: @@ -384,16 +388,30 @@ static inline bool audio_is_valid_format(uint32_t format) static inline bool audio_is_linear_pcm(uint32_t format) { + return ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM); +} + +static inline size_t audio_bytes_per_sample(uint32_t format) +{ + size_t size = 0; + switch (format) { - case AUDIO_FORMAT_PCM_16_BIT: - case AUDIO_FORMAT_PCM_8_BIT: - return true; - default: - return false; + case AUDIO_FORMAT_PCM_32_BIT: + case AUDIO_FORMAT_PCM_8_24_BIT: + size = sizeof(int32_t); + break; + case AUDIO_FORMAT_PCM_16_BIT: + size = sizeof(int16_t); + break; + case AUDIO_FORMAT_PCM_8_BIT: + size = sizeof(uint8_t); + break; + default: + break; } + return size; } - __END_DECLS #endif // ANDROID_AUDIO_CORE_H |
