You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2020/12/14 15:30:19 UTC
[incubator-nuttx-apps] branch master updated: system: nxplayer and
nxrecorder shouldn't hardcode message length to 16
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 16c6e1f system: nxplayer and nxrecorder shouldn't hardcode message length to 16
16c6e1f is described below
commit 16c6e1f0b886cf6db5b343e68af45f0adf83278f
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Dec 14 18:13:54 2020 +0800
system: nxplayer and nxrecorder shouldn't hardcode message length to 16
the audio driver may config a very large buffer count,
so let's adjust the message queue length dynamically.
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
system/nxplayer/nxplayer.c | 17 ++++++++++++++---
system/nxrecorder/nxrecorder.c | 17 ++++++++++++++---
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/system/nxplayer/nxplayer.c b/system/nxplayer/nxplayer.c
index 8f74a9a..a959b94 100644
--- a/system/nxplayer/nxplayer.c
+++ b/system/nxplayer/nxplayer.c
@@ -791,12 +791,12 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
audinfo("Entry\n");
- /* Query the audio device for it's preferred buffer size / qty */
+ /* Query the audio device for its preferred buffer size / qty */
if ((ret = ioctl(pplayer->dev_fd, AUDIOIOC_GETBUFFERINFO,
(unsigned long) &buf_info)) != OK)
{
- /* Driver doesn't report it's buffer size. Use our default. */
+ /* Driver doesn't report its buffer size. Use our default. */
buf_info.buffer_size = CONFIG_AUDIO_BUFFER_NUMBYTES;
buf_info.nbuffers = CONFIG_AUDIO_NUM_BUFFERS;
@@ -1797,6 +1797,7 @@ static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
pthread_attr_t tattr;
FAR void *value;
struct audio_caps_desc_s cap_desc;
+ struct ap_buffer_info_s buf_info;
#ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR
char path[128];
#endif
@@ -1932,9 +1933,19 @@ static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
ioctl(pplayer->dev_fd, AUDIOIOC_CONFIGURE, (unsigned long)&cap_desc);
}
+ /* Query the audio device for its preferred buffer count */
+
+ if (ioctl(pplayer->dev_fd, AUDIOIOC_GETBUFFERINFO,
+ (unsigned long)&buf_info) != OK)
+ {
+ /* Driver doesn't report its buffer size. Use our default. */
+
+ buf_info.nbuffers = CONFIG_AUDIO_NUM_BUFFERS;
+ }
+
/* Create a message queue for the playthread */
- attr.mq_maxmsg = 16;
+ attr.mq_maxmsg = buf_info.nbuffers + 8;
attr.mq_msgsize = sizeof(struct audio_msg_s);
attr.mq_curmsgs = 0;
attr.mq_flags = 0;
diff --git a/system/nxrecorder/nxrecorder.c b/system/nxrecorder/nxrecorder.c
index 8f11283..06f29c2 100644
--- a/system/nxrecorder/nxrecorder.c
+++ b/system/nxrecorder/nxrecorder.c
@@ -242,12 +242,12 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
audinfo("Entry\n");
- /* Query the audio device for it's preferred buffer size / qty */
+ /* Query the audio device for its preferred buffer size / qty */
if ((ret = ioctl(precorder->dev_fd, AUDIOIOC_GETBUFFERINFO,
(unsigned long) &buf_info)) != OK)
{
- /* Driver doesn't report it's buffer size. Use our default. */
+ /* Driver doesn't report its buffer size. Use our default. */
buf_info.buffer_size = CONFIG_AUDIO_BUFFER_NUMBYTES;
buf_info.nbuffers = CONFIG_AUDIO_NUM_BUFFERS;
@@ -773,6 +773,7 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
struct sched_param sparam;
pthread_attr_t tattr;
struct audio_caps_desc_s cap_desc;
+ struct ap_buffer_info_s buf_info;
FAR void *value;
int ret;
@@ -844,9 +845,19 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
goto err_out;
}
+ /* Query the audio device for its preferred buffer count */
+
+ if (ioctl(precorder->dev_fd, AUDIOIOC_GETBUFFERINFO,
+ (unsigned long)&buf_info) != OK)
+ {
+ /* Driver doesn't report its buffer size. Use our default. */
+
+ buf_info.nbuffers = CONFIG_AUDIO_NUM_BUFFERS;
+ }
+
/* Create a message queue for the recordthread */
- attr.mq_maxmsg = 16;
+ attr.mq_maxmsg = buf_info.nbuffers + 8;
attr.mq_msgsize = sizeof(struct audio_msg_s);
attr.mq_curmsgs = 0;
attr.mq_flags = 0;