29static void fourLetterCode(
int err,
char *cbuf) {
30 cbuf[0] = ((
char*)&err)[3];
31 cbuf[1] = ((
char*)&err)[2];
32 cbuf[2] = ((
char*)&err)[1];
33 cbuf[3] = ((
char*)&err)[0];
42 fprintf (stderr,
"UnsupportedAudioFileException: '%s' %d (%4.4s)\n", message, (
int)err, (
char*)&err);
45 fourLetterCode(err, cbuf);
46 char formattedMessage [strlen(message)+8];
47 snprintf(formattedMessage, strlen(message)+8,
"%s (%4.4s)", message, cbuf);
48 jclass excCls = env->FindClass(
"javax/sound/sampled/UnsupportedAudioFileException");
49 env->ThrowNew(excCls, formattedMessage);
59 fprintf (stderr,
"IOException: '%s' %d (%4.4s)\n", message, (
int)err, (
char*)&err);
62 fourLetterCode(err, cbuf);
63 char formattedMessage [strlen(message)+8];
64 snprintf(formattedMessage, strlen(message)+8,
"%s (%4.4s)", message, cbuf);
65 jclass excCls = env->FindClass(
"java/io/IOException");
66 env->ThrowNew(excCls, formattedMessage);
76 fprintf (stderr,
"IllegalArgumentException: '%s' %d (%4.4s)\n", message, (
int)err, (
char*)&err);
79 fourLetterCode(err, cbuf);
80 char formattedMessage [strlen(message)+8];
81 snprintf(formattedMessage, strlen(message)+8,
"%s (%4.4s)", message, cbuf);
82 jclass excCls = env->FindClass(
"java/lang/IllegalArgumentException");
83 env->ThrowNew(excCls, formattedMessage);
93 jclass excCls = env->FindClass(
"java/io/FileNotFoundException");
94 env->ThrowNew(excCls, message);
102 const jchar *chars = env->GetStringChars(path, NULL);
103 CFStringRef cfPath = CFStringCreateWithCharacters (kCFAllocatorDefault, chars, env->GetStringLength(path));
104 env->ReleaseStringChars(path, chars);
105 urlRef = CFURLCreateWithString(kCFAllocatorDefault, cfPath, NULL);
void throwFileNotFoundExceptionIfError(JNIEnv *env, int err, const char *message)
Throws an IllegalArgumentException.
void throwIllegalArgumentExceptionIfError(JNIEnv *env, int err, const char *message)
Throws an IllegalArgumentException.
void throwUnsupportedAudioFileExceptionIfError(JNIEnv *env, int err, const char *message)
Throws an UnsupportedAudioFileException exception.
void throwIOExceptionIfError(JNIEnv *env, int err, const char *message)
Throws an IOException.
void ca_create_url_ref(JNIEnv *env, jstring path, CFURLRef &urlRef)
Creates a CFURLRef from the given path.