2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #define ANDROID_DEFAULT_AUDIOTRACK_BUFFER_SIZE 4096
19 /**************************************************************************************************
20 * AudioPlayer lifecycle
21 ****************************/
23 * Checks that the combination of source and sink parameters is supported in this implementation.
26 * SL_PARAMETER_INVALID
28 extern SLresult android_audioPlayer_checkSourceSink(CAudioPlayer *pAudioPlayer);
31 * Determines the Android media framework object that maps to the given audio source and sink.
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)
38 extern SLresult android_audioPlayer_create(CAudioPlayer *pAudioPlayer);
41 * Allocates and initializes the Android media framework objects intended to be used with the
42 * given CAudioPlayer data
45 * SL_RESULT_CONTENT_UNSUPPORTED if an error occurred during the allocation and initialization
46 * of the Android resources
48 extern SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async);
53 * SL_RESULT_PARAMETER_INVALID
54 * SL_RESULT_INTERNAL_ERROR
55 * SL_RESULT_PRECONDITIONS_VIOLATED
57 extern SLresult android_audioPlayer_setConfig(CAudioPlayer *pAudioPlayer, const SLchar *configKey,
58 const void *pConfigValue, SLuint32 valueSize);
61 * if pConfigValue is NULL, pValueSize contains the size required for the given key
65 * SL_RESULT_PARAMETER_INVALID
66 * SL_RESULT_INTERNAL_ERROR
67 * SL_RESULT_PRECONDITIONS_VIOLATED
69 extern SLresult android_audioPlayer_getConfig(CAudioPlayer *pAudioPlayer, const SLchar *configKey,
70 SLuint32* pValueSize, void *pConfigValue);
72 extern SLresult android_audioPlayer_preDestroy(CAudioPlayer *pAudioPlayer);
74 extern SLresult android_audioPlayer_destroy(CAudioPlayer *pAudioPlayer);
76 /**************************************************************************************************
78 ****************************/
79 extern SLresult android_audioPlayer_setPlaybackRateAndConstraints(CAudioPlayer *pAudioPlayer,
80 SLpermille rate, SLuint32 constraints);
82 extern SLresult android_audioPlayer_getDuration(IPlay *pPlayItf, SLmillisecond *pDurMsec);
84 extern void android_audioPlayer_volumeUpdate(CAudioPlayer *pAudioPlayer);
86 extern SLresult android_audioPlayer_setBufferingUpdateThresholdPerMille(CAudioPlayer *pAudioPlayer,
87 SLpermille threshold);
89 /**************************************************************************************************
91 ****************************/
93 * For all metadata extraction functions:
96 * pAudioPlayer != NULL
97 * input pointers != NULL (pItemCount, pKeySize, pKey, pValueSize, pValue)
100 * SL_RESULT_PARAMETER_INVALID
102 extern SLresult android_audioPlayer_metadata_getItemCount(CAudioPlayer *pAudioPlayer,
103 SLuint32 *pItemCount);
105 extern SLresult android_audioPlayer_metadata_getKeySize(CAudioPlayer *pAudioPlayer,
106 SLuint32 index, SLuint32 *pKeySize);
108 extern SLresult android_audioPlayer_metadata_getKey(CAudioPlayer *pAudioPlayer,
109 SLuint32 index, SLuint32 size, SLMetadataInfo *pKey);
111 extern SLresult android_audioPlayer_metadata_getValueSize(CAudioPlayer *pAudioPlayer,
112 SLuint32 index, SLuint32 *pValueSize);
114 extern SLresult android_audioPlayer_metadata_getValue(CAudioPlayer *pAudioPlayer,
115 SLuint32 index, SLuint32 size, SLMetadataInfo *pValue);
117 /**************************************************************************************************
118 * Playback control and events
119 ****************************/
120 extern void android_audioPlayer_setPlayState(CAudioPlayer *pAudioPlayer);
122 extern void android_audioPlayer_useEventMask(CAudioPlayer *pAudioPlayer);
124 extern void android_audioPlayer_seek(CAudioPlayer *pAudioPlayer, SLmillisecond posMsec);
126 extern void android_audioPlayer_loop(CAudioPlayer *pAudioPlayer, SLboolean loopEnable);
128 extern void android_audioPlayer_getPosition(IPlay *pPlayItf, SLmillisecond *pPosMsec);
130 /**************************************************************************************************
131 * Buffer Queue events
132 ****************************/
133 extern void android_audioPlayer_bufferQueue_onRefilled_l(CAudioPlayer *pAudioPlayer);
135 extern SLresult android_audioPlayer_bufferQueue_onClear(CAudioPlayer *pAudioPlayer);
137 /**************************************************************************************************
138 * Android Buffer Queue
139 ****************************/
140 /* must be called with a lock on pAudioPlayer->mThis */
141 extern SLresult android_audioPlayer_androidBufferQueue_registerCallback_l(
142 CAudioPlayer *pAudioPlayer);
143 /* must be called with a lock on pAudioPlayer->mThis */
144 extern void android_audioPlayer_androidBufferQueue_clear_l(CAudioPlayer *pAudioPlayer);
145 /* must be called with a lock on pAudioPlayer->mThis */
146 extern void android_audioPlayer_androidBufferQueue_onRefilled_l(CAudioPlayer *pAudioPlayer);