Lines Matching refs:buffer

46     // The output buffer.  Set to null when the transport is closed.
49 // The input buffer pool.
231 protected abstract int ioRead(byte[] buffer, int offset, int count)
233 protected abstract void ioWrite(byte[] buffer, int offset, int count)
253 final ByteBuffer buffer = (ByteBuffer)msg.obj;
255 final int limit = buffer.limit();
256 while (buffer.position() < limit) {
257 final int service = buffer.getShort() & 0xffff;
258 final int what = buffer.getShort() & 0xffff;
259 final int contentSize = buffer.getInt();
263 final int end = buffer.position() + contentSize;
264 buffer.limit(end);
265 dispatchMessageReceived(service, what, buffer);
266 buffer.limit(limit);
267 buffer.position(end);
271 mInputBufferPool.release(buffer);
291 ByteBuffer buffer = null;
295 // Get a buffer.
296 if (buffer == null) {
297 buffer = mInputBufferPool.acquire(length);
299 buffer = mInputBufferPool.grow(buffer, length);
303 int position = buffer.position();
306 count = ioRead(buffer.array(), position, buffer.capacity() - position);
315 buffer.position(position);
317 contentSize = buffer.getInt(4);
328 // There is at least one complete message in the buffer.
339 contentSize = buffer.getInt(next + 4);
351 // Post the buffer then don't modify it anymore.
353 // be acquiring buffers from the buffer pool so we can keep on
354 // referring to this buffer as long as we don't modify its contents.
356 buffer.limit(next);
357 buffer.rewind();
358 mHandler.obtainMessage(0, buffer).sendToTarget();
361 // to copy it to a fresh buffer before continuing. In the single-buffered
362 // case, we may acquire the same buffer as before which is fine.
364 buffer = null;
366 final ByteBuffer oldBuffer = buffer;
367 buffer = mInputBufferPool.acquire(length);
368 System.arraycopy(oldBuffer.array(), next, buffer.array(), 0, remaining);
369 buffer.position(remaining);
373 if (buffer != null) {
374 mInputBufferPool.release(buffer);