Panda3D
opusAudio.cxx
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 opusAudio.cxx
10  * @author rdb
11  * @date 2017-05-24
12  */
13 
14 #include "opusAudio.h"
15 #include "opusAudioCursor.h"
16 #include "virtualFileSystem.h"
17 #include "dcast.h"
18 
19 #ifdef HAVE_OPUS
20 
21 TypeHandle OpusAudio::_type_handle;
22 
23 /**
24  * xxx
25  */
26 OpusAudio::
27 OpusAudio(const Filename &name) :
28  MovieAudio(name)
29 {
30  _filename = name;
31 }
32 
33 /**
34  * xxx
35  */
36 OpusAudio::
37 ~OpusAudio() {
38 }
39 
40 /**
41  * Open this audio, returning a MovieAudioCursor
42  */
43 PT(MovieAudioCursor) OpusAudio::
44 open() {
46  std::istream *stream = vfs->open_read_file(_filename, true);
47 
48  if (stream == nullptr) {
49  return nullptr;
50  } else {
51  PT(OpusAudioCursor) cursor = new OpusAudioCursor(this, stream);
52  if (cursor == nullptr || !cursor->_is_valid) {
53  return nullptr;
54  } else {
55  return DCAST(MovieAudioCursor, cursor);
56  }
57  }
58 }
59 
60 /**
61  * Obtains a MovieAudio that references a file.
62  */
63 PT(MovieAudio) OpusAudio::
64 make(const Filename &name) {
65  return DCAST(MovieAudio, new OpusAudio(name));
66 }
67 
68 #endif // HAVE_OPUS
A hierarchy of directories and files that appears to be one continuous file system,...
std::istream * open_read_file(const Filename &filename, bool auto_unwrap) const
Convenience function; returns a newly allocated istream if the file exists and can be read,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
A MovieAudio is actually any source that provides a sequence of audio samples.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
A MovieAudio is actually any source that provides a sequence of audio samples.
Definition: movieAudio.h:44