Android Open Source - droid-aegis Buffer Pool






From Project

Back to project page droid-aegis.

License

The source code is released under:

MIT License

If you think the Android project droid-aegis listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.app.camstreamer;
/* w w  w  .j  av  a 2 s . com*/
import java.nio.ByteBuffer;
import java.util.ArrayList;

public class BufferPool {
  ArrayList<ByteBuffer>    mBufferQueue;
  
  public  BufferPool (int size, int maxElements) {
    ByteBuffer    mBuffs;
    mBufferQueue   = new ArrayList<ByteBuffer>(maxElements);
    for (int n = 0; n < maxElements; n++) {
      mBuffs = ByteBuffer.allocate(size);
      mBuffs.clear();
      mBufferQueue.add(n, mBuffs);
    }
  }

  public ByteBuffer dequeueBuffer () {
    ByteBuffer  mBuff = null;
    synchronized (mBufferQueue) {
      mBuff = mBufferQueue.remove(0);
    }
    return mBuff;
  }

  public void pushBack (ByteBuffer mBuff) {
    synchronized (mBufferQueue) {
      mBuff.clear();
      mBufferQueue.add(mBuff);
    }
  }
  
  public void release () {
    synchronized (mBufferQueue) {
      for(int n = 0; n < mBufferQueue.size(); n++) {
        ByteBuffer  mBuff = mBufferQueue.remove(0);
        mBuff.capacity();
        mBuff = null;
      }
      mBufferQueue.clear();
    }
    mBufferQueue = null;
  }
}




Java Source Code List

andi.cctv.app.MainActivity.java
andi.cctv.app.MediaController.java
andi.cctv.app.Sockit.java
andi.cctv.app.ToFile.java
andi.cctv.app.WifiCheck.java
com.app.camstreamer.BufferHandler.java
com.app.camstreamer.BufferNotifications.java
com.app.camstreamer.BufferPool.java
com.app.camstreamer.MainActivity.java
com.app.camstreamer.MockCamera.java
com.app.camstreamer.StreamSock.java