OpenSLES播放、錄制鼠次、聲道切換更哄、音量控制

  1. OpenSLES(Open Sound Library for Embedded Systems)無授權(quán)費、跨平臺腥寇、針對嵌入式系統(tǒng)精心優(yōu)化的硬件音頻加速API成翩。它為嵌入式移動多媒體設備上的本地應用程序開發(fā)者提供標準化, 高性能,低響應時間的音頻功能實現(xiàn)方法,并實現(xiàn)軟/硬件音頻性能的直接跨平臺部署赦役,降低執(zhí)行難度麻敌,促進高級音頻市場的發(fā)展。

  2. Android里面ndk->platforms-> android-xx -> arch-xx ->usr->lib目錄里面包含了ndk內(nèi)置的so掂摔,可以看到支持了libOpenSLES.so术羔。

  3. githubgooglesamples/android-ndk可以看到ndk庫的sample,里面native-audio目錄就是OpenSLESsample

  1. OpenSLES播放主要步驟如下:
  1. 創(chuàng)建接口對象
  2. 設置混音器
  3. 創(chuàng)建播放器(錄音器)
  4. 設置緩沖隊列和回調(diào)函數(shù)
  5. 設置播放狀態(tài)
  6. 啟動回調(diào)函數(shù)
  7. 銷毀

4.1 創(chuàng)建接口對象


    // 引擎接口
    SLObjectItf engineObject = NULL;
    SLEngineItf engineEngine = NULL;
    
    // 創(chuàng)建引擎對象
     slCreateEngine(&engineObject,  0, NULL, 0, NULL, NULL);
     (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
     (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);


4.2 設置混音器


    //混音器
    SLObjectItf outputMixObject = NULL;
    SLEnvironmentalReverbItf outputMixEnvironmentalReverb = NULL;
    SLEnvironmentalReverbSettings reverbSettings = SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR;
    
    
    const SLInterfaceID mids[1] = {SL_IID_ENVIRONMENTALREVERB};
    const SLboolean mreq[1] = {SL_BOOLEAN_FALSE};
    (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, mids, mreq);
    (void)result;
    result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
    (void)result;
    result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB, &outputMixEnvironmentalReverb);
    if (SL_RESULT_SUCCESS == result) {
        result = (*outputMixEnvironmentalReverb)->SetEnvironmentalReverbProperties( outputMixEnvironmentalReverb, &reverbSettings);
        (void)result;
    }
    
    SLDataLocator_OutputMix outputMix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObject};


4.3 創(chuàng)建播放器


    //pcm
    SLObjectItf pcmPlayerObject = NULL;
    SLPlayItf pcmPlayerPlay = NULL;
    SLVolumeItf pcmPlayerVolume = NULL;
    
    
    SLDataLocator_AndroidSimpleBufferQueue android_queue={SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,2};
    SLDataFormat_PCM pcm={
                SL_DATAFORMAT_PCM,//播放pcm格式的數(shù)據(jù)
                2,//2個聲道(立體聲)
                SL_SAMPLINGRATE_44_1,//44100hz的頻率
                SL_PCMSAMPLEFORMAT_FIXED_16,//位數(shù) 16位
                SL_PCMSAMPLEFORMAT_FIXED_16,//和位數(shù)一致就行
                SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT,//立體聲(前左前右)
                SL_BYTEORDER_LITTLEENDIAN//結(jié)束標志
     };
    
    SLDataSource slDataSource = {&android_queue, &pcm};
    SLDataSink audioSnk = {&outputMix, NULL};
   // SL_IID_BUFFERQUEUE:緩沖  SL_IID_VOLUME:音量  SL_IID_PLAYBACKRATE:微調(diào)功能 防止卡頓 微調(diào)功能 SL_IID_MUTESOLO:聲道切換
    const SLInterfaceID ids[4] = {SL_IID_BUFFERQUEUE, SL_IID_VOLUME, SL_IID_PLAYBACKRATE, SL_IID_MUTESOLO};
    const SLboolean req[4] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
    
     result = (*engineEngine)->CreateAudioPlayer(engineEngine, &pcmPlayerObject, &slDataSource, &audioSnk, 3, ids, req);
        // 初始化播放器
    (*pcmPlayerObject)->Realize(pcmPlayerObject, SL_BOOLEAN_FALSE);
    
        //得到接口后調(diào)用  獲取Player接口
    (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_PLAY, &pcmPlayerPlay);

