wined3d: Get rid of the tracing code in shader_vaddline().
[wine.git] / dlls / wineqtdecoder / qtdatahandler.c
blobbfbeab9276961270c53efc79d2920833dca9f101
1 /*
2 * QuickTime Data Handler
4 * Copyright 2011 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #define ULONG CoreFoundation_ULONG
24 #define HRESULT CoreFoundation_HRESULT
26 #define LoadResource __carbon_LoadResource
27 #define CompareString __carbon_CompareString
28 #define GetCurrentThread __carbon_GetCurrentThread
29 #define GetCurrentProcess __carbon_GetCurrentProcess
30 #define AnimatePalette __carbon_AnimatePalette
31 #define EqualRgn __carbon_EqualRgn
32 #define FillRgn __carbon_FillRgn
33 #define FrameRgn __carbon_FrameRgn
34 #define GetPixel __carbon_GetPixel
35 #define InvertRgn __carbon_InvertRgn
36 #define LineTo __carbon_LineTo
37 #define OffsetRgn __carbon_OffsetRgn
38 #define PaintRgn __carbon_PaintRgn
39 #define Polygon __carbon_Polygon
40 #define ResizePalette __carbon_ResizePalette
41 #define SetRectRgn __carbon_SetRectRgn
43 #define CheckMenuItem __carbon_CheckMenuItem
44 #define DeleteMenu __carbon_DeleteMenu
45 #define DrawMenuBar __carbon_DrawMenuBar
46 #define EnableMenuItem __carbon_EnableMenuItem
47 #define EqualRect __carbon_EqualRect
48 #define FillRect __carbon_FillRect
49 #define FrameRect __carbon_FrameRect
50 #define GetCursor __carbon_GetCursor
51 #define GetMenu __carbon_GetMenu
52 #define InvertRect __carbon_InvertRect
53 #define IsWindowVisible __carbon_IsWindowVisible
54 #define MoveWindow __carbon_MoveWindow
55 #define OffsetRect __carbon_OffsetRect
56 #define PtInRect __carbon_PtInRect
57 #define SetCursor __carbon_SetCursor
58 #define SetRect __carbon_SetRect
59 #define ShowCursor __carbon_ShowCursor
60 #define ShowWindow __carbon_ShowWindow
61 #define UnionRect __carbon_UnionRect
63 #include <QuickTime/QuickTimeComponents.h>
65 #undef LoadResource
66 #undef CompareString
67 #undef GetCurrentThread
68 #undef _CDECL
69 #undef DPRINTF
70 #undef GetCurrentProcess
71 #undef AnimatePalette
72 #undef EqualRgn
73 #undef FillRgn
74 #undef FrameRgn
75 #undef GetPixel
76 #undef InvertRgn
77 #undef LineTo
78 #undef OffsetRgn
79 #undef PaintRgn
80 #undef Polygon
81 #undef ResizePalette
82 #undef SetRectRgn
83 #undef CheckMenuItem
84 #undef DeleteMenu
85 #undef DrawMenuBar
86 #undef EnableMenuItem
87 #undef EqualRect
88 #undef FillRect
89 #undef FrameRect
90 #undef GetCursor
91 #undef GetMenu
92 #undef InvertRect
93 #undef IsWindowVisible
94 #undef MoveWindow
95 #undef OffsetRect
96 #undef PtInRect
97 #undef SetCursor
98 #undef SetRect
99 #undef ShowCursor
100 #undef ShowWindow
101 #undef UnionRect
103 #undef ULONG
104 #undef HRESULT
105 #undef DPRINTF
106 #undef STDMETHODCALLTYPE
108 #include <assert.h>
109 #include <stdio.h>
110 #include <stdarg.h>
112 #define NONAMELESSSTRUCT
113 #define NONAMELESSUNION
114 #define COBJMACROS
116 #include "windef.h"
117 #include "winbase.h"
118 #include "wtypes.h"
119 #include "winuser.h"
120 #include "dshow.h"
122 #include "wine/unicode.h"
123 #include "wine/debug.h"
125 #include "qtprivate.h"
127 WINE_DEFAULT_DEBUG_CHANNEL(qtdatahandler);
129 static ComponentDescription myType =
131 'dhlr',
132 'WINE',
133 'WINE',
138 typedef struct DHData
140 WineDataRefRecord dataRef;
142 Ptr AsyncPtr;
143 long AsyncRefCon;
144 DataHCompletionUPP AsyncCompletionRtn;
145 } DHData;
147 static pascal ComponentResult myComponentRoutineProc ( ComponentParameters *
148 cp, Handle componentStorage);
150 void RegisterWineDataHandler( void )
152 ComponentRoutineUPP MyComponentRoutineUPP;
154 MyComponentRoutineUPP = NewComponentRoutineUPP(&myComponentRoutineProc);
155 RegisterComponent( &myType , MyComponentRoutineUPP, 0, NULL, NULL, NULL);
158 static pascal ComponentResult myDataHCanUseDataRef ( DataHandler dh,
159 Handle dataRef,
160 long *useFlags
163 WineDataRefRecord *record = (WineDataRefRecord*)(*dataRef);
164 TRACE("%p %p %p\n",dh,dataRef,useFlags);
165 if (record->pReader == NULL)
166 return badComponentSelector;
167 *useFlags = kDataHCanRead;
168 return noErr;
171 static pascal ComponentResult myDataHSetDataRef ( DataHandler dh, Handle dataRef)
173 Handle storage = GetComponentInstanceStorage(dh);
174 DHData *data = (DHData*)*storage;
175 WineDataRefRecord* newRef = (WineDataRefRecord*)(*dataRef);
176 TRACE("\n");
177 if (newRef->pReader != data->dataRef.pReader)
178 IAsyncReader_AddRef(newRef->pReader);
179 data->dataRef = *newRef;
180 return noErr;
183 static pascal ComponentResult myDataHGetAvailableFileSize ( DataHandler dh,
184 long *fileSize)
186 Handle storage = GetComponentInstanceStorage(dh);
187 DHData *data = (DHData*)*storage;
188 LONGLONG total;
189 LONGLONG available;
191 TRACE("%p\n",dh);
193 IAsyncReader_Length(data->dataRef.pReader,&total,&available);
194 *fileSize = available;
195 return noErr;
198 static pascal ComponentResult myDataHGetFileSize ( DataHandler dh, long *fileSize)
200 Handle storage = GetComponentInstanceStorage(dh);
201 DHData *data = (DHData*)*storage;
202 LONGLONG total;
203 LONGLONG available;
205 TRACE("%p\n",dh);
207 IAsyncReader_Length(data->dataRef.pReader,&total,&available);
208 *fileSize = total;
209 return noErr;
212 static pascal ComponentResult myDataHScheduleData ( DataHandler dh,
213 Ptr PlaceToPutDataPtr,
214 long FileOffset,
215 long DataSize,
216 long RefCon,
217 DataHSchedulePtr scheduleRec,
218 DataHCompletionUPP CompletionRtn)
220 Handle storage = GetComponentInstanceStorage(dh);
221 DHData *data = (DHData*)*storage;
222 HRESULT hr;
223 LONGLONG offset = FileOffset;
224 BYTE* buffer = (BYTE*)PlaceToPutDataPtr;
226 TRACE("%p %p %li %li %li %p %p\n",dh, PlaceToPutDataPtr, FileOffset, DataSize, RefCon, scheduleRec, CompletionRtn);
228 hr = IAsyncReader_SyncRead(data->dataRef.pReader, offset, DataSize, buffer);
229 TRACE("result %x\n",hr);
230 if (CompletionRtn)
232 if (data->AsyncCompletionRtn)
233 InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
235 data->AsyncPtr = PlaceToPutDataPtr;
236 data->AsyncRefCon = RefCon;
237 data->AsyncCompletionRtn = CompletionRtn;
240 return noErr;
243 static pascal ComponentResult myDataHFinishData (DataHandler dh, Ptr PlaceToPutDataPtr, Boolean Cancel)
245 Handle storage = GetComponentInstanceStorage(dh);
246 DHData *data = (DHData*)*storage;
247 if (!data->AsyncCompletionRtn)
248 return noErr;
249 if (!PlaceToPutDataPtr || PlaceToPutDataPtr == data->AsyncPtr)
251 if (!Cancel)
252 InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
253 data->AsyncPtr = NULL;
254 data->AsyncRefCon = 0;
255 data->AsyncCompletionRtn = NULL;
257 return noErr;
260 static pascal ComponentResult myDataHGetData ( DataHandler dh,
261 Handle h,
262 long hOffset,
263 long offset,
264 long size)
266 Handle storage = GetComponentInstanceStorage(dh);
267 DHData *data = (DHData*)*storage;
268 BYTE *target = (BYTE*)*h;
269 LONGLONG off = offset;
270 HRESULT hr;
272 TRACE("%p %p %li %li %li\n",dh, h, hOffset, offset, size);
273 hr = IAsyncReader_SyncRead(data->dataRef.pReader, off, size, target+hOffset);
274 TRACE("result %x\n",hr);
276 return noErr;
279 static pascal ComponentResult myDataHCompareDataRef ( DataHandler dh,
280 Handle dataRef, Boolean *equal)
282 WineDataRefRecord *ptr1;
283 Handle storage = GetComponentInstanceStorage(dh);
284 DHData *data = (DHData*)*storage;
285 TRACE("\n");
287 ptr1 = (WineDataRefRecord*)dataRef;
289 *equal = (ptr1->pReader == data->dataRef.pReader);
290 return noErr;
293 static pascal ComponentResult myDataHGetDataRef ( DataHandler dh, Handle *dataRef)
295 Handle storage = GetComponentInstanceStorage(dh);
296 TRACE("\n");
297 *dataRef = storage;
298 HandToHand(dataRef);
299 return noErr;
302 static pascal ComponentResult myDataHGetScheduleAheadTime ( DataHandler dh,
303 long *millisecs)
305 TRACE("\n");
306 *millisecs = 1000;
307 return noErr;
310 static pascal ComponentResult myDataHGetInfoFlags ( DataHandler dh, UInt32 *flags)
312 TRACE("\n");
313 *flags = 0;
314 return noErr;
317 static pascal ComponentResult myDataHGetFileTypeOrdering ( DataHandler dh,
318 DataHFileTypeOrderingHandle *orderingListHandle)
320 OSType orderlist[1] = {kDataHFileTypeExtension};
321 TRACE("\n");
322 PtrToHand( &orderlist, (Handle*)orderingListHandle, sizeof(OSType));
323 return noErr;
326 typedef struct {
327 const char *const fname;
328 const int sig_length;
329 const BYTE sig[10];
330 } signature;
332 static const signature stream_sigs[] = {
333 {"video.asf",4,{0x30,0x26,0xb2,0x75}},
334 {"video.mov",8,{0x00,0x00,0x00,0x14,0x66,0x74,0x79,0x70}},
335 {"video.mp4",8,{0x00,0x00,0x00,0x18,0x66,0x74,0x79,0x70}},
336 {"video.m4v",8,{0x00,0x00,0x00,0x1c,0x66,0x74,0x79,0x70}},
337 {"video.flv",4,{0x46,0x4C,0x56,0x01}},
338 {"video.mpg",3,{0x00,0x00,0x01}},
339 {"avideo.rm",4,{0x2E,0x52,0x4D,0x46}}
342 static pascal ComponentResult myDataHGetFileName ( DataHandler dh, Str255 str)
344 Handle storage = GetComponentInstanceStorage(dh);
345 DHData *data = (DHData*)*storage;
346 TRACE("%p %s\n",str,debugstr_guid(&data->dataRef.streamSubtype));
348 /* Todo Expand this list */
349 if (IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_MPEG1Video) ||
350 IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_MPEG1System))
351 CFStringGetPascalString(CFSTR("video.mpg"),str,256,kCFStringEncodingMacRoman);
352 else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_Asf))
353 CFStringGetPascalString(CFSTR("video.asf"),str,256,kCFStringEncodingMacRoman);
354 else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_Avi))
355 CFStringGetPascalString(CFSTR("video.avi"),str,256,kCFStringEncodingMacRoman);
356 else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_QTMovie))
357 CFStringGetPascalString(CFSTR("video.mov"),str,256,kCFStringEncodingMacRoman);
358 else
360 BYTE header[10] = {0,0,0,0,0,0,0,0,0,0};
361 int i;
362 IAsyncReader_SyncRead(data->dataRef.pReader, 0, 8, header);
364 for (i=0; i < sizeof(stream_sigs)/sizeof(signature); i++)
365 if (memcmp(header, stream_sigs[i].sig, stream_sigs[i].sig_length)==0)
367 str[0] = strlen(stream_sigs[i].fname);
368 memcpy(str + 1, stream_sigs[i].fname, str[0]);
369 return noErr;
372 return badComponentSelector;
375 return noErr;
378 static pascal ComponentResult myDataHOpenForRead(DataHandler dh)
380 TRACE("\n");
381 return noErr;
384 static pascal ComponentResult myDataHTask(DataHandler dh)
386 Handle storage = GetComponentInstanceStorage(dh);
387 DHData *data = (DHData*)*storage;
389 if (data->AsyncCompletionRtn)
391 TRACE("Sending Completion\n");
392 InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
393 data->AsyncPtr = NULL;
394 data->AsyncRefCon = 0;
395 data->AsyncCompletionRtn = NULL;
397 return noErr;
400 static pascal ComponentResult myDataHPlaybackHints(DataHandler dh, long flags,
401 unsigned long minFileOffset, unsigned long maxFileOffset,
402 long bytesPerSecond)
404 TRACE("%lu %lu %li\n",minFileOffset, maxFileOffset, bytesPerSecond);
405 return noErr;
408 static pascal ComponentResult myDataHPlaybackHints64(DataHandler dh, long flags,
409 wide *minFileOffset, wide *maxFileOffset,
410 long bytesPerSecond)
412 if (TRACE_ON(qtdatahandler))
414 SInt64 minFileOffset64 = WideToSInt64(*minFileOffset);
415 LONGLONG minFileOffsetLL = minFileOffset64;
416 SInt64 maxFileOffset64 = WideToSInt64(*maxFileOffset);
417 LONGLONG maxFileOffsetLL = maxFileOffset64;
419 TRACE("%s %s %li\n",wine_dbgstr_longlong(minFileOffsetLL), wine_dbgstr_longlong(maxFileOffsetLL), bytesPerSecond);
421 return noErr;
424 static pascal ComponentResult myDataHGetFileSize64(DataHandler dh, wide * fileSize)
426 Handle storage = GetComponentInstanceStorage(dh);
427 DHData *data = (DHData*)*storage;
428 LONGLONG total;
429 LONGLONG available;
430 SInt64 total64;
432 TRACE("%p\n",dh);
434 IAsyncReader_Length(data->dataRef.pReader,&total,&available);
435 total64 = total;
436 *fileSize = SInt64ToWide(total64);
437 return noErr;
440 static pascal ComponentResult myDataHGetFileSizeAsync ( DataHandler dh, wide *fileSize, DataHCompletionUPP CompletionRtn, long RefCon )
442 Handle storage = GetComponentInstanceStorage(dh);
443 DHData *data = (DHData*)*storage;
444 LONGLONG total;
445 LONGLONG available;
446 SInt64 total64;
448 TRACE("%p\n",dh);
450 IAsyncReader_Length(data->dataRef.pReader,&total,&available);
451 total64 = total;
452 *fileSize = SInt64ToWide(total64);
454 if (CompletionRtn)
456 if (data->AsyncCompletionRtn)
457 InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
459 data->AsyncPtr = (Ptr)fileSize;
460 data->AsyncRefCon = RefCon;
461 data->AsyncCompletionRtn = CompletionRtn;
464 return noErr;
467 static pascal ComponentResult myDataHGetAvailableFileSize64(DataHandler dh, wide * fileSize)
469 Handle storage = GetComponentInstanceStorage(dh);
470 DHData *data = (DHData*)*storage;
471 LONGLONG total;
472 LONGLONG available;
473 SInt64 total64;
475 TRACE("%p\n",dh);
477 IAsyncReader_Length(data->dataRef.pReader,&total,&available);
478 total64 = available;
479 *fileSize = SInt64ToWide(total64);
480 return noErr;
483 static pascal ComponentResult myDataHScheduleData64( DataHandler dh,
484 Ptr PlaceToPutDataPtr,
485 const wide * FileOffset,
486 long DataSize,
487 long RefCon,
488 DataHSchedulePtr scheduleRec,
489 DataHCompletionUPP CompletionRtn)
491 Handle storage = GetComponentInstanceStorage(dh);
492 DHData *data = (DHData*)*storage;
493 HRESULT hr;
494 SInt64 fileOffset64 = WideToSInt64(*FileOffset);
495 LONGLONG offset = fileOffset64;
496 BYTE* buffer = (BYTE*)PlaceToPutDataPtr;
498 TRACE("%p %p %s %li %li %p %p\n",dh, PlaceToPutDataPtr, wine_dbgstr_longlong(offset), DataSize, RefCon, scheduleRec, CompletionRtn);
500 hr = IAsyncReader_SyncRead(data->dataRef.pReader, offset, DataSize, buffer);
501 TRACE("result %x\n",hr);
502 if (CompletionRtn)
504 if (data->AsyncCompletionRtn)
505 InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
507 data->AsyncPtr = PlaceToPutDataPtr;
508 data->AsyncRefCon = RefCon;
509 data->AsyncCompletionRtn = CompletionRtn;
512 return noErr;
515 static const struct { LPVOID proc; ProcInfoType type;} componentFunctions[] =
517 {NULL, 0}, /* 0 */
518 {NULL, 0}, /* 1 */
519 {myDataHGetData, kPascalStackBased
520 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
521 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
522 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
523 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
524 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
525 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
526 }, /* kDataHGetDataSelect */
527 {NULL, 0}, /* kDataHPutDataSelect */
528 {NULL, 0}, /* kDataHFlushDataSelect */
529 {NULL, 0}, /* kDataHOpenForWriteSelect */
530 {NULL, 0}, /* kDataHCloseForWriteSelect */
531 {NULL, 0}, /* 7 */
532 {myDataHOpenForRead, kPascalStackBased
533 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
534 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
535 }, /* kDataHOpenForReadSelect
537 {NULL, 0}, /* kDataHCloseForReadSelect */
538 {myDataHSetDataRef, kPascalStackBased
539 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
540 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
541 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
542 }, /* kDataHSetDataRefSelect */
543 {myDataHGetDataRef, kPascalStackBased
544 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
545 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
546 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
547 }, /* kDataHGetDataRefSelect */
548 {myDataHCompareDataRef, kPascalStackBased
549 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
550 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
551 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
552 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean*)))
553 }, /* kDataHCompareDataRefSelect */
554 {myDataHTask, kPascalStackBased
555 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
556 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
557 }, /* kDataHTaskSelect */
558 {myDataHScheduleData, kPascalStackBased
559 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
560 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
561 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
562 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
563 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
564 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
565 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr)))
566 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP)))
567 }, /* kDataHScheduleDataSelect */
568 {myDataHFinishData, kPascalStackBased
569 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
570 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
571 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
572 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean)))
573 }, /* kDataHFinishDataSelect */
574 {NULL, 0}, /* kDataHFlushCacheSelect 0x10 */
575 {NULL, 0}, /* kDataHResolveDataRefSelect */
576 {myDataHGetFileSize, kPascalStackBased
577 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
578 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
579 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
580 }, /* kDataHGetFileSizeSelect */
581 {myDataHCanUseDataRef, kPascalStackBased
582 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
583 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
584 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
585 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long*)))
586 }, /* kDataHCanUseDataRefSelect */
587 {NULL, 0}, /* kDataHGetVolumeListSelect */
588 {NULL, 0}, /* kDataHWriteSelect */
589 {NULL, 0}, /* kDataHPreextendSelect */
590 {NULL, 0}, /* kDataHSetFileSizeSelect */
591 {NULL, 0}, /* kDataHGetFreeSpaceSelect */
592 {NULL, 0}, /* kDataHCreateFileSelect */
593 {NULL, 0}, /* kDataHGetPreferredBlockSizeSelect */
594 {NULL, 0}, /* kDataHGetDeviceIndexSelect */
595 {NULL, 0}, /* kDataHIsStreamingDataHandlerSelect */
596 {NULL, 0}, /* kDataHGetDataInBufferSelect */
597 {myDataHGetScheduleAheadTime, kPascalStackBased
598 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
599 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
600 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
601 }, /* kDataHGetScheduleAheadTimeSelect */
602 /* End of Required List */
603 {NULL, 0}, /* kDataHSetCacheSizeLimitSelect */
604 {NULL, 0}, /* kDataHGetCacheSizeLimitSelect 0x20 */
605 {NULL, 0}, /* kDataHGetMovieSelect */
606 {NULL, 0}, /* kDataHAddMovieSelect */
607 {NULL, 0}, /* kDataHUpdateMovieSelect */
608 {NULL, 0}, /* kDataHDoesBufferSelect */
609 {myDataHGetFileName, kPascalStackBased
610 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
611 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
612 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Str255*)))
613 }, /* kDataHGetFileNameSelect */
614 {myDataHGetAvailableFileSize, kPascalStackBased
615 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
616 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
617 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
618 }, /* kDataHGetAvailableFileSizeSelect */
619 {NULL, 0}, /* kDataHGetMacOSFileTypeSelect */
620 {NULL, 0}, /* kDataHGetMIMETypeSelect */
621 {NULL, 0}, /* kDataHSetDataRefWithAnchorSelect */
622 {NULL, 0}, /* kDataHGetDataRefWithAnchorSelect */
623 {NULL, 0}, /* kDataHSetMacOSFileTypeSelect */
624 {NULL, 0}, /* kDataHSetTimeBaseSelect */
625 {myDataHGetInfoFlags, kPascalStackBased
626 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
627 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
628 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(UInt32*)))
629 }, /* kDataHGetInfoFlagsSelect */
630 {myDataHScheduleData64, kPascalStackBased
631 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
632 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
633 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
634 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(wide*)))
635 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
636 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
637 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr)))
638 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP)))
639 }, /* kDataHScheduleData64Select */
640 {NULL, 0}, /* kDataHWrite64Select */
641 {myDataHGetFileSize64, kPascalStackBased
642 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
643 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
644 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide*)))
645 }, /* kDataHGetFileSize64Select 0x30 */
646 {NULL, 0}, /* kDataHPreextend64Select */
647 {NULL, 0}, /* kDataHSetFileSize64Select */
648 {NULL, 0}, /* kDataHGetFreeSpace64Select */
649 {NULL, 0}, /* kDataHAppend64Select */
650 {NULL, 0}, /* kDataHReadAsyncSelect */
651 {NULL, 0}, /* kDataHPollReadSelect */
652 {NULL, 0}, /* kDataHGetDataAvailabilitySelect */
653 {NULL, 0}, /* 0x0038 */
654 {NULL, 0}, /* 0x0039 */
655 {myDataHGetFileSizeAsync, kPascalStackBased
656 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
657 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
658 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide*)))
659 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(DataHCompletionUPP)))
660 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
661 }, /* kDataHGetFileSizeAsyncSelect */
662 {NULL, 0}, /* kDataHGetDataRefAsTypeSelect */
663 {NULL, 0}, /* kDataHSetDataRefExtensionSelect */
664 {NULL, 0}, /* kDataHGetDataRefExtensionSelect */
665 {NULL, 0}, /* kDataHGetMovieWithFlagsSelect */
666 {NULL, 0}, /* 0x3F */
667 {myDataHGetFileTypeOrdering, kPascalStackBased
668 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
669 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
670 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DataHFileTypeOrderingHandle*)))
671 }, /* kDataHGetFileTypeOrderingSelect 0x40 */
672 {NULL, 0}, /* kDataHCreateFileWithFlagsSelect */
673 {NULL, 0}, /* kDataHGetMIMETypeAsyncSelect */
674 {NULL, 0}, /* kDataHGetInfoSelect */
675 {NULL, 0}, /* kDataHSetIdleManagerSelect */
676 {NULL, 0}, /* kDataHDeleteFileSelect */
677 {NULL, 0}, /* kDataHSetMovieUsageFlagsSelect */
678 {NULL, 0}, /* kDataHUseTemporaryDataRefSelect */
679 {NULL, 0}, /* kDataHGetTemporaryDataRefCapabilitiesSelect */
680 {NULL, 0}, /* kDataHRenameFileSelect */
681 {NULL, 0}, /* 0x4A */
682 {NULL, 0}, /* 0x4B */
683 {NULL, 0}, /* 0x4C */
684 {NULL, 0}, /* 0x4D */
685 {myDataHGetAvailableFileSize64, kPascalStackBased
686 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
687 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
688 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide*)))
689 }, /* kDataHGetAvailableFileSize64Select */
690 {NULL, 0}, /* kDataHGetDataAvailability64Select */
693 static const struct { LPVOID proc; ProcInfoType type;} componentFunctions_2[] =
695 {myDataHPlaybackHints, kPascalStackBased
696 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
697 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
698 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
699 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(unsigned long)))
700 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(unsigned long)))
701 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
702 }, /* kDataHPlaybackHintsSelect 0x103 */
703 {myDataHPlaybackHints64, kPascalStackBased
704 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
705 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
706 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
707 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(wide*)))
708 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(wide*)))
709 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
710 }, /* kDataHPlaybackHints64Select 0x10E */
711 {NULL, 0}, /* kDataHGetDataRateSelect 0x110 */
712 {NULL, 0}, /* kDataHSetTimeHintsSelect 0x111 */
715 /* Component Functions */
717 static pascal ComponentResult myComponentOpen(ComponentInstance ci, ComponentInstance self)
719 DHData myData;
720 Handle storage;
722 ZeroMemory(&myData,sizeof(DHData));
723 PtrToHand( &myData, &storage, sizeof(DHData));
724 SetComponentInstanceStorage(self,storage);
726 return noErr;
729 static pascal ComponentResult myComponentClose(ComponentInstance ci, ComponentInstance self)
731 Handle storage = GetComponentInstanceStorage(self);
732 DHData *data;
733 if (storage)
735 data = (DHData*)*storage;
736 if (data && data->dataRef.pReader != NULL)
737 IAsyncReader_Release(data->dataRef.pReader);
738 DisposeHandle(storage);
739 SetComponentInstanceStorage(self,NULL);
741 return noErr;
744 static pascal ComponentResult myComponentCanDo(ComponentInstance ci, SInt16 ftnNumber)
746 TRACE("test 0x%x\n",ftnNumber);
747 if (ftnNumber <= kComponentOpenSelect && ftnNumber >= kComponentCanDoSelect)
748 return TRUE;
749 if (ftnNumber == kDataHPlaybackHintsSelect)
750 return TRUE;
751 if (ftnNumber == kDataHPlaybackHints64Select)
752 return TRUE;
753 if (ftnNumber > kDataHGetDataAvailability64Select)
754 return FALSE;
755 TRACE("impl? %i\n",(componentFunctions[ftnNumber].proc != NULL));
756 return (componentFunctions[ftnNumber].proc != NULL);
759 /* Main Proc */
761 static ComponentResult callOurFunction(LPVOID proc, ProcInfoType type, ComponentParameters * cp)
763 ComponentRoutineUPP myUUP;
764 ComponentResult result;
766 myUUP = NewComponentFunctionUPP(proc, type);
767 result = CallComponentFunction(cp, myUUP);
768 DisposeComponentFunctionUPP(myUUP);
769 return result;
772 static pascal ComponentResult myComponentRoutineProc ( ComponentParameters * cp,
773 Handle componentStorage)
775 switch (cp->what)
777 case kComponentOpenSelect:
778 return callOurFunction(myComponentOpen, uppCallComponentOpenProcInfo, cp);
779 case kComponentCloseSelect:
780 return callOurFunction(myComponentClose, uppCallComponentOpenProcInfo, cp);
781 case kComponentCanDoSelect:
782 return callOurFunction(myComponentCanDo, uppCallComponentCanDoProcInfo, cp);
783 case kDataHPlaybackHintsSelect:
784 return callOurFunction(componentFunctions_2[0].proc, componentFunctions_2[0].type, cp);
785 case kDataHPlaybackHints64Select:
786 return callOurFunction(componentFunctions_2[1].proc, componentFunctions_2[1].type, cp);
789 if (cp->what > 0 && cp->what <=kDataHGetDataAvailability64Select && componentFunctions[cp->what].proc)
790 return callOurFunction(componentFunctions[cp->what].proc, componentFunctions[cp->what].type, cp);
792 FIXME("unhandled select 0x%x\n",cp->what);
793 return badComponentSelector;