Panda3D
Loading...
Searching...
No Matches
audioLoadRequest.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file audioLoadRequest.I
10 * @author drose
11 * @date 2006-08-29
12 */
13
14/**
15 * Create a new AudioLoadRequest, and add it to the loader via load_async(),
16 * to begin an asynchronous load.
17 */
19AudioLoadRequest(AudioManager *audio_manager, const std::string &filename,
20 bool positional) :
21 _audio_manager(audio_manager),
22 _filename(filename),
23 _positional(positional)
24{
25}
26
27/**
28 * Returns the AudioManager that will serve this asynchronous
29 * AudioLoadRequest.
30 */
32get_audio_manager() const {
33 return _audio_manager;
34}
35
36/**
37 * Returns the filename associated with this asynchronous AudioLoadRequest.
38 */
39INLINE const std::string &AudioLoadRequest::
40get_filename() const {
41 return _filename;
42}
43
44/**
45 * Returns the positional flag associated with this asynchronous
46 * AudioLoadRequest.
47 */
49get_positional() const {
50 return _positional;
51}
52
53/**
54 * Returns true if this request has completed, false if it is still pending.
55 * When this returns true, you may retrieve the sound loaded by calling
56 * get_sound().
57 * Equivalent to `req.done() and not req.cancelled()`.
58 * @see done()
59 */
61is_ready() const {
62 return (FutureState)AtomicAdjust::get(_future_state) == FS_finished;
63}
64
65/**
66 * Returns the sound that was loaded asynchronously, if any, or nullptr if
67 * there was an error. It is an error to call this unless done() returns
68 * true.
69 * @deprecated Use result() instead.
70 */
72get_sound() const {
73 nassertr_always(done(), nullptr);
74 return (AudioSound *)_result;
75}
bool done() const
Returns true if the future is done or has been cancelled.
Definition asyncFuture.I:29
static Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.
AudioLoadRequest(AudioManager *audio_manager, const std::string &filename, bool positional)
Create a new AudioLoadRequest, and add it to the loader via load_async(), to begin an asynchronous lo...
bool is_ready() const
Returns true if this request has completed, false if it is still pending.
AudioManager * get_audio_manager() const
Returns the AudioManager that will serve this asynchronous AudioLoadRequest.
const std::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.
AudioSound * get_sound() const
Returns the sound that was loaded asynchronously, if any, or nullptr if there was an error.