當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。