public synchronized void fail() throws Fail { int err = GetLastError(); Memory buffer = new Memory(2048); int res = FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, null, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, (int) buffer.size(), null); log = log && log( 1, "fail() %s, Windows GetLastError()= %d, %s\n", lineno(1), err, buffer.getString(0, true)); // FIXME here convert from Windows error code to 'posix' error code Fail f = new Fail(); throw f; }
@Override public void display( DirectMediaPlayer mediaPlayer, Memory[] nativeBuffers, BufferFormat bufferFormat) { Memory nativeBuffer = nativeBuffers[0]; ByteBuffer byteBuffer = nativeBuffer.getByteBuffer(0, nativeBuffer.size()); pixelWriter.setPixels( 0, 0, bufferFormat.getWidth(), bufferFormat.getHeight(), pixelFormat, byteBuffer, bufferFormat.getPitches()[0]); }
// https://github.com/twall/jna/issues/53 public String hack(Memory m) { String str = ""; for (int i = 0; i < m.size(); i += 2) { byte b1 = m.getByte(i + 0); byte b2 = m.getByte(i + 1); String s; try { s = new String(new byte[] {-2, -1, b2, b1}, "UTF-16"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } str += s; } return str; }