Skip to content

Commit

Permalink
bridge: add dsp_stream_free_buffers()
Browse files Browse the repository at this point in the history
Free a previously allocated stream data buffer.

Used by strmcopy command.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
  • Loading branch information
ceyusa authored and felipec committed Jul 3, 2010
1 parent 6e92030 commit 54c6b6a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
34 changes: 34 additions & 0 deletions dsp_bridge.c
Expand Up @@ -146,6 +146,7 @@
#define STRM_ALLOCATEBUFFER _IOWR(DB, DB_IOC(DB_STRM, 0), unsigned long)
#define STRM_IDLE _IOW(DB, DB_IOC(DB_STRM, 5), unsigned long)
#define STRM_RECLAIM _IOWR(DB, DB_IOC(DB_STRM, 8), unsigned long)
#define STRM_FREEBUFFER _IOWR(DB, DB_IOC(DB_STRM, 2), unsigned long)

int dsp_open(void)
{
Expand Down Expand Up @@ -1149,3 +1150,36 @@ bool dsp_stream_allocate_buffers(int handle,

return true;
}

struct stream_free_buffers {
void *stream;
unsigned char **buff;
unsigned int num_buf;
};

bool dsp_stream_free_buffers(int handle,
void *stream,
unsigned char **buff,
unsigned int num_buf)
{
unsigned int i;
struct stream_info info;
if (!get_stream_info(handle, stream, &info, sizeof(struct stream_info)))
return false;

if (info.segment) {
struct stream_free_buffers arg = {
.stream = stream,
.buff = buff,
.num_buf = num_buf,
};
return DSP_SUCCEEDED(ioctl(handle, STRM_FREEBUFFER, &arg));
}

for (i = 0; i < num_buf; i++) {
free(buff[i]);
buff[i] = NULL;
}

return true;
}
5 changes: 5 additions & 0 deletions dsp_bridge.h
Expand Up @@ -435,4 +435,9 @@ bool dsp_stream_allocate_buffers(int handle,
unsigned char **buff,
unsigned int num_buf);

bool dsp_stream_free_buffers(int handle,
void *stream,
unsigned char **buff,
unsigned int num_buf);

#endif /* DSP_BRIDGE_H */

0 comments on commit 54c6b6a

Please sign in to comment.