android_media_AudioFormat.h revision fe834d30f4f3f51b754d55fecb36f11279733948
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 26static inline audio_format_t audioFormatToNative(int audioFormat) 27{ 28 switch (audioFormat) { 29 case ENCODING_PCM_16BIT: 30 return AUDIO_FORMAT_PCM_16_BIT; 31 case ENCODING_PCM_8BIT: 32 return AUDIO_FORMAT_PCM_8_BIT; 33 default: 34 return AUDIO_FORMAT_INVALID; 35 } 36} 37 38#endif // ANDROID_MEDIA_AUDIOFORMAT_H 39