00001 // Filename: microphoneAudio.cxx 00002 // Created by: jyelon (02Jul07) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "microphoneAudio.h" 00016 #include "movieAudioCursor.h" 00017 00018 pvector<PT(MicrophoneAudio)> MicrophoneAudio::_all_microphones; 00019 TypeHandle MicrophoneAudio::_type_handle; 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // Function: MicrophoneAudio::Destructor 00023 // Access: Published, Virtual 00024 // Description: 00025 //////////////////////////////////////////////////////////////////// 00026 MicrophoneAudio:: 00027 ~MicrophoneAudio() { 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: MicrophoneAudio::find_all_microphones 00032 // Access: Public 00033 // Description: Scans the hardware for microphones, and pushes them 00034 // onto the global list of all microphones. 00035 // 00036 // There are several implementations of MicrophoneAudio, 00037 // including one based on DirectShow, one based on 00038 // Linux ALSA, and so forth. These implementations 00039 // are contained in one C++ file each, and they export 00040 // nothing at all except a single "find_all" function. 00041 // Otherwise, they can only be accessed through the 00042 // virtual methods of the MicrophoneAudio objects they 00043 // create. 00044 //////////////////////////////////////////////////////////////////// 00045 void MicrophoneAudio:: 00046 find_all_microphones() { 00047 static bool initialized = false; 00048 if (initialized) return; 00049 initialized = true; 00050 00051 #ifdef HAVE_DIRECTCAM 00052 extern void find_all_microphones_ds(); 00053 find_all_microphones_ds(); 00054 #endif 00055 00056 #ifdef HAVE_ALSA 00057 extern void find_all_microphones_alsa(); 00058 find_all_microphones_alsa(); 00059 #endif 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function: MicrophoneAudio::get_num_options 00064 // Access: Public 00065 // Description: Returns the number of microphone options. An "option" 00066 // consists of a device plus a set of configuration 00067 // parameters. For example, "Soundblaster Audigy Line in 00068 // at 44,100 samples/sec" would be an option. 00069 //////////////////////////////////////////////////////////////////// 00070 int MicrophoneAudio:: 00071 get_num_options() { 00072 find_all_microphones(); 00073 return _all_microphones.size(); 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function: MicrophoneAudio::get_option 00078 // Access: Public 00079 // Description: Returns the nth microphone option. 00080 //////////////////////////////////////////////////////////////////// 00081 PT(MicrophoneAudio) MicrophoneAudio:: 00082 get_option(int n) { 00083 find_all_microphones(); 00084 nassertr((n >= 0) && (n < (int)_all_microphones.size()), NULL); 00085 return _all_microphones[n]; 00086 }