Dave Schuyler пре 24 година
родитељ
комит
594b30a84c

+ 52 - 0
panda/src/audio/nullAudioManager.cxx

@@ -0,0 +1,52 @@
+// Filename: nullAudioManager.cxx
+// Created by:  skyler (June 6, 2001)
+// Prior system by: cary
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "nullAudioManager.h"
+
+NullAudioManager::NullAudioManager() {
+  audio_info("NullAudioManager");
+}
+
+NullAudioManager::~NullAudioManager() {
+  // intentionally blank.
+}
+  
+AudioSound* NullAudioManager::get_sound(const string&) {
+  return new NullAudioSound();
+}
+
+void NullAudioManager::drop_sound(const string&) {
+  // intentionally blank.
+}
+
+void NullAudioManager::set_volume(float) {
+  // intentionally blank.
+}
+
+float NullAudioManager::get_volume() {
+  return 0;
+}
+  
+void NullAudioManager::set_active(bool) {
+  // intentionally blank.
+}
+
+bool NullAudioManager::get_active() {
+  return 0;
+}

+ 57 - 0
panda/src/audio/nullAudioManager.h

@@ -0,0 +1,57 @@
+// Filename: nullAudioManager.h
+// Created by:  skyler (June 6, 2001)
+// Prior system by: cary
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef __NULL_AUDIO_MANAGER_H__
+#define __NULL_AUDIO_MANAGER_H__
+
+#include "audioManager.h"
+#include "nullAudioSound.h"
+
+#define NAME_MACRO_FOR_AUDIO_MANAGER() NullAudioManager
+
+class EXPCL_PANDA NullAudioManager : public AudioManager {
+public:
+  NullAudioManager();
+  virtual ~NullAudioManager();
+  
+  // Get a sound:
+  // You own this sound.  Be sure to delete it when you're done.
+  virtual AudioSound* get_sound(const string&);
+  // Tell the AudioManager there is no need to keep this one cached.
+  virtual void drop_sound(const string&);
+
+  // Control volume:
+  // FYI:
+  //   If you start a sound with the volume off and turn the volume 
+  //   up later, you'll hear the sound playing at that late point.
+  virtual void set_volume(float);
+  virtual float get_volume();
+  
+  // Turn the manager on an off.
+  // If you play a sound while the manager is inactive, it won't start.
+  // If you deactivate the manager while sounds are playing, they'll
+  // stop.
+  // If you activate the manager while looping sounds are playing
+  // (those that have a loop_count of zero),
+  // they will start playing from the begining of their loop.
+  virtual void set_active(bool);
+  virtual bool get_active();
+};
+
+#endif /* __NULL_AUDIO_MANAGER_H__ */

+ 97 - 0
panda/src/audio/nullAudioSound.cxx

@@ -0,0 +1,97 @@
+// Filename: nullAudioSound.cxx
+// Created by:  skyler (June 6, 2001)
+// Prior system by: cary
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "nullAudioSound.h"
+
+
+NullAudioSound::NullAudioSound() {
+  // Intentionally blank.
+}
+
+NullAudioSound::~NullAudioSound() {
+  // Intentionally blank.
+}
+  
+void NullAudioSound::play() {
+  // Intentionally blank.
+}
+
+void NullAudioSound::stop() {
+  // Intentionally blank.
+}
+  
+void NullAudioSound::set_loop(bool) {
+  // Intentionally blank.
+}
+
+bool NullAudioSound::get_loop() const {
+  return false; 
+}
+  
+void NullAudioSound::set_loop_count(unsigned long) {
+  // Intentionally blank.
+}
+
+unsigned long NullAudioSound::get_loop_count() const {
+  return 0; 
+}
+  
+void NullAudioSound::set_time(float) {
+  // Intentionally blank.
+}
+
+float NullAudioSound::get_time() const {
+  return 0; 
+}
+
+void NullAudioSound::set_volume(float) {
+  // Intentionally blank.
+}
+
+float NullAudioSound::get_volume() const {
+  return 0; 
+}
+
+void NullAudioSound::set_balance(float) {
+  // Intentionally blank.
+}
+
+float NullAudioSound::get_balance() const {
+  return 0; 
+}
+
+void NullAudioSound::set_active(bool) {
+  // Intentionally blank.
+}
+
+bool NullAudioSound::get_active() const {
+  return false; 
+}
+
+const string& NullAudioSound::get_name() const {
+  return ""; 
+}
+
+float NullAudioSound::length() const {
+  return 0;
+}
+
+AudioSound::SoundStatus NullAudioSound::status() const {
+  return AudioSound::READY; 
+}

+ 85 - 0
panda/src/audio/nullAudioSound.h

@@ -0,0 +1,85 @@
+// Filename: nullAudioSound.h
+// Created by:  skyler (June 6, 2001)
+// Prior system by: cary
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef __NULL_AUDIO_SOUND_H__
+#define __NULL_AUDIO_SOUND_H__
+
+#include "audioSound.h"
+
+
+// This class intentionally does next to nothing.
+// It's used as a placeholder when you don't want a sound
+// system.
+class EXPCL_PANDA NullAudioSound : public AudioSound {
+public:
+  ~NullAudioSound();
+  
+  // For best compatability, set the loop_count, start_time,
+  // volume, and balance, prior to calling play().  You may
+  // set them while they're playing, but it's implementation
+  // specific whether you get the results.
+  void play();
+  void stop();
+  
+  // loop: 0 = play once; 1 = play forever.
+  // inits to false.
+  void set_loop(bool);
+  bool get_loop() const;
+  
+  // loop_count: 0 = forever; 1 = play once; n = play n times.
+  // inits to 1.
+  void set_loop_count(unsigned long);
+  unsigned long get_loop_count() const;
+  
+  // start_time: 0 = begining; length() = end.
+  // inits to 0.0.
+  void set_time(float);
+  float get_time() const;
+  
+  // 0 = minimum; 1.0 = maximum.
+  // inits to 1.0.
+  void set_volume(float);
+  float get_volume() const;
+  
+  // -1.0 is hard left
+  // 0.0 is centered
+  // 1.0 is hard right
+  // inits to 0.0.
+  void set_balance(float);
+  float get_balance() const;
+
+  // inits to manager's state.
+  void set_active(bool);
+  bool get_active() const;
+  
+  // There is no set_name(), this is intentional.
+  const string& get_name() const;
+  
+  // return: playing time in seconds.
+  float length() const;
+
+  AudioSound::SoundStatus status() const;
+
+protected:
+  NullAudioSound();
+
+  friend class NullAudioManager;
+};
+
+#endif /* __NULL_AUDIO_SOUND_H__ */