Panda3D
|
00001 // Filename: userDataAudioCursor.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 "userDataAudioCursor.h" 00016 00017 TypeHandle UserDataAudioCursor::_type_handle; 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: UserDataAudioCursor::Constructor 00021 // Access: 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 UserDataAudioCursor:: 00025 UserDataAudioCursor(UserDataAudio *src) : 00026 MovieAudioCursor(src) 00027 { 00028 _audio_rate = src->_desired_rate; 00029 _audio_channels = src->_desired_channels; 00030 _can_seek = false; 00031 _can_seek_fast = false; 00032 _aborted = false; 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function: UserDataAudioCursor::Destructor 00037 // Access: Public, Virtual 00038 // Description: 00039 //////////////////////////////////////////////////////////////////// 00040 UserDataAudioCursor:: 00041 ~UserDataAudioCursor() { 00042 UserDataAudio *source = (UserDataAudio*)(MovieAudio*)_source; 00043 source->_cursor = NULL; 00044 } 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Function: UserDataAudioCursor::read_samples 00048 // Access: Private 00049 // Description: Read audio samples from the stream. N is the 00050 // number of samples you wish to read. Your buffer 00051 // must be equal in size to N * channels. 00052 // Multiple-channel audio will be interleaved. 00053 //////////////////////////////////////////////////////////////////// 00054 void UserDataAudioCursor:: 00055 read_samples(int n, PN_int16 *data) { 00056 UserDataAudio *source = (UserDataAudio*)(MovieAudio*)_source; 00057 source->read_samples(n, data); 00058 _samples_read += n; 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: UserDataAudioCursor::ready 00063 // Access: Private 00064 // Description: Returns the number of audio samples ready to be 00065 // read. 00066 //////////////////////////////////////////////////////////////////// 00067 int UserDataAudioCursor:: 00068 ready() const { 00069 UserDataAudio *source = (UserDataAudio*)(MovieAudio*)_source; 00070 ((UserDataAudioCursor*)this)->_aborted = source->_aborted; 00071 return (source->_data.size()) / _audio_channels; 00072 }