4.4 設置緩沖隊列和回調(diào)函數(shù)


    //緩沖器隊列接口
    SLAndroidSimpleBufferQueueItf pcmBufferQueue;
    void *buffer;
    uint8_t *out_buffer;
    
    void getPcmData(void **pcm){
        while(!feof(pcmFile))  {
            int size = static_cast<int>(fread(out_buffer,1,44100 * 2 * 2,pcmFile));
            if(out_buffer == NULL)  {
                LOGI("%s  %d", "read end",size);
                break;
            } else{
                LOGI("%s  %d", "reading",size);
            }
            *pcm = out_buffer;
            break;
        }
    }

    void pcmBufferCallBack(SLAndroidSimpleBufferQueueItf bf, void * context){
        //assert(NULL == context);
        getPcmData(&buffer);
        // for streaming playback, replace this test by logic to find and fill the next buffer
        if (NULL != buffer) {
            SLresult result;
            // enqueue another buffer
            result = (*pcmBufferQueue)->Enqueue(pcmBufferQueue, buffer, 44100 * 2 * 2);
            // the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
            // which for this code example would indicate a programming error
        }
    }


    

    // 創(chuàng)建緩沖區(qū)和回調(diào)函數(shù)
    (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_BUFFERQUEUE, &pcmBufferQueue);

    //緩沖接口回調(diào)
    (*pcmBufferQueue)->RegisterCallback(pcmBufferQueue, pcmBufferCallBack, NULL);
    //獲取音量接口
    (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_VOLUME, &pcmPlayerVolume);


4.5 設置播放狀態(tài)

     (*pcmPlayerPlay)->SetPlayState(pcmPlayerPlay, SL_PLAYSTATE_PLAYING);

4.6 啟動回調(diào)函數(shù)

     // 主動調(diào)用回調(diào)函數(shù)開始工作
    pcmBufferCallBack(pcmBufferQueue, NULL);

4.7 銷毀

    

     if (pcmPlayerObject != NULL) {
        (*pcmPlayerObject)->Destroy(pcmPlayerObject);
        pcmPlayerObject = NULL;
        pcmPlayerPlay = NULL;
        pcmBufferQueue = NULL;
        pcmPlayerVolume = NULL;
    }
    
    
    if (outputMixObject != NULL) {
        (*outputMixObject)->Destroy(outputMixObject);
        outputMixObject = NULL;
        outputMixEnvironmentalReverb = NULL;
    }
  
     if (engineObject != NULL) {
        (*engineObject)->Destroy(engineObject);
        engineObject = NULL;
        engineEngine = NULL;
    }

示例代碼如下:

#include <jni.h>
#include <string>


extern "C"
{
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
}

#include <android/log.h>
#define LOGI(FORMAT,...) __android_log_print(ANDROID_LOG_INFO,"zzw",FORMAT,##__VA_ARGS__);
#define LOGE(FORMAT,...) __android_log_print(ANDROID_LOG_ERROR,"zzw",FORMAT,##__VA_ARGS__);

// 引擎接口
SLObjectItf engineObject = NULL;
SLEngineItf engineEngine = NULL;

//混音器
SLObjectItf outputMixObject = NULL;
SLEnvironmentalReverbItf outputMixEnvironmentalReverb = NULL;
SLEnvironmentalReverbSettings reverbSettings = SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR;


//pcm
SLObjectItf pcmPlayerObject = NULL;
SLPlayItf pcmPlayerPlay = NULL;
SLVolumeItf pcmPlayerVolume = NULL;

//緩沖器隊列接口
SLAndroidSimpleBufferQueueItf pcmBufferQueue;

FILE *pcmFile;
void *buffer;

uint8_t *out_buffer;

void getPcmData(void **pcm)
{
    while(!feof(pcmFile))
    {
        int size = static_cast<int>(fread(out_buffer,1,44100 * 2 * 2,pcmFile));
        if(out_buffer == NULL)
        {
            LOGI("%s  %d", "read end",size);
            break;
        } else{
            LOGI("%s  %d", "reading",size);
        }
        *pcm = out_buffer;
        break;
    }
}

