Exemplo n.º 1
0
  private void listenAck() {
    Modulation.initDecoder(); // for record
    Modulation.setListenMode('p');

    mRecordData = new short[mRecordBufSize / 2];

    while (!Thread.interrupted() && mIsPlaying) {

      int readBytes = mRecorder.read(mRecordData, 0, mRecordBufSize / 2);

      if (readBytes > 0) {
        int ret = Modulation.process(mRecordData, readBytes);
        if (ret == 2) {
          String str = "";
          byte[] result = Modulation.getResult();
          try {
            str = new String(result, "UTF-8");

            Log.d(TAG, "recorder ProcessData GetResult : " + str);
          } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
          }

          Message msg = mHandler.obtainMessage();
          msg.what = Modulation.MODULATION_HANDLER_RECV_NOTIFY_ACK;
          mHandler.sendMessage(msg);
          // break;
        }
      } else {
        Log.d(TAG, "recorder read ret : " + readBytes);
      }
    }

    try {
      if (mRecorder != null) {
        mRecorder.stop();
        mRecorder.release();
        mRecorder = null;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    Modulation.setListenMode('r');
    Modulation.releaseDecoder();
  }