You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/28 15:07:15 UTC
[GitHub] [incubator-nuttx-apps] GUIDINGLI opened a new pull request #1101: nxlooper: support different period size of player & recorder
GUIDINGLI opened a new pull request #1101:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1101
## Summary
nxlooper: support different period size of player & recorder
## Impact
nxlooper
## Testing
VELA
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] pkarashchenko commented on a change in pull request #1101: nxlooper: support different period size of player & recorder
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #1101:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1101#discussion_r837376433
##########
File path: system/nxlooper/nxlooper.c
##########
@@ -502,33 +506,51 @@ static void *nxlooper_loopthread(pthread_addr_t pvarg)
dq_addlast(&apb->dq_entry, &recorddq);
}
- if (dq_count(&playdq) != 0 && dq_count(&recorddq) != 0)
+ if (dq_count(&playdq) != 0 && dq_count(&recorddq) != 0)
{
- apbtemp = (struct ap_buffer_s *)dq_remfirst(&recorddq);
- apb = (struct ap_buffer_s *)dq_remfirst(&playdq);
-
- apb->nbytes = apbtemp->nbytes;
- memcpy(apb->samp, apbtemp->samp, apbtemp->nbytes);
-
- ret = nxlooper_enqueuerecordbuffer(plooper, apbtemp);
- if (ret == OK)
- {
- ret = nxlooper_enqueueplaybuffer(plooper, apb);
- if (ret == OK &&
- plooper->loopstate == NXLOOPER_STATE_RECORDING)
- {
-#ifdef CONFIG_AUDIO_MULTI_SESSION
- ret = ioctl(plooper->playdev_fd, AUDIOIOC_START,
- (unsigned long)plooper->pplayses);
+ FAR struct ap_buffer_s *apbrec;
+ int copy;
Review comment:
```suggestion
uint32_t copy;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 merged pull request #1101: nxlooper: support different period size of player & recorder
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #1101:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1101
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] pkarashchenko commented on a change in pull request #1101: nxlooper: support different period size of player & recorder
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #1101:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1101#discussion_r836731682
##########
File path: system/nxlooper/nxlooper.c
##########
@@ -502,33 +506,50 @@ static void *nxlooper_loopthread(pthread_addr_t pvarg)
dq_addlast(&apb->dq_entry, &recorddq);
}
- if (dq_count(&playdq) != 0 && dq_count(&recorddq) != 0)
+ if (dq_count(&playdq) != 0 && dq_count(&recorddq) != 0)
{
- apbtemp = (struct ap_buffer_s *)dq_remfirst(&recorddq);
- apb = (struct ap_buffer_s *)dq_remfirst(&playdq);
-
- apb->nbytes = apbtemp->nbytes;
- memcpy(apb->samp, apbtemp->samp, apbtemp->nbytes);
-
- ret = nxlooper_enqueuerecordbuffer(plooper, apbtemp);
- if (ret == OK)
- {
- ret = nxlooper_enqueueplaybuffer(plooper, apb);
- if (ret == OK &&
- plooper->loopstate == NXLOOPER_STATE_RECORDING)
- {
-#ifdef CONFIG_AUDIO_MULTI_SESSION
- ret = ioctl(plooper->playdev_fd, AUDIOIOC_START,
- (unsigned long)plooper->pplayses);
+ FAR struct ap_buffer_s *apbrec;
+ int copy;
+
+ apbrec = (struct ap_buffer_s *)dq_peek(&recorddq);
+ apb = (struct ap_buffer_s *)dq_peek(&playdq);
+
+ copy = MIN(apbrec->nbytes - apbrec->curbyte,
+ apb->nmaxbytes - apb->curbyte);
+
+ memcpy(apb->samp + apb->curbyte,
+ apbrec->samp + apbrec->curbyte, copy);
+ apbrec->curbyte += copy;
+ apb->curbyte += copy;
+
+ if (apbrec->curbyte == apbrec->nbytes)
+ {
+ apbrec = (struct ap_buffer_s *)dq_remfirst(&recorddq);
+ apbrec->curbyte = 0;
+ ret = nxlooper_enqueuerecordbuffer(plooper, apbrec);
+ }
+
+ if (ret == OK && apb->curbyte == apb->nmaxbytes)
+ {
+ apb = (struct ap_buffer_s *)dq_remfirst(&playdq);
Review comment:
```suggestion
apb = (FAR struct ap_buffer_s *)dq_remfirst(&playdq);
```
##########
File path: system/nxlooper/nxlooper.c
##########
@@ -502,33 +506,50 @@ static void *nxlooper_loopthread(pthread_addr_t pvarg)
dq_addlast(&apb->dq_entry, &recorddq);
}
- if (dq_count(&playdq) != 0 && dq_count(&recorddq) != 0)
+ if (dq_count(&playdq) != 0 && dq_count(&recorddq) != 0)
{
- apbtemp = (struct ap_buffer_s *)dq_remfirst(&recorddq);
- apb = (struct ap_buffer_s *)dq_remfirst(&playdq);
-
- apb->nbytes = apbtemp->nbytes;
- memcpy(apb->samp, apbtemp->samp, apbtemp->nbytes);
-
- ret = nxlooper_enqueuerecordbuffer(plooper, apbtemp);
- if (ret == OK)
- {
- ret = nxlooper_enqueueplaybuffer(plooper, apb);
- if (ret == OK &&
- plooper->loopstate == NXLOOPER_STATE_RECORDING)
- {
-#ifdef CONFIG_AUDIO_MULTI_SESSION
- ret = ioctl(plooper->playdev_fd, AUDIOIOC_START,
- (unsigned long)plooper->pplayses);
+ FAR struct ap_buffer_s *apbrec;
+ int copy;
+
+ apbrec = (struct ap_buffer_s *)dq_peek(&recorddq);
+ apb = (struct ap_buffer_s *)dq_peek(&playdq);
+
+ copy = MIN(apbrec->nbytes - apbrec->curbyte,
+ apb->nmaxbytes - apb->curbyte);
+
+ memcpy(apb->samp + apb->curbyte,
+ apbrec->samp + apbrec->curbyte, copy);
+ apbrec->curbyte += copy;
+ apb->curbyte += copy;
+
+ if (apbrec->curbyte == apbrec->nbytes)
+ {
+ apbrec = (struct ap_buffer_s *)dq_remfirst(&recorddq);
Review comment:
```suggestion
apbrec = (FAR struct ap_buffer_s *)dq_remfirst(&recorddq);
```
##########
File path: system/nxlooper/nxlooper.c
##########
@@ -502,33 +506,50 @@ static void *nxlooper_loopthread(pthread_addr_t pvarg)
dq_addlast(&apb->dq_entry, &recorddq);
}
- if (dq_count(&playdq) != 0 && dq_count(&recorddq) != 0)
+ if (dq_count(&playdq) != 0 && dq_count(&recorddq) != 0)
{
- apbtemp = (struct ap_buffer_s *)dq_remfirst(&recorddq);
- apb = (struct ap_buffer_s *)dq_remfirst(&playdq);
-
- apb->nbytes = apbtemp->nbytes;
- memcpy(apb->samp, apbtemp->samp, apbtemp->nbytes);
-
- ret = nxlooper_enqueuerecordbuffer(plooper, apbtemp);
- if (ret == OK)
- {
- ret = nxlooper_enqueueplaybuffer(plooper, apb);
- if (ret == OK &&
- plooper->loopstate == NXLOOPER_STATE_RECORDING)
- {
-#ifdef CONFIG_AUDIO_MULTI_SESSION
- ret = ioctl(plooper->playdev_fd, AUDIOIOC_START,
- (unsigned long)plooper->pplayses);
+ FAR struct ap_buffer_s *apbrec;
+ int copy;
+
+ apbrec = (struct ap_buffer_s *)dq_peek(&recorddq);
+ apb = (struct ap_buffer_s *)dq_peek(&playdq);
Review comment:
```suggestion
apbrec = (FAR struct ap_buffer_s *)dq_peek(&recorddq);
apb = (FAR struct ap_buffer_s *)dq_peek(&playdq);
```
##########
File path: system/nxlooper/nxlooper.c
##########
@@ -502,33 +506,50 @@ static void *nxlooper_loopthread(pthread_addr_t pvarg)
dq_addlast(&apb->dq_entry, &recorddq);
}
- if (dq_count(&playdq) != 0 && dq_count(&recorddq) != 0)
+ if (dq_count(&playdq) != 0 && dq_count(&recorddq) != 0)
{
- apbtemp = (struct ap_buffer_s *)dq_remfirst(&recorddq);
- apb = (struct ap_buffer_s *)dq_remfirst(&playdq);
-
- apb->nbytes = apbtemp->nbytes;
- memcpy(apb->samp, apbtemp->samp, apbtemp->nbytes);
-
- ret = nxlooper_enqueuerecordbuffer(plooper, apbtemp);
- if (ret == OK)
- {
- ret = nxlooper_enqueueplaybuffer(plooper, apb);
- if (ret == OK &&
- plooper->loopstate == NXLOOPER_STATE_RECORDING)
- {
-#ifdef CONFIG_AUDIO_MULTI_SESSION
- ret = ioctl(plooper->playdev_fd, AUDIOIOC_START,
- (unsigned long)plooper->pplayses);
+ FAR struct ap_buffer_s *apbrec;
+ int copy;
+
+ apbrec = (struct ap_buffer_s *)dq_peek(&recorddq);
+ apb = (struct ap_buffer_s *)dq_peek(&playdq);
+
+ copy = MIN(apbrec->nbytes - apbrec->curbyte,
+ apb->nmaxbytes - apb->curbyte);
+
+ memcpy(apb->samp + apb->curbyte,
+ apbrec->samp + apbrec->curbyte, copy);
+ apbrec->curbyte += copy;
+ apb->curbyte += copy;
+
+ if (apbrec->curbyte == apbrec->nbytes)
+ {
+ apbrec = (struct ap_buffer_s *)dq_remfirst(&recorddq);
+ apbrec->curbyte = 0;
+ ret = nxlooper_enqueuerecordbuffer(plooper, apbrec);
+ }
+
+ if (ret == OK && apb->curbyte == apb->nmaxbytes)
+ {
+ apb = (struct ap_buffer_s *)dq_remfirst(&playdq);
+ apb->nbytes = apb->nmaxbytes;
+ apb->curbyte = 0;
+ ret = nxlooper_enqueueplaybuffer(plooper, apb);
+ }
+ }
+
+ if (ret == OK && plooper->loopstate == NXLOOPER_STATE_RECORDING)
+ {
+#ifdef CONFIG_O_MULTI_SESSION
+ ret = ioctl(plooper->playdev_fd, AUDIOIOC_START,
+ (unsigned long)plooper->pplayses);
Review comment:
```suggestion
ret = ioctl(plooper->playdev_fd, AUDIOIOC_START,
(unsigned long)plooper->pplayses);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org