public static ShortBuffer getDirectBuffer(int size, ShortBuffer buffer) { if (buffer == null) { return(buffer); } size = Round2(size); if (buffer.Direct) { buffer.limit((size >> 1) + buffer.position()); return(buffer); } ShortBuffer directBuffer = allocateDirectBuffer(size).asShortBuffer(); directBuffer.put((ShortBuffer)((ShortBuffer)buffer).slice().limit(size >> 1)); directBuffer.rewind(); return(directBuffer); }