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_setPlaybackRateAndConstraints(CAudioPlayer *pAudioPlayer, 80 SLpermille rate, SLuint32 constraints); 81 82extern SLresult android_audioPlayer_getDuration(IPlay *pPlayItf, SLmillisecond *pDurMsec); 83 84extern void android_audioPlayer_volumeUpdate(CAudioPlayer *pAudioPlayer); 85 86extern SLresult android_audioPlayer_setBufferingUpdateThresholdPerMille(CAudioPlayer *pAudioPlayer, 87 SLpermille threshold); 88 89/************************************************************************************************** 90 * Metadata Extraction 91 ****************************/ 92/* 93 * For all metadata extraction functions: 94 * Precondition: 95 * no lock held 96 * pAudioPlayer != NULL 97 * input pointers != NULL (pItemCount, pKeySize, pKey, pValueSize, pValue) 98 * Return: 99 * SL_RESULT_SUCCESS 100 * SL_RESULT_PARAMETER_INVALID 101 */ 102extern SLresult android_audioPlayer_metadata_getItemCount(CAudioPlayer *pAudioPlayer, 103 SLuint32 *pItemCount); 104 105extern SLresult android_audioPlayer_metadata_getKeySize(CAudioPlayer *pAudioPlayer, 106 SLuint32 index, SLuint32 *pKeySize); 107 108extern SLresult android_audioPlayer_metadata_getKey(CAudioPlayer *pAudioPlayer, 109 SLuint32 index, SLuint32 size, SLMetadataInfo *pKey); 110 111extern SLresult android_audioPlayer_metadata_getValueSize(CAudioPlayer *pAudioPlayer, 112 SLuint32 index, SLuint32 *pValueSize); 113 114extern SLresult android_audioPlayer_metadata_getValue(CAudioPlayer *pAudioPlayer, 115 SLuint32 index, SLuint32 size, SLMetadataInfo *pValue); 116 117/************************************************************************************************** 118 * Playback control and events 119 ****************************/ 120extern void android_audioPlayer_setPlayState(CAudioPlayer *pAudioPlayer); 121 122extern void android_audioPlayer_usePlayEventMask(CAudioPlayer *pAudioPlayer); 123 124extern SLresult android_audioPlayer_seek(CAudioPlayer *pAudioPlayer, SLmillisecond posMsec); 125 126extern SLresult android_audioPlayer_loop(CAudioPlayer *pAudioPlayer, SLboolean loopEnable); 127 128extern void android_audioPlayer_getPosition(IPlay *pPlayItf, SLmillisecond *pPosMsec); 129 130/************************************************************************************************** 131 * Buffer Queue events 132 ****************************/ 133extern void android_audioPlayer_bufferQueue_onRefilled_l(CAudioPlayer *pAudioPlayer); 134 135extern SLresult android_audioPlayer_bufferQueue_onClear(CAudioPlayer *pAudioPlayer); 136 137/************************************************************************************************** 138 * Android Buffer Queue 139 ****************************/ 140/* must be called with a lock on pAudioPlayer->mThis */ 141extern SLresult android_audioPlayer_androidBufferQueue_registerCallback_l( 142 CAudioPlayer *pAudioPlayer); 143/* must be called with a lock on pAudioPlayer->mThis */ 144extern void android_audioPlayer_androidBufferQueue_clear_l(CAudioPlayer *pAudioPlayer); 145/* must be called with a lock on pAudioPlayer->mThis */ 146extern void android_audioPlayer_androidBufferQueue_onRefilled_l(CAudioPlayer *pAudioPlayer); 147