AudioPlayer_to_android.h revision 70c49ae2867094072a4365423417ea452bf82231
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_destroy(CAudioPlayer *pAudioPlayer); 73 74/************************************************************************************************** 75 * Configuration 76 ****************************/ 77extern SLresult android_audioPlayer_setPlayRate(CAudioPlayer *pAudioPlayer, SLpermille rate, 78 bool lockAP); 79 80extern SLresult android_audioPlayer_setPlaybackRateBehavior(CAudioPlayer *pAudioPlayer, 81 SLuint32 constraints); 82 83extern SLresult android_audioPlayer_getCapabilitiesOfRate(CAudioPlayer *pAudioPlayer, 84 SLuint32 *pCapabilities); 85 86extern SLresult android_audioPlayer_getDuration(IPlay *pPlayItf, SLmillisecond *pDurMsec); 87 88extern SLresult android_audioPlayer_volumeUpdate(CAudioPlayer *pAudioPlayer); 89 90/************************************************************************************************** 91 * Playback control and events 92 ****************************/ 93extern void android_audioPlayer_setPlayState(CAudioPlayer *pAudioPlayer, bool lockAP); 94 95extern void android_audioPlayer_useEventMask(CAudioPlayer *pAudioPlayer); 96 97extern void android_audioPlayer_seek(CAudioPlayer *pAudioPlayer, SLmillisecond posMsec); 98 99extern void android_audioPlayer_loop(CAudioPlayer *pAudioPlayer, SLboolean loopEnable); 100 101extern void android_audioPlayer_getPosition(IPlay *pPlayItf, SLmillisecond *pPosMsec); 102 103/************************************************************************************************** 104 * Buffer Queue events 105 ****************************/ 106extern void android_audioPlayer_bufferQueue_onRefilled_l(CAudioPlayer *pAudioPlayer); 107 108extern SLresult android_audioPlayer_bufferQueue_onClear(CAudioPlayer *pAudioPlayer); 109 110/************************************************************************************************** 111 * Android Buffer Queue 112 ****************************/ 113/* must be called with a lock on pAudioPlayer->mThis */ 114extern void android_audioPlayer_androidBufferQueue_registerCallback_l(CAudioPlayer *pAudioPlayer); 115/* must be called with a lock on pAudioPlayer->mThis */ 116extern void android_audioPlayer_androidBufferQueue_clear_l(CAudioPlayer *pAudioPlayer); 117/* must be called with a lock on pAudioPlayer->mThis */ 118extern void android_audioPlayer_androidBufferQueue_onRefilled_l(CAudioPlayer *pAudioPlayer); 119