当前位置: 首页>>代码示例>>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;未经允许,请勿转载。