Switch to new logging API.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@510 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Michael Bayne
2008-05-27 22:55:10 +00:00
parent b521b4bfbf
commit e00b4ddd6b
108 changed files with 497 additions and 605 deletions
@@ -29,6 +29,8 @@ import org.lwjgl.openal.AL10;
import com.samskivert.util.ObserverList;
import static com.threerings.openal.Log.log;
/**
* Represents a sound that has been loaded into the OpenAL system.
*/
@@ -154,7 +156,7 @@ public class ClipBuffer
AL10.alGenBuffers(_bufferId);
int errno = AL10.alGetError();
if (errno != AL10.AL_NO_ERROR) {
Log.warning("Failed to create buffer [key=" + getKey() +
log.warning("Failed to create buffer [key=" + getKey() +
", errno=" + errno + "].");
_bufferId = null;
// queue up a failure notification so that we properly return
@@ -211,7 +213,7 @@ public class ClipBuffer
_bufferId.get(0), clip.format, clip.data, clip.frequency);
int errno = AL10.alGetError();
if (errno != AL10.AL_NO_ERROR) {
Log.warning("Failed to bind clip [key=" + getKey() +
log.warning("Failed to bind clip [key=" + getKey() +
", errno=" + errno + "].");
failed();
return false;
+4 -28
View File
@@ -21,36 +21,12 @@
package com.threerings.openal;
import com.samskivert.util.Logger;
/**
* A placeholder class that contains a reference to the log object used by
* this package.
* Contains a reference to the log object used by this package.
*/
public class Log
{
public static com.samskivert.util.Log log =
new com.samskivert.util.Log("narya.openal");
/** Convenience function. */
public static void debug (String message)
{
log.debug(message);
}
/** Convenience function. */
public static void info (String message)
{
log.info(message);
}
/** Convenience function. */
public static void warning (String message)
{
log.warning(message);
}
/** Convenience function. */
public static void logStackTrace (Throwable t)
{
log.logStackTrace(com.samskivert.util.Log.WARNING, t);
}
public static Logger log = Logger.getLogger("com.threerings.openal");
}
@@ -27,6 +27,8 @@ import java.util.ArrayList;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL10;
import static com.threerings.openal.Log.log;
/**
* Manages a group of sounds, binding them to OpenAL sources as they are
* played and freeing up those sources for use by other sounds when the
@@ -107,7 +109,7 @@ public class SoundGroup
AL10.alGenSources(_sourceIds);
int errno = AL10.alGetError();
if (errno != AL10.AL_NO_ERROR) {
Log.warning("Failed to create sources [cprov=" + provider +
log.warning("Failed to create sources [cprov=" + provider +
", sources=" + sources + ", errno=" + errno + "].");
_sourceIds = null;
// we'll have no sources which means all requests to play
@@ -33,6 +33,8 @@ import com.samskivert.util.LRUHashMap;
import com.samskivert.util.Queue;
import com.samskivert.util.RunQueue;
import static com.threerings.openal.Log.log;
/**
* An interface to the OpenAL library that provides a number of additional services:
*
@@ -155,15 +157,14 @@ public class SoundManager
try {
AL.create("", 44100, 15, false);
} catch (Exception e) {
Log.warning("Failed to initialize sound system.");
Log.logStackTrace(e);
log.warning("Failed to initialize sound system.", e);
// don't start the background loading thread
return;
}
int errno = AL10.alGetError();
if (errno != AL10.AL_NO_ERROR) {
Log.warning("Failed to initialize sound system [errno=" + errno + "].");
log.warning("Failed to initialize sound system [errno=" + errno + "].");
// don't start the background loading thread
return;
}
@@ -174,7 +175,7 @@ public class SoundManager
final ClipBuffer item) {
_rqueue.postRunnable(new Runnable() {
public void run () {
Log.debug("Flushing " + item.getKey());
log.debug("Flushing " + item.getKey());
item.dispose();
}
});
@@ -211,8 +212,7 @@ public class SoundManager
return buffer;
} catch (Throwable t) {
Log.warning("Failure resolving buffer [key=" + ckey + "].");
Log.logStackTrace(t);
log.warning("Failure resolving buffer [key=" + ckey + "].", t);
return null;
}
}
@@ -275,12 +275,12 @@ public class SoundManager
while (true) {
final ClipBuffer buffer = (ClipBuffer)_toLoad.get();
try {
Log.debug("Loading " + buffer.getKey() + ".");
log.debug("Loading " + buffer.getKey() + ".");
final Clip clip = buffer.load();
_rqueue.postRunnable(new Runnable() {
public void run () {
Comparable ckey = buffer.getKey();
Log.debug("Loaded " + ckey + ".");
log.debug("Loaded " + ckey + ".");
_loading.remove(ckey);
if (buffer.bind(clip)) {
_clips.put(ckey, buffer);
@@ -292,8 +292,7 @@ public class SoundManager
});
} catch (Throwable t) {
Log.warning("Failed to load clip [key=" + buffer.getKey() + "].");
Log.logStackTrace(t);
log.warning("Failed to load clip [key=" + buffer.getKey() + "].", t);
// let the clip and its observers know that we are a miserable failure
queueClipFailure(buffer);
+6 -4
View File
@@ -30,6 +30,8 @@ import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL10;
import static com.threerings.openal.Log.log;
/**
* Represents a streaming source of sound data.
*/
@@ -91,7 +93,7 @@ public abstract class Stream
public void play ()
{
if (_state == AL10.AL_PLAYING) {
Log.warning("Tried to play stream already playing.");
log.warning("Tried to play stream already playing.");
return;
}
if (_state == AL10.AL_INITIAL) {
@@ -108,7 +110,7 @@ public abstract class Stream
public void pause ()
{
if (_state != AL10.AL_PLAYING) {
Log.warning("Tried to pause stream that wasn't playing.");
log.warning("Tried to pause stream that wasn't playing.");
return;
}
AL10.alSourcePause(_sourceId);
@@ -121,7 +123,7 @@ public abstract class Stream
public void stop ()
{
if (_state == AL10.AL_STOPPED) {
Log.warning("Tried to stop stream that was already stopped.");
log.warning("Tried to stop stream that was already stopped.");
return;
}
AL10.alSourceStop(_sourceId);
@@ -271,7 +273,7 @@ public abstract class Stream
try {
read = Math.max(populateBuffer(_abuf), 0);
} catch (IOException e) {
Log.warning("Error reading audio stream [error=" + e + "].");
log.warning("Error reading audio stream [error=" + e + "].");
}
if (read <= 0) {
return false;
@@ -30,6 +30,8 @@ import java.io.InputStream;
import java.nio.ByteBuffer;
import static com.threerings.openal.Log.log;
/**
* Decodes audio streams from data read from an {@link InputStream}.
*/
@@ -52,13 +54,13 @@ public abstract class StreamDecoder
String path = file.getPath();
int idx = path.lastIndexOf('.');
if (idx == -1) {
Log.warning("Missing extension for file [file=" + path + "].");
log.warning("Missing extension for file [file=" + path + "].");
return null;
}
String extension = path.substring(idx+1);
Class clazz = _extensions.get(extension);
if (clazz == null) {
Log.warning("No decoder registered for extension [extension=" + extension +
log.warning("No decoder registered for extension [extension=" + extension +
", file=" + path + "].");
return null;
}
@@ -66,7 +68,7 @@ public abstract class StreamDecoder
try {
decoder = (StreamDecoder)clazz.newInstance();
} catch (Exception e) {
Log.warning("Error instantiating decoder [file=" + path + ", error=" + e + "].");
log.warning("Error instantiating decoder [file=" + path + ", error=" + e + "].");
return null;
}
decoder.init(new FileInputStream(file));