root/trunk/codecID.c.m4

Revision 1213, 1.9 KB (checked in by gbooker, 8 months ago)

Auto-generate yet another massive case statement. The info is passed as a void * b/c I don't want to include the QuickTime headers in a header file used by so many other files just to have the info typed correctly.

Line 
1include(`defines.m4')
2
3define(<!doCase!>, <!ifelse($1, lastCase, , <!ifdef(<!lastCase!>, <!                    codecID = lastCase;
4                        break;
5               
6!>)!>)<!                case $2:!>
7define(<!lastCase!>, <!$1!>)!>)dnl
8define(<!printCaseStatement!>, <!ifelse(len($1), 0, <!!>, <!foreach(<!X!>, <!doCase($1, X)!>, shift($@))!>)!>)dnl
9define(<!Codec!>, <!printCaseStatement($2, shift(shift(shift(shift($@)))))!>)dnl
10dnl
11define(<!EntryPoint!>, <!!>)dnl
12define(<!ResourceOnly!>, <!!>)dnl
13#include "avcodec.h"
14#include "CodecIDs.h"
15#include <QuickTime/QuickTime.h>
16#include "PerianResourceIDs.h"
17
18int getCodecID(OSType componentType)
19{
20        enum CodecID codecID = CODEC_ID_NONE;
21        switch(componentType)
22        {
23include(<!codecList.m4!>)
24                        codecID = lastCase;
25                        break;
26                default:
27                        break;
28        }
29        return codecID;
30}
31
32undefine(<!lastCase!>)dnl
33define(<!doCase!>, <!ifelse($1, lastCase, , <!ifdef(<!lastCase!>, <!                    err = GetComponentResource((Component)self, codecInfoResourceType, lastCase, (Handle *)&tempCodecInfo);
34                        break;
35               
36!>)!>)<!                case $2:!>
37define(<!lastCase!>, <!$1!>)!>)dnl
38define(<!Codec!>, <!printCaseStatement($1, shift(shift(shift(shift($@)))))!>)dnl
39
40pascal ComponentResult getPerianCodecInfo(ComponentInstance self, OSType componentType, void *info)
41{
42    OSErr err = noErr;
43       
44    if (info == NULL)
45    {
46        err = paramErr;
47    }
48    else
49    {
50        CodecInfo **tempCodecInfo;
51               
52        switch (componentType)
53        {
54include(<!codecList.m4!>)
55                err = GetComponentResource((Component)self, codecInfoResourceType, lastCase, (Handle *)&tempCodecInfo);
56                break;
57
58
59            default:    // should never happen but we have to handle the case
60                err = GetComponentResource((Component)self, codecInfoResourceType, kDivX4CodecInfoResID, (Handle *)&tempCodecInfo);
61                               
62        }
63       
64        if (err == noErr)
65        {
66            *((CodecInfo *)info) = **tempCodecInfo;
67           
68            DisposeHandle((Handle)tempCodecInfo);
69        }
70    }
71       
72    return err;
73}
Note: See TracBrowser for help on using the browser.