pcm_buffer: move formula to new function align_8k()
This commit is contained in:
parent
f5f1bfbef1
commit
a1e824ada0
@ -19,6 +19,16 @@
|
|||||||
|
|
||||||
#include "pcm_buffer.h"
|
#include "pcm_buffer.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Align the specified size to the next 8k boundary.
|
||||||
|
*/
|
||||||
|
G_GNUC_CONST
|
||||||
|
static size_t
|
||||||
|
align_8k(size_t size)
|
||||||
|
{
|
||||||
|
return ((size - 1) | 0x1fff) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
pcm_buffer_get(struct pcm_buffer *buffer, size_t size)
|
pcm_buffer_get(struct pcm_buffer *buffer, size_t size)
|
||||||
{
|
{
|
||||||
@ -26,8 +36,7 @@ pcm_buffer_get(struct pcm_buffer *buffer, size_t size)
|
|||||||
/* free the old buffer */
|
/* free the old buffer */
|
||||||
g_free(buffer->buffer);
|
g_free(buffer->buffer);
|
||||||
|
|
||||||
/* allocate a new buffer; align at 8 kB boundaries */
|
buffer->size = align_8k(size);
|
||||||
buffer->size = ((size - 1) | 0x1fff) + 1;
|
|
||||||
buffer->buffer = g_malloc(buffer->size);
|
buffer->buffer = g_malloc(buffer->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user