diff options
Diffstat (limited to 'songdbj/org/tritonus/lowlevel/ogg/Buffer.java')
-rw-r--r-- | songdbj/org/tritonus/lowlevel/ogg/Buffer.java | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/songdbj/org/tritonus/lowlevel/ogg/Buffer.java b/songdbj/org/tritonus/lowlevel/ogg/Buffer.java new file mode 100644 index 0000000000..2903f0e17e --- /dev/null +++ b/songdbj/org/tritonus/lowlevel/ogg/Buffer.java | |||
@@ -0,0 +1,173 @@ | |||
1 | /* | ||
2 | * Buffer.java | ||
3 | * | ||
4 | * This file is part of Tritonus: http://www.tritonus.org/ | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * Copyright (c) 2000 - 2001 by Matthias Pfisterer | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU Library General Public License as published | ||
12 | * by the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU Library General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU Library General Public | ||
21 | * License along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | /* | ||
26 | |<--- this code is formatted to fit into 80 columns --->| | ||
27 | */ | ||
28 | |||
29 | package org.tritonus.lowlevel.ogg; | ||
30 | |||
31 | import org.tritonus.share.TDebug; | ||
32 | |||
33 | |||
34 | /** Wrapper for oggpack_buffer. | ||
35 | */ | ||
36 | public class Buffer | ||
37 | { | ||
38 | static | ||
39 | { | ||
40 | Ogg.loadNativeLibrary(); | ||
41 | if (TDebug.TraceOggNative) | ||
42 | { | ||
43 | setTrace(true); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | |||
48 | /** | ||
49 | * Holds the pointer to oggpack_buffer | ||
50 | * for the native code. | ||
51 | * This must be long to be 64bit-clean. | ||
52 | */ | ||
53 | private long m_lNativeHandle; | ||
54 | |||
55 | |||
56 | |||
57 | public Buffer() | ||
58 | { | ||
59 | if (TDebug.TraceOggNative) { TDebug.out("Buffer.<init>(): begin"); } | ||
60 | int nReturn = malloc(); | ||
61 | if (nReturn < 0) | ||
62 | { | ||
63 | throw new RuntimeException("malloc of ogg_page failed"); | ||
64 | } | ||
65 | if (TDebug.TraceOggNative) { TDebug.out("Buffer.<init>(): end"); } | ||
66 | } | ||
67 | |||
68 | |||
69 | |||
70 | public void finalize() | ||
71 | { | ||
72 | // TODO: call free() | ||
73 | // call super.finalize() first or last? | ||
74 | // and introduce a flag if free() has already been called? | ||
75 | } | ||
76 | |||
77 | |||
78 | |||
79 | private native int malloc(); | ||
80 | public native void free(); | ||
81 | |||
82 | |||
83 | /** Calls oggpack_writeinit(). | ||
84 | */ | ||
85 | public native void writeInit(); | ||
86 | |||
87 | |||
88 | /** Calls oggpack_writetrunc(). | ||
89 | */ | ||
90 | public native void writeTrunc(int nBits); | ||
91 | |||
92 | |||
93 | /** Calls oggpack_writealign(). | ||
94 | */ | ||
95 | public native void writeAlign(); | ||
96 | |||
97 | |||
98 | /** Calls oggpack_writecopy(). | ||
99 | */ | ||
100 | public native void writeCopy(byte[] abSource, int nBits); | ||
101 | |||
102 | |||
103 | /** Calls oggpack_reset(). | ||
104 | */ | ||
105 | public native void reset(); | ||
106 | |||
107 | |||
108 | /** Calls oggpack_writeclear(). | ||
109 | */ | ||
110 | public native void writeClear(); | ||
111 | |||
112 | |||
113 | /** Calls oggpack_readinit(). | ||
114 | */ | ||
115 | public native void readInit(byte[] abBuffer, int nBytes); | ||
116 | |||
117 | |||
118 | /** Calls oggpack_write(). | ||
119 | */ | ||
120 | public native void write(int nValue, int nBits); | ||
121 | |||
122 | |||
123 | /** Calls oggpack_look(). | ||
124 | */ | ||
125 | public native int look(int nBits); | ||
126 | |||
127 | |||
128 | /** Calls oggpack_look1(). | ||
129 | */ | ||
130 | public native int look1(); | ||
131 | |||
132 | |||
133 | /** Calls oggpack_adv(). | ||
134 | */ | ||
135 | public native void adv(int nBits); | ||
136 | |||
137 | |||
138 | /** Calls oggpack_adv1(). | ||
139 | */ | ||
140 | public native void adv1(); | ||
141 | |||
142 | |||
143 | /** Calls oggpack_read(). | ||
144 | */ | ||
145 | public native int read(int nBits); | ||
146 | |||
147 | |||
148 | /** Calls oggpack_read1(). | ||
149 | */ | ||
150 | public native int read1(); | ||
151 | |||
152 | |||
153 | /** Calls oggpack_bytes(). | ||
154 | */ | ||
155 | public native int bytes(); | ||
156 | |||
157 | |||
158 | /** Calls oggpack_bits(). | ||
159 | */ | ||
160 | public native int bits(); | ||
161 | |||
162 | |||
163 | /** Calls oggpack_get_buffer(). | ||
164 | */ | ||
165 | public native byte[] getBuffer(); | ||
166 | |||
167 | |||
168 | private static native void setTrace(boolean bTrace); | ||
169 | } | ||
170 | |||
171 | |||
172 | |||
173 | /*** Buffer.java ***/ | ||