From: Kishore SN Date: Wed, 13 Sep 2017 06:01:34 +0000 (+0530) Subject: Fix tinyalsa issues during testing X-Git-Tag: 1.1_Public_Release~188^2~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b4a19d91a9cb4adb746e5ba64209c3a0a4dcc52;p=rtos%2Ftinyara.git Fix tinyalsa issues during testing Set apb flags, nbytes, curbyte before enque --- diff --git a/framework/src/tinyalsa/tinyalsa.c b/framework/src/tinyalsa/tinyalsa.c index b5bb211..3afb4ec 100644 --- a/framework/src/tinyalsa/tinyalsa.c +++ b/framework/src/tinyalsa/tinyalsa.c @@ -480,6 +480,9 @@ int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count) #ifdef CONFIG_AUDIO_MULTI_SESSION bufdesc.session = pcm->session; #endif + apb->nbytes = nbytes; + apb->curbyte = 0; + apb->flags = 0; bufdesc.numbytes = apb->nbytes; bufdesc.u.pBuffer = apb; if (ioctl(pcm->fd, AUDIOIOC_ENQUEUEBUFFER, (unsigned long)&bufdesc) < 0) { @@ -559,6 +562,10 @@ int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count) /* Copy data to user buffer */ memcpy(data, apb->samp, apb->nbytes); /* Enque buffer for next read opertion */ + nbytes = apb->nbytes; + apb->nbytes = 0; + apb->curbyte = 0; + apb->flags = 0; bufdesc.u.pBuffer = apb; if (ioctl(pcm->fd, AUDIOIOC_ENQUEUEBUFFER, (unsigned long)&bufdesc) < 0) { return oops(pcm, errno, "failed to enque buffer after read"); @@ -567,7 +574,7 @@ int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count) return oops(pcm, EINTR, "Recieved unexpected msg (id = %d) while waiting for deque message from kernel", msg.msgId); } - return pcm_bytes_to_frames(pcm, apb->nbytes); + return pcm_bytes_to_frames(pcm, nbytes); } /** Writes audio samples to PCM. @@ -1056,6 +1063,7 @@ int pcm_prepare(struct pcm *pcm) int pcm_start(struct pcm *pcm) { struct audio_buf_desc_s bufdesc; + struct ap_buffer_s *apb; if (pcm == NULL) { return -EINVAL; @@ -1078,7 +1086,11 @@ int pcm_start(struct pcm *pcm) for (pcm->bufPtr = 0; pcm->bufPtr < CONFIG_AUDIO_NUM_BUFFERS; pcm->bufPtr++) #endif { - bufdesc.u.pBuffer = pcm->pBuffers[pcm->bufPtr]; + apb = pcm->pBuffers[pcm->bufPtr]; + apb->nbytes = 0; + apb->curbyte = 0; + apb->flags = 0; + bufdesc.u.pBuffer = apb; if (ioctl(pcm->fd, AUDIOIOC_ENQUEUEBUFFER, (unsigned long)&bufdesc) < 0) { return oops(pcm, errno, "AUDIOIOC_ENQUEUEBUFFER ioctl failed"); }