AudioPlayer_to_android.h revision fa2bd93c3a9852a1f879663eeff598d13cf8fa81
1/* 2 * Copyright (C) 2010 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#define ANDROID_DEFAULT_AUDIOTRACK_BUFFER_SIZE 4096 18 19/************************************************************************************************** 20 * AudioPlayer lifecycle 21 ****************************/ 22/* 23 * Checks that the combination of source and sink parameters is supported in this implementation. 24 * Return 25 * SL_RESULT_SUCCESS 26 * SL_PARAMETER_INVALID 27 */ 28extern SLresult android_audioPlayer_checkSourceSink(CAudioPlayer *pAudioPlayer); 29 30/* 31 * Determines the Android media framework object that maps to the given audio source and sink. 32 * Return 33 * SL_RESULT_SUCCESS if the Android resources were successfully created 34 * SL_PARAMETER_INVALID if the Android resources couldn't be created due to an invalid or 35 * unsupported parameter or value 36 * SL_RESULT_CONTENT_UNSUPPORTED if a format is not supported (e.g. sample rate too high) 37 */ 38extern SLresult android_audioPlayer_create(CAudioPlayer *pAudioPlayer); 39 40/* 41 * Allocates and initializes the Android media framework objects intended to be used with the 42 * given CAudioPlayer data 43 * Return 44 * SL_RESULT_SUCCESS 45 * SL_RESULT_CONTENT_UNSUPPORTED if an error occurred during the allocation and initialization 46 * of the Android resources 47 */ 48extern SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async); 49 50/* 51 * Return 52 * SL_RESULT_SUCCESS 53 * SL_RESULT_PARAMETER_INVALID 54 * SL_RESULT_INTERNAL_ERROR 55 * SL_RESULT_PRECONDITIONS_VIOLATED 56 */ 57extern SLresult android_audioPlayer_setConfig(CAudioPlayer *pAudioPlayer, const SLchar *configKey, 58 const void *pConfigValue, SLuint32 valueSize); 59 60/* 61 * if pConfigValue is NULL, pValueSize contains the size required for the given key 62 * 63 * Return 64 * SL_RESULT_SUCCESS 65 * SL_RESULT_PARAMETER_INVALID 66 * SL_RESULT_INTERNAL_ERROR 67 * SL_RESULT_PRECONDITIONS_VIOLATED 68 */ 69extern SLresult android_audioPlayer_getConfig(CAudioPlayer *pAudioPlayer, const SLchar *configKey, 70 SLuint32* pValueSize, void *pConfigValue); 71 72extern SLresult android_audioPlayer_preDestroy(CAudioPlayer *pAudioPlayer); 73 74extern SLresult android_audioPlayer_destroy(CAudioPlayer *pAudioPlayer); 75 76/************************************************************************************************** 77 * Configuration 78 ****************************/ 79extern SLresult android_audioPlayer_setPlayRate(CAudioPlayer *pAudioPlayer, SLpermille rate, 80 bool lockAP); 81 82extern SLresult android_audioPlayer_setPlaybackRateBehavior(CAudioPlayer *pAudioPlayer, 83 SLuint32 constraints); 84 85extern SLresult android_audioPlayer_getCapabilitiesOfRate(CAudioPlayer *pAudioPlayer, 86 SLuint32 *pCapabilities); 87 88extern SLresult android_audioPlayer_getDuration(IPlay *pPlayItf, SLmillisecond *pDurMsec); 89 90extern void android_audioPlayer_volumeUpdate(CAudioPlayer *pAudioPlayer); 91 92extern SLresult android_audioPlayer_setBufferingUpdateThresholdPerMille(CAudioPlayer *pAudioPlayer, 93 SLpermille threshold); 94 95/************************************************************************************************** 96 * Metadata Extraction 97 ****************************/ 98/* 99 * For all metadata extraction functions: 100 * Precondition: 101 * no lock held 102 * pAudioPlayer != NULL 103 * input pointers != NULL (pItemCount, pKeySize, pKey, pValueSize, pValue) 104 * Return: 105 * SL_RESULT_SUCCESS 106 * SL_RESULT_PARAMETER_INVALID 107 */ 108extern SLresult android_audioPlayer_metadata_getItemCount(CAudioPlayer *pAudioPlayer, 109 SLuint32 *pItemCount); 110 111extern SLresult android_audioPlayer_metadata_getKeySize(CAudioPlayer *pAudioPlayer, 112 SLuint32 index, SLuint32 *pKeySize); 113 114extern SLresult android_audioPlayer_metadata_getKey(CAudioPlayer *pAudioPlayer, 115 SLuint32 index, SLuint32 size, SLMetadataInfo *pKey); 116 117extern SLresult android_audioPlayer_metadata_getValueSize(CAudioPlayer *pAudioPlayer, 118 SLuint32 index, SLuint32 *pValueSize); 119 120extern SLresult android_audioPlayer_metadata_getValue(CAudioPlayer *pAudioPlayer, 121 SLuint32 index, SLuint32 size, SLMetadataInfo *pValue); 122 123/************************************************************************************************** 124 * Playback control and events 125 ****************************/ 126extern void android_audioPlayer_setPlayState(CAudioPlayer *pAudioPlayer); 127 128extern void android_audioPlayer_useEventMask(CAudioPlayer *pAudioPlayer); 129 130extern void android_audioPlayer_seek(CAudioPlayer *pAudioPlayer, SLmillisecond posMsec); 131 132extern void android_audioPlayer_loop(CAudioPlayer *pAudioPlayer, SLboolean loopEnable); 133 134extern void android_audioPlayer_getPosition(IPlay *pPlayItf, SLmillisecond *pPosMsec); 135 136/************************************************************************************************** 137 * Buffer Queue events 138 ****************************/ 139extern void android_audioPlayer_bufferQueue_onRefilled_l(CAudioPlayer *pAudioPlayer); 140 141extern SLresult android_audioPlayer_bufferQueue_onClear(CAudioPlayer *pAudioPlayer); 142 143/************************************************************************************************** 144 * Android Buffer Queue 145 ****************************/ 146/* must be called with a lock on pAudioPlayer->mThis */ 147extern void android_audioPlayer_androidBufferQueue_registerCallback_l(CAudioPlayer *pAudioPlayer); 148/* must be called with a lock on pAudioPlayer->mThis */ 149extern void android_audioPlayer_androidBufferQueue_clear_l(CAudioPlayer *pAudioPlayer); 150/* must be called with a lock on pAudioPlayer->mThis */ 151extern void android_audioPlayer_androidBufferQueue_onRefilled_l(CAudioPlayer *pAudioPlayer); 152