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


Java SystemClock.elapsedRealtimeNanos方法代碼示例

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


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

示例1: getLogTime

import android.os.SystemClock; //導入方法依賴的package包/類
/**
 * Returns the current time in either millis or nanos depending on the api level to be used with
 * {@link #getElapsedMillis(long)}.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static long getLogTime() {
  if (Build.VERSION_CODES.JELLY_BEAN_MR1 <= Build.VERSION.SDK_INT) {
    return SystemClock.elapsedRealtimeNanos();
  } else {
    return System.currentTimeMillis();
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:LogTime.java

示例2: getLogTime

import android.os.SystemClock; //導入方法依賴的package包/類
/**
 * Returns the current time in either millis or nanos depending on the api level to be used with
 * {@link #getElapsedMillis(long)}.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static long getLogTime() {
  if (Build.VERSION_CODES.JELLY_BEAN_MR1 <= Build.VERSION.SDK_INT) {
    return SystemClock.elapsedRealtimeNanos();
  } else {
    return SystemClock.uptimeMillis();
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:LogTime.java

示例3: audioEncodeStep

import android.os.SystemClock; //導入方法依賴的package包/類
private synchronized boolean audioEncodeStep(boolean isEnd){
    if(isStarted){
        AvLog.d("audioEncodeStep");
        int inputIndex=mAudioEncoder.dequeueInputBuffer(TIME_OUT);
        if(inputIndex>=0){
            ByteBuffer buffer= CodecUtil.getInputBuffer(mAudioEncoder,inputIndex);
            buffer.clear();
            long time= (SystemClock.elapsedRealtimeNanos()-startTime)/1000;
            int length=mRecord.read(buffer,mRecordBufferSize);
            if(length>=0){
                mAudioEncoder.queueInputBuffer(inputIndex,0,length,time,
                        isEnd?MediaCodec.BUFFER_FLAG_END_OF_STREAM:0);
            }
        }
        MediaCodec.BufferInfo info=new MediaCodec.BufferInfo();
        while (true){
            int outputIndex=mAudioEncoder.dequeueOutputBuffer(info,TIME_OUT);
            if(outputIndex>=0){
                if(mStore!=null){
                    mStore.addData(mAudioTrack,new HardMediaData(CodecUtil.getOutputBuffer(mAudioEncoder,outputIndex),info));
                }
                mAudioEncoder.releaseOutputBuffer(outputIndex,false);
                if(info.flags==MediaCodec.BUFFER_FLAG_END_OF_STREAM){
                    AvLog.d("CameraRecorder get audio encode end of stream");
                    stop();
                    return true;
                }
            }else if(outputIndex==MediaCodec.INFO_TRY_AGAIN_LATER){
                break;
            }else if(outputIndex==MediaCodec.INFO_OUTPUT_FORMAT_CHANGED){
                AvLog.d("get audio output format changed ->"+mAudioEncoder.getOutputFormat().toString());
                mAudioTrack=mStore.addTrack(mAudioEncoder.getOutputFormat());
            }
        }
    }
    return false;
}
 
開發者ID:aiyaapp,項目名稱:AAVT,代碼行數:38,代碼來源:SoundRecorder.java

示例4: decodeStream

import android.os.SystemClock; //導入方法依賴的package包/類
/**
 * Decode an input stream into a bitmap.
 *
 * This method save input stream to temporary file on cache directory, because HEIF data
 * structure requires multi-pass parsing.
 *
 * @param is The input stream that holds the raw data to be decoded into a bitmap.
 * @return The decoded bitmap, or null if the image could not be decoded.
 */
public static Bitmap decodeStream(InputStream is) {
    assertPrecondition();
    try {
        // write stream to temporary file
        long beginTime = SystemClock.elapsedRealtimeNanos();
        File heifFile = File.createTempFile("heifreader", "heif", mCacheDir);
        FileOutputStream fos = new FileOutputStream(heifFile);
        try {
            byte[] buf = new byte[4096];
            int totalLength = 0;
            int len;
            while ((len = is.read(buf)) > 0) {
                fos.write(buf, 0, len);
                totalLength += len;
                if (LIMIT_FILESIZE < totalLength) {
                    Log.e(TAG, "data size exceeds limit(" + LIMIT_FILESIZE + ")");
                    return null;
                }
            }
        } finally {
            fos.close();
        }
        long endTime = SystemClock.elapsedRealtimeNanos();
        Log.i(TAG, "HEIC caching elapsed=" + (endTime - beginTime) / 1000000.f + "[msec]");
        return decodeFile(heifFile.getAbsolutePath());
    } catch (IOException ex) {
        Log.e(TAG, "decodeStream failure", ex);
        return null;
    }
}
 
開發者ID:yohhoy,項目名稱:heifreader,代碼行數:40,代碼來源:HeifReader.java

示例5: getAge

import android.os.SystemClock; //導入方法依賴的package包/類
/**
 * @param loc location object
 * @return age of event in ns
 */