void pcmBufferCallBack(SLAndroidSimpleBufferQueueItf bf, void * context)
{
    //assert(NULL == context);
    getPcmData(&buffer);
    // for streaming playback, replace this test by logic to find and fill the next buffer
    if (NULL != buffer) {
        SLresult result;
        // enqueue another buffer
        result = (*pcmBufferQueue)->Enqueue(pcmBufferQueue, buffer, 44100 * 2 * 2);
        // the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
        // which for this code example would indicate a programming error
    }
}

extern "C"
JNIEXPORT void JNICALL
Java_com_example_zzw_androidopenslaudio_MainActivity_palypcm(JNIEnv *env, jobject instance,
                                                               jstring url_) {
    const char *url = env->GetStringUTFChars(url_, 0);

    // TODO
    //讀取pcm文件
    pcmFile = fopen(url, "r");
    if(pcmFile == NULL)
    {
        LOGE("%s", "fopen file error");
        return;
    }
    out_buffer = (uint8_t *) malloc(44100 * 2 * 2);


    SLresult result;
    //第一步------------------------------------------
    // 創(chuàng)建引擎對象
    slCreateEngine(&engineObject, 0, 0, 0, 0, 0);
    (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
    (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);


    //第二步-------------------------------------------
    // 創(chuàng)建混音器
    const SLInterfaceID mids[1] = {SL_IID_ENVIRONMENTALREVERB};
    const SLboolean mreq[1] = {SL_BOOLEAN_FALSE};
    result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, mids, mreq);
    (void)result;
    result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
    (void)result;
    result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB, &outputMixEnvironmentalReverb);
    if (SL_RESULT_SUCCESS == result) {
        result = (*outputMixEnvironmentalReverb)->SetEnvironmentalReverbProperties(
                outputMixEnvironmentalReverb, &reverbSettings);
        (void)result;
    }
    SLDataLocator_OutputMix outputMix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObject};

    // 第三步--------------------------------------------
    // 創(chuàng)建播放器
    SLDataLocator_AndroidSimpleBufferQueue android_queue={SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,2};
    SLDataFormat_PCM pcm={
            SL_DATAFORMAT_PCM,//播放pcm格式的數(shù)據(jù)
            2,//2個聲道(立體聲)
            SL_SAMPLINGRATE_44_1,//44100hz的頻率
            SL_PCMSAMPLEFORMAT_FIXED_16,//位數(shù) 16位
            SL_PCMSAMPLEFORMAT_FIXED_16,//和位數(shù)一致就行
            SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT,//立體聲(前左前右)
            SL_BYTEORDER_LITTLEENDIAN//結(jié)束標志
    };

    SLDataSource slDataSource = {&android_queue, &pcm};
    SLDataSink audioSnk = {&outputMix, NULL};
    
    // SL_IID_BUFFERQUEUE:緩沖  SL_IID_VOLUME:音量  SL_IID_PLAYBACKRATE:微調(diào)功能 防止卡頓 微調(diào)功能 SL_IID_MUTESOLO:聲道切換
    const SLInterfaceID ids[4] = {SL_IID_BUFFERQUEUE, SL_IID_VOLUME, SL_IID_PLAYBACKRATE, SL_IID_MUTESOLO};
    const SLboolean req[4] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};

    result = (*engineEngine)->CreateAudioPlayer(engineEngine, &pcmPlayerObject, &slDataSource, &audioSnk, 3, ids, req);
    // 初始化播放器
    (*pcmPlayerObject)->Realize(pcmPlayerObject, SL_BOOLEAN_FALSE);

    //得到接口后調(diào)用  獲取Player接口
    (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_PLAY, &pcmPlayerPlay);

    //第四步---------------------------------------
    // 創(chuàng)建緩沖區(qū)和回調(diào)函數(shù)
    (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_BUFFERQUEUE, &pcmBufferQueue);

    //緩沖接口回調(diào)
    (*pcmBufferQueue)->RegisterCallback(pcmBufferQueue, pcmBufferCallBack, NULL);
    //獲取音量接口
    (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_VOLUME, &pcmPlayerVolume);

    //第五步----------------------------------------
    // 設置播放狀態(tài)
    (*pcmPlayerPlay)->SetPlayState(pcmPlayerPlay, SL_PLAYSTATE_PLAYING);


    //第六步----------------------------------------
    // 主動調(diào)用回調(diào)函數(shù)開始工作
    pcmBufferCallBack(pcmBufferQueue, NULL);

    env->ReleaseStringUTFChars(url_, url);
}

  1. 暫停乙漓、繼續(xù)级历、停止
    使用播放控制接口 SLPlayItf
    //暫停
    if (pcmPlayerPlay != NULL) {
        (*pcmPlayerPlay)->SetPlayState(pcmPlayerPlay, SL_PLAYSTATE_PAUSED);
    }
    //繼續(xù)
    if (pcmPlayerPlay != NULL) {
        (*pcmPlayerPlay)->SetPlayState(pcmPlayerPlay, SL_PLAYSTATE_PLAYING);
    }
    //停止
    if (pcmPlayerPlay != NULL) {
        (*pcmPlayerPlay)->SetPlayState(pcmPlayerPlay, SL_PLAYSTATE_STOPPED);
    }

  1. 音量控制
    使用音量控制接口 SLVolumeItf
