Not receive any data from AudioRecord

31 Views Asked by At

I cant receive any data from my esp8266 with this code The module receive any other bytes data... Its add permissions

uses-permission android:name="android.permission.RECORD_AUDIO"

The buffersize

private int BufferSize = AudioRecord.getMinBufferSize(44100,
        AudioFormat.CHANNEL_CONFIGURATION_MONO,
        AudioFormat.ENCODING_PCM_16BIT);

void Recording() {
    call = new AudioRecord(MediaRecorder.AudioSource.MIC, 44100, AudioFormat.CHANNEL_IN_DEFAULT, AudioFormat.ENCODING_PCM_16BIT, BufferSize);
    if(CallFlag) {
        call.startRecording();
    }
    else {
        call.stop();
        call.release();
    }
    android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
    Thread callmagi = new Thread(new Runnable() {
        @Override
        public void run() {
            synchronized (this) {
                byte buff[]  = new byte[BufferSize];
                while (CallFlag) {
                    int count = call.read(buff,0,BufferSize);
                    try {
                        InetAddress ip = InetAddress.getByName("192.168.43.96");
                        DatagramPacket db = new DatagramPacket(buff, count, ip, 9001);
                        clientSocket.send(db);;
                //      buff = null;
                    } catch (SocketException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (UnknownHostException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
}
                }
        }
            });
    callmagi.start();
        }
0

There are 0 best solutions below