當前位置: 首頁>>代碼示例>>Java>>正文


Java AudioRecord.RECORDSTATE_RECORDING屬性代碼示例

本文整理匯總了Java中android.media.AudioRecord.RECORDSTATE_RECORDING屬性的典型用法代碼示例。如果您正苦於以下問題:Java AudioRecord.RECORDSTATE_RECORDING屬性的具體用法?Java AudioRecord.RECORDSTATE_RECORDING怎麽用?Java AudioRecord.RECORDSTATE_RECORDING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.media.AudioRecord的用法示例。


在下文中一共展示了AudioRecord.RECORDSTATE_RECORDING屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: start

/**
 * <p>Starts the recording, and sets the state to RECORDING.</p>
 */
public void start() {
	if (mRecorder.getState() == AudioRecord.STATE_INITIALIZED) {
		mRecorder.startRecording();
		if (mRecorder.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
			setState(State.RECORDING);
			new Thread() {
				public void run() {
					while (mRecorder != null && mRecorder.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
						int status = read(mRecorder);
						if (status < 0) {
							break;
						}
					}
				}
			}.start();
		} else {
			Log.e(LOG_TAG, "startRecording() failed");
			setState(State.ERROR);
		}
	} else {
		Log.e(LOG_TAG, "start() called on illegal state");
		setState(State.ERROR);
	}
}
 
開發者ID:suelensilva,項目名稱:KaldiAndroid,代碼行數:27,代碼來源:RawAudioRecorder.java

示例2: stop

/**
 * <p>Stops the recording, and sets the state to STOPPED.
 * If stopping fails then sets the state to ERROR.</p>
 */
public void stop() {
	// We check the underlying AudioRecord state trying to avoid IllegalStateException.
	// If it still occurs then we catch it.
	if (mRecorder.getState() == AudioRecord.STATE_INITIALIZED &&
			mRecorder.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
		try {
			mRecorder.stop();
			mRecorder.release();
			setState(State.STOPPED);
		} catch (IllegalStateException e) {
			Log.e(LOG_TAG, "native stop() called in illegal state: " + e.getMessage());
			setState(State.ERROR);
		}
	} else {
		Log.e(LOG_TAG, "stop() called in illegal state");
		setState(State.ERROR);
	}
}
 
開發者ID:suelensilva,項目名稱:KaldiAndroid,代碼行數:22,代碼來源:RawAudioRecorder.java

示例3: listen

public byte[] listen() {
        mReceivedBytes = new byte[]{};
        mFinished = false;

        if (mAudioRec.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
            mAudioRec.startRecording();
        }

        while (true) {
            if (mFinished) break;

//            short[] audioData = readAudioData();
//            window(audioData);
//
//            int[] powerlist = new int[18];
//            for (int i = 0; i < powerlist.length; i++) {
//                powerlist[i] = goertzel(CHAR_FREQ[i]);
//            }
//            int base = goertzel(BASELINE);
//
//            updateState(powerlist, base);
//            signalToBits();
//            processByte();
        }
        return mReceivedBytes;
    }
 
開發者ID:egglang,項目名稱:sonicky,代碼行數:26,代碼來源:Decoder.java

示例4: isRecodingStopped

private boolean isRecodingStopped() {
    if (mRecordState == RecordState.STOPPING) {
        // AudioRecord has been released, it means recorder thread is stopped.
        if (mRecord == null) {
            return true;
        } else {
            // Check AudioRecord state if recorder thread is still running.
            if (mRecord.getState() != AudioRecord.RECORDSTATE_RECORDING) {
                return true;
            }
        }
    } else if (mRecordState == RecordState.STOPPED) {
        return true;
    }

    return false;
}
 
開發者ID:olami-developers,項目名稱:olami-android-client-sdk,代碼行數:17,代碼來源:RecorderSpeechRecognizer.java

示例5: stopCapture

