Commit 17fa1d38 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Add check on data size coming from the AudioRecord.

Some Android devices trigger the AudioRecord callback with the more data
event but without data... So ignore this event when this happens.
parent 2e0ef7e3
......@@ -277,16 +277,18 @@ static void android_snd_read_cb(int event, void* user, void *p_info){
}
if (event==AudioRecord::EVENT_MORE_DATA){
AudioRecord::Buffer * info=reinterpret_cast<AudioRecord::Buffer*>(p_info);
mblk_t *m=allocb(info->size,0);
memcpy(m->b_wptr,info->raw,info->size);
m->b_wptr+=info->size;
ad->read_samples+=info->frameCount;
ms_mutex_lock(&ad->mutex);
compute_timespec(ad);
putq(&ad->q,m);
ms_mutex_unlock(&ad->mutex);
//ms_message("android_snd_read_cb: got %i bytes",info->size);
if (info->size > 0) {
mblk_t *m=allocb(info->size,0);
memcpy(m->b_wptr,info->raw,info->size);
m->b_wptr+=info->size;
ad->read_samples+=info->frameCount;
ms_mutex_lock(&ad->mutex);
compute_timespec(ad);
putq(&ad->q,m);
ms_mutex_unlock(&ad->mutex);
//ms_message("android_snd_read_cb: got %i bytes",info->size);
}
}else if (event==AudioRecord::EVENT_OVERRUN){
ms_warning("AudioRecord overrun");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment