@@ -52,8 +52,9 @@ private QueuedSample(@NonNull TrackType type,
52
52
53
53
private final static Logger LOG = new Logger ("DefaultDataSink" );
54
54
55
- // I have no idea whether this value is appropriate or not...
56
- private final static int BUFFER_SIZE = 64 * 1024 ;
55
+ // We must be able to handle potentially big buffers (e.g. first keyframe) in the queue.
56
+ // Got crashes with 152kb - let's use 256kb. TODO use a dynamic queue instead
57
+ private final static int BUFFER_SIZE = 256 * 1024 ;
57
58
58
59
private boolean mMuxerStarted = false ;
59
60
private final MediaMuxer mMuxer ;
@@ -117,10 +118,10 @@ public void setTrackFormat(@NonNull TrackType type, @NonNull MediaFormat format)
117
118
mMuxerChecks .checkOutputFormat (type , format );
118
119
}
119
120
mLastFormat .set (type , format );
120
- startIfNeeded ();
121
+ maybeStart ();
121
122
}
122
123
123
- private void startIfNeeded () {
124
+ private void maybeStart () {
124
125
if (mMuxerStarted ) return ;
125
126
boolean isTranscodingVideo = mStatus .get (TrackType .VIDEO ).isTranscoding ();
126
127
boolean isTranscodingAudio = mStatus .get (TrackType .AUDIO ).isTranscoding ();
@@ -170,6 +171,12 @@ private void enqueue(@NonNull TrackType type,
170
171
if (mQueueBuffer == null ) {
171
172
mQueueBuffer = ByteBuffer .allocateDirect (BUFFER_SIZE ).order (ByteOrder .nativeOrder ());
172
173
}
174
+ LOG .v ("enqueue(" + type + "): offset=" + bufferInfo .offset
175
+ + "\t realOffset=" + buffer .position ()
176
+ + "\t size=" + bufferInfo .size
177
+ + "\t realSize=" + buffer .remaining ()
178
+ + "\t available=" + mQueueBuffer .remaining ()
179
+ + "\t total=" + BUFFER_SIZE );
173
180
buffer .limit (bufferInfo .offset + bufferInfo .size );
174
181
buffer .position (bufferInfo .offset );
175
182
mQueueBuffer .put (buffer );
0 commit comments