언어 설정

Menu
Sites
Language
How to drop audio input data in synchronized mode on wearable device

I am writing an app which recogized specific voice type, which needs to be real-time responsing. I am using the audio input api in wearable device based on 2.3.1 sdk. 
I want to check the audio every 0.3s, if it detects something useful, then it record the PCM audio  and stop, or it will keep detecting.
the pseudo code looks like this:

#include <audio_io>
audio_in_h input;
audio_in_create(SAMPLE_RATE, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, &input);
ecore_thread_run(synchronous_recording, NULL, NULL, NULL);
void synchronous_recording(void *data, Ecore_Thread *thread)
{
    audio_in_prepare(input);
    bool captured = false;
    while(captured == false){
        audio_in_read(input, buffer, buffer_size);
        check the buffer , if the data satisfied some constraint then set captured to true
    }
    audio_in_unprepare(input);
}
audio_in_destroy(&input);

If i need to keep looping , i think i need to drop that previous data before the next loop like in the asynchronized mode "audio_in_peek/audio_in_drop".
But i just could find a function like audio_in_drop.
Unlike the sdk 2.4.0 of the mobile version, it has an api like "audio_in_flush" which could do that cleaning-previous-buffer jobs.
So what should i do ?

Responses

1 댓글
Mehedi Alamgir

Hi Qian

Previously i also searched buffer flush API for Tizen 2.3.1 but i didn't find any Tizen 2.3.1 API to clear buffer data like "audio_in_flush" in Tizen 2.4. As you stop after recording the audio, you can release the memory allocated to buffer using free() function. For reference please check the following link

https://developer.tizen.org/development/tutorials/native-application/multimedia/audio-io#simple