//初始化
(*pcmPlayerObject)->GetInterface(pcmPlayerObject,SL_IID_VOLUME,&pcmPlayerVolume);
//設置音量
(*pcmPlayerVolume)->SetVolumeLevel(pcmPlayerVolume, (100 - percent) * -50);

可用示例

void WlAudio::setVolume(int percent) {
    volumePercent = percent;
    if(pcmVolumePlay != NULL)
    {
        if(percent > 30)
        {
            (*pcmVolumePlay)->SetVolumeLevel(pcmVolumePlay, (100 - percent) * -20);
        }
        else if(percent > 25)
        {
            (*pcmVolumePlay)->SetVolumeLevel(pcmVolumePlay, (100 - percent) * -22);
        }
        else if(percent > 20)
        {
            (*pcmVolumePlay)->SetVolumeLevel(pcmVolumePlay, (100 - percent) * -25);
        }
        else if(percent > 15)
        {
            (*pcmVolumePlay)->SetVolumeLevel(pcmVolumePlay, (100 - percent) * -28);
        }
        else if(percent > 10)
        {
            (*pcmVolumePlay)->SetVolumeLevel(pcmVolumePlay, (100 - percent) * -30);
        }
        else if(percent > 5)
        {
            (*pcmVolumePlay)->SetVolumeLevel(pcmVolumePlay, (100 - percent) * -34);
        }
        else if(percent > 3)
        {
            (*pcmVolumePlay)->SetVolumeLevel(pcmVolumePlay, (100 - percent) * -37);
        }
        else if(percent > 0)
        {
            (*pcmVolumePlay)->SetVolumeLevel(pcmVolumePlay, (100 - percent) * -40);
        }
        else{
            (*pcmVolumePlay)->SetVolumeLevel(pcmVolumePlay, (100 - percent) * -100);
        }
    }
}
  1. 聲道控制

采用聲道控制接口SLMuteSoloItf接口

    SLMuteSoloItf  pcmMutePlay = NULL;

  //初始化
    (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_MUTESOLO, &pcmMutePlay);
    
  // 設置聲道:
    (*pcmPlayPlayerMuteSolo)->SetChannelMute(
                pcmPlayPlayerMuteSolo, 
                1,  //0右聲道1左聲道
                false //聲道是否開啟
                );



有效示例:

 SLMuteSoloItf  pcmMutePlay = NULL;
 //初始化
    ...
void WlAudio::setMute(int mute) {
    this->mute = mute;
    if(pcmMutePlay != NULL)
    {
        if(mute == 0)//right
        {
            (*pcmMutePlay)->SetChannelMute(pcmMutePlay, 1, false);
            (*pcmMutePlay)->SetChannelMute(pcmMutePlay, 0, true);
        }
        else if(mute == 1)//left
        {
            (*pcmMutePlay)->SetChannelMute(pcmMutePlay, 1, true);
            (*pcmMutePlay)->SetChannelMute(pcmMutePlay, 0, false);
        }
        else if(mute == 2)//center
        {
            (*pcmMutePlay)->SetChannelMute(pcmMutePlay, 1, false);
            (*pcmMutePlay)->SetChannelMute(pcmMutePlay, 0, false);
        }
    }
}
  1. 錄音

