Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system/nxplayer/nxrecorder: move apb buffer instance to stack #3023

Merged
merged 1 commit into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 11 additions & 31 deletions system/nxplayer/nxplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ static FAR void *nxplayer_playthread(pthread_addr_t pvarg)
bool streaming = true;
bool failed = false;
struct ap_buffer_info_s buf_info;
FAR struct ap_buffer_s **buffers;
unsigned int prio;
#ifdef CONFIG_DEBUG_FEATURES
int outstanding = 0;
Expand All @@ -819,23 +818,11 @@ static FAR void *nxplayer_playthread(pthread_addr_t pvarg)

/* Create array of pointers to buffers */

buffers = (FAR struct ap_buffer_s **)
malloc(buf_info.nbuffers * sizeof(FAR void *));
if (buffers == NULL)
{
/* Error allocating memory for buffer storage! */

ret = -ENOMEM;
running = false;
goto err_out;
}
FAR struct ap_buffer_s *buffers[buf_info.nbuffers];

/* Create our audio pipeline buffers to use for queueing up data */

for (x = 0; x < buf_info.nbuffers; x++)
{
buffers[x] = NULL;
}
memset(buffers, 0, sizeof(buffers));

for (x = 0; x < buf_info.nbuffers; x++)
{
Expand Down Expand Up @@ -1145,27 +1132,20 @@ static FAR void *nxplayer_playthread(pthread_addr_t pvarg)
err_out:
audinfo("Clean-up and exit\n");

if (buffers != NULL)
audinfo("Freeing buffers\n");
for (x = 0; x < buf_info.nbuffers; x++)
{
audinfo("Freeing buffers\n");
for (x = 0; x < buf_info.nbuffers; x++)
{
/* Fill in the buffer descriptor struct to issue a free request */
/* Fill in the buffer descriptor struct to issue a free request */

if (buffers[x] != NULL)
{
if (buffers[x] != NULL)
{
#ifdef CONFIG_AUDIO_MULTI_SESSION
buf_desc.session = pplayer->session;
buf_desc.session = pplayer->session;
#endif
buf_desc.u.buffer = buffers[x];
ioctl(pplayer->dev_fd, AUDIOIOC_FREEBUFFER,
(unsigned long)&buf_desc);
}
buf_desc.u.buffer = buffers[x];
ioctl(pplayer->dev_fd, AUDIOIOC_FREEBUFFER,
(unsigned long)&buf_desc);
}

/* Free the pointers to the buffers */

free(buffers);
}

/* Unregister the message queue and release the session */
Expand Down
43 changes: 11 additions & 32 deletions system/nxrecorder/nxrecorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ static FAR void *nxrecorder_recordthread(pthread_addr_t pvarg)
bool streaming = true;
bool failed = false;
struct ap_buffer_info_s buf_info;
FAR struct ap_buffer_s **pbuffers;
unsigned int prio;
#ifdef CONFIG_DEBUG_FEATURES
int outstanding = 0;
Expand All @@ -551,23 +550,11 @@ static FAR void *nxrecorder_recordthread(pthread_addr_t pvarg)

/* Create array of pointers to buffers */

pbuffers = (FAR struct ap_buffer_s **) malloc(buf_info.nbuffers *
sizeof(FAR void *));
if (pbuffers == NULL)
{
/* Error allocating memory for buffer storage! */

ret = -ENOMEM;
running = false;
goto err_out;
}
FAR struct ap_buffer_s *pbuffers[buf_info.nbuffers];

/* Create our audio pipeline buffers to use for queueing up data */

for (x = 0; x < buf_info.nbuffers; x++)
{
pbuffers[x] = NULL;
}
memset(pbuffers, 0, sizeof(pbuffers));

for (x = 0; x < buf_info.nbuffers; x++)
{
Expand Down Expand Up @@ -820,28 +807,20 @@ static FAR void *nxrecorder_recordthread(pthread_addr_t pvarg)
err_out:
audinfo("Clean-up and exit\n");

if (pbuffers != NULL)
audinfo("Freeing buffers\n");
for (x = 0; x < buf_info.nbuffers; x++)
{
audinfo("Freeing buffers\n");
for (x = 0; x < buf_info.nbuffers; x++)
{
/* Fill in the buffer descriptor struct to issue a free request */
/* Fill in the buffer descriptor struct to issue a free request */

if (pbuffers[x] != NULL)
{
if (pbuffers[x] != NULL)
{
#ifdef CONFIG_AUDIO_MULTI_SESSION
buf_desc.session = precorder->session;
buf_desc.session = precorder->session;
#endif
buf_desc.u.buffer = pbuffers[x];
ioctl(precorder->dev_fd,
AUDIOIOC_FREEBUFFER,
(uintptr_t)&buf_desc);
}
buf_desc.u.buffer = pbuffers[x];
ioctl(precorder->dev_fd, AUDIOIOC_FREEBUFFER,
(uintptr_t)&buf_desc);
}

/* Free the pointers to the buffers */

free(pbuffers);
}

/* Unregister the message queue and release the session */
Expand Down
Loading