android_media_AudioFormat.h revision 313f59887b1439fa2f39dbf3578407c52fcbf60d
1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef ANDROID_MEDIA_AUDIOFORMAT_H 18#define ANDROID_MEDIA_AUDIOFORMAT_H 19 20#include <system/audio.h> 21 22// keep these values in sync with AudioFormat.java 23#define ENCODING_PCM_16BIT 2 24#define ENCODING_PCM_8BIT 3 25#define ENCODING_PCM_FLOAT 4 26 27static inline audio_format_t audioFormatToNative(int audioFormat) 28{ 29 switch (audioFormat) { 30 case ENCODING_PCM_16BIT: 31 return AUDIO_FORMAT_PCM_16_BIT; 32 case ENCODING_PCM_8BIT: 33 return AUDIO_FORMAT_PCM_8_BIT; 34 case ENCODING_PCM_FLOAT: 35 return AUDIO_FORMAT_PCM_FLOAT; 36 default: 37 return AUDIO_FORMAT_INVALID; 38 } 39} 40 41#endif // ANDROID_MEDIA_AUDIOFORMAT_H 42