Panda3D
audioLoadRequest.I
1 // Filename: audioLoadRequest.I
2 // Created by: drose (29Aug06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: AudioLoadRequest::Constructor
18 // Access: Published
19 // Description: Create a new AudioLoadRequest, and add it to the loader
20 // via load_async(), to begin an asynchronous load.
21 ////////////////////////////////////////////////////////////////////
22 INLINE AudioLoadRequest::
23 AudioLoadRequest(AudioManager *audio_manager, const string &filename,
24  bool positional) :
25  _audio_manager(audio_manager),
26  _filename(filename),
27  _positional(positional),
28  _is_ready(false)
29 {
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: AudioLoadRequest::get_audio_manager
34 // Access: Published
35 // Description: Returns the AudioManager that will serve this
36 // asynchronous AudioLoadRequest.
37 ////////////////////////////////////////////////////////////////////
40  return _audio_manager;
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: AudioLoadRequest::get_filename
45 // Access: Published
46 // Description: Returns the filename associated with this
47 // asynchronous AudioLoadRequest.
48 ////////////////////////////////////////////////////////////////////
49 INLINE const string &AudioLoadRequest::
50 get_filename() const {
51  return _filename;
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: AudioLoadRequest::get_positional
56 // Access: Published
57 // Description: Returns the positional flag associated with this
58 // asynchronous AudioLoadRequest.
59 ////////////////////////////////////////////////////////////////////
60 INLINE bool AudioLoadRequest::
61 get_positional() const {
62  return _positional;
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: AudioLoadRequest::is_ready
67 // Access: Published
68 // Description: Returns true if this request has completed, false if
69 // it is still pending. When this returns true, you may
70 // retrieve the sound loaded by calling get_sound().
71 ////////////////////////////////////////////////////////////////////
72 INLINE bool AudioLoadRequest::
73 is_ready() const {
74  return _is_ready;
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: AudioLoadRequest::get_sound
79 // Access: Published
80 // Description: Returns the sound that was loaded asynchronously, if
81 // any, or NULL if there was an error. It is an error
82 // to call this unless is_ready() returns true.
83 ////////////////////////////////////////////////////////////////////
85 get_sound() const {
86  nassertr(_is_ready, NULL);
87  return _sound;
88 }
AudioManager * get_audio_manager() const
Returns the AudioManager that will serve this asynchronous AudioLoadRequest.
bool is_ready() const
Returns true if this request has completed, false if it is still pending.
AudioSound * get_sound() const
Returns the sound that was loaded asynchronously, if any, or NULL if there was an error...
const string & get_filename() const
Returns the filename associated with this asynchronous AudioLoadRequest.
bool get_positional() const
Returns the positional flag associated with this asynchronous AudioLoadRequest.
AudioLoadRequest(AudioManager *audio_manager, const string &filename, bool positional)
Create a new AudioLoadRequest, and add it to the loader via load_async(), to begin an asynchronous lo...