@@ -99,13 +99,13 @@ OpenALAudioSound::
99
99
void OpenALAudioSound::
100
100
cleanup () {
101
101
ReMutexHolder holder (OpenALAudioManager::_lock);
102
- if (_manager == 0 ) {
102
+ if (! is_valid () ) {
103
103
return ;
104
104
}
105
- if (_source ) {
105
+ if (is_playing () ) {
106
106
stop ();
107
107
}
108
- if (_sd ) {
108
+ if (has_sound_data () ) {
109
109
_manager->decrement_client_count (_sd);
110
110
_sd = 0 ;
111
111
}
@@ -119,7 +119,7 @@ cleanup() {
119
119
void OpenALAudioSound::
120
120
play () {
121
121
ReMutexHolder holder (OpenALAudioManager::_lock);
122
- if (_manager == 0 ) return ;
122
+ if (! is_valid () ) return ;
123
123
124
124
PN_stdfloat px,py,pz,vx,vy,vz;
125
125
@@ -136,7 +136,7 @@ play() {
136
136
}
137
137
138
138
_manager->starting_sound (this );
139
- if (!_source ) {
139
+ if (!is_playing () ) {
140
140
return ;
141
141
}
142
142
@@ -195,9 +195,9 @@ play() {
195
195
void OpenALAudioSound::
196
196
stop () {
197
197
ReMutexHolder holder (OpenALAudioManager::_lock);
198
- if (_manager== 0 ) return ;
198
+ if (! is_valid () ) return ;
199
199
200
- if (_source ) {
200
+ if (is_playing () ) {
201
201
_manager->make_current ();
202
202
203
203
alGetError (); // clear errors
@@ -254,7 +254,7 @@ get_loop() const {
254
254
void OpenALAudioSound::
255
255
set_loop_count (unsigned long loop_count) {
256
256
ReMutexHolder holder (OpenALAudioManager::_lock);
257
- if (_manager== 0 ) return ;
257
+ if (! is_valid () ) return ;
258
258
259
259
if (loop_count >= 1000000000 ) {
260
260
loop_count = 0 ;
@@ -434,7 +434,7 @@ correct_calibrated_clock(double rtc, double t) {
434
434
void OpenALAudioSound::
435
435
pull_used_buffers () {
436
436
ReMutexHolder holder (OpenALAudioManager::_lock);
437
- if (_manager == 0 ) return ;
437
+ if (! is_valid () ) return ;
438
438
while (_stream_queued.size ()) {
439
439
ALuint buffer = 0 ;
440
440
ALint num_buffers = 0 ;
@@ -490,7 +490,7 @@ push_fresh_buffers() {
490
490
ReMutexHolder holder (OpenALAudioManager::_lock);
491
491
static unsigned char data[65536 ];
492
492
493
- if (_manager == 0 ) return ;
493
+ if (! is_valid () ) return ;
494
494
495
495
if (_sd->_sample ) {
496
496
while ((_loops_completed < _playing_loops) &&
@@ -517,9 +517,9 @@ push_fresh_buffers() {
517
517
break ;
518
518
}
519
519
ALuint buffer = make_buffer (samples, channels, rate, data);
520
- if (_manager == 0 ) return ;
520
+ if (! is_valid () ) return ;
521
521
queue_buffer (buffer, samples, loop_index, time_offset);
522
- if (_manager == 0 ) return ;
522
+ if (! is_valid () ) return ;
523
523
fill += samples;
524
524
}
525
525
}
@@ -541,7 +541,7 @@ set_time(PN_stdfloat time) {
541
541
PN_stdfloat OpenALAudioSound::
542
542
get_time () const {
543
543
ReMutexHolder holder (OpenALAudioManager::_lock);
544
- if (_manager == 0 ) {
544
+ if (! is_valid () ) {
545
545
return 0.0 ;
546
546
}
547
547
return _current_time;
@@ -553,7 +553,7 @@ get_time() const {
553
553
void OpenALAudioSound::
554
554
cache_time (double rtc) {
555
555
ReMutexHolder holder (OpenALAudioManager::_lock);
556
- assert (_source != 0 );
556
+ assert (is_playing () );
557
557
double t=get_calibrated_clock (rtc);
558
558
double max = _length * _playing_loops;
559
559
if (t >= max) {
@@ -571,7 +571,7 @@ set_volume(PN_stdfloat volume) {
571
571
ReMutexHolder holder (OpenALAudioManager::_lock);
572
572
_volume=volume;
573
573
574
- if (_source ) {
574
+ if (is_playing () ) {
575
575
volume*=_manager->get_volume ();
576
576
_manager->make_current ();
577
577
alGetError (); // clear errors
@@ -615,7 +615,7 @@ void OpenALAudioSound::
615
615
set_play_rate (PN_stdfloat play_rate) {
616
616
ReMutexHolder holder (OpenALAudioManager::_lock);
617
617
_play_rate = play_rate;
618
- if (_source ) {
618
+ if (is_playing () ) {
619
619
alSourcef (_source, AL_PITCH, play_rate);
620
620
}
621
621
}
@@ -657,7 +657,7 @@ set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx
657
657
_velocity[1 ] = vz;
658
658
_velocity[2 ] = -vy;
659
659
660
- if (_source ) {
660
+ if (is_playing () ) {
661
661
_manager->make_current ();
662
662
663
663
alGetError (); // clear errors
@@ -693,7 +693,7 @@ set_3d_min_distance(PN_stdfloat dist) {
693
693
ReMutexHolder holder (OpenALAudioManager::_lock);
694
694
_min_dist = dist;
695
695
696
- if (_source ) {
696
+ if (is_playing () ) {
697
697
_manager->make_current ();
698
698
699
699
alGetError (); // clear errors
@@ -718,7 +718,7 @@ set_3d_max_distance(PN_stdfloat dist) {
718
718
ReMutexHolder holder (OpenALAudioManager::_lock);
719
719
_max_dist = dist;
720
720
721
- if (_source ) {
721
+ if (is_playing () ) {
722
722
_manager->make_current ();
723
723
724
724
alGetError (); // clear errors
@@ -743,7 +743,7 @@ set_3d_drop_off_factor(PN_stdfloat factor) {
743
743
ReMutexHolder holder (OpenALAudioManager::_lock);
744
744
_drop_off_factor = factor;
745
745
746
- if (_source ) {
746
+ if (is_playing () ) {
747
747
_manager->make_current ();
748
748
749
749
alGetError (); // clear errors
@@ -831,7 +831,7 @@ get_name() const {
831
831
AudioSound::SoundStatus OpenALAudioSound::
832
832
status () const {
833
833
ReMutexHolder holder (OpenALAudioManager::_lock);
834
- if (_source== 0 ) {
834
+ if (! is_playing () ) {
835
835
return AudioSound::READY;
836
836
}
837
837
if ((_loops_completed >= _playing_loops)&&(_stream_queued.size ()==0 )) {
0 commit comments