Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 7bcf829

Browse files
Turn MCacptr into an object handle
1 parent 6c14bac commit 7bcf829

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

engine/src/aclip.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ MCAudioClip::~MCAudioClip()
152152
if (MCacptr == this)
153153
{
154154
stop(True);
155-
MCacptr = NULL;
155+
MCacptr = nil;
156156
}
157157
delete[] samples; /* Allocated with new[] */
158158
delete osamples;
@@ -187,7 +187,7 @@ void MCAudioClip::timer(MCNameRef mptr, MCParameter *params)
187187
}
188188
else
189189
{
190-
MCacptr = NULL;
190+
MCacptr = nil;
191191
if (mstack != NULL)
192192
{
193193
if (mstack->getopened())

engine/src/desktop.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,13 +1408,13 @@ void MCPlatformHandlePlayerBufferUpdated(MCPlatformPlayerRef p_player)
14081408

14091409
void MCPlatformHandleSoundFinished(MCPlatformSoundRef p_sound)
14101410
{
1411-
if (MCacptr != nil)
1411+
if (MCacptr)
14121412
{
14131413
MCscreen -> addtimer(MCacptr, MCM_internal, 0);
14141414
// PM-2014-12-09: [[ Bug 14176 ]] Release and nullify the sound once it is done
14151415
MCacptr->stop(True);
14161416
// PM-2014-12-22: [[ Bug 14269 ]] Nullify MCacptr to prevent looping when play audioclip is followed by wait until the sound is done
1417-
MCacptr = NULL;
1417+
MCacptr = nil;
14181418
}
14191419
}
14201420

engine/src/dispatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ void MCDispatch::destroystack(MCStack *sptr, Boolean needremove)
341341
MCstaticdefaultstackptr = stacks;
342342
if (sptr == MCdefaultstackptr)
343343
MCdefaultstackptr = MCstaticdefaultstackptr;
344-
if (MCacptr != NULL && MCacptr->getmessagestack() == sptr)
344+
if (MCacptr && MCacptr->getmessagestack() == sptr)
345345
MCacptr->setmessagestack(NULL);
346346
Boolean oldstate = MClockmessages;
347347
MClockmessages = True;

engine/src/exec-interface2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2587,7 +2587,7 @@ void MCInterfaceEvalAudioClipOfStackByName(MCExecContext& ctxt, MCObjectPtr p_st
25872587
t_clip = nil;
25882588

25892589
if (!static_cast<MCStack *>(p_stack . object) -> getAVname(CT_AUDIO_CLIP, p_name, t_clip) &&
2590-
(MCacptr != NULL && MCacptr -> hasname(p_name)))
2590+
(MCacptr && MCacptr -> hasname(p_name)))
25912591
t_clip = MCacptr;
25922592

25932593
if (t_clip != nil)

engine/src/exec-multimedia.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ void MCMultimediaEvalSound(MCExecContext& ctxt, MCStringRef& r_sound)
284284
#ifndef FEATURE_PLATFORM_AUDIO
285285
MCU_play();
286286
#endif
287-
if (MCacptr != nil && MCacptr -> isPlaying())
287+
if (MCacptr && MCacptr -> isPlaying())
288288
{
289289
MCacptr -> getstringprop(ctxt, 0, P_NAME, False, r_sound);
290290
return;
@@ -608,8 +608,8 @@ void MCMultimediaExecPlayAudioClip(MCExecContext& ctxt, MCStack *p_target, int p
608608

609609
MCNewAutoNameRef t_clipname;
610610
/* UNCHECKED */ MCNameCreate(p_clip, &t_clipname);
611-
if ((MCacptr = (MCAudioClip *)(sptr->getAV((Chunk_term)p_chunk_type, p_clip, CT_AUDIO_CLIP))) == NULL &&
612-
(MCacptr = (MCAudioClip *)(sptr->getobjname(CT_AUDIO_CLIP, *t_clipname))) == NULL)
611+
if (!(MCacptr = MCObjectCast<MCAudioClip>(sptr->getAV((Chunk_term)p_chunk_type, p_clip, CT_AUDIO_CLIP)))
612+
&& !(MCacptr = MCObjectCast<MCAudioClip>(sptr->getobjname(CT_AUDIO_CLIP, *t_clipname))))
613613
{
614614
IO_handle stream;
615615

@@ -634,15 +634,15 @@ void MCMultimediaExecPlayAudioClip(MCExecContext& ctxt, MCStack *p_target, int p
634634
MCS_close(stream);
635635
MCresult->sets("error reading audioClip");
636636
delete MCacptr;
637-
MCacptr = NULL;
637+
MCacptr = nil;
638638
ctxt . Throw();
639639
return;
640640
}
641641
MCS_close(stream);
642642
}
643643
MCacptr->setlooping(p_looping);
644644
MCU_play();
645-
if (MCacptr != NULL)
645+
if (MCacptr)
646646
MCscreen->addtimer(MCacptr, MCM_internal, p_looping ? LOOP_RATE : PLAY_RATE);
647647
}
648648

engine/src/globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ MCObjectHandle MCerrorptr;
275275
MCObjectHandle MCerrorlockptr;
276276
MCObjectPtr MCtargetptr;
277277
MCGroup *MCsavegroupptr;
278-
MCAudioClip *MCacptr;
279278
MCObjectHandle MCmenuobjectptr;
280279
MCGroupHandle MCdefaultmenubar;
281280
MCGroupHandle MCmenubar;
282281
MCPlayerHandle MCplayers;
282+
MCAudioClipHandle MCacptr;
283283

284284
MCStack *MCtemplatestack;
285285
MCAudioClip *MCtemplateaudio;

engine/src/globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ extern MCObjectHandle MCmenuobjectptr;
192192
extern MCCardHandle MCdynamiccard;
193193
extern Boolean MCdynamicpath;
194194
extern MCGroup *MCsavegroupptr;
195-
extern MCAudioClip *MCacptr;
196195
extern MCObjectHandle MCerrorptr;
197196
extern MCObjectHandle MCerrorlockptr;
198197
extern MCGroupHandle MCdefaultmenubar;
199198
extern MCGroupHandle MCmenubar;
199+
extern MCAudioClipHandle MCacptr;
200200
extern MCPlayerHandle MCplayers;
201201

202202
extern MCStack *MCtemplatestack;

engine/src/stack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ void MCStack::close()
759759
// MW-2011-09-12: [[ MacScroll ]] Clear the current scroll setting from the stack.
760760
clearscroll();
761761

762-
if (MCacptr != NULL && MCacptr->getmessagestack() == this)
762+
if (MCacptr && MCacptr->getmessagestack() == this)
763763
MCacptr->setmessagestack(NULL);
764764
if (state & CS_ICONIC)
765765
{

engine/src/util.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static MCPoint qa_points[QA_NPOINTS + 1];
6060
static void MCU_play_message()
6161
{
6262
MCAudioClip *acptr = MCacptr;
63-
MCacptr = NULL;
63+
MCacptr = nil;
6464
// PM-2014-12-22: [[ Bug 14269 ]] Nil checks to prevent a crash
6565
MCStack *sptr = (acptr != NULL ? acptr->getmessagestack() : NULL);
6666
if (sptr != NULL)
@@ -74,13 +74,13 @@ static void MCU_play_message()
7474

7575
void MCU_play()
7676
{
77-
if (MCacptr != NULL && !MCacptr->play())
77+
if (MCacptr && !MCacptr->play())
7878
MCU_play_message();
7979
}
8080

8181
void MCU_play_stop()
8282
{
83-
if (MCacptr != NULL)
83+
if (MCacptr)
8484
{
8585
MCacptr->stop(True);
8686
MCU_play_message();

0 commit comments

Comments
 (0)