有效示例:


#include <jni.h>
#include <string>
#include "AndroidLog.h"
#include "RecordBuffer.h"


#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>

bool finish = false;
FILE *recodeFile = NULL;


const static int RECORDER_BUFFER_SIZE = 4096;

SLObjectItf engineObject = NULL;
SLEngineItf engineItf = NULL;

SLObjectItf recordObj = NULL;
SLRecordItf recordItf = NULL;
SLAndroidSimpleBufferQueueItf recorderBufferQueue = NULL;

RecordBuffer *recordBuffer = NULL;

// this callback handler is called every time a buffer finishes recording
void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {
    fwrite(recordBuffer->getNowBuffer(), 1, RECORDER_BUFFER_SIZE * sizeof(short), recodeFile);
    if (finish) {
        LOGE("錄制完成");
        //設置停止
        (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_STOPPED);

        fclose(recodeFile);

        //釋放資源
        (*recordObj)->Destroy(recordObj);
        recordObj = NULL;
        recordItf = NULL;
        (*engineObject)->Destroy(engineObject);
        engineObject = NULL;
        engineItf = NULL;
        delete (recordBuffer);

    } else {
        LOGE("正在錄制");
        // 入隊
        (*recorderBufferQueue)->Enqueue(recorderBufferQueue, recordBuffer->getRecordBuffer(),
                                        RECORDER_BUFFER_SIZE * sizeof(short));
    }

}

extern "C"
JNIEXPORT void JNICALL
Java_com_zzw_openslesrecoder_MainActivity_startRecord(JNIEnv *env, jobject instance,
                                                      jstring path_) {

    const char *path = env->GetStringUTFChars(path_, 0);
    finish = false;

    recodeFile = fopen(path, "w+");

    //1. 創(chuàng)建引擎對象
    slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);

    //2. 實現(xiàn)引擎對象
    (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);

    //3. 獲取引擎接口
    (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineItf);



    // configure audio source
    SLDataLocator_IODevice loc_dev = {SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT,
                                      SL_DEFAULTDEVICEID_AUDIOINPUT, NULL};
    SLDataSource audioSrc = {&loc_dev, NULL};

    // configure audio sink
    SLDataLocator_AndroidSimpleBufferQueue loc_bq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};
    SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM, //PCM格式
                                   2,//立體聲
                                   SL_SAMPLINGRATE_44_1,//44100HZ
                                   SL_PCMSAMPLEFORMAT_FIXED_16,//
                                   SL_PCMSAMPLEFORMAT_FIXED_16,
                                   SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT, //左右聲道
                                   SL_BYTEORDER_LITTLEENDIAN};//小尾端
    SLDataSink audioSnk = {&loc_bq, &format_pcm};


    // (requires the RECORD_AUDIO permission)
    const SLInterfaceID id[1] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
    const SLboolean req[1] = {SL_BOOLEAN_TRUE};

    //4. 配置獲取錄音的引擎對象
    (*engineItf)->CreateAudioRecorder(engineItf, &recordObj, &audioSrc,
                                      &audioSnk, 1, id, req);

    //5. 實現(xiàn)錄音的引擎對象
    // realize the audio recorder
    (*recordObj)->Realize(recordObj, SL_BOOLEAN_FALSE);

    //6. 獲取錄音的引擎接口
    //get the record interface
    (*recordObj)->GetInterface(recordObj, SL_IID_RECORD, &recordItf);


    //7. 獲取緩沖隊列接口
    //get the buffer queue interface
    (*recordObj)->GetInterface(recordObj, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
                               &recorderBufferQueue);

    //8. 設置錄音回掉
    (*recorderBufferQueue)->RegisterCallback(recorderBufferQueue, bqRecorderCallback,
                                             NULL);

    recordBuffer = new RecordBuffer(RECORDER_BUFFER_SIZE);
    //9. 入隊
    (*recorderBufferQueue)->Enqueue(recorderBufferQueue, recordBuffer->getRecordBuffer(),
                                    RECORDER_BUFFER_SIZE * sizeof(short));

    //10. 設置狀態(tài)開啟錄音
    (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_RECORDING);
    env->ReleaseStringUTFChars(path_, path);
}




