Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (517)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Cleanup with AudioSystem3D  (Read 3057 times)
0 Members and 1 Guest are viewing this topic.
Offline Conzar

Junior Duke




There is nothing common about common sense


« Posted 2007-03-25 03:39:24 »

Hello,
  I was wondering what the necessary steps are for shutting down the audio engine if the AudioSystem3D object is used (instead of the traditional OpenAL way of doing things - c-style like).

When I start up the engine, I do this
1  
2  
3  
4  
5  
6  
7  
AudioSystem3D.init()
dev = AudioSystem3D.openDevice(null);
ctx = AudioSystem3D.createContext(dev);
AudioSystem3D.makeContextCurrent(ctx);

// later on I do this to create buffers
Buffer buffer = AudioSystem3D.loadBuffer("filename");


I see several methods in the API that I could potentially use such as
1  
2  
3  
ctx.destroy();
dev.close();
ALut.alutExit();


Just not sure what to do.

Thanks for your help.

Ubuntu
Offline Ultraq

Junior Duke




That's what she said


« Reply #1 - Posted 2007-03-26 22:27:35 »

On top of the methods you've found, be sure to also do Buffer.delete() and Source.delete() on all your buffers and sources as well.

Delete sources first, then buffers, on the context you're wishing to destroy.  Then destroy the context, and close the device.  I dunno where ALut.exit() fits into that though.

Ultraq's Final MooCow
Bits and Pieces by Emanuel Rabina
Offline Conzar

Junior Duke




There is nothing common about common sense


« Reply #2 - Posted 2007-03-27 23:29:02 »

How do I get the sources if I only call

1  
Buffer buffer = AudioSystem3D.loadBuffer("filename");



Thanks for the help!!!

Ubuntu
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ultraq

Junior Duke




That's what she said


« Reply #3 - Posted 2007-03-28 21:59:19 »

Well I don't think you can play a buffer without a source.  So somewhere in your program you might have the following lines, which will give you your reference/s to your source/s:

Source source = AudioSystem3D.generateSource(Buffer)
Source[] sources = AudioSystem3D.generateSources(int)

Ultraq's Final MooCow
Bits and Pieces by Emanuel Rabina
Offline Conzar

Junior Duke




There is nothing common about common sense


« Reply #4 - Posted 2007-03-29 23:16:10 »

Negative.  I never load a source.  I call the loadBuffer method from AudioSystem3D.  Note that it takes a string for a parameter (file name).  I'm guessing AudioSystem3D handles generating a source; however, I don't see any release resources methods associated with AudioSystem3D.  Listed below is the javadoc for this method.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public static Buffer loadBuffer(String filename) throws IOException, UnsupportedAudioFileException

    Loads a Sound3D buffer with the specified audio file.

    Parameters:
        filename - the name of the file to load.
    Returns:
        a new Sound3D buffer containing the audio data from the specified file.
    Throws:
        IOException - If the file cannot be found or some other IO error occurs.
        UnsupportedAudioFileException - If the format of the sudio data is not supported

Ubuntu
Offline Ultraq

Junior Duke




That's what she said


« Reply #5 - Posted 2007-03-30 20:24:51 »

OK, so you don't load any sources, but I'm pretty sure you can't play a buffer.  Only the Source class has the play/pause/stop methods (and in OpenAL, play/pause/stop can only occur on a source).  So how do you play sounds then?

Anyway, if your app doesn't use sources, then there's no need to do any Source.delete().  Just using the Buffer.delete(), plus the other methods you found, are enough for an OpenAL cleanup.

Ultraq's Final MooCow
Bits and Pieces by Emanuel Rabina
Offline Conzar

Junior Duke




There is nothing common about common sense


« Reply #6 - Posted 2007-03-31 15:18:19 »

Actually your right ... I create Sources later on in my "Effects" objects --- I just forgot about them. 

So how should I go about deleting buffers?  I see there is a function in the AL interface for deleting buffers; however, I really don't have an AL interface.  I just have the AudioSystem3D object...

Ubuntu
Offline Ultraq

Junior Duke




That's what she said


« Reply #7 - Posted 2007-03-31 22:56:54 »

Be sure to keep references to any buffers you create.  When it's time to cleanup, use their delete() method.

Ultraq's Final MooCow
Bits and Pieces by Emanuel Rabina
Offline Conzar

Junior Duke




There is nothing common about common sense


« Reply #8 - Posted 2007-04-01 00:02:58 »

Thanks man!  All of your advise worked out and I'm able to sucessfully release all the Sound resources!!!!

Ubuntu
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (38 views)
2014-10-27 03:28:38

TehJavaDev (29 views)
2014-10-27 03:27:51

DarkCart (43 views)
2014-10-26 19:37:11

Luminem (24 views)
2014-10-26 10:17:50

Luminem (29 views)
2014-10-26 10:14:04

theagentd (35 views)
2014-10-25 15:46:29

Longarmx (63 views)
2014-10-17 03:59:02

Norakomi (61 views)
2014-10-16 15:22:06

Norakomi (50 views)
2014-10-16 15:20:20

lcass (46 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!