Skip to content

Commit 2e146b9

Browse files
committed
MCVideoClip/MCAudioClip/MCEPS ::import() and hc_import() methods
1 parent 7127aab commit 2e146b9

12 files changed

Lines changed: 24 additions & 33 deletions

File tree

engine/src/aclip.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ void MCAudioClip::setlooping(Boolean loop)
491491
looping = loop;
492492
}
493493

494-
Boolean MCAudioClip::import(const char *fname, IO_handle stream)
494+
Boolean MCAudioClip::import(MCStringRef fname, IO_handle stream)
495495
{
496496
size = (uint4)MCS_fsize(stream);
497497
if (size == 0)
@@ -606,11 +606,11 @@ Boolean MCAudioClip::import(const char *fname, IO_handle stream)
606606
rate = 11000;
607607
}
608608
}
609-
const char *tname = strrchr(fname, PATH_SEPARATOR);
609+
const char *tname = strrchr(MCStringGetCString(fname), PATH_SEPARATOR);
610610
if (tname != NULL)
611611
tname += 1;
612612
else
613-
tname = fname;
613+
tname = MCStringGetCString(fname);
614614
setname_cstring(tname);
615615
return True;
616616
}

engine/src/aclip.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class MCAudioClip : public MCObject
102102
Boolean issupported();
103103
void setdisposable();
104104
void setlooping(Boolean loop);
105-
Boolean import(const char *fname, IO_handle stream);
105+
Boolean import(MCStringRef fname, IO_handle stream);
106106
Boolean open_audio();
107107
Boolean play();
108108
void stop(Boolean abort);

engine/src/dispatch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,13 +751,13 @@ IO_stat MCDispatch::doreadfile(const char *openpath, const char *inname, IO_hand
751751
}
752752
else
753753
{
754-
char *tname = strclone(inname);
754+
MCAutoStringRef tname;
755+
/* UNCHECKED */ MCStringCreateWithCString(inname, &tname);
755756

756757
// MW-2008-06-12: [[ Bug 6476 ]] Media won't open HC stacks
757-
if (!MCdispatcher->cut(True) || hc_import(tname, stream, sptr) != IO_NORMAL)
758+
if (!MCdispatcher->cut(True) || hc_import(*tname, stream, sptr) != IO_NORMAL)
758759
{
759760
MCresult->sets("file is not a stack");
760-
delete tname;
761761
return IO_ERROR;
762762
}
763763
}

engine/src/eps.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -721,23 +721,20 @@ void MCEPS::resetscale()
721721
yscale = xscale;
722722
}
723723
}
724-
/* WRAPPER */ bool MCEPS::import(MCStringRef p_filename, IO_handle p_stream)
725-
{
726-
return True == import(MCStringGetCString(p_filename), p_stream);
727-
}
728-
Boolean MCEPS::import(const char *fname, IO_handle stream)
724+
725+
Boolean MCEPS::import(MCStringRef fname, IO_handle stream)
729726
{
730727
size = (uint4)MCS_fsize(stream);
731728
delete postscript;
732729
postscript = new char[size + 1];
733730
if (IO_read(postscript, size, stream) != IO_NORMAL)
734731
return False;
735732
postscript[size] = '\0';
736-
const char *tname = strrchr(fname, PATH_SEPARATOR);
733+
const char *tname = strrchr(MCStringGetCString(fname), PATH_SEPARATOR);
737734
if (tname != NULL)
738735
tname += 1;
739736
else
740-
tname = fname;
737+
tname = MCStringGetCString(fname);
741738
setname_cstring(tname);
742739
setextents();
743740
rect.width = (uint2)(ex * xscale / xf);

engine/src/eps.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class MCEPS : public MCControl
6767
// Eps functions
6868
void setextents();
6969
void resetscale();
70-
bool import(MCStringRef p_filename, IO_handle p_stream);
71-
Boolean import(const char *fname, IO_handle stream);
70+
Boolean import(MCStringRef fname, IO_handle stream);
7271
};
7372
#endif

engine/src/exec-interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3372,7 +3372,7 @@ void MCInterfaceExecImportAudioClip(MCExecContext& ctxt, MCStringRef p_filename)
33723372
if (t_stream != NULL)
33733373
{
33743374
MCAudioClip *aptr = new MCAudioClip;
3375-
if (!aptr->import(MCStringGetCString(p_filename), t_stream))
3375+
if (!aptr->import(p_filename, t_stream))
33763376
{
33773377
ctxt . LegacyThrow(EE_IMPORT_CANTREAD);
33783378
delete aptr;
@@ -3398,7 +3398,7 @@ void MCInterfaceExecImportVideoClip(MCExecContext& ctxt, MCStringRef p_filename)
33983398
if (t_stream != NULL)
33993399
{
34003400
MCVideoClip *vptr = new MCVideoClip;
3401-
if (!vptr->import(MCStringGetCString(p_filename), t_stream))
3401+
if (!vptr->import(p_filename, t_stream))
34023402
{
34033403
ctxt . LegacyThrow(EE_IMPORT_CANTREAD);
34043404
delete vptr;

engine/src/exec-multimedia.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ void MCMultimediaExecPlayAudioClip(MCExecContext& ctxt, MCStack *p_target, int p
485485
}
486486
MCacptr = new MCAudioClip;
487487
MCacptr->setdisposable();
488-
if (!MCacptr->import(MCStringGetCString(p_clip), stream))
488+
if (!MCacptr->import(p_clip, stream))
489489
{
490490
MCS_close(stream);
491491
MCresult->sets("error reading audioClip");

engine/src/hc.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,18 +2405,14 @@ MCStack *MCHcstak::build()
24052405
return sptr;
24062406
}
24072407

2408-
/* WRAPPER */ IO_stat hc_import(MCStringRef p_name, IO_handle p_stream, MCStack *&p_stack)
2409-
{
2410-
return hc_import(MCStringGetCString(p_name), p_stream, *&p_stack);
2411-
}
24122408

2413-
IO_stat hc_import(const char *name, IO_handle stream, MCStack *&sptr)
2409+
IO_stat hc_import(MCStringRef name, IO_handle stream, MCStack *&sptr)
24142410
{
24152411
maxid = 0;
24162412
MCValueAssign(MChcstat, kMCEmptyString);
24172413

2418-
MCHcstak *hcstak = new MCHcstak(strclone(name));
2419-
hcstat_append("Loading stack %s...", name);
2414+
MCHcstak *hcstak = new MCHcstak(strdup(MCStringGetCString(name)));
2415+
hcstat_append("Loading stack %@...", name);
24202416
uint2 startlen = MCStringGetLength(MChcstat);
24212417
IO_stat stat;
24222418
if ((stat = hcstak->read(stream)) == IO_NORMAL)

engine/src/hc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,5 @@ class MCHcstak
403403
#endif
404404
};
405405

406-
extern IO_stat hc_import(MCStringRef p_name, IO_handle p_stream, MCStack *&p_stack);
407-
extern IO_stat hc_import(const char *name, IO_handle stream, MCStack *&sptr);
406+
extern IO_stat hc_import(MCStringRef p_name, IO_handle p_stream, MCStack *&p_sptr);
408407

engine/src/stacke.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ void MCStack::effectrect(const MCRectangle& p_area, Boolean& r_abort)
252252
{
253253
acptr = new MCAudioClip;
254254
acptr->setdisposable();
255-
if (!acptr->import(t_effects->sound, stream))
255+
if (!acptr->import(*t_sound, stream))
256256
{
257257
delete acptr;
258258
acptr = NULL;

0 commit comments

Comments
 (0)