xref: /haiku/src/tests/kits/media/BufferTest.cpp (revision 51978af14a173e7fae0563b562be5603bc652aeb)
1 #include <Application.h>
2 #include <BufferGroup.h>
3 #include <Buffer.h>
4 #include <stdio.h>
5 
6 int main()
7 {
8 	// app_server connection (no need to run it)
9 	BApplication app("application/x-vnd-test");
10 
11 	BBufferGroup * group;
12 	status_t s;
13 	int32 count;
14 	BBuffer *buffer;
15 
16 /*
17 	printf("using default constructor:\n");
18 	group = new BBufferGroup();
19 
20 
21 	s = group->InitCheck();
22 	printf("InitCheck: status = %ld\n",s);
23 
24 	s = group->CountBuffers(&count);
25 	printf("CountBuffers: count = %ld, status = %ld\n",count,s);
26 
27 	delete group;
28 */
29 	printf("\n");
30 	printf("using size = 1234 constructor:\n");
31 	group = new BBufferGroup(1234);
32 
33 	s = group->InitCheck();
34 	printf("InitCheck: status = %ld\n",s);
35 
36 	s = group->CountBuffers(&count);
37 	printf("CountBuffers: count = %ld, status = %ld\n",count,s);
38 
39 	s = group->GetBufferList(1,&buffer);
40 	printf("GetBufferList: status = %ld\n",s);
41 
42 	printf("Buffer->Data:  = %08x\n",(int)buffer->Data());
43 
44 	printf("Buffer->ID:  = %d\n",(int)buffer->ID());
45 
46 	printf("Buffer->Size:  = %ld\n",buffer->Size());
47 
48 	printf("Buffer->SizeAvailable:  = %ld\n",buffer->SizeAvailable());
49 
50 	printf("Buffer->SizeUsed:  = %ld\n",buffer->SizeUsed());
51 
52 	printf("\n");
53 
54 	media_buffer_id id = buffer->ID();
55 	BBufferGroup * group2 = new BBufferGroup(1,&id);
56 	printf("creating second group with a buffer from first group:\n");
57 
58 	s = group2->InitCheck();
59 	printf("InitCheck: status = %ld\n",s);
60 
61 	s = group2->CountBuffers(&count);
62 	printf("CountBuffers: count = %ld, status = %ld\n",count,s);
63 
64 	buffer = 0;
65 	s = group2->GetBufferList(1,&buffer);
66 	printf("GetBufferList: status = %ld\n",s);
67 
68 	printf("Buffer->Data:  = %08x\n",(int)buffer->Data());
69 
70 	printf("Buffer->ID:  = %d\n",(int)buffer->ID());
71 
72 	printf("Buffer->Size:  = %ld\n",buffer->Size());
73 
74 	printf("Buffer->SizeAvailable:  = %ld\n",buffer->SizeAvailable());
75 
76 	printf("Buffer->SizeUsed:  = %ld\n",buffer->SizeUsed());
77 
78 	delete group;
79 	delete group2;
80 
81 	printf("\n");
82 /*
83 	printf("creating a BSmallBuffer:\n");
84 	BSmallBuffer * sb = new BSmallBuffer;
85 
86 	printf("sb->Data:  = %08x\n",(int)sb->Data());
87 
88 	printf("sb->ID:  = %d\n",(int)sb->ID());
89 
90 	printf("sb->Size:  = %ld\n",sb->Size());
91 
92 	printf("sb->SizeAvailable:  = %ld\n",sb->SizeAvailable());
93 
94 	printf("sb->SizeUsed:  = %ld\n",sb->SizeUsed());
95 
96 	printf("sb->SmallBufferSizeLimit:  = %ld\n",sb->SmallBufferSizeLimit());
97 
98 	delete sb;
99 */
100 	return 0;
101 }
102