Mercurial > mplayer.hg
comparison libmpcodecs/ad_realaud.c @ 13860:d6f716fdd734
remove mac shlb support to use new helix codec for realvideo support on osx
author | nplourde |
---|---|
date | Wed, 03 Nov 2004 02:50:01 +0000 |
parents | 702b39f72394 |
children | 500eb730c784 |
comparison
equal
deleted
inserted
replaced
13859:1b0d5a6ab7dc | 13860:d6f716fdd734 |
---|---|
13 #endif | 13 #endif |
14 #include "help_mp.h" | 14 #include "help_mp.h" |
15 | 15 |
16 #include "ad_internal.h" | 16 #include "ad_internal.h" |
17 #include "wine/windef.h" | 17 #include "wine/windef.h" |
18 | |
19 #ifdef USE_MACSHLB | |
20 #include <CoreServices/CoreServices.h> | |
21 #endif | |
22 | 18 |
23 static ad_info_t info = { | 19 static ad_info_t info = { |
24 "RealAudio decoder", | 20 "RealAudio decoder", |
25 "realaud", | 21 "realaud", |
26 "Alex Beregszaszi", | 22 "Alex Beregszaszi", |
210 | 206 |
211 } | 207 } |
212 #endif | 208 #endif |
213 | 209 |
214 | 210 |
215 #ifdef USE_MACSHLB | |
216 /* | |
217 Helper function to create a function pointer (from a null terminated (!) | |
218 pascal string) like GetProcAddress(). Some assembler is required due | |
219 to different calling conventions, for further details, see | |
220 http://developer.apple.com/ samplecode/CFM_MachO_CFM/listing1.html . | |
221 | |
222 Caller is expected to DisposePtr(mfp). | |
223 N.B.: Code is used by vd_realaud.c as well. | |
224 */ | |
225 void *load_one_sym_mac(char *symbolName, CFragConnectionID *connID) { | |
226 OSErr err; | |
227 Ptr symbolAddr; | |
228 CFragSymbolClass symbolClass; | |
229 UInt32 *mfp; | |
230 char realname[255]; | |
231 | |
232 if (strlen(symbolName) > 255) | |
233 { | |
234 mp_msg(MSGT_DECVIDEO, MSGL_V, "FindSymbol symbolname overflow\n"); | |
235 return NULL; | |
236 } | |
237 | |
238 snprintf(realname, 255, "%c%s", strlen(symbolName), symbolName); | |
239 | |
240 if ( (err = FindSymbol( *connID, realname, | |
241 &symbolAddr, &symbolClass )) != noErr ) { | |
242 mp_msg(MSGT_DECVIDEO,MSGL_V,"FindSymbol( \"%s\" ) failed with error code %d.\n", symbolName + 1, err ); | |
243 return NULL; | |
244 } | |
245 | |
246 if ( (mfp = (UInt32 *)NewPtr( 6 * sizeof(UInt32) )) == nil ) | |
247 return NULL; | |
248 | |
249 mfp[0] = 0x3D800000 | ((UInt32)symbolAddr >> 16); | |
250 mfp[1] = 0x618C0000 | ((UInt32)symbolAddr & 0xFFFF); | |
251 mfp[2] = 0x800C0000; | |
252 mfp[3] = 0x804C0004; | |
253 mfp[4] = 0x7C0903A6; | |
254 mfp[5] = 0x4E800420; | |
255 MakeDataExecutable( mfp, 6 * sizeof(UInt32) ); | |
256 | |
257 return( mfp ); | |
258 } | |
259 | |
260 static int load_syms_mac(char *path) | |
261 { | |
262 Ptr mainAddr; | |
263 OSStatus status; | |
264 FSRef fsref; | |
265 FSSpec fsspec; | |
266 OSErr err; | |
267 Str255 errMessage; | |
268 CFragConnectionID *connID; | |
269 | |
270 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "opening mac shlb '%s'\n", path); | |
271 | |
272 if ( (connID = (CFragConnectionID *)NewPtr( sizeof( CFragConnectionID ))) == nil ) { | |
273 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"NewPtr() failed.\n" ); | |
274 return 0; | |
275 } | |
276 | |
277 if ( (status = FSPathMakeRef( path, &fsref, NULL )) != noErr ) { | |
278 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"FSPathMakeRef() failed with error %d.\n", status ); | |
279 return 0; | |
280 } | |
281 | |
282 if ( (status = FSGetCatalogInfo( &fsref, kFSCatInfoNone, NULL, NULL, &fsspec, NULL )) != noErr ) { | |
283 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"FSGetCatalogInfo() failed with error %d.\n", status ); | |
284 return 0; | |
285 } | |
286 | |
287 if ( (err = GetDiskFragment( &fsspec, 0, kCFragGoesToEOF, NULL, kPrivateCFragCopy, connID, &mainAddr, errMessage )) != noErr ) { | |
288 | |
289 p2cstrcpy( errMessage, errMessage ); | |
290 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"GetDiskFragment() failed with error %d: %s\n", err, errMessage ); | |
291 return 0; | |
292 } | |
293 | |
294 raCloseCodec = load_one_sym_mac( "RACloseCodec", connID); | |
295 raDecode = load_one_sym_mac("RADecode", connID); | |
296 raFlush = load_one_sym_mac("RAFlush", connID); | |
297 raFreeDecoder = load_one_sym_mac("RAFreeDecoder", connID); | |
298 raGetFlavorProperty = load_one_sym_mac("RAGetFlavorProperty", connID); | |
299 raOpenCodec = load_one_sym_mac("RAOpenCodec", connID); | |
300 raOpenCodec2 = load_one_sym_mac("RAOpenCodec2", connID); | |
301 raInitDecoder = load_one_sym_mac("RAInitDecoder", connID); | |
302 raSetFlavor = load_one_sym_mac("RASetFlavor", connID); | |
303 raSetDLLAccessPath = load_one_sym_mac("SetDLLAccessPath", connID); | |
304 raSetPwd = load_one_sym_mac("RASetPwd", connID); // optional, used by SIPR | |
305 | |
306 if (raCloseCodec && raDecode && /*raFlush && */raFreeDecoder && | |
307 raGetFlavorProperty && (raOpenCodec || raOpenCodec2) && raSetFlavor && | |
308 /*raSetDLLAccessPath &&*/ raInitDecoder) | |
309 { | |
310 rv_handle = connID; | |
311 return 1; | |
312 } | |
313 | |
314 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Cannot resolve symbols - incompatible shlb: %s\n",path); | |
315 (void)CloseConnection(connID); | |
316 return 0; | |
317 } | |
318 | |
319 #endif | |
320 | |
321 static int preinit(sh_audio_t *sh){ | 211 static int preinit(sh_audio_t *sh){ |
322 // let's check if the driver is available, return 0 if not. | 212 // let's check if the driver is available, return 0 if not. |
323 // (you should do that if you use external lib(s) which is optional) | 213 // (you should do that if you use external lib(s) which is optional) |
324 unsigned int result; | 214 unsigned int result; |
325 int len=0; | 215 int len=0; |
331 sprintf(path, REALCODEC_PATH "/%s", sh->codec->dll); | 221 sprintf(path, REALCODEC_PATH "/%s", sh->codec->dll); |
332 | 222 |
333 /* first try to load linux dlls, if failed and we're supporting win32 dlls, | 223 /* first try to load linux dlls, if failed and we're supporting win32 dlls, |
334 then try to load the windows ones */ | 224 then try to load the windows ones */ |
335 | 225 |
336 #ifdef USE_MACSHLB | |
337 if (strstr(sh->codec->dll,".shlb") && !load_syms_mac(path)) | |
338 #endif | |
339 #ifdef HAVE_LIBDL | 226 #ifdef HAVE_LIBDL |
340 if (strstr(sh->codec->dll,".dll") || !load_syms_linux(path)) | 227 if (strstr(sh->codec->dll,".dll") || !load_syms_linux(path)) |
341 #endif | 228 #endif |
342 #ifdef USE_WIN32DLL | 229 #ifdef USE_WIN32DLL |
343 if (!load_syms_windows(sh->codec->dll)) | 230 if (!load_syms_windows(sh->codec->dll)) |
407 ((short*)(sh->wf+1))[0], // subpacket size | 294 ((short*)(sh->wf+1))[0], // subpacket size |
408 ((short*)(sh->wf+1))[3], // coded frame size | 295 ((short*)(sh->wf+1))[3], // coded frame size |
409 ((short*)(sh->wf+1))[4], // codec data length | 296 ((short*)(sh->wf+1))[4], // codec data length |
410 ((char*)(sh->wf+1))+10 // extras | 297 ((char*)(sh->wf+1))+10 // extras |
411 }; | 298 }; |
412 #if defined(USE_WIN32DLL) || defined(USE_MACSHLB) | 299 #ifdef USE_WIN32DLL |
413 wra_init_t winit_data={ | 300 wra_init_t winit_data={ |
414 sh->wf->nSamplesPerSec, | 301 sh->wf->nSamplesPerSec, |
415 sh->wf->wBitsPerSample, | 302 sh->wf->wBitsPerSample, |
416 sh->wf->nChannels, | 303 sh->wf->nChannels, |
417 100, // quality | 304 100, // quality |
419 ((short*)(sh->wf+1))[3], // coded frame size | 306 ((short*)(sh->wf+1))[3], // coded frame size |
420 ((short*)(sh->wf+1))[4], // codec data length | 307 ((short*)(sh->wf+1))[4], // codec data length |
421 ((char*)(sh->wf+1))+10 // extras | 308 ((char*)(sh->wf+1))+10 // extras |
422 }; | 309 }; |
423 #endif | 310 #endif |
424 #ifdef USE_MACSHLB | |
425 result=raInitDecoder(sh->context,&winit_data); | |
426 #else | |
427 #ifdef USE_WIN32DLL | 311 #ifdef USE_WIN32DLL |
428 if (dll_type == 1) | 312 if (dll_type == 1) |
429 result=wraInitDecoder(sh->context,&winit_data); | 313 result=wraInitDecoder(sh->context,&winit_data); |
430 else | 314 else |
431 #endif | 315 #endif |
432 result=raInitDecoder(sh->context,&init_data); | 316 result=raInitDecoder(sh->context,&init_data); |
433 #endif | 317 |
434 if(result){ | 318 if(result){ |
435 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder init failed, error code: 0x%X\n",result); | 319 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder init failed, error code: 0x%X\n",result); |
436 return 0; | 320 return 0; |
437 } | 321 } |
438 // printf("initdecoder ok (result: %x)\n", result); | 322 // printf("initdecoder ok (result: %x)\n", result); |
515 #endif | 399 #endif |
516 | 400 |
517 if (raFreeDecoder) raFreeDecoder(sh->context); | 401 if (raFreeDecoder) raFreeDecoder(sh->context); |
518 if (raCloseCodec) raCloseCodec(sh->context); | 402 if (raCloseCodec) raCloseCodec(sh->context); |
519 | 403 |
520 #ifdef USE_MACSHLB | |
521 if (rv_handle){ | |
522 (void)CloseConnection(rv_handle); | |
523 DisposePtr((Ptr)rv_handle); | |
524 } | |
525 if (raCloseCodec) DisposePtr((Ptr)raCloseCodec); | |
526 if (raDecode) DisposePtr((Ptr)raDecode); | |
527 if (raFlush) DisposePtr((Ptr)raFlush); | |
528 if (raFreeDecoder) DisposePtr((Ptr)raFreeDecoder); | |
529 if (raGetFlavorProperty) DisposePtr((Ptr)raGetFlavorProperty); | |
530 if (raOpenCodec) DisposePtr((Ptr)raOpenCodec); | |
531 if (raOpenCodec2) DisposePtr((Ptr)raOpenCodec2); | |
532 if (raInitDecoder) DisposePtr((Ptr)raInitDecoder); | |
533 #endif | |
534 | 404 |
535 #ifdef USE_WIN32DLL | 405 #ifdef USE_WIN32DLL |
536 if (dll_type == 1) | 406 if (dll_type == 1) |
537 { | 407 { |
538 if (rv_handle) FreeLibrary(rv_handle); | 408 if (rv_handle) FreeLibrary(rv_handle); |