public void stopCapture() {
    if (!mIsCaptureStarted) {
        return;
    }

    mIsLoopExit = true;
    try {
        mCaptureThread.interrupt();
        mCaptureThread.join(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    if (mAudioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
        mAudioRecord.stop();
    }

    mAudioRecord.release();

    mIsCaptureStarted = false;
    mOnAudioFrameCapturedListener = null;

    Log.d(TAG, "Stop audio capture success !");
}
 
開發者ID:pili-engineering,項目名稱:PLDroidRTCStreaming,代碼行數:24,代碼來源:ExtAudioCapture.java

示例6: start

public void start()
{
    if(getState()==AudioRecord.STATE_INITIALIZED)
    {
        startRecording();
        if(getRecordingState()==AudioRecord.RECORDSTATE_RECORDING)
        {
            new Thread() {
                public void run() {
                    recorderLoop();
                }
            }.start();
        }  else {
        Log.e("startRecording()"," failed");
        }
    } else {
        Log.e("start()"," called on illegal state");
    }

}
 
開發者ID:raj10071997,項目名稱:Alexa-Voice-Service,代碼行數:20,代碼來源:RecordAudioinBytes.java

示例7: startRecording

private boolean startRecording() {
  Logging.d(TAG, "startRecording");
  assertTrue(audioRecord != null);
  assertTrue(audioThread == null);
  try {
    audioRecord.startRecording();
  } catch (IllegalStateException e) {
    reportWebRtcAudioRecordStartError("AudioRecord.startRecording failed: " + e.getMessage());
    return false;
  }
  if (audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
    reportWebRtcAudioRecordStartError("AudioRecord.startRecording failed - incorrect state :"
        + audioRecord.getRecordingState());
    return false;
  }
  audioThread = new AudioRecordThread("AudioRecordJavaThread");
  audioThread.start();
  return true;
}
 
開發者ID:lgyjg,項目名稱:AndroidRTC,代碼行數:19,代碼來源:WebRtcAudioRecord.java

示例8: stopCapture

public void stopCapture() {
    if (!mIsCaptureStarted) {
        return;
    }

    mIsLoopExit = true;

    try {
        mCaptureThread.interrupt();
        mCaptureThread.join(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    if (mAudioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
        mAudioRecord.stop();
    }

    mAudioRecord.release();
    mIsCaptureStarted = false;
    mAudioFrameCapturedListener = null;

    Log.d(TAG, "Stop audio capture success !");

}
 
開發者ID:ThinkKeep,項目名稱:EvilsLive,代碼行數:25,代碼來源:AudioCapture.java

示例9: stopAudioRecord

private boolean stopAudioRecord(Context context)
{
	try
	{
		if (audioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING)
		{
			isAudioRecordRunning = false;
			audioRecord.setRecordPositionUpdateListener(null);
			audioRecord.stop();
			audioRecordRandomAccessFile.seek(4);
			audioRecordRandomAccessFile.writeInt(Integer.reverseBytes(36 + audioRecordPayloadSize)); // 04 - Size of the overall file
			audioRecordRandomAccessFile.seek(40);
			audioRecordRandomAccessFile.writeInt(Integer.reverseBytes(audioRecordPayloadSize)); // 40 - Size of the data section
			audioRecordRandomAccessFile.close();
		}
	}
	catch (Exception e)
	{
		Log.w("RecordFileWriter", "stopAudioRecord : " + context.getString(R.string.log_record_file_writer_error_stop_audiorecord) + " : " + e);
		databaseManager.insertLog(context, "" + context.getString(R.string.log_record_file_writer_error_stop_audiorecord), new Date().getTime(), 2, false);
		return false;
	}
	
	return true;
}
 
開發者ID:vassela,項目名稱:AC2RD,代碼行數:25,代碼來源:RecordFileWriter.java

示例10: release

/**
 * <p>Stops the recording (if needed) and releases the resources.
 * The object can no longer be used and the reference should be
 * set to null after a call to release().</p>
 */
public synchronized void release() {
	if (mRecorder != null) {
		if (mRecorder.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
			stop();
		}
		mRecorder.release();
		mRecorder = null;
	}
}
 
開發者ID:suelensilva,項目名稱:KaldiAndroid,代碼行數:14,代碼來源:RawAudioRecorder.java

示例11: recorderLoop

private void recorderLoop() {
    while (getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
        int status = read(mBuffer);
        if (status < 0) {
            Log.e("status = ", String.valueOf(status));
            break;
        }
    }
}
 
開發者ID:raj10071997,項目名稱:Alexa-Voice-Service,代碼行數:9,代碼來源:RecordAudioinBytes.java

示例12: startRecording

private boolean startRecording() {
  threadChecker.checkIsOnValidThread();
  Logging.d(TAG, "startRecording");
  assertTrue(audioRecord != null);
  assertTrue(audioThread == null);

  // Starts recording from the AudioRecord instance.
  try {
    audioRecord.startRecording();
  } catch (IllegalStateException e) {
    reportWebRtcAudioRecordStartError(AudioRecordStartErrorCode.AUDIO_RECORD_START_EXCEPTION,
        "AudioRecord.startRecording failed: " + e.getMessage());
    return false;
  }

  // Verify the recording state up to two times (with a sleep in between)
  // before returning false and reporting an error.
  int numberOfStateChecks = 0;
  while (audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING &&
         ++numberOfStateChecks < 2) {
    threadSleep(200);
  }
  if (audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
    reportWebRtcAudioRecordStartError(
        AudioRecordStartErrorCode.AUDIO_RECORD_START_STATE_MISMATCH,
        "AudioRecord.startRecording failed - incorrect state :"
        + audioRecord.getRecordingState());
    return false;
  }

  // Create and start new high-priority thread which calls AudioRecord.read()
  // and where we also call the native DataIsRecorded() callback to feed
  // WebRTC with recorded audio.
  audioThread = new AudioRecordThread("AudioRecordJavaThread");
  audioThread.start();
  return true;
}
 
開發者ID:Piasy,項目名稱:AppRTC-Android,代碼行數:37,代碼來源:WebRtcAudioRecord.java

示例13: releaseAudioRecord

private boolean releaseAudioRecord(Context context)
{
	try
	{
		if (audioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING)
		{
			stopAudioRecord(context);
		}
		else if(audioRecord.getState() == AudioRecord.STATE_INITIALIZED)
		{
			audioRecordRandomAccessFile.close();
		}
		
		if (audioRecord != null)
		{
			audioRecord.release();
		}
	}
	catch (Exception e)
	{
		Log.w("RecordFileWriter", "releaseAudioRecord : " + context.getString(R.string.log_record_file_writer_error_release_audiorecord) + " : " + e);
		databaseManager.insertLog(context, "" + context.getString(R.string.log_record_file_writer_error_release_audiorecord), new Date().getTime(), 2, false);
		return false;
	}
	
	return true;
}
 
開發者ID:vassela,項目名稱:AC2RD,代碼行數:27,代碼來源:RecordFileWriter.java

示例14: isRecord

public boolean isRecord() {
    return running.get() && mRecorder.getStatus() == AudioRecord.RECORDSTATE_RECORDING;
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:3,代碼來源:PcmRecorder.java

示例15: startRecording

public void startRecording() {
    if (mAudioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING)
        return;
    mAudioRecord.startRecording();
}
 
開發者ID:lrannn,項目名稱:SimpleRecorder,代碼行數:5,代碼來源:Recorder.java


注:本文中的android.media.AudioRecord.RECORDSTATE_RECORDING屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。