You Are Here:

Community: Developer Discussion Boards

#1 Old media intensive app - Hell Bug.(s60- 3650) - 2005-04-21, 04:27

Join Date: Apr 2005
Posts: 1
EridanMan
Offline
Registered User
I have a media intensive app (game), and am currently in the throws of a truly hellish bug.

I seem to have an extremely sporadic sound bug... every few dozen games, an IllegalStateException is sneaking out uncaught.

The problem is, the game works fine a great majority of the time, there is no rhyme or reason to the exception (save that it always occurs on a loadSound or playSound), and I think I've caught every possible place an IllegalStateException could be thrown.

I don't mind if audio drops here or there, I just need it to not crash.

The media is a combination of Wav's and midi's, several of them are time-critical (item pickups, etc). Because of this, I have a mediahandler than spawns a threads on media requests, and then runs a synchronized interface to this class, which physically loads and plays the media.

This works great on every other platform/handset I've tried it on.

Code Below:

public void loadSound(int s) {

try {

if ((loaded != s && !isPlaying) || forceLoad) {
forceLoad = false;

// if sound playing/running, stop and kill it
if (loaded != NONE) {
stopSound(false);
killSound(loaded);
}

//System.out.print("Attempting to Load: " + soundFiles[s] + ": ");
InputStream is = getClass().getResourceAsStream(soundFiles[s]);

try {
//#ifdef wav
if (soundFiles[s].endsWith("wav")) {
//System.out.print("WAV, ");
player = Manager.createPlayer(is, "audio/x-wav");

} else
//#endif
if (soundFiles[s].endsWith("mid")) {
//System.out.print("MID, ");
player = Manager.createPlayer(is, "audio/midi");
} else {
//System.out.print("UNKNOWN TYPE: ");
}

boolean success = false;


player.realize();
player.prefetch();
player.addPlayerListener(this);
} catch (IllegalStateException e) {
//ignore
} finally {
is.close();
}

loaded = s;

}
} catch (Exception real) {
//PacBowlMIDlet.output.append(soundFiles[s] + "(LOAD: "+real+")");
}
}

public void playSound(int s) {
try {

if (loaded != s) {
forceLoad = true;
loadSound(s);
} else {
if (isPlaying) stopSound(false);
//System.out.println("PreCached: SUCCESS");
}

if (player.getState() == Player.PREFETCHED) {
try {
player.start();
} catch (IllegalStateException e) {
// IGNORE
}
isPlaying = true;
}

} catch (Exception e) {
//System.out.println(IMP_NAME+"SndPlay: " + e);
}
}

public void killSound(int s) {

try {
if (player != null) {
stopSound(true);
try {
player.close();
} catch (IllegalStateException E) {
// IGNORE
}
player = null;
System.gc();
loaded = NONE;
}
} catch (Exception e) {
//System.out.println(IMP_NAME+"SndKill: " + e);
}

}

public boolean isPlaying() {

return isPlaying;

}


public void stopSound(boolean force) {

try {
if (player != null) {
if (player.getState() == Player.STARTED) {
isPlaying = false;
try {
player.stop();
} catch (IllegalStateException e) {
}
}
}
} catch (Exception e) {
//System.out.println(IMP_NAME+"SndStop: " + e);
}
System.gc();
}

public void playerUpdate(Player p, String event, Object data) {
synchronized (this) {
try {
if (event == PlayerListener.END_OF_MEDIA) {
stopSound(false);
}
} catch (Exception e) {
//System.out.println(IMP_NAME+"SndUpdt: " + e);
}
}
}

any and all suggestions would be greatly appreciated, thanks!

edit: clarification: my media handler class works great, obviously this particular media interface is nokia specific. Unfortunatley, the only handset I have available to test is the 3650. It works great on the emulator, however.;

-Scott
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