buffer

Java copy part of InputStream to OutputStream

Deadly 提交于 2020-01-13 04:47:13
问题 I have a file with 3236000 bytes and I want to read 2936000 from start and write to an OutputStream InputStream is = new FileInputStream(file1); OutputStream os = new FileOutputStream(file2); AFunctionToCopy(is,os,0,2936000); /* a function or sourcecode to write input stream 0to2936000 bytes */ I can read and write byte by byte, but it's to slow (i think) from buffered reading How can do I copy it? 回答1: public static void copyStream(InputStream input, OutputStream output, long start, long end

How to get around the performance issues with Buffer.put() and Android OpenGL

心不动则不痛 提交于 2020-01-12 10:39:27
问题 It is a Java issue in general, though in this particular case I am using Vertex Arrays in Android for OpenGL. To use this basic GL system, you must use Java's Buffer system in native allocation mode. This is very slow on Java. And roughly 40-50% of my entire application's time is spent inside of buffer.put(). Is there any way to speed this up while staying in Java (ie, don't use the native sdk)? 回答1: Avoid allocations in general. Use a pool of buffers and juggle them around as needed. You can

I want to change the sample rate from my input node from 44100 to 8000

点点圈 提交于 2020-01-12 09:52:52
问题 I want to read the buffer from my microphone into an array, with 441khz its working fine but with the sample rate 8khz it comes to an error ERROR: >avae> AVAudioIONodeImpl.mm:884: SetOutputFormat: required condition is false: format.sampleRate == hwFormat.sampleRate 2016-11-26 19:32:40.674 Atem[5800:1168274] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: format.sampleRate == hwFormat.sampleRate' with my following code : var

I want to change the sample rate from my input node from 44100 to 8000

折月煮酒 提交于 2020-01-12 09:52:28
问题 I want to read the buffer from my microphone into an array, with 441khz its working fine but with the sample rate 8khz it comes to an error ERROR: >avae> AVAudioIONodeImpl.mm:884: SetOutputFormat: required condition is false: format.sampleRate == hwFormat.sampleRate 2016-11-26 19:32:40.674 Atem[5800:1168274] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: format.sampleRate == hwFormat.sampleRate' with my following code : var

Buffer entire file in memory with NodeJs

旧城冷巷雨未停 提交于 2020-01-12 02:29:11
问题 I have a relatevely small file (some hundreds of kilobytes) that I want to be in memory for direct access for the entire execution of the code. I don't know exactly the internals of NodeJs, so I'm asking if a fs open is enough or I have to read all file and copy to a Buffer ? 回答1: Basically, you need to use the readFile or readFileSync function from the fs module. They return the complete content of the given file, but differ in their behavior (asynchronous versus synchronous). If blocking

Find the exact address of variable Buf

那年仲夏 提交于 2020-01-11 21:24:58
问题 As reference, I'm using the following code: #include <stdio.h> #include <string.h> int main (void) { char buf[100]; // ------> How do I find the address in gdb? printf ("Buffer is at memory location: %08x\n", &buf); strcpy (buf, "some random text"); printf ("Text is [%s]\n", buf); return 0; } How can I get gdb to show me the address of the buf variable? 回答1: (gdb) p &a if you need the address of variable a . A variable might be cached in a register though, in which case GDB would tell you

Find the exact address of variable Buf

冷暖自知 提交于 2020-01-11 21:17:47
问题 As reference, I'm using the following code: #include <stdio.h> #include <string.h> int main (void) { char buf[100]; // ------> How do I find the address in gdb? printf ("Buffer is at memory location: %08x\n", &buf); strcpy (buf, "some random text"); printf ("Text is [%s]\n", buf); return 0; } How can I get gdb to show me the address of the buf variable? 回答1: (gdb) p &a if you need the address of variable a . A variable might be cached in a register though, in which case GDB would tell you

Emacs Lisp Buffer out of focus function?

无人久伴 提交于 2020-01-11 12:03:22
问题 Is there an emacs lisp function that will allow me to tell if a buffer is out of focus? I am trying to write a hook that will get rid of the semantics *possible completion's* buffer right after it is out of focus. Also is it possible to get rid of the *Messages* Buffer as well? I haven't found a function that would kill it. 回答1: Related to your second question, Also is it possible to get rid of the Messages Buffer as well . If you're using ido-mode (and everyone should be using it!), you can

Multiple threads using System.out.println in Java

别来无恙 提交于 2020-01-10 19:48:05
问题 I have a multi-threaded Java application that will output information about a message it receives to the console for debugging purposes. Each time the application receives a message, it will call a System.out.println(String) on the message. The problem that I am having is that if the application gets flooded with messages, System.out.println() prints erroneous information (like old buffer information). This is leading me to wonder if there is a threading issue where multiple threads are

Node Buffers, from utf8 to binary

断了今生、忘了曾经 提交于 2020-01-09 10:10:14
问题 I'm receiving data as utf8 from a source and this data was originally in binary form (it was a Buffer ). I have to convert back this data to a Buffer . I'm having a hard time figuring how to do this. Here's a small sample that shows my problem: var hexString = 'e61b08020304e61c09020304e61d0a020304e61e65'; var buffer1 = new Buffer(hexString, 'hex'); var str = buffer1.toString('utf8'); var buffer2 = new Buffer(str, 'utf8'); console.log('original content:', hexString); console.log('buffer1