MCPcopy Create free account
hub / github.com/cocos/cocos-engine / decodeToPcm

Method decodeToPcm

native/cocos/audio/android/AudioDecoderSLES.cpp:128–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128bool AudioDecoderSLES::decodeToPcm() {
129#if CC_PLATFORM == CC_PLATFORM_ANDROID
130 SLresult result;
131
132 /* Objects this application uses: one audio player */
133 SLObjectItf player;
134
135 /* Interfaces for the audio player */
136 CCSLBufferQueueItf decBuffQueueItf;
137 SLPrefetchStatusItf prefetchItf;
138 SLPlayItf playItf;
139 SLMetadataExtractionItf mdExtrItf;
140
141 /* Source of audio data for the decoding */
142 SLDataSource decSource;
143
144 // decUri & locFd should be defined here
145 SLDataLocator_URI decUri;
146 SLDataLocator_AndroidFD locFd;
147
148 /* Data sink for decoded audio */
149 SLDataSink decDest;
150 SLDataLocator_AndroidSimpleBufferQueue decBuffQueue;
151 SLDataFormat_PCM pcm;
152
153 SLboolean required[NUM_EXPLICIT_INTERFACES_FOR_PLAYER];
154 SLInterfaceID iidArray[NUM_EXPLICIT_INTERFACES_FOR_PLAYER];
155
156 /* Initialize arrays required[] and iidArray[] */
157 for (int i = 0; i < NUM_EXPLICIT_INTERFACES_FOR_PLAYER; i++) {
158 required[i] = SL_BOOLEAN_FALSE;
159 iidArray[i] = SL_IID_NULL;
160 }
161
162 /* ------------------------------------------------------ */
163 /* Configuration of the player */
164
165 /* Request the AndroidSimpleBufferQueue interface */
166 required[0] = SL_BOOLEAN_TRUE;
167 iidArray[0] = SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
168 /* Request the PrefetchStatus interface */
169 required[1] = SL_BOOLEAN_TRUE;
170 iidArray[1] = SL_IID_PREFETCHSTATUS;
171 /* Request the PrefetchStatus interface */
172 required[2] = SL_BOOLEAN_TRUE;
173 iidArray[2] = SL_IID_METADATAEXTRACTION;
174
175 SLDataFormat_MIME formatMime = {SL_DATAFORMAT_MIME, nullptr, SL_CONTAINERTYPE_UNSPECIFIED};
176 decSource.pFormat = &formatMime;
177
178 if (_url[0] != '/') {
179 off_t start = 0;
180 off_t length = 0;
181 ccstd::string relativePath;
182 size_t position = _url.find("@assets/");
183
184 if (0 == position) {
185 // "@assets/" is at the beginning of the path and we don't want it

Callers

nothing calls this directly

Calls 8

mallocFunction · 0.85
checkMetaDataFunction · 0.85
substrMethod · 0.80
findMethod · 0.65
sizeMethod · 0.65
toStringMethod · 0.65
freeFunction · 0.50
waitMethod · 0.45

Tested by

no test coverage detected