Panda3D
vorbisAudio.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 vorbisAudio.cxx
10  * @author rdb
11  * @date 2013-08-23
12  */
13 
14 #include "vorbisAudio.h"
15 #include "vorbisAudioCursor.h"
16 #include "virtualFileSystem.h"
17 #include "dcast.h"
18 
19 #ifdef HAVE_VORBIS
20 
21 TypeHandle VorbisAudio::_type_handle;
22 
23 /**
24  * xxx
25  */
26 VorbisAudio::
27 VorbisAudio(const Filename &name) :
28  MovieAudio(name)
29 {
30  _filename = name;
31 }
32 
33 /**
34  * xxx
35  */
36 VorbisAudio::
37 ~VorbisAudio() {
38 }
39 
40 /**
41  * Open this audio, returning a MovieAudioCursor
42  */
43 PT(MovieAudioCursor) VorbisAudio::
44 open() {
46  std::istream *stream = vfs->open_read_file(_filename, true);
47 
48  if (stream == nullptr) {
49  return nullptr;
50  } else {
51  PT(VorbisAudioCursor) cursor = new VorbisAudioCursor(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) VorbisAudio::
64 make(const Filename &name) {
65  return DCAST(MovieAudio, new VorbisAudio(name));
66 }
67 
68 #endif // HAVE_VORBIS
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.
A MovieAudio is actually any source that provides a sequence of audio samples.
Definition: movieAudio.h:44
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
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,...
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.