当前位置: 首页>>代码示例>>Java>>正文


Java AudioRecord.STATE_UNINITIALIZED属性代码示例

本文整理汇总了Java中android.media.AudioRecord.STATE_UNINITIALIZED属性的典型用法代码示例。如果您正苦于以下问题:Java AudioRecord.STATE_UNINITIALIZED属性的具体用法?Java AudioRecord.STATE_UNINITIALIZED怎么用?Java AudioRecord.STATE_UNINITIALIZED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.media.AudioRecord的用法示例。


在下文中一共展示了AudioRecord.STATE_UNINITIALIZED属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RecognizerThread

public RecognizerThread(int timeout) {
    if (timeout != NO_TIMEOUT) {
        this.timeoutSamples = timeout * sampleRate / 1000;
    } else {
        this.timeoutSamples = NO_TIMEOUT;
    }
    this.remainingSamples = this.timeoutSamples;
    recorder = new AudioRecord(6, sampleRate, 16, 2, bufferSize * 2);
    if (recorder.getState() == AudioRecord.STATE_UNINITIALIZED) {
        recorder.release();
        try {
            throw new IOException(
                    "Failed to initialize recorder. Microphone might be already in use.");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:icaksama,项目名称:RapidSphinx,代码行数:18,代码来源:RapidRecognizer.java

示例2: stopAndRelease

/**
 * Stop and release resource.
 *
 */
public void stopAndRelease() {
    if ((mAudioRecord != null) && (mAudioRecord.getState() != AudioRecord.STATE_UNINITIALIZED)) {
        try {
            mAudioRecord.stop();
            mAudioRecord.release();
        } catch (Exception e) {
            Log.e(TAG, "stopAndRelease() Exception: " + e.getMessage());
        }
    }
    mAudioRecord = null;
}
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:15,代码来源:AudioRecordManager.java

示例3: startCapture

public boolean startCapture(int audioSource, int sampleRateInHz, int channelConfig, int audioFormat) {
    if (mIsCaptureStarted) {
        Log.e(TAG, "Capture already started !");
        return false;
    }

    int minBufferSize = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);
    if (minBufferSize == AudioRecord.ERROR_BAD_VALUE) {
        Log.e(TAG, "Invalid parameter !");
        return false;
    }

    mAudioRecord = new AudioRecord(audioSource, sampleRateInHz, channelConfig, audioFormat, minBufferSize * 4);
    if (mAudioRecord.getState() == AudioRecord.STATE_UNINITIALIZED) {
        Log.e(TAG, "AudioRecord initialize fail !");
        return false;
    }

    mAudioRecord.startRecording();

    mIsLoopExit = false;
    mCaptureThread = new Thread(new AudioCaptureRunnable());
    mCaptureThread.start();

    mIsCaptureStarted = true;

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

    return true;
}
 
开发者ID:pili-engineering,项目名称:PLDroidRTCStreaming,代码行数:30,代码来源:ExtAudioCapture.java

示例4: stop

public void stop() {
    if (recorder != null
        && recorder.getState() != AudioRecord.STATE_UNINITIALIZED) {
    	recorder.stop();
    	recorder.release();
    	Log.i("AudioCodec", "Sampling stopped");
    }
    Log.i("AudioCodec", "Recorder set to null");
    recorder = null;
}
 
开发者ID:guardianproject,项目名称:haven,代码行数:10,代码来源:AudioCodec.java

示例5: initialise

/**
 * Initialise the Voice Recorder
 *
 * @return The audio record initialisation state.
 */
public int initialise() {

    int count = 0;

    while (count < 4) {
        count++;

        saiyAudio = new SaiyAudio(audioSource, sampleRateInHz, channelConfig, audioFormat,
                bufferSizeInBytes, enhance);

        if (saiyAudio.getState() == AudioRecord.STATE_INITIALIZED) {
            return AudioRecord.STATE_INITIALIZED;
        } else {
            if (DEBUG) {
                MyLog.w(CLS_NAME, "SaiyAudio reinitialisation attempt ~ " + count);
            }

            if (Looper.myLooper() != null && Looper.myLooper() != Looper.getMainLooper()) {

                // Give the audio object a small chance to sort itself out
                try {
                    Thread.sleep(250);
                } catch (InterruptedException e) {
                    if (DEBUG) {
                        MyLog.w(CLS_NAME, "SaiyAudio InterruptedException");
                        e.printStackTrace();
                    }
                }
            }
        }
    }

    if (DEBUG) {
        MyLog.w(CLS_NAME, "SaiyAudio initialisation failed");
    }

    return AudioRecord.STATE_UNINITIALIZED;
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:43,代码来源:SaiyRecorder.java

示例6: startCapture

public boolean startCapture(int audioSource, int sampleRateInHz, int channelConfig, int audioFormat) {

        if (mIsCaptureStarted) {
            Log.e(TAG, "hujd Capture already started !");
            return false;
        }

        mMinBufferSize = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);

        if (mMinBufferSize == AudioRecord.ERROR_BAD_VALUE) {
            Log.e(TAG, "hujd Invalid parameter !");
            return false;
        }

        Log.e(TAG, "hujd getMinBufferSize = " + mMinBufferSize + " bytes !");

        mAudioRecord = new AudioRecord(audioSource, sampleRateInHz, channelConfig, audioFormat, mMinBufferSize);

        if (mAudioRecord.getState() == AudioRecord.STATE_UNINITIALIZED) {
            Log.e(TAG, "hujd AudioRecord initialize fail !");
            return false;
        }

        mAudioRecord.startRecording();


        mIsLoopExit = false;
        mCaptureThread = new Thread(new AudioCaptureRunnable());

        mCaptureThread.start();

        mIsCaptureStarted = true;

        Log.e(TAG, "hujd Start audio capture success !");
        return true;

    }
 
开发者ID:ThinkKeep,项目名称:EvilsLive,代码行数:37,代码来源:AudioCapture.java


注:本文中的android.media.AudioRecord.STATE_UNINITIALIZED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。