我想使用OpenSL ES FileDescriptor对象从音频资产中获取字节缓冲区,因此我可以将其重复排队到SimpleBufferQueue,而不是使用SL接口来播放/停止/搜索文件.
我想直接管理样本字节有三个主要原因:
好的,所以理由完成 - 这就是我尝试过的 - 我有一个Sample结构,它实质上包含一个输入和输出轨道,以及一个用于保存样本的字节数组.输入是我的FileDescriptor播放器,输出是SimpleBufferQueue对象.这是我的结构:
typedef struct Sample_ {
    // buffer to hold all samples
    short *buffer;      
    int totalSamples;
    SLObjectItf fdPlayerObject;
    // file descriptor player interfaces
    SLPlayItf fdPlayerPlay;
    SLSeekItf fdPlayerSeek;
    SLMuteSoloItf fdPlayerMuteSolo;
    SLVolumeItf fdPlayerVolume;
    SLAndroidSimpleBufferQueueItf fdBufferQueue;
    SLObjectItf outputPlayerObject; 
    SLPlayItf outputPlayerPlay; 
    // output buffer interfaces
    SLAndroidSimpleBufferQueueItf outputBufferQueue;        
} Sample;
Run Code Online (Sandbox Code Playgroud)
初始化文件播放器fdPlayerObject后,以及用于我的字节缓冲区的malloc-ing内存
sample->buffer = malloc(sizeof(short)*sample->totalSamples);
Run Code Online (Sandbox Code Playgroud)
我正在使用它的BufferQueue接口
// get the buffer queue interface
result = (*(sample->fdPlayerObject))->GetInterface(sample->fdPlayerObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &(sample->fdBufferQueue));
Run Code Online (Sandbox Code Playgroud)
然后我实例化一个 …
使用OpenGL ES,圆角矩形似乎有两个可行的选项:
第一个选项的问题是抗锯齿不是免费的,如果你的目标是与各种各样的设备兼容,那么就不能指望OpenGL抗锯齿提示来实际在硬件上工作.所以你留下看起来不连贯的圆角矩形,特别是对于小矩形,以及制作另一个顶点数组绘制调用的性能开销.我想改掉这个
第二个选项(9-Slice或9-Patch)似乎是UI圆形rect元素的首选方法,但是在OpenGL ES中实现9-patching的信息却很少.
我想要的是:在OpenGL ES中渲染抗锯齿圆角矩形的有效策略,可调节边框宽度,边框颜色和填充颜色.有什么建议?
在大多数Android设备上,如果我用Integers而不是Floats进行所有OpenGL顶点计算/渲染,我是否应该期望性能提升?
我最近从使用0:宽度,0:高度而不是-1:1,-1:1的OpenGL视口切换,所以如果需要,我可以将所有绘图计算/缓冲区转换为Ints而不是Floats为了表现.
例如,如果我在我的应用程序中执行以下许多类型的计算和渲染.
float x1 = someFloatCalculation(foo);
float x2 = someFloatCalculation(bar);
float y1 = someOtherFloatCalculation(foo);
float y2 = someOtherFloatCalculation(bar);
// the float buffer for the coordinates
FloatBuffer buf = makeFloatBuffer(new float[] { x1, y1, x2, y1, x1,
                                                y2, x2, y2 });
gl.glVertexPointer(2, GL10.GL_FLOAT, 0, buf);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
Run Code Online (Sandbox Code Playgroud)
可以通过改变类似的东西来加快速度
int x1 = someIntCalculation(foo);
int x2 = someIntCalculation(bar);
int y1 = someOtherIntCalculation(foo);
int y2 = someOtherIntCalculation(bar);
// the float buffer for the coordinates
IntBuffer buf = makeIntBuffer(new int[] { x1, y1, …Run Code Online (Sandbox Code Playgroud)