extern "C"
JNIEXPORT void JNICALL
Java_com_zzw_openslesrecoder_MainActivity_stopRecord(JNIEnv *env, jobject instance) {

    finish = true;
}



RecordBuffer.cpp:


#include "RecordBuffer.h"



RecordBuffer::RecordBuffer(int bufferSize) {
    buffer = new short *[2];
    for (int i = 0; i < 2; i++) {
        buffer[i] = new short[bufferSize];
    }
}

short *RecordBuffer::getRecordBuffer() {
    index++;
    if (index > 1) {
        index = 0;
    }
    return buffer[index];
}

RecordBuffer::~RecordBuffer() {
    for (int i = 0; i < 2; i++) {
        delete buffer[i];
    }
    delete buffer;
}

short *RecordBuffer::getNowBuffer() {
    return buffer[index];
}

RecordBuffer.h

class RecordBuffer {

public:
    short **buffer;
    int index = 0;

public:
    RecordBuffer(int bufferSize);
    ~RecordBuffer();

    short *getRecordBuffer();

    short * getNowBuffer();


};

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市叭披,隨后出現(xiàn)的幾起案子寥殖,更是在濱河造成了極大的恐慌,老刑警劉巖涩蜘,帶你破解...
    沈念sama閱讀 218,204評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件嚼贡,死亡現(xiàn)場離奇詭異,居然都是意外死亡同诫,警方通過查閱死者的電腦和手機粤策,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,091評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來误窖,“玉大人叮盘,你說我怎么就攤上這事秩贰。” “怎么了熊户?”我有些...
    開封第一講書人閱讀 164,548評論 0 354
  • 文/不壞的土叔 我叫張陵萍膛,是天一觀的道長。 經(jīng)常有香客問我嚷堡,道長蝗罗,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,657評論 1 293
  • 正文 為了忘掉前任蝌戒,我火速辦了婚禮串塑,結(jié)果婚禮上北苟,老公的妹妹穿的比我還像新娘桩匪。我一直安慰自己,他們只是感情好友鼻,可當我...
    茶點故事閱讀 67,689評論 6 392
  • 文/花漫 我一把揭開白布傻昙。 她就那樣靜靜地躺著,像睡著了一般彩扔。 火紅的嫁衣襯著肌膚如雪妆档。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,554評論 1 305
  • 那天虫碉,我揣著相機與錄音贾惦,去河邊找鬼。 笑死敦捧,一個胖子當著我的面吹牛须板,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播兢卵,決...
    沈念sama閱讀 40,302評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼习瑰,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了秽荤?” 一聲冷哼從身側(cè)響起甜奄,我...
    開封第一講書人閱讀 39,216評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎王滤,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體滓鸠,經(jīng)...
    沈念sama閱讀 45,661評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡雁乡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,851評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了糜俗。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片踱稍。...
    茶點故事閱讀 39,977評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡曲饱,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出珠月,到底是詐尸還是另有隱情扩淀,我是刑警寧澤,帶...
    沈念sama閱讀 35,697評論 5 347
  • 正文 年R本政府宣布啤挎,位于F島的核電站驻谆,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏庆聘。R本人自食惡果不足惜胜臊,卻給世界環(huán)境...
    茶點故事閱讀 41,306評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望伙判。 院中可真熱鬧象对,春花似錦、人聲如沸宴抚。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,898評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽菇曲。三九已至冠绢,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間羊娃,已是汗流浹背唐全。 一陣腳步聲響...
    開封第一講書人閱讀 33,019評論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留蕊玷,地道東北人邮利。 一個月前我還...
    沈念sama閱讀 48,138評論 3 370
  • 正文 我出身青樓,卻偏偏與公主長得像垃帅,于是被迫代替她去往敵國和親延届。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,927評論 2 355

推薦閱讀更多精彩內(nèi)容