summaryrefslogtreecommitdiff
path: root/songdbj/org/tritonus/lowlevel/ogg/SyncState.java
diff options
context:
space:
mode:
Diffstat (limited to 'songdbj/org/tritonus/lowlevel/ogg/SyncState.java')
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/SyncState.java127
1 files changed, 127 insertions, 0 deletions
diff --git a/songdbj/org/tritonus/lowlevel/ogg/SyncState.java b/songdbj/org/tritonus/lowlevel/ogg/SyncState.java
new file mode 100644
index 0000000000..3b3b535fbe
--- /dev/null
+++ b/songdbj/org/tritonus/lowlevel/ogg/SyncState.java
@@ -0,0 +1,127 @@
1/*
2 * SyncState.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
29package org.tritonus.lowlevel.ogg;
30
31import org.tritonus.share.TDebug;
32
33
34/** Wrapper for ogg_sync_state.
35 */
36public class SyncState
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 ogg_sync_state
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 SyncState()
58 {
59 if (TDebug.TraceOggNative) { TDebug.out("SyncState.<init>(): begin"); }
60 int nReturn = malloc();
61 if (nReturn < 0)
62 {
63 throw new RuntimeException("malloc of ogg_sync_state failed");
64 }
65 if (TDebug.TraceOggNative) { TDebug.out("SyncState.<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
84 /** Calls ogg_sync_init().
85 */
86 public native void init();
87
88
89 /** Calls ogg_sync_clear().
90 */
91 public native void clear();
92
93
94 /** Calls ogg_sync_reset().
95 */
96 public native void reset();
97
98
99 /** Calls ogg_sync_destroy().
100 */
101 public native void destroy();
102
103
104 /** Calls ogg_sync_buffer()
105 and ogg_sync_wrote().
106 */
107 public native int write(byte[] abBuffer, int nBytes);
108
109
110 /** Calls ogg_sync_pageseek().
111 */
112 public native int pageseek(Page page);
113
114
115 /** Calls ogg_sync_pageout().
116 */
117 public native int pageOut(Page page);
118
119
120 private static native void setTrace(boolean bTrace);
121}
122
123
124
125
126
127/*** SyncState.java ***/