@@ -63,7 +63,8 @@ public FfmpegAudioDecoder(
63
63
codecName = Assertions .checkNotNull (FfmpegLibrary .getCodecName (format .sampleMimeType ));
64
64
extraData = getExtraData (format .sampleMimeType , format .initializationData );
65
65
encoding = outputFloat ? C .ENCODING_PCM_FLOAT : C .ENCODING_PCM_16BIT ;
66
- outputBufferSize = outputFloat ? INITIAL_OUTPUT_BUFFER_SIZE_32BIT : INITIAL_OUTPUT_BUFFER_SIZE_16BIT ;
66
+ outputBufferSize =
67
+ outputFloat ? INITIAL_OUTPUT_BUFFER_SIZE_32BIT : INITIAL_OUTPUT_BUFFER_SIZE_16BIT ;
67
68
nativeContext =
68
69
ffmpegInitialize (codecName , extraData , outputFloat , format .sampleRate , format .channelCount );
69
70
if (nativeContext == 0 ) {
@@ -106,9 +107,10 @@ protected FfmpegDecoderException decode(
106
107
}
107
108
ByteBuffer inputData = Util .castNonNull (inputBuffer .data );
108
109
int inputSize = inputData .limit ();
109
- outputBuffer .init (inputBuffer .timeUs , outputBufferSize );
110
-
111
- int result = ffmpegDecode (nativeContext , inputData , inputSize , outputBuffer , outputBuffer .data , outputBufferSize );
110
+ ByteBuffer outputData = outputBuffer .init (inputBuffer .timeUs , outputBufferSize );
111
+ int result =
112
+ ffmpegDecode (
113
+ nativeContext , inputData , inputSize , outputBuffer , outputData , outputBufferSize );
112
114
if (result == AUDIO_DECODER_ERROR_OTHER ) {
113
115
return new FfmpegDecoderException ("Error decoding (see logcat)." );
114
116
} else if (result == AUDIO_DECODER_ERROR_INVALID_DATA ) {
@@ -135,13 +137,15 @@ protected FfmpegDecoderException decode(
135
137
}
136
138
hasOutputFormat = true ;
137
139
}
138
- outputBuffer . data .position (0 );
139
- outputBuffer . data .limit (result );
140
+ outputData .position (0 );
141
+ outputData .limit (result );
140
142
return null ;
141
143
}
142
144
143
145
// Called from native code
144
- /** @noinspection unused*/
146
+ /**
147
+ * @noinspection unused
148
+ */
145
149
private ByteBuffer growOutputBuffer (SimpleDecoderOutputBuffer outputBuffer , int requiredSize ) {
146
150
// Use it for new buffer so that hopefully we won't need to reallocate again
147
151
outputBufferSize = requiredSize ;
@@ -229,7 +233,12 @@ private native long ffmpegInitialize(
229
233
int rawChannelCount );
230
234
231
235
private native int ffmpegDecode (
232
- long context , ByteBuffer inputData , int inputSize , SimpleDecoderOutputBuffer decoderOutputBuffer , ByteBuffer outputData , int outputSize );
236
+ long context ,
237
+ ByteBuffer inputData ,
238
+ int inputSize ,
239
+ SimpleDecoderOutputBuffer decoderOutputBuffer ,
240
+ ByteBuffer outputData ,
241
+ int outputSize );
233
242
234
243
private native int ffmpegGetChannelCount (long context );
235
244
0 commit comments