public void write (Kryo kryo, Output output, LongMap map) { int length = map.size; output.writeVarInt(length, true); output.writeBoolean(false); // whether type is written (in case future version of LongMap supports type awareness) Serializer valueSerializer = null; if (valueGenericType != null) { if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueGenericType); valueGenericType = null; } for (Iterator iter = map.iterator(); iter.hasNext();) { LongMap.Entry entry = (LongMap.Entry)iter.next(); output.writeLong(entry.key); if (valueSerializer != null) { kryo.writeObjectOrNull(output, entry.value, valueSerializer); } else kryo.writeClassAndObject(output, entry.value); } }
public LongMap read (Kryo kryo, Input input, Class<LongMap> type) { int length = input.readVarInt(true); input.readBoolean(); // currently unused LongMap map = new LongMap(length); Class valueClass = null; Serializer valueSerializer = null; if (valueGenericType != null) { valueClass = valueGenericType; if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass); valueGenericType = null; } kryo.reference(map); for (int i = 0; i < length; i++) { long key = input.readLong(); Object value; if (valueSerializer != null) { value = kryo.readObjectOrNull(input, valueClass, valueSerializer); } else value = kryo.readClassAndObject(input); map.put(key, value); } return map; }
public OpenALAudio (int simultaneousSources, int deviceBufferCount, int deviceBufferSize) { this.deviceBufferSize = deviceBufferSize; this.deviceBufferCount = deviceBufferCount; registerSound("ogg", Ogg.Sound.class); registerMusic("ogg", Ogg.Music.class); registerSound("wav", Wav.Sound.class); registerMusic("wav", Wav.Music.class); registerSound("mp3", Mp3.Sound.class); registerMusic("mp3", Mp3.Music.class); try { AL.create(); } catch (LWJGLException ex) { noDevice = true; ex.printStackTrace(); return; } allSources = new IntArray(false, simultaneousSources); for (int i = 0; i < simultaneousSources; i++) { int sourceID = alGenSources(); if (alGetError() != AL_NO_ERROR) break; allSources.add(sourceID); } idleSources = new IntArray(allSources); soundIdToSource = new LongMap<Integer>(); sourceToSoundId = new IntMap<Long>(); FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6) .put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip(); alListener(AL_ORIENTATION, orientation); FloatBuffer velocity = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip(); alListener(AL_VELOCITY, velocity); FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip(); alListener(AL_POSITION, position); recentSounds = new OpenALSound[simultaneousSources]; }
public OpenALAudio (int simultaneousSources, int deviceBufferCount, int deviceBufferSize) { this.deviceBufferSize = deviceBufferSize; this.deviceBufferCount = deviceBufferCount; registerSound("ogg", Ogg.Sound.class); registerMusic("ogg", Ogg.Music.class); registerSound("wav", Wav.Sound.class); registerMusic("wav", Wav.Music.class); registerSound("mp3", Mp3.Sound.class); registerMusic("mp3", Mp3.Music.class); alContext = ALContext.create(); allSources = new IntArray(false, simultaneousSources); for (int i = 0; i < simultaneousSources; i++) { int sourceID = alGenSources(); if (alGetError() != AL_NO_ERROR) break; allSources.add(sourceID); } idleSources = new IntArray(allSources); soundIdToSource = new LongMap<Integer>(); sourceToSoundId = new IntMap<Long>(); FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6) .put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip(); alListenerfv(AL_ORIENTATION, orientation); FloatBuffer velocity = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip(); alListenerfv(AL_VELOCITY, velocity); FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip(); alListenerfv(AL_POSITION, position); recentSounds = new OpenALSound[simultaneousSources]; }
public static void init() { try { Field field = OpenALAudio.class.getDeclaredField("soundIdToSource"); field.setAccessible(true); soundIdToSource = (LongMap<Integer>) field.get(Gdx.audio); } catch (Exception e) { throw new RuntimeException("Error getting soundIdToSource", e); } }
public Scheduler(Environment env) { this.env = env; this.destroyed = false; this.tasks = new LongMap<>(); this.activeTasks = new OrderedMap<>(); }
public Engine(){ entities = new Array<Entity>(false, 16); entitiesById = new LongMap<Entity>(); }
public OpenALAudio(int simultaneousSources, int deviceBufferCount, int deviceBufferSize) { this.deviceBufferSize = deviceBufferSize; this.deviceBufferCount = deviceBufferCount; registerSound("ogg", Ogg.Sound.class); registerMusic("ogg", Ogg.Music.class); registerSound("wav", Wav.Sound.class); registerMusic("wav", Wav.Music.class); registerSound("mp3", Mp3.Sound.class); registerMusic("mp3", Mp3.Music.class); try { AL.create(); } catch (LWJGLException ex) { noDevice = true; ex.printStackTrace(); return; } allSources = new IntArray(false, simultaneousSources); for (int i = 0; i < simultaneousSources; i++) { int sourceID = alGenSources(); if (alGetError() != AL_NO_ERROR) { break; } allSources.add(sourceID); } idleSources = new IntArray(allSources); soundIdToSource = new LongMap<>(); sourceToSoundId = new IntMap<>(); FloatBuffer orientation = (FloatBuffer) BufferUtils.createFloatBuffer(6) .put(new float[]{0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip(); alListener(AL_ORIENTATION, orientation); FloatBuffer velocity = (FloatBuffer) BufferUtils.createFloatBuffer(3).put(new float[]{0.0f, 0.0f, 0.0f}).flip(); alListener(AL_VELOCITY, velocity); FloatBuffer position = (FloatBuffer) BufferUtils.createFloatBuffer(3).put(new float[]{0.0f, 0.0f, 0.0f}).flip(); alListener(AL_POSITION, position); recentSounds = new OpenALSound[simultaneousSources]; }