home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Information / Digests / CSMP Digest / volume 3 / csmp-digest-v3-071 / doubleCR.1 < prev   
Encoding:
Text File  |  1995-12-31  |  44.6 KB  |  1,277 lines

  1. C.S.M.P. Digest             Mon, 28 Nov 94       Volume 3 : Issue 71
  2.  
  3. Today's Topics:
  4.  
  5.         (PPC) MDEF's in application code
  6.         Getting The PSN or Sig of AE Client
  7.         Is THINK Pascal dead?
  8.         Newbie Q:Why no DisposeHandle-ReleaseResource call?
  9.         Prograph 2.5
  10.         [Q] Programming with the QuickTime toolkit
  11.  
  12.  
  13.  
  14. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  15. (pottier@clipper.ens.fr).
  16.  
  17. The digest is a collection of article threads from the internet newsgroup
  18. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  19. regularly and want an archive of the discussions.  If you don't know what a
  20. newsgroup is, you probably don't have access to it.  Ask your systems
  21. administrator(s) for details.  If you don't have access to news, you may
  22. still be able to post messages to the group by using a mail server like
  23. anon.penet.fi (mail help@anon.penet.fi for more information).
  24.  
  25. Each issue of the digest contains one or more sets of articles (called
  26. threads), with each set corresponding to a 'discussion' of a particular
  27. subject.  The articles are not edited; all articles included in this digest
  28. are in their original posted form (as received by our news server at
  29. nef.ens.fr).  Article threads are not added to the digest until the last
  30. article added to the thread is at least two weeks old (this is to ensure that
  31. the thread is dead before adding it to the digest).  Article threads that
  32. consist of only one message are generally not included in the digest.
  33.  
  34. The digest is officially distributed by two means, by email and ftp.
  35.  
  36. If you want to receive the digest by mail, send email to listserv@ens.fr
  37. with no subject and one of the following commands as body:
  38.     help                        Sends you a summary of commands
  39.     subscribe csmp-digest Your Name    Adds you to the mailing list
  40.     signoff csmp-digest            Removes you from the list
  41. Once you have subscribed, you will automatically receive each new
  42. issue as it is created.
  43.  
  44. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  45. Questions related to the ftp site should be directed to
  46. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  47. digest are available there.
  48.  
  49. Also, the digests are available to WAIS users.  To search back issues
  50. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  51. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  52.  
  53.  
  54. -------------------------------------------------------
  55.  
  56. >From tcarsten@cayman.jpmorgan.com (Tom Carstensen)
  57. Subject: (PPC) MDEF's in application code
  58. Date: 25 Oct 1994 16:25:54 GMT
  59. Organization: J.P. Morgan & Co
  60.  
  61.  
  62. Before PPC, I would load a stub 'MDEF' and set the proc ptr:
  63.  
  64. typedef struct GenericMDEF {
  65.     short        JMPInstruction;
  66.     void        *defProc;
  67. } GenericMDEF;
  68.  
  69.    mdefHdl = GetResource('MDEF', 200);        /* sub def */
  70.    
  71.     (**((GenericMDEF **) mdefHdl)).defProc = myMdefProc;
  72.  
  73.  
  74. NOW, with PPC, I'm doing:
  75.  
  76.     (**((GenericMDEF **) mdefHdl)).defProc = NewMenuDefProc(myMdefProc);
  77.  
  78. which, with code warrior, creates a new routine descriptor, and sets it up
  79. appropriately.
  80.  
  81. This does not work.  I've read IM PowerPC System Software - but it's 
  82. somewhat confusing.  If I'm defining an accelerated resource, than I need
  83. a routine descriptor that tells what kind of code is ahead.  I thought
  84. the above should work, assuming the menu manager uses CallUniversalProc
  85. to call the menu definition procedure.
  86.  
  87. BTW - I'm using Code warrior in the above example.
  88.  
  89. Thanks for any hints.
  90.  
  91. Tom Carstensen
  92. --
  93. --                    ___
  94. Thomas Carstensen          //__/  60 Wall Street  17th Floor
  95.   tcarsten@jpmorgan.com      /__//      New York, NY  10260
  96.   tomc@digex.access.net      Morgan     212.648.4584
  97.  
  98. +++++++++++++++++++++++++++
  99.  
  100. >From d88-bli@xbyse.nada.kth.se (Bo Lindbergh)
  101. Date: 31 Oct 1994 16:31:38 GMT
  102. Organization: Royal Institute of Technology, Stockholm, Sweden
  103.  
  104. In article <TCARSTEN.94Oct25122554@cayman.jpmorgan.com> tcarsten@cayman.jpmorgan.com (Tom Carstensen) writes:
  105.  
  106. [mostly correct example of stub MDEF hacking deleted]
  107.  
  108. Try bracketing the struct definition with alignment pragmas:
  109.  
  110.     #if defined(powerc) || defined (__powerc)
  111.     #pragma options align=mac68k
  112.     #endif
  113.  
  114.     typedef struct GenericMDEF {
  115.         short       JMPInstruction;
  116.         void        *defProc;
  117.     } GenericMDEF;
  118.  
  119.     #if defined(powerc) || defined(__powerc)
  120.     #pragma options align=reset
  121.     #endif
  122.  
  123. Without them, you'll get two bytes of padding between the short and the
  124. void *.
  125.  
  126.  
  127. /Bo Lindbergh
  128.  
  129. +++++++++++++++++++++++++++
  130.  
  131. >From Graham@impro.demon.co.uk (Graham)
  132. Date: Wed, 9 Nov 1994 17:02:12 GMT
  133. Organization: N/A
  134.  
  135. I use the following routines to do this- on 68K macs it defaults to the
  136. old way of creating a stub for the jump, on PowerMacs it creates a
  137. routine dscriptor, so the same code works in all cases. try it.
  138.  
  139. #include    "MixedMode.h"
  140.  
  141. typedef struct
  142. {
  143.    short   Jmp;            // jmp instruction
  144.    void*   Routine;        // address to jump to
  145. }
  146. JmpInstructionTemplate;
  147.  
  148.  
  149. Handle    GetUniversalFunctionHandle(ProcPtr functionAddress,ProcInfoType
  150. pInfo);
  151. void     PatchJmpInstruction(void* patchAddress, void* jumpAddress);
  152.  
  153.  
  154.  
  155. Handle    GetUniversalFunctionHandle(ProcPtr functionAddress,ProcInfoType
  156. pInfo)
  157. {
  158.     Handle                pHNullProc = NULL;
  159.     ISAType                isa;
  160.     UniversalProcPtr     axDEFUPP;
  161.     
  162.     isa = GetCurrentISA();
  163.     
  164.     if (isa == kPowerPCISA)
  165.     {
  166.        pHNullProc = NewHandle(sizeof(RoutineDescriptor));
  167.        axDEFUPP = NewRoutineDescriptor(functionAddress,pInfo,isa);
  168.        BlockMove(axDEFUPP, *pHNullProc, sizeof(RoutineDescriptor));
  169.        DisposeRoutineDescriptor(axDEFUPP);
  170.     }
  171.     else
  172.     {
  173.        pHNullProc = NewHandle(sizeof(JmpInstructionTemplate));
  174.        PatchJmpInstruction(*pHNullProc, (void*)functionAddress);
  175.     }
  176.     return(pHNullProc);
  177. }
  178.  
  179.  
  180. void PatchJmpInstruction(void* patchAddress, void* jumpAddress)
  181. {
  182.    JmpInstructionTemplate* aJmpInstructionPtr;
  183.    
  184.    aJmpInstructionPtr = (JmpInstructionTemplate *) patchAddress;
  185.    aJmpInstructionPtr->Jmp = 0x4EF9;
  186.    aJmpInstructionPtr->Routine = jumpAddress;
  187. }
  188.  
  189.  
  190. You have to pass the proc info type for the routine, which youll have
  191. to look up in the universal headers, and the proc ptr to your MDEF
  192. function, it returns a handle which you simply stuff into the relevant
  193. defProc field.
  194. Apple DTS gave me the bones for this, so it even has the "official"
  195. stamp of approval!
  196.  
  197. ************************************************************************
  198. *
  199. MHROTD, Graham.  (Sorry, I haven't got time to think of
  200.                                        a witty signature)
  201.  
  202. +++++++++++++++++++++++++++
  203.  
  204. >From rang@winternet.com (Anton Rang)
  205. Date: 10 Nov 1994 14:33:59 GMT
  206. Organization: Trillium Research, Inc.
  207.  
  208. In article <Cz0FBo.FvL@demon.co.uk> Graham@impro.demon.co.uk (Graham) writes:
  209. >I use the following routines to do this- on 68K macs it defaults to the
  210. >old way of creating a stub for the jump, [...]
  211.  
  212.   Don't forget the posting last month from someone who had created a
  213. six-byte handle to hold their 'JMP $xxx' instruction and found that
  214. when the handle was moved by the memory manager, the i-cache wasn't
  215. flushed 'cause the handle was too small.  :)
  216. --
  217. Anton Rang (rang@winternet.com)
  218.  
  219. +++++++++++++++++++++++++++
  220.  
  221. >From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  222. Date: Fri, 11 Nov 1994 05:15:43 +1200 (NZST)
  223. Organization: (none)
  224.  
  225. rang@winternet.com (Anton Rang) writes:
  226. > In article <Cz0FBo.FvL@demon.co.uk> Graham@impro.demon.co.uk (Graham) writes:
  227. > >I use the following routines to do this- on 68K macs it defaults to the
  228. > >old way of creating a stub for the jump, [...]
  229. >   Don't forget the posting last month from someone who had created a
  230. > six-byte handle to hold their 'JMP $xxx' instruction and found that
  231. > when the handle was moved by the memory manager, the i-cache wasn't
  232. > flushed 'cause the handle was too small.  :)
  233.  
  234. I missed that one.
  235.  
  236. But I've never understood why people use the "six-byte resource" trick
  237. when it's so easy to use a "ten-byte resource" trick that is I-cache
  238. safe.
  239.  
  240. -- Bruce
  241.  
  242. ---------------------------
  243.  
  244. >From Jonathan Gary <jgary@ssd.kodak.com>
  245. Subject: Getting The PSN or Sig of AE Client
  246. Date: Tue, 8 Nov 1994 19:59:50 GMT
  247. Organization: Eastman Kodak
  248.  
  249. I'm trying to get the the PSN of the process that sends me an AE. I can
  250. get the
  251. address from the event, but how do I get at the PSN?
  252.  
  253. +++++++++++++++++++++++++++
  254.  
  255. >From wysocki@netcom.com (Chris Wysocki)
  256. Date: Fri, 11 Nov 1994 06:52:40 GMT
  257. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  258.  
  259. In article <Cyysvr.2yK@newsserver.pixel.kodak.com>,
  260. Jonathan Gary  <jgary@ssd.kodak.com> wrote:
  261.  
  262. >I'm trying to get the the PSN of the process that sends me an AE. I can
  263. >get the address from the event, but how do I get at the PSN?
  264.  
  265. The following routine should work:
  266.  
  267. // ----------------------------------------------------------------------
  268. // CAppleEvent::GetProcessSerialNumber
  269. // ----------------------------------------------------------------------
  270.  
  271. void CAppleEvent::GetProcessSerialNumber(ProcessSerialNumber& thePSN) const
  272. {
  273.     DescType actualType;
  274.     Size actualSize;
  275.     TargetID theTargetID;
  276.     
  277.     FailOSErr(AEGetAttributePtr(&fMessage, keyAddressAttr, typeTargetID,
  278.               &actualType, &theTargetID, sizeof(theTargetID), &actualSize));
  279.     FailOSErr(GetProcessSerialNumberFromPortName(&theTargetID.name, &thePSN));
  280. }
  281.  
  282. I believe that the sending process needs to be running on the same
  283. machine as the target process for this to work, since PSNs are only
  284. unique to a particular machine.
  285.  
  286. Chris.
  287.  
  288.  
  289.  
  290. ---------------------------
  291.  
  292. >From bernier@dialup.francenet.fr (Jean-Yves Bernier)
  293. Subject: Is THINK Pascal dead?
  294. Date: Fri, 04 Nov 1994 11:14:55 +0100
  295. Organization: SPECTRA Soft
  296.  
  297.  
  298. Excuse-me if the topic has already been discussed here (I am a newcomer)
  299. but I have see no such thing in the 100 last articles, and I could not
  300. figure a more suitable group.
  301.  
  302. I am one of the many THINK Pascal users left in the dark by Symantec, after
  303. the PowerPC. I have thousand of lines of Pascal to port to the PowerPC and
  304. I don't want to loose the advantages of THINK Pascal (the wonderful
  305. source-level debugger, among others).
  306.  
  307. What is the official status of THINK Pascal? Will ever exist a PowerPC
  308. version? Is it dead? I am a registered user, but I receive absolutely no
  309. information from Symantec. Have they e-mail support?
  310.  
  311. Thanks.
  312.  
  313.  
  314.  
  315. - -------------------------
  316. Jean-Yves Bernier - SPECTRA
  317. bernier@dialup.francenet.fr
  318. - -------------------------
  319.  
  320.  
  321. +++++++++++++++++++++++++++
  322.  
  323. >From nick+@pitt.edu ( nick.c )
  324. Date: Fri, 04 Nov 1994 10:49:30 -0500
  325. Organization: The Pitt, Chemistry
  326.  
  327.  
  328.    Yes, very dead.  I would not expect any udates or new versions.
  329.      That said a lot of folks still use it.  It should be possible to
  330.      port your code to CodeWarrrior Pascal (one of the compilers 
  331.      included with the CodeWarrior Gold or Bronze CD).  The Gold
  332.      version runs native (fat - I think) and compiles for PPC.
  333.  
  334.  
  335.  Internet: nick+@pitt.edu            _/   _/  _/  _/_/_/   _/   _/  
  336.    eWorld: nick                     _/_/ _/  _/  _/   _/  _/_/_/ 
  337.       CIS: 71232,766               _/ _/_/  _/  _/       _/ _/    
  338.      http://www.pitt.edu/~nick/   _/   _/  _/   _/_/_/  _/   _/     
  339.                     
  340.  
  341. +++++++++++++++++++++++++++
  342.  
  343. >From lbotez@picard.cs.wisc.edu (Lynda Botez)
  344. Date: 6 Nov 1994 17:36:45 GMT
  345. Organization: U of Wisconsin CS Dept
  346.  
  347. Er, Think Pascal isn't really dead, it's just comatose.
  348.  
  349. If you need to convert stuff over to the powerpc, though, I would suggest
  350. you look into CodeWarrior. They actually have a pascal powerpc compiler
  351. (its in beta, but I would imagine it works pretty good)... and I doubt
  352. Symantec will bother with Think Pascal.  
  353.  
  354. Also, I think most of the programmers that developed Think Pascal are now
  355. working for Metrowerks (the company that owns CodeWarrior); so you can
  356. imagine that Think Pascal is not long for this world..
  357.  
  358.  
  359. +++++++++++++++++++++++++++
  360.  
  361. >From johnmce@world.std.com (John McEnerney)
  362. Date: Sun, 6 Nov 1994 19:11:16 GMT
  363. Organization: The World Public Access UNIX, Brookline, MA
  364.  
  365. lbotez@picard.cs.wisc.edu (Lynda Botez) writes:
  366.  
  367. >Also, I think most of the programmers that developed Think Pascal are now
  368. >working for Metrowerks (the company that owns CodeWarrior); so you can
  369. >imagine that Think Pascal is not long for this world..
  370.  
  371. For anyone who's interested, the programmers who developed THINK Pascal are:
  372.  
  373. Me (at Metrowerks these days)
  374. David Neal (director of Symantec's Mac language group)
  375. Rich Siegel (of Bare Bones software fame)
  376. Pete Maruhnic (author of CA's Realizer for Windows)
  377.  
  378. So only one of us ended up at Metrowerks. Still, the product is pretty 
  379. much dead wrt PowerPC, as much my fault as anyone else's: a lot of the 
  380. code was written in assembly language, the context-switch mechanism would 
  381. probably not survive a port to the PPC, etc. It is rumored that Symantec 
  382. still has plans in the Pascal arena (but as you might imagine they don't 
  383. tell me that sort of thing anymore)
  384.  
  385. -- John McEnerney, Metrowerks PowerPC Product Architect
  386.  
  387.  
  388. +++++++++++++++++++++++++++
  389.  
  390. >From RobTerrell@vmedia.com (Rob Terrell)
  391. Date: 6 Nov 1994 21:26:52 GMT
  392. Organization: Jecta Development Corp.
  393.  
  394. John McEnerney said:
  395. > So only one of us ended up at Metrowerks. Still, the product is pretty
  396. > much dead wrt PowerPC, as much my fault as anyone else's: a lot of the
  397. > code was written in assembly language, the context-switch mechanism
  398. > would probably not survive a port to the PPC, etc. It is rumored that
  399. > Symantec still has plans in the Pascal arena (but as you might imagine
  400. > they don't tell me that sort of thing anymore)
  401.  
  402. Yeah, there was a rumor in MacWeek regarding this. I doubt it. The
  403. Symantec folks were real arrogant on the topic of the death of Pascal
  404. at the WWDC.
  405.  
  406. So, John, what's happening with Metrowerks' Pascal? I would totally
  407. abandon Think Pascal if CW supported an Object Pascal.
  408.  
  409.  
  410. Rob
  411.  
  412. +++++++++++++++++++++++++++
  413.  
  414. >From siegel@netcom.com (Rich Siegel)
  415. Date: Mon, 7 Nov 1994 17:57:38 GMT
  416. Organization: Bare Bones Software
  417.  
  418. In article <39j47d$gfq@spool.cs.wisc.edu> lbotez@picard.cs.wisc.edu (Lynda Botez) writes:
  419. >
  420. >Also, I think most of the programmers that developed Think Pascal are now
  421. >working for Metrowerks (the company that owns CodeWarrior); so you can
  422. >imagine that Think Pascal is not long for this world..
  423. >
  424.  
  425. That is not true.
  426.  
  427. Of the four people most directly involved in the development of THINK Pascal:
  428.  
  429. - one is at Metrowerks
  430. - one is director of the development tools group at Symantec
  431. - one is off doing something else (I don't recall where)
  432. - one is president and CEO of his own software company
  433.  
  434. When this question was recently posted to Symantec personnel at a
  435. recent BCS MacTechGroup meeting, the response was (basically) that
  436. they plan to work with certain third-party compiler makers to produce
  437. a Pascal solution for Rainbow (their new development environment that
  438. is currently under development).
  439.  
  440. R.
  441. -- 
  442. Rich Siegel % siegel@netcom.com    % President & CEO, Bare Bones Software Inc.
  443. --> For information about BBEdit, finger bbedit@world.std.com <--
  444.  
  445. +++++++++++++++++++++++++++
  446.  
  447. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  448. Date: Tue, 08 Nov 1994 11:23:59 +0800
  449. Organization: NCRPDA, Curtin University
  450.  
  451. In article <39jhms$ja@redstone.interpath.net>, RobTerrell@vmedia.com (Rob
  452. Terrell) wrote:
  453.  
  454. >Yeah, there was a rumor in MacWeek regarding this. I doubt it. The
  455. >Symantec folks were real arrogant on the topic of the death of Pascal
  456. >at the WWDC.
  457.  
  458. A Symantec fellow told me that the rumour is crap.  There is no Symantec
  459. plans for a PPC pascal compiler.
  460.  
  461. >So, John, what's happening with Metrowerks' Pascal? I would totally
  462. >abandon Think Pascal if CW supported an Object Pascal.
  463.  
  464. You and me both.  I'm strugling on with THINK Pascal waiting for objects
  465. to show up in MW Pascal.  MW Pascal is scheduled to go 1.0 without objects
  466. in January (CW5), and MW Object Pascal is scheduled for CW6 in May (it
  467. better be there, otherwise Greg will have to face down some heckling at
  468. the WWDC :-).
  469.  
  470. The best you can do to help is to a) make sure MW knows that Object Pascal
  471. is what you need; b) buy MW CW; c) feed any bugs back to the MW bug report
  472. line as precisely as you can.  That's what i've been doing, an Marcel has
  473. been very good at fixing bugs (such that basically every bug I have
  474. reported has been fixed by the next version).
  475.  
  476. Enjoy,
  477.    Peter.
  478. -- 
  479. Peter N Lewis <peter.lewis@info.curtin.edu.au> - Macintosh TCP fingerpainter
  480. FTP my programs from redback.cs.uwa.edu.au:Others/PeterLewis/ or
  481. amug.org:pub/peterlewis/ or nic.switch.ch:software/mac/peterlewis/
  482.  
  483. +++++++++++++++++++++++++++
  484.  
  485. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  486. Date: 8 Nov 1994 08:17:05 GMT
  487. Organization: (none)
  488.  
  489. johnmce@world.std.com (John McEnerney) writes:
  490.  
  491. >lbotez@picard.cs.wisc.edu (Lynda Botez) writes:
  492.  
  493. >>Also, I think most of the programmers that developed Think Pascal are now
  494. >>working for Metrowerks (the company that owns CodeWarrior); so you can
  495. >>imagine that Think Pascal is not long for this world..
  496.  
  497. >For anyone who's interested, the programmers who developed THINK Pascal are:
  498.  
  499. >Me (at Metrowerks these days)
  500. >David Neal (director of Symantec's Mac language group)
  501. >Rich Siegel (of Bare Bones software fame)
  502. >Pete Maruhnic (author of CA's Realizer for Windows)
  503.  
  504. >So only one of us ended up at Metrowerks. Still, the product is pretty 
  505. >much dead wrt PowerPC, as much my fault as anyone else's: a lot of the 
  506. >code was written in assembly language, the context-switch mechanism would 
  507. >probably not survive a port to the PPC, etc.
  508.  
  509. MetroWerks Pascal is sort of ok as replacement. It doesn't have Instant,
  510. it's debugger is far from the elegance of Lightsbug, but it works.
  511.  
  512. But I wonder, why wasn't the debugger integrated with the compiler?
  513. No flames, but I really didn't think a Think Pascal decveloper would
  514. let so many Think C flaw through.
  515.  
  516. Why mimick the clumsy Think C when Think Pascal is so much better (language
  517. issues aside). Imagine a system where you step and set breakpoints in the
  518. editor, while the editor and the debugger communicated with Apple Events.
  519. I can't see the problem, as long as we don't demand Instant.
  520.  
  521. >It is rumored that Symantec 
  522. >still has plans in the Pascal arena (but as you might imagine they don't 
  523. >tell me that sort of thing anymore)
  524.  
  525. Long ago, I bought Think C. It took several years before I got any feedback
  526. - probably that was after buying Think Pascal. When Symantec now tries to
  527. convince me that I should get SC++, I bought CodeWarrior instead. Much better
  528. C environment, and a future for my Pascal code.
  529.  
  530. Fortunately, my Think Pascal isn't dead yet. I guess it will stop working
  531. somewhere between 7.5 and 8.0 or so, but not yet.
  532.  
  533. --
  534. - -
  535. Ingemar Ragnemalm, PhD
  536. Image processing, Mac shareware games
  537. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  538.  
  539. +++++++++++++++++++++++++++
  540.  
  541. >From palais@binah.cc.brandeis.edu
  542. Date: 12 Nov 1994 19:55:02 GMT
  543. Organization: Brandeis University
  544.  
  545. One should also mention that Language Systems is making a very
  546. credible effort at developing an industrial strength Pascal
  547. compiler. Unlike CodeWarrior, the LS version runs under
  548. MPW, which you may or may not find an advantage. But for those
  549. of us who got hooked on Object Pascal before Apple pulled the
  550. rug out from under us, it is the only way to go, since it does
  551. compile Object Pascal while CodeWarrior does not.
  552.  
  553.    R. Palais
  554.  
  555. ---------------------------
  556.  
  557. >From roxanne@bnr.ca (Roxanne Friesen)
  558. Subject: Newbie Q:Why no DisposeHandle-ReleaseResource call?
  559. Date: Mon, 07 Nov 1994 11:53:32 -0400
  560. Organization: Bell-Northern Research Ltd.
  561.  
  562. I'm trying to get a better *handle* on when handles should be disposed of
  563. and resources released.
  564.  
  565. In the first sample function below, I would have thought that the alias
  566. handle should be disposed of once the resource has been written to the
  567. resource file but this function doesn't do that.  Am I wrong, is this
  568. function wrong, or is it simply not necessary, in this case, to dispose of
  569. the handle? (For the sake of simplifying the samples, assume I'm writing
  570. to my apps own resource fork and not a prefs file of some kind ... or does
  571. that make a difference?)
  572.  
  573. FUNCTION doCreateAlias(fileSpec:FSSpec):OSErr;
  574. VAR
  575.   alisHandle : AliasHandle;
  576.   result : OSErr;
  577.  
  578. BEGIN
  579.   result := NewAlias(NIL, fileSpec, alisHandle);
  580.   IF (alisHandle <> NIL) THEN BEGIN
  581.     AddResource(Handle(alisHandle), rAliasType, 128, 'File Alias');
  582.     result := ResError;
  583.  
  584.     IF (result = NoErr) THEN BEGIN
  585.       WriteResource(Handle(alisHandle));
  586.       result := ResError;
  587.     END;
  588.   END;
  589.  
  590.   doCreateAlias := result;
  591. END; {doCreateAlias}
  592.  
  593.  
  594. In the second sample function below, again, I would have thought that the
  595. resource should be released once I'm finished with it but, again, this
  596. function doesn't do that.  Am I wrong, is this function wrong, or is it
  597. simply not necessary, in this case, to release the resource?
  598.  
  599. FUNCTION setResStr(rsrcType:ResType; rsrcID:INTEGER; content:STR255):OSErr;
  600. VAR   
  601.   rsrcHdl : Handle;
  602.   result  : OSErr;
  603.          
  604. BEGIN
  605.   rsrcHdl := GetResource(rsrcType, rsrcID);
  606.   result := ResError;
  607.          
  608.   IF (rsrcHdl <> NIL) THEN BEGIN
  609.     SetHandleSize(rsrcHdl, LENGTH(content) + 1);          
  610.     BlockMove(@content, rsrcHdl^, LENGTH(content) + 1); 
  611.     ChangedResource(rsrcHdl);
  612.     result := ResError;                                              
  613.  
  614.     IF (result = NoErr) THEN BEGIN
  615.       WriteResource(rsrcHdl);
  616.       result := ResError;
  617.     END;                                       
  618.   END;
  619.   
  620.   setResStr :=
  621. result;                                                                    
  622.  
  623. END; {setResStr}
  624.  
  625.  
  626. Any help, hints, tips, suggestions would be appreciated.
  627. Roxanne.
  628.  
  629. -- 
  630. Roxanne Friesen
  631. Bell-Northern Research Ltd.
  632. roxanne@bnr.ca
  633.  
  634. +++++++++++++++++++++++++++
  635.  
  636. >From jones.794@osu.edu (Matt Jones)
  637. Date: Mon, 07 Nov 1994 19:15:24 +0500
  638. Organization: The Ohio State University
  639.  
  640. In article <roxanne-0711941153320001@47.221.33.54>, roxanne@bnr.ca (Roxanne
  641. Friesen) wrote:
  642.  
  643. > I'm trying to get a better *handle* on when handles should be disposed of
  644. > and resources released.
  645. > In the first sample function below, I would have thought that the alias
  646. > handle should be disposed of once the resource has been written to the
  647. > resource file but this function doesn't do that.  Am I wrong, is this
  648. > function wrong, or is it simply not necessary, in this case, to dispose of
  649. > the handle? (For the sake of simplifying the samples, assume I'm writing
  650. > to my apps own resource fork and not a prefs file of some kind ... or does
  651. > that make a difference?)
  652. > FUNCTION doCreateAlias(fileSpec:FSSpec):OSErr;
  653. > VAR
  654. >   alisHandle : AliasHandle;
  655. >   result : OSErr;
  656. > BEGIN
  657. >   result := NewAlias(NIL, fileSpec, alisHandle);
  658. >   IF (alisHandle <> NIL) THEN BEGIN
  659. >     AddResource(Handle(alisHandle), rAliasType, 128, 'File Alias');
  660. >     result := ResError;
  661. >     IF (result = NoErr) THEN BEGIN
  662. >       WriteResource(Handle(alisHandle));
  663. >       result := ResError;
  664. >     END;
  665. >   END;
  666. >  
  667. >   doCreateAlias := result;
  668. > END; {doCreateAlias}
  669. > In the second sample function below, again, I would have thought that the
  670. > resource should be released once I'm finished with it but, again, this
  671. > function doesn't do that.  Am I wrong, is this function wrong, or is it
  672. > simply not necessary, in this case, to release the resource?
  673. > FUNCTION setResStr(rsrcType:ResType; rsrcID:INTEGER; content:STR255):OSErr;
  674. > VAR   
  675. >   rsrcHdl : Handle;
  676. >   result  : OSErr;
  677. >          
  678. > BEGIN
  679. >   rsrcHdl := GetResource(rsrcType, rsrcID);
  680. >   result := ResError;
  681. >          
  682. >   IF (rsrcHdl <> NIL) THEN BEGIN
  683. >     SetHandleSize(rsrcHdl, LENGTH(content) + 1);          
  684. >     BlockMove(@content, rsrcHdl^, LENGTH(content) + 1); 
  685. >     ChangedResource(rsrcHdl);
  686. >     result := ResError;                                              
  687. >     IF (result = NoErr) THEN BEGIN
  688. >       WriteResource(rsrcHdl);
  689. >       result := ResError;
  690. >     END;                                       
  691. >   END;
  692. >   
  693. >   setResStr :=
  694. > result;                                                                    
  695. > END; {setResStr}
  696. > Any help, hints, tips, suggestions would be appreciated.
  697. > Roxanne.
  698. > -- 
  699. > Roxanne Friesen
  700. > Bell-Northern Research Ltd.
  701. > roxanne@bnr.ca
  702.  
  703. If your compiler is any good, it checks if any of the handles in local
  704. storage are still attached. ( I think ) Otherwise, you would be unable to
  705. find the handles to dispose of them later. However, this is tricky internal
  706. compiler stuff, much like pre-initialized variables. I always explicitly
  707. dispose of handles since the moment you assume your compiler does it for
  708. you, it stops.
  709. - ------------------------------------------------------------------------
  710. | it won't give up it wants me dead | |\  | | |  /| | jones.794          |
  711. | goddamn this noise inside my head | | \ | | | / | |    @ohio-state.edu |
  712. |                   Trent Reznor    | |  \| | |/  | | Stop the Clipper!  |
  713. - ------------------------------------------------------------------------
  714.  
  715. +++++++++++++++++++++++++++
  716.  
  717. >From sigurasg@rhi.hi.is (Sigurdur Asgeirsson)
  718. Date: Tue, 08 Nov 1994 09:49:56 -0100
  719. Organization: University of Iceland
  720.  
  721. In article <roxanne-0711941153320001@47.221.33.54>, roxanne@bnr.ca
  722. (Roxanne Friesen) wrote:
  723.  
  724. [snip]
  725.  
  726. > In the first sample function below, I would have thought that the alias
  727. > handle should be disposed of once the resource has been written to the
  728. > resource file but this function doesn't do that.  Am I wrong, is this
  729. > function wrong, or is it simply not necessary, in this case, to dispose of
  730. > the handle?
  731.  
  732. [snip]
  733.  
  734. > FUNCTION doCreateAlias(fileSpec:FSSpec):OSErr;
  735. > VAR
  736. >   alisHandle : AliasHandle;
  737. >   result : OSErr;
  738. > BEGIN
  739. >   result := NewAlias(NIL, fileSpec, alisHandle);
  740. >   IF (alisHandle <> NIL) THEN BEGIN
  741. >     AddResource(Handle(alisHandle), rAliasType, 128, 'File Alias');
  742. >     result := ResError;
  743. >     IF (result = NoErr) THEN BEGIN
  744. >       WriteResource(Handle(alisHandle));
  745. >       result := ResError;
  746. >     END;
  747. >   END;
  748. >  
  749. >   doCreateAlias := result;
  750. > END; {doCreateAlias}
  751. [second code example snipped for brevity]
  752.  
  753.   There is no need in this case to dispose the handle, unless the
  754. AddResource call fails, in which case the handle should be disposed of
  755. with DisposeHandle (since the handle is not a resource if the call fails -
  756. see below). 
  757.   In general there is no need to dispose of resource handles, because they
  758. are the responsibility of the Resource Manager. Resource handles must
  759. NEVER be disposed of via DisposeHandle, since that confuses the Resource
  760. Manager and you end up with heap corruption. (The Resource Manager does a
  761. DisposeHandle for all loaded resources in a resource file when the
  762. resource file is closed). 
  763.   If you feel the need to dispose of a resource handle when you're done
  764. with it (maybe because you'd like to free the memory that the resource is
  765. using) do it with the ReleaseResource call. It's generally better though
  766. to mark your resources as purgeable and leave it up to the Memory and
  767. Resource Managers to free the memory when needed. Be sure however, to use
  768. LoadResource in this case and mark the resource unpurgeable (or lock it)
  769. if you need to be sure that it doesn't "go away" while you're using it.
  770.  
  771. -- 
  772. Sigurdur Asgeirsson    | "Well you know, C isn't that hard, void (*(*f[])())()
  773. Kambasel 26            | for instance declares f as an array of unspecified
  774. 109 Reykjavik, Iceland | size, of pointers to functions that return pointers to
  775. sigurasg@rhi.hi.is     | functions that return void... I think"
  776.  
  777. +++++++++++++++++++++++++++
  778.  
  779. >From johns@efn.org (John Selhorst)
  780. Date: Tue, 8 Nov 1994 14:43:55 GMT
  781. Organization: hisself
  782.  
  783. In article <jones.794-071194191524@slip1-12.acs.ohio-state.edu>,
  784. jones.794@osu.edu (Matt Jones) wrote:
  785.  
  786. [ stuff from Roxanne deleted ]
  787.  
  788. > If your compiler is any good, it checks if any of the handles in local
  789. > storage are still attached. ( I think ) Otherwise, you would be unable to
  790. > find the handles to dispose of them later. However, this is tricky internal
  791. > compiler stuff, much like pre-initialized variables. I always explicitly
  792. > dispose of handles since the moment you assume your compiler does it for
  793. > you, it stops.
  794.  
  795. Wrong.  This is not fancy compiler stuff.  The handles Roxanne was
  796. referring to belong to the resource manager and the resource manager will
  797. dispose of them when it needs to.
  798.  
  799. Johnny
  800.  
  801. johns@efn.org
  802.  
  803. +++++++++++++++++++++++++++
  804.  
  805. >From Scott.Francis@SuperMac.com (eScott Francisternet alt.bbs.lists alt.bbs.lists.d alt.bbs.majorbbs alt.bbs.metal alt.bbs.pcboard alt.bbs.pcbuucp alt.bbs.renegade alt.bbs.searchlight alt.bbs.unixbbs alt.bbs.unixbbs.uniboard alt.bbs.uupcb alt.bbs.waffle alt.bbs.wildcat alt.beadworld alt.)
  806. Date: Tue, 08 Nov 1994 10:49:31 -0800
  807. Organization: Radius
  808.  
  809. In article <roxanne-0711941153320001@47.221.33.54>, roxanne@bnr.ca
  810. (Roxanne Friesen) wrote:
  811.  
  812. > I'm trying to get a better *handle* on when handles should be disposed of
  813. > and resources released.
  814.  
  815. In both cases the resource handle should be released with
  816. ReleaseResource().  Many programmers have not always done so, particularly
  817. when building apps since the res file will be closed (and all resources
  818. from that file released) when the app quits.  While calling
  819. ReleaseResource() is then not strictly necessary, it is good form, and can
  820. help some types of memory problems.
  821.  
  822. Another dimension to the problem:  If you will be refetching resources
  823. again and again, you might want to make the preloadable, and *not* release
  824. them.  This will keep them in memory and speed up the calls to
  825. GetResource().
  826.  
  827. --Scott
  828.  
  829. +++++++++++++++++++++++++++
  830.  
  831. >From mxmora@unix.sri.com (Matt Mora)
  832. Date: 8 Nov 1994 15:39:07 -0800
  833. Organization: SRI International, Menlo Park, CA
  834.  
  835. In article <roxanne-0711941153320001@47.221.33.54> roxanne@bnr.ca (Roxanne Friesen) writes:
  836. >I'm trying to get a better *handle* on when handles should be disposed of
  837. >and resources released.
  838.  
  839. Simple.  Handle are disposed and Resources are released.
  840.  
  841. >BEGIN
  842. >  result := NewAlias(NIL, fileSpec, alisHandle);
  843. >  IF (alisHandle <> NIL) THEN BEGIN
  844. >    AddResource(Handle(alisHandle), rAliasType, 128, 'File Alias');
  845.  
  846. At this point aliasHandle is no longer a plain ol handle. After you
  847. call Addresource the handle you supply becomes a ResourceHandle.
  848.  
  849. If its a resource handle what are you supposed to do with it? Yep
  850. ReleaseResource. 
  851.  
  852. DON'T CALL DISPOSEHANDLE AFTER YOU CALLED ADDRESOURCE ON THAT HANDLE.
  853.  
  854. >
  855. >In the second sample function below, again, I would have thought that the
  856. >resource should be released once I'm finished with it but, again, this
  857. >function doesn't do that.  Am I wrong, is this function wrong, or is it
  858. >simply not necessary, in this case, to release the resource?
  859.  
  860.  
  861. In the example that was shown, you don't have to call release resource
  862. if you might use that resource again. If you don't want it around
  863. go ahead and call release resource.
  864.  
  865. If the resource file is closed, the Resource handles will be released.
  866.  
  867. Xavier
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879. -- 
  880. ___________________________________________________________
  881. Matthew Xavier Mora                       Matt_Mora@sri.com
  882. SRI International                       mxmora@unix.sri.com
  883. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  884.  
  885. +++++++++++++++++++++++++++
  886.  
  887. >From mxmora@unix.sri.com (Matt Mora)
  888. Date: 8 Nov 1994 15:40:13 -0800
  889. Organization: SRI International, Menlo Park, CA
  890.  
  891. In article <jones.794-071194191524@slip1-12.acs.ohio-state.edu> jones.794@osu.edu (Matt Jones) writes:
  892.  
  893. >If your compiler is any good, it checks if any of the handles in local
  894. >storage are still attached. ( I think ) Otherwise, you would be unable to
  895. >find the handles to dispose of them later. However, this is tricky internal
  896. >compiler stuff, much like pre-initialized variables. I always explicitly
  897. >dispose of handles since the moment you assume your compiler does it for
  898. >you, it stops.
  899.  
  900.  
  901. Huh?
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909. Xavier
  910.  
  911. -- 
  912. ___________________________________________________________
  913. Matthew Xavier Mora                       Matt_Mora@sri.com
  914. SRI International                       mxmora@unix.sri.com
  915. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  916.  
  917. +++++++++++++++++++++++++++
  918.  
  919. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  920. Date: Wed, 09 Nov 1994 11:27:40 +0800
  921. Organization: NCRPDA, Curtin University
  922.  
  923. In article <roxanne-0711941153320001@47.221.33.54>, roxanne@bnr.ca
  924. (Roxanne Friesen) wrote:
  925.  
  926. >In the first sample function below, I would have thought that the alias
  927. >handle should be disposed of once the resource has been written to the
  928. >resource file but this function doesn't do that.  Am I wrong, is this
  929. >function wrong, or is it simply not necessary, in this case, to dispose of
  930. >the handle? (For the sake of simplifying the samples, assume I'm writing
  931. >to my apps own resource fork and not a prefs file of some kind ... or does
  932. >that make a difference?)
  933.  
  934. First off, you must never call DisposeHandle on a resource handle, nor
  935. ReleaseResource on a non-resource handle.  Bad THings(tm) will happen. 
  936. There are a pair fo inits (DoubleTrouble and DisposeResource or some such)
  937. that catch bugs like this, available from ftp.apple.com:/mac/dts/ I
  938. believe.
  939.  
  940. Second, when you write a resource to a file, it's not necessayr to release
  941. it afterwards, since it will be automatically released when the resource
  942. file is closed (which tends to be quite soon afterwards anyway).  Also,
  943. you can set the handle to be purged (HPurge) and then it'll be released
  944. when memory is needed, but not until.  Make sure to call GetResource again
  945. to reload the (possibly) purged handle before reusing it.
  946.  
  947. Enjoy,
  948.    Peter.
  949. -- 
  950. Peter N Lewis <peter.lewis@info.curtin.edu.au> - Macintosh TCP fingerpainter
  951.  
  952. ---------------------------
  953.  
  954. >From fallside@rahul.net (David C. Fallside)
  955. Subject: Prograph 2.5
  956. Date: 10 Nov 1994 06:39:19 GMT
  957. Organization: a2i network
  958.  
  959. I recently accepted a $59.95 offer for Prograph 2.5. The promo blurb "Very
  960. High Level Pictorial Object-Oriented Programming Environment" seems to be
  961. accurate, and having worked my way through half of the tutorials, it seems
  962. that it should be possible to develop complex applications. But I'm not a
  963. professional programmer, and haven't found anyone else who has ever heard
  964. of Prograph. Any comments from Netland? Thank you.
  965. David
  966.  
  967. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  968. I'd rather be on the river ....
  969. K1/4, SQRT/3
  970. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  971.  
  972. +++++++++++++++++++++++++++
  973.  
  974. >From nick+@pitt.edu ( nick.c )
  975. Date: Thu, 10 Nov 1994 11:42:38 -0500
  976. Organization: The Pitt, Chemistry
  977.  
  978. In article <fallside-0911942243270001@382.rahul.net>, fallside@rahul.net
  979. (David C. Fallside) wrote:
  980.  
  981. > I recently accepted a $59.95 offer for Prograph 2.5. The promo blurb "Very
  982. > High Level Pictorial Object-Oriented Programming Environment" seems to be
  983. > accurate, and having worked my way through half of the tutorials, it seems
  984. > that it should be possible to develop complex applications. But I'm not a
  985. > professional programmer, and haven't found anyone else who has ever heard
  986. > of Prograph. Any comments from Netland? Thank you.
  987.  
  988.  
  989.    Prograph was my first environment (not counting hypercard), and
  990.       I consider that a mistake.  Don't get me wrong - prograph is
  991.       both a great concept and a great engineering feet.  I still
  992.       argue that inconic input will be the way we'll all code 10 years
  993.       from now (or sooner).  However, prograph is a dual mode environment,
  994.       it allows you to program at a low level, but defaults to a high
  995.       level environment by use of it's integrated class library.
  996.       As a result, and with the added factor there is very little
  997.       sample code or literature, it's hard to tell where the library
  998.       ends and the toolbox begins.  You can generate nice (albeit
  999.       large and slow) apps with 2.5.2 - nicer ones with CPX - but
  1000.       you won't learn anything about Mac programming with it.
  1001.  
  1002.    To learn how to program the Mac you'll need to learn a classical
  1003.       low level language (Pascal or C would be best), and when you do
  1004.       you'll find you can generate much smaller, faster binaries and
  1005.       have access to a wealth of established library code and example
  1006.       code from all over the world.  My guess is most "professional"
  1007.       programmers, don't want to give up those advantages.
  1008.  
  1009.    Prograph was marketed as a non-programmers programming language, and
  1010.       I think that's still true.  However, as I said above, it does
  1011.       allow low level coding, is very powerfull, and has the best
  1012.       interface and debugger I've ever seen.  It's a glimpse of the
  1013.       future of programming, and worth knowing, just remeber you 
  1014.       get paid in the present.
  1015.  
  1016.  
  1017.  Internet: nick+@pitt.edu            _/   _/  _/  _/_/_/   _/   _/  
  1018.    eWorld: nick                     _/_/ _/  _/  _/   _/  _/_/_/ 
  1019.       CIS: 71232,766               _/ _/_/  _/  _/       _/ _/    
  1020.      http://www.pitt.edu/~nick/   _/   _/  _/   _/_/_/  _/   _/     
  1021.                     
  1022.  
  1023. +++++++++++++++++++++++++++
  1024.  
  1025. >From pjensen@netcom.com (Peter Jensen)
  1026. Date: Thu, 10 Nov 1994 16:53:40 GMT
  1027. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1028.  
  1029. fallside@rahul.net (David C. Fallside) writes:
  1030.  
  1031. >I recently accepted a $59.95 offer for Prograph 2.5. The promo blurb "Very
  1032. >High Level Pictorial Object-Oriented Programming Environment" seems to be
  1033. >accurate, and having worked my way through half of the tutorials, it seems
  1034. >that it should be possible to develop complex applications. But I'm not a
  1035. >professional programmer, and haven't found anyone else who has ever heard
  1036. >of Prograph. Any comments from Netland? Thank you.
  1037. >David
  1038.  
  1039. Prograph 2.5 is the predecessor of Prograph CPX 1.x, which is the 
  1040. Prograph development environment with all the bells and whistles.  $60 is 
  1041. a great price for 2.5 which has the full language implementation found in 
  1042. CPX.  CPX has a rich class library a'la TCL/MacApp and a user-modifiable 
  1043. GUI Builder.  
  1044.  
  1045. I use Prograph full-time to develop complex commercial applications.  
  1046. There are some very intriguing apps with high-volume potential being 
  1047. developed in Prograph right now.  Prograph has arguably one of the best 
  1048. debuggers ever implemented (in the interpretive mode).  There is an 
  1049. optimizing compiler that generates stand-alone apps.  The code isn't as 
  1050. fast or tight as C/C++ but you get RTTI, garbage collection, automatic 
  1051. deref of handles/pointers, cool list management stuff, and of course, a 
  1052. gorgreous visual syntax that prevents syntax errors via constrained input.
  1053.  
  1054. Visual Programming is for real; and Prograph is the most "real" of the new
  1055. generation.  It's one of the things that makes the Mac a special
  1056. development platform.  Sometime next year there will be a Windows Prograph
  1057. and the framework will become cross-platform.  Plus they're developing
  1058. DAL/SQL database tools that will allow you to do everything you can do in
  1059. Omnis/4D but drop into Prograph if you want real programming power.  For
  1060. compute-bound operations it's fairly straightforward to import external
  1061. primitives written in C if you feel the need for speed.  In normal usage,
  1062. you can't tell whether well-crafted apps were written in Prograph or C++ 
  1063. (well, maybe you can, since they're delivered earlier!). 
  1064.  
  1065. I'm very happy with Prograph.  net.persons interested in Prograph can join
  1066. the commotion over on comp.lang.prograph.  Also, Kurt Schmucker of Apple's
  1067. ATG has written an extensive review of CPX in November's MacTech.  Look
  1068. for more Prograph articles in coming issues. 
  1069.  
  1070. Peter Jensen                                  pjensen@netcom.com
  1071. Pepper Tree Design, Inc.                      Santa Clara, CA
  1072.    "Software crafted from the choicest of electrons" (tm)
  1073.  
  1074. +++++++++++++++++++++++++++
  1075.  
  1076. >From howardb@enlil.premenos.com (Howard Berkey)
  1077. Date: 10 Nov 1994 17:03:19 GMT
  1078. Organization: Premenos Corp
  1079.  
  1080. In article <fallside-0911942243270001@382.rahul.net>,
  1081. David C. Fallside <fallside@rahul.net> wrote:
  1082. >I recently accepted a $59.95 offer for Prograph 2.5. The promo blurb "Very
  1083. >High Level Pictorial Object-Oriented Programming Environment" seems to be
  1084. >accurate, and having worked my way through half of the tutorials, it seems
  1085. >that it should be possible to develop complex applications. But I'm not a
  1086. >professional programmer, and haven't found anyone else who has ever heard
  1087. >of Prograph. Any comments from Netland? Thank you.
  1088. >David
  1089. >
  1090.  
  1091.  
  1092.  
  1093.  
  1094. I've never used it myself but it gets a lot of praise from those who
  1095. have.  
  1096.  
  1097. You might want to check out comp.lang.prograph... I'm sure you'll get
  1098. a lot of info there.
  1099.  
  1100. -H-
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111. ---------------------------
  1112.  
  1113. >From ladan@cs.umd.edu (Ladan Gharai)
  1114. Subject: [Q] Programming with the QuickTime toolkit
  1115. Date: 2 Nov 1994 18:52:59 -0500
  1116. Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
  1117.  
  1118.  
  1119. Hi everyone
  1120.  
  1121. I am new to the QuickTime and am trying to understand how it works. I have
  1122. a bunch of questions and would appreciate any answers. I need to write a player
  1123. with very specific functionality. Going through the Inside the Mac: Quicktime
  1124. I have the following questions:
  1125.  
  1126. 1. A sample is defined as "A single element of a sequence of time-ordered
  1127.    data" does this mean that for a vedio a sample would be a frame?
  1128.  
  1129. 2. What function calls should I use to be able to access a single frame? In the
  1130.    Inside the Mac it says that a programmer can access every frame. How?
  1131.  
  1132. 3. Where does QuickTime store information about the frame rates (fps) of a movie? 
  1133.    For example the frame rate that a movie was created with? 
  1134.  
  1135. 4. Is there a realtionship between frame rate (fps) and playback rate?  
  1136.  
  1137. 5. When QuickTime does not have enough time to display all the frames of a
  1138.    movie, it starts dropping frames. Is there a pattern to this frame dropping?
  1139.    For example does it drop everyother frame, or the third in every 3 frames? 
  1140.    How does it decide which frames to drop?
  1141.  
  1142.  
  1143.  
  1144. thanx
  1145. Ladan
  1146.  
  1147. +++++++++++++++++++++++++++
  1148.  
  1149. >From rich@cs.umd.edu (Richard Gerber)
  1150. Date: 2 Nov 1994 19:44:03 -0500
  1151. Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
  1152.  
  1153. I am interested too.  But specifically: from within a quicktime player is there
  1154. any way to dynamically determine -- as the movie is playing -- which particular 
  1155. frames are being dropped.  
  1156.  
  1157. If not, what's the lowest level of granularity I can get to?
  1158.  
  1159. rich
  1160.  
  1161. - ----------
  1162.  
  1163. Richard Gerber
  1164. Assistant Professor
  1165.     
  1166. Department of Computer Science
  1167. University of Maryland
  1168. College Park, MD  20742 USA
  1169.  
  1170. Email:   rich@cs.umd.edu
  1171. Tel:     (301) 405-2710
  1172. FAX:     (301) 405-6707
  1173.  
  1174.  
  1175.  
  1176. +++++++++++++++++++++++++++
  1177.  
  1178. >From ivan_cavero_belaunde@avid.com (Ivan Cavero Belaunde)
  1179. Date: 8 Nov 1994 00:00:42 GMT
  1180. Organization: Avid Technology, Inc.
  1181.  
  1182. In article <3998qv$7id@mingus.cs.umd.edu>, ladan@cs.umd.edu (Ladan Gharai)
  1183. wrote:
  1184. > Hi everyone
  1185. > I am new to the QuickTime and am trying to understand how it works. I have
  1186. > a bunch of questions and would appreciate any answers. I need to write a
  1187. player
  1188. > with very specific functionality. Going through the Inside the Mac: Quicktime
  1189. > I have the following questions:
  1190. > 1. A sample is defined as "A single element of a sequence of time-ordered
  1191. >    data" does this mean that for a vedio a sample would be a frame?
  1192.  
  1193. Yup.
  1194.  
  1195. > 2. What function calls should I use to be able to access a single frame?
  1196. In the
  1197. >    Inside the Mac it says that a programmer can access every frame. How?
  1198.  
  1199. If I want the sample at time 10 on the first track:
  1200.    theTrack = GetMovieIndTrack(theMovie, 1);
  1201.    theMedia = GetTrackMedia(theTrack);
  1202.    mediaTime = TrackTimeToMediaTime(theTrack, 10);
  1203.    if (mediaTime != -1) {
  1204.       err = GetMediaSample(theMedia, sampleDataHandle, 0, &sampleDataSize,
  1205.             mediaTime, nil, nil, sampleDescriptionHandle, nil, 1, nil,
  1206.             &sampleFlags);
  1207.  
  1208. > 3. Where does QuickTime store information about the frame rates (fps) of
  1209. a movie? 
  1210. >    For example the frame rate that a movie was created with? 
  1211.  
  1212. It doesn't since the frame rate can vary over time throughout the movie.
  1213. You can estimate it by walking each track by track edits via
  1214. GetTrackNextInterestingTime and then figuring out the frame rate for each
  1215. edit by looking at the edit rate for each edit as well as the durations of
  1216. the samples spanned by the edit.
  1217.  
  1218. > 4. Is there a realtionship between frame rate (fps) and playback rate?  
  1219.  
  1220. I'm not sure what you mean here. The QuickTime movie will never play at a
  1221. better rate than its original stored rate - additionally, it is eminently
  1222. possible to create a movie with too high a stored frame rate that will not
  1223. play properly and will drop frames.
  1224.  
  1225. > 5. When QuickTime does not have enough time to display all the frames of a
  1226. >    movie, it starts dropping frames. Is there a pattern to this frame
  1227. dropping?
  1228. >    For example does it drop everyother frame, or the third in every 3 frames? 
  1229. >    How does it decide which frames to drop?
  1230.  
  1231. A movie has a "running clock" that tells it what "time" it is within the
  1232. movie. When falling behind, QT will drop as many frames as necessary to
  1233. catch up the frame being displayed with its running clock. The results are
  1234. dependent on boatloads of factors, such as the horsepower of your machine,
  1235. the bandwidth of your storage device, the seek speed of your storage
  1236. device, the compression scheme used, the frame-differencing
  1237. characteristics of the movie, and where within the movie the "playback
  1238. head" is. There's no simple answer, sorry.
  1239.  
  1240. Hope this helps. Followups redirected to comp.sys.mac.programmer.
  1241.  
  1242. -Ivan
  1243. - --
  1244. Ivan Cavero Belaunde (ivan_cavero_belaunde@avid.com)
  1245. Avid VideoShop Lead
  1246. Avid Technology, Inc.
  1247. Disclaimer:  All views expressed are entirely my own and do not
  1248. reflect  the opinions of Avid Technology, Inc.
  1249.  
  1250. ---------------------------
  1251.  
  1252. End of C.S.M.P. Digest
  1253. **********************
  1254.  
  1255.  
  1256. ˇ