54
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
70
|
3 #include "types.h"
|
54
|
4 #include "DmaBuffer.h"
|
|
5
|
|
6 DmaBuffer::DmaBuffer(int size)
|
|
7 {
|
86
|
8 buffer[0] = malloc(size);
|
|
9 buffer[1] = malloc(size);
|
70
|
10
|
86
|
11 //posix_memalign(&buffer[0], DEFAULT_ALIGNMENT, size);
|
|
12 //posix_memalign(&buffer[1], DEFAULT_ALIGNMENT, size);
|
70
|
13
|
54
|
14 flag = 0;
|
|
15 }
|
|
16
|
|
17 DmaBuffer::~DmaBuffer(void)
|
|
18 {
|
|
19 free(buffer[0]);
|
|
20 free(buffer[1]);
|
|
21 }
|
|
22
|
|
23 void
|
|
24 DmaBuffer::swap_buffer(void)
|
|
25 {
|
|
26 flag ^= 1;
|
|
27 }
|
|
28
|
|
29 void
|
|
30 DmaBuffer::get_buffer(void *_dst)
|
|
31 {
|
|
32 void **dst = (void**)_dst;
|
|
33 *dst = buffer[flag];
|
|
34 }
|