Hi all,
I follow the audio i/o tutorial (https://developer.tizen.org/dev-guide/2.4/org.tizen.tutorials/html/native/multimedia/audio_io_tutorial_n.htm) to build a real-time audio recording app. However, the callback is called very infrequently for recording the whole sound. For example, when I start the recording for 5 second, the callback actually only gives a 2-second clip (instead of 5).
Here is a dummy testing code which only dumps how many bytes have been recorded:
int _audio_read_total; static void _audio_io_stream_read_cb(audio_in_h handle, size_t nbytes, void *userdata) { const void *buffer = NULL; if (nbytes > 0) { int error_code = audio_in_peek(handle, &buffer, &nbytes); _audio_read_total += nbytes; dlog_print(DLOG_DEBUG, LOG_TAG, "nbytes = %d,_audio_read_total = %d", nbytes, _audio_read_total); error_code = audio_in_drop(handle); // remove audio data from internal buffer } } static void start_audio_recording(appdata_s *ad) { int error_code = audio_in_create(48000, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, &ad->input); error_code = audio_in_set_stream_cb(ad->input, _audio_io_stream_read_cb, ad); error_code = audio_in_prepare(ad->input);}
![](http://i.imgur.com/CMVWiKA.png)
![](http://i.imgur.com/mcICrQC.png)
Attached images include the result of running this code on Galaxy Gear S3. As you can see in the image, the recording callback is called from time 32.3 to time 37.7 (over 5 seconds), but only 224250 bytes are received (it should be (37.7-32.3)*48000*sizeof( short) = 518400). That means only less than 40% of audio is recorded.
Could you give me some suggestion to solve this issue?
Yu-Chih