public static Long getAge(Location loc) {
    if (loc == null) {
        return null;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return SystemClock.elapsedRealtimeNanos() - loc.getElapsedRealtimeNanos();
    } else {
        return (System.currentTimeMillis() - loc.getTime()) * 1000000L;
    }
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:15,代碼來源:Helperfunctions.java

示例6: start

import android.os.SystemClock; //導入方法依賴的package包/類
public void start(){
    if(!isStarted){
        stopFlag=false;

        mRecordBufferSize = AudioRecord.getMinBufferSize(mRecordSampleRate,
                mRecordChannelConfig, mRecordAudioFormat)*2;
        mRecord=new AudioRecord(MediaRecorder.AudioSource.MIC,mRecordSampleRate,mRecordChannelConfig,
                mRecordAudioFormat,mRecordBufferSize);
        mRecord.startRecording();
        try {
            MediaFormat format=convertAudioConfigToFormat(mConfig.mAudio);
            mAudioEncoder=MediaCodec.createEncoderByType(format.getString(MediaFormat.KEY_MIME));
            mAudioEncoder.configure(format,null,null,MediaCodec.CONFIGURE_FLAG_ENCODE);
            mAudioEncoder.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Thread thread=new Thread(new Runnable() {
            @Override
            public void run() {
                while (!stopFlag&&!audioEncodeStep(false)){};
                audioEncodeStep(true);
                Log.e("wuwang","audio stop");
                if(isStarted){
                    mRecord.stop();
                    mRecord.release();
                    mRecord=null;
                }
                if(mAudioEncoder!=null){
                    mAudioEncoder.stop();
                    mAudioEncoder.release();
                    mAudioEncoder=null;
                }
                isStarted=false;
            }
        });
        thread.start();
        startTime=SystemClock.elapsedRealtimeNanos();
        isStarted=true;
    }
}
 
開發者ID:aiyaapp,項目名稱:AAVT,代碼行數:42,代碼來源:SoundRecorder.java

示例7: renderHevcImage

import android.os.SystemClock; //導入方法依賴的package包/類
private static void renderHevcImage(ByteBuffer bitstream, ImageInfo info, Surface surface) {
    long beginTime = SystemClock.elapsedRealtimeNanos();

    // configure HEVC decoder
    MediaCodec decoder = configureDecoder(info, bitstream.limit(), surface);
    MediaFormat outputFormat = decoder.getOutputFormat();
    Log.d(TAG, "HEVC output-format=" + outputFormat);

    decoder.start();
    try {
        // set bitstream to decoder
        int inputBufferId = decoder.dequeueInputBuffer(-1);
        if (inputBufferId < 0) {
            throw new IllegalStateException("dequeueInputBuffer return " + inputBufferId);
        }
        ByteBuffer inBuffer = decoder.getInputBuffer(inputBufferId);
        inBuffer.put(bitstream);
        decoder.queueInputBuffer(inputBufferId, 0, bitstream.limit(), 0, 0);

        // notify end of stream
        inputBufferId = decoder.dequeueInputBuffer(-1);
        if (inputBufferId < 0) {
            throw new IllegalStateException("dequeueInputBuffer return " + inputBufferId);
        }
        decoder.queueInputBuffer(inputBufferId, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);

        // get decoded image
        MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
        while (true) {
            int outputBufferId = decoder.dequeueOutputBuffer(bufferInfo, -1);
            if (outputBufferId >= 0) {
                decoder.releaseOutputBuffer(outputBufferId, true);
                break;
            } else if (outputBufferId == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
                outputFormat = decoder.getOutputFormat();
                Log.d(TAG, "HEVC output-format=" + outputFormat);
            } else {
                Log.d(TAG, "HEVC dequeueOutputBuffer return " + outputBufferId);
            }
        }
        decoder.flush();
    } finally {
        decoder.stop();
        decoder.release();
    }
    long endTime = SystemClock.elapsedRealtimeNanos();
    Log.i(TAG, "HEVC decoding elapsed=" + (endTime - beginTime) / 1000000.f + "[msec]");
}
 
開發者ID:yohhoy,項目名稱:heifreader,代碼行數:49,代碼來源:HeifReader.java

示例8: getStopwatchSessionId

import android.os.SystemClock; //導入方法依賴的package包/類
@VisibleForTesting
protected String getStopwatchSessionId(@NonNull HttpRequest request) {
    return request.method() + " " + request.url().getPath() + " (" + SystemClock.elapsedRealtimeNanos() + ")";
}
 
開發者ID:BioID-GmbH,項目名稱:BWS-Android,代碼行數:5,代碼來源:HttpRequestHelper.java

示例9: getStopwatchSessionId

import android.os.SystemClock; //導入方法依賴的package包/類
private String getStopwatchSessionId(@NonNull String methodName) {
    return methodName + " (" + SystemClock.elapsedRealtimeNanos() + ")";
}
 
開發者ID:BioID-GmbH,項目名稱:BWS-Android,代碼行數:4,代碼來源:ImageFormatConverter.java

示例10: getStopwatchSessionId

import android.os.SystemClock; //導入方法依賴的package包/類
@SuppressWarnings("SameParameterValue")
private String getStopwatchSessionId(@NonNull String methodName) {
    return methodName + " (" + SystemClock.elapsedRealtimeNanos() + ")";
}
 
開發者ID:BioID-GmbH,項目名稱:BWS-Android,代碼行數:5,代碼來源:ImageTransformer.java


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