2 * ALURE OpenAL utility library
3 * Copyright (c) 2009 by Chris Robinson.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 /* Title: Main and Miscellanious */
42 std::map<ALint,UserCallbacks> InstalledCallbacks;
43 CRITICAL_SECTION cs_StreamPlay;
44 alureStream::ListType alureStream::StreamList;
46 PFNALCSETTHREADCONTEXTPROC palcSetThreadContext;
47 PFNALCGETTHREADCONTEXTPROC palcGetThreadContext;
51 static inline void LoadALCProc(ALCdevice *dev, const char *name, T **ptr)
52 { *ptr = reinterpret_cast<T*>(alcGetProcAddress(dev, name)); }
55 #ifdef HAVE_GCC_CONSTRUCTOR
56 static void init_alure(void) __attribute__((constructor));
57 static void deinit_alure(void) __attribute__((destructor));
58 static struct MyConstructorClass {
60 { alureStream::Clear(); };
62 #elif defined(_WIN32) && !defined(ALURE_STATIC_LIBRARY)
63 static void init_alure(void);
64 static void deinit_alure(void);
65 static struct MyConstructorClass {
67 { alureStream::Clear(); };
70 extern "C" BOOL APIENTRY DllMain(HINSTANCE module, DWORD reason, LPVOID /*reserved*/)
72 // Perform actions based on the reason for calling.
75 case DLL_PROCESS_ATTACH:
76 DisableThreadLibraryCalls(module);
80 case DLL_PROCESS_DETACH:
87 static void init_alure(void);
88 static void deinit_alure(void);
90 static struct MyConstructorClass {
94 { alureStream::Clear();
99 static void init_alure(void)
101 InitializeCriticalSection(&cs_StreamPlay);
103 // These calls actually just return references to the codecs' Decoder
104 // objects. They aren't really used for anything other than to prevent the
105 // compiler from removing the codec initializers.
108 #ifdef HAS_VORBISFILE
109 alure_init_vorbisfile();
115 alure_init_sndfile();
117 #ifdef HAS_FLUIDSYNTH
118 alure_init_fluidsynth();
124 alure_init_modplug();
130 if(alcIsExtensionPresent(NULL, "ALC_EXT_thread_local_context"))
132 LoadALCProc(NULL, "alcSetThreadContext", &palcSetThreadContext);
133 LoadALCProc(NULL, "alcGetThreadContext", &palcGetThreadContext);
134 if(!palcSetThreadContext || !palcGetThreadContext)
136 fprintf(stderr, "Alure lib: ALC_EXT_thread_local_context advertised, but missing function:\n"
137 " alcSetThreadContext=%p\n"
138 " alcGetThreadContext=%p\n",
139 palcSetThreadContext, palcGetThreadContext);
140 palcSetThreadContext = NULL;
141 palcGetThreadContext = NULL;
146 static void deinit_alure(void)
148 alureUpdateInterval(0.0f);
149 DeleteCriticalSection(&cs_StreamPlay);
153 #ifndef HAVE_WINDOWS_H
155 void EnterCriticalSection(CRITICAL_SECTION *cs)
158 ret = pthread_mutex_lock(cs);
161 void LeaveCriticalSection(CRITICAL_SECTION *cs)
164 ret = pthread_mutex_unlock(cs);
167 void InitializeCriticalSection(CRITICAL_SECTION *cs)
169 pthread_mutexattr_t attrib;
172 ret = pthread_mutexattr_init(&attrib);
175 ret = pthread_mutexattr_settype(&attrib, PTHREAD_MUTEX_RECURSIVE);
176 #ifdef HAVE_PTHREAD_NP_H
178 ret = pthread_mutexattr_setkind_np(&attrib, PTHREAD_MUTEX_RECURSIVE);
181 ret = pthread_mutex_init(cs, &attrib);
184 pthread_mutexattr_destroy(&attrib);
186 void DeleteCriticalSection(CRITICAL_SECTION *cs)
189 ret = pthread_mutex_destroy(cs);
197 void *OpenLib(const char *libname)
198 { return LoadLibraryA(libname); }
199 void CloseLib(void *hdl)
200 { FreeLibrary((HINSTANCE)hdl); }
201 void *GetLibProc(void *hdl, const char *funcname)
202 { return (void*)GetProcAddress((HINSTANCE)hdl, funcname); }
204 void *OpenLib(const char *libname)
206 const char *err = dlerror();
207 void *hdl = dlopen(libname, RTLD_NOW);
208 if((err=dlerror()) != NULL)
210 fprintf(stderr, "Error loading %s: %s\n", libname, err);
215 void *GetLibProc(void *hdl, const char *funcname)
217 const char *err = dlerror();
218 void *fn = dlsym(hdl, funcname);
219 if((err=dlerror()) != NULL)
221 fprintf(stderr, "Error loading %s: %s\n", funcname, err);
226 void CloseLib(void *hdl)
232 static const ALchar *last_error = "No error";
233 void SetError(const char *err)
239 ALuint DetectBlockAlignment(ALenum format)
243 #define CHECK_RET(f,s) case (f): return (s)
244 CHECK_RET(AL_FORMAT_MONO8, sizeof(ALubyte));
245 CHECK_RET(AL_FORMAT_MONO16, sizeof(ALshort));
246 CHECK_RET(AL_FORMAT_MONO_FLOAT32, sizeof(ALfloat));
247 CHECK_RET(AL_FORMAT_MONO_DOUBLE_EXT, sizeof(ALdouble));
248 CHECK_RET(AL_FORMAT_MONO_MULAW, sizeof(ALubyte)*1);
250 CHECK_RET(AL_FORMAT_STEREO8, sizeof(ALubyte)*2);
251 CHECK_RET(AL_FORMAT_STEREO16, sizeof(ALshort)*2);
252 CHECK_RET(AL_FORMAT_STEREO_FLOAT32, sizeof(ALfloat)*2);
253 CHECK_RET(AL_FORMAT_STEREO_DOUBLE_EXT, sizeof(ALdouble)*2);
254 CHECK_RET(AL_FORMAT_STEREO_MULAW, sizeof(ALubyte)*2);
256 CHECK_RET(AL_FORMAT_QUAD8, sizeof(ALubyte)*4);
257 CHECK_RET(AL_FORMAT_QUAD16, sizeof(ALshort)*4);
258 CHECK_RET(AL_FORMAT_QUAD32, sizeof(ALfloat)*4);
259 CHECK_RET(AL_FORMAT_QUAD_MULAW, sizeof(ALubyte)*4);
261 CHECK_RET(AL_FORMAT_REAR8, sizeof(ALubyte)*2);
262 CHECK_RET(AL_FORMAT_REAR16, sizeof(ALshort)*2);
263 CHECK_RET(AL_FORMAT_REAR32, sizeof(ALfloat)*2);
264 CHECK_RET(AL_FORMAT_REAR_MULAW, sizeof(ALubyte)*2);
266 CHECK_RET(AL_FORMAT_51CHN8, sizeof(ALubyte)*6);
267 CHECK_RET(AL_FORMAT_51CHN16, sizeof(ALshort)*6);
268 CHECK_RET(AL_FORMAT_51CHN32, sizeof(ALfloat)*6);
269 CHECK_RET(AL_FORMAT_51CHN_MULAW, sizeof(ALubyte)*6);
271 CHECK_RET(AL_FORMAT_61CHN8, sizeof(ALubyte)*7);
272 CHECK_RET(AL_FORMAT_61CHN16, sizeof(ALshort)*7);
273 CHECK_RET(AL_FORMAT_61CHN32, sizeof(ALfloat)*7);
274 CHECK_RET(AL_FORMAT_61CHN_MULAW, sizeof(ALubyte)*7);
276 CHECK_RET(AL_FORMAT_71CHN8, sizeof(ALubyte)*8);
277 CHECK_RET(AL_FORMAT_71CHN16, sizeof(ALshort)*8);
278 CHECK_RET(AL_FORMAT_71CHN32, sizeof(ALfloat)*8);
279 CHECK_RET(AL_FORMAT_71CHN_MULAW, sizeof(ALubyte)*8);
281 CHECK_RET(AL_FORMAT_MONO_IMA4, 36);
282 CHECK_RET(AL_FORMAT_STEREO_IMA4, 36*2);
288 ALuint DetectCompressionRate(ALenum format)
292 case AL_FORMAT_MONO8:
293 case AL_FORMAT_MONO16:
294 case AL_FORMAT_MONO_FLOAT32:
295 case AL_FORMAT_MONO_DOUBLE_EXT:
296 case AL_FORMAT_STEREO8:
297 case AL_FORMAT_STEREO16:
298 case AL_FORMAT_STEREO_FLOAT32:
299 case AL_FORMAT_STEREO_DOUBLE_EXT:
300 case AL_FORMAT_QUAD8:
301 case AL_FORMAT_QUAD16:
302 case AL_FORMAT_QUAD32:
303 case AL_FORMAT_REAR8:
304 case AL_FORMAT_REAR16:
305 case AL_FORMAT_REAR32:
306 case AL_FORMAT_51CHN8:
307 case AL_FORMAT_51CHN16:
308 case AL_FORMAT_51CHN32:
309 case AL_FORMAT_61CHN8:
310 case AL_FORMAT_61CHN16:
311 case AL_FORMAT_61CHN32:
312 case AL_FORMAT_71CHN8:
313 case AL_FORMAT_71CHN16:
314 case AL_FORMAT_71CHN32:
317 case AL_FORMAT_MONO_MULAW:
318 case AL_FORMAT_STEREO_MULAW:
319 case AL_FORMAT_QUAD_MULAW:
320 case AL_FORMAT_REAR_MULAW:
321 case AL_FORMAT_51CHN_MULAW:
322 case AL_FORMAT_61CHN_MULAW:
323 case AL_FORMAT_71CHN_MULAW:
326 case AL_FORMAT_MONO_IMA4:
327 case AL_FORMAT_STEREO_IMA4:
330 fprintf(stderr, "Alure lib: Unhandled format: %#x\n", format);
334 ALenum GetSampleFormat(ALuint channels, ALuint bits, bool isFloat)
336 #define CHECK_FMT_RET(f) do { \
337 ALenum fmt = alGetEnumValue(#f); \
338 if(alGetError() == AL_NO_ERROR && fmt != 0 && fmt != -1) \
345 if(channels == 1) CHECK_FMT_RET(AL_FORMAT_MONO8);
346 if(channels == 2) CHECK_FMT_RET(AL_FORMAT_STEREO8);
347 if(alIsExtensionPresent("AL_EXT_MCFORMATS"))
349 if(channels == 4) CHECK_FMT_RET(AL_FORMAT_QUAD8);
350 if(channels == 6) CHECK_FMT_RET(AL_FORMAT_51CHN8);
351 if(channels == 7) CHECK_FMT_RET(AL_FORMAT_61CHN8);
352 if(channels == 8) CHECK_FMT_RET(AL_FORMAT_71CHN8);
354 if(alIsExtensionPresent("AL_LOKI_quadriphonic"))
356 if(channels == 4) CHECK_FMT_RET(AL_FORMAT_QUAD8_LOKI);
358 SetError("Unsupported 8-bit channel count\n");
363 if(channels == 1) CHECK_FMT_RET(AL_FORMAT_MONO16);
364 if(channels == 2) CHECK_FMT_RET(AL_FORMAT_STEREO16);
365 if(alIsExtensionPresent("AL_EXT_MCFORMATS"))
367 if(channels == 4) CHECK_FMT_RET(AL_FORMAT_QUAD16);
368 if(channels == 6) CHECK_FMT_RET(AL_FORMAT_51CHN16);
369 if(channels == 7) CHECK_FMT_RET(AL_FORMAT_61CHN16);
370 if(channels == 8) CHECK_FMT_RET(AL_FORMAT_71CHN16);
372 if(alIsExtensionPresent("AL_LOKI_quadriphonic"))
374 if(channels == 4) CHECK_FMT_RET(AL_FORMAT_QUAD16_LOKI);
376 SetError("Unsupported 16-bit channel count\n");
379 SetError("Unsupported PCM bit depth\n");
383 if(bits == 32 && alIsExtensionPresent("AL_EXT_FLOAT32"))
385 if(channels == 1) CHECK_FMT_RET(AL_FORMAT_MONO_FLOAT32);
386 if(channels == 2) CHECK_FMT_RET(AL_FORMAT_STEREO_FLOAT32);
387 if(alIsExtensionPresent("AL_EXT_MCFORMATS"))
389 if(channels == 4) CHECK_FMT_RET(AL_FORMAT_QUAD32);
390 if(channels == 6) CHECK_FMT_RET(AL_FORMAT_51CHN32);
391 if(channels == 7) CHECK_FMT_RET(AL_FORMAT_61CHN32);
392 if(channels == 8) CHECK_FMT_RET(AL_FORMAT_71CHN32);
394 SetError("Unsupported float32 channel count\n");
397 if(bits == 64 && alIsExtensionPresent("AL_EXT_DOUBLE"))
399 if(channels == 1) CHECK_FMT_RET(AL_FORMAT_MONO_DOUBLE_EXT);
400 if(channels == 2) CHECK_FMT_RET(AL_FORMAT_STEREO_DOUBLE_EXT);
401 SetError("Unsupported double channel count\n");
406 SetError("Unsupported float bit depth\n");
412 /* Function: alureGetVersion
414 * Stores the major and minor version of the library. If either major or minor
415 * are NULL, that value is not provided.
417 ALURE_API void ALURE_APIENTRY alureGetVersion(ALuint *major, ALuint *minor)
419 if(major) *major = ALURE_VER_MAJOR;
420 if(minor) *minor = ALURE_VER_MINOR;
423 /* Function: alureGetErrorString
425 * Returns a string describing the last error encountered.
427 ALURE_API const ALchar* ALURE_APIENTRY alureGetErrorString(void)
429 const ALchar *ret = last_error;
430 last_error = "No error";
435 /* Function: alureGetDeviceNames
437 * Gets an array of device name strings from OpenAL. This encapsulates
438 * AL_ENUMERATE_ALL_EXT (if supported and 'all' is true) and standard
439 * enumeration, with 'count' being set to the number of returned device
443 * An array of device name strings, or NULL on error.
446 * <alureFreeDeviceNames>
448 ALURE_API const ALCchar** ALURE_APIENTRY alureGetDeviceNames(ALCboolean all, ALCsizei *count)
450 const ALCchar *list = NULL;
451 if(all && alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT"))
452 list = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
454 list = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
458 SetError("No device names found");
462 const ALCchar *cur = list;
463 ALuint retlistLen = 0;
466 cur += strlen(cur)+1;
470 const ALCchar **retlist = new const ALCchar*[retlistLen+1];
475 ALCuint len = strlen(cur)+1;
476 ALCchar *newstr = new ALCchar[len];
478 memcpy(newstr, cur, len);
481 retlist[retlistLen] = newstr;
484 retlist[retlistLen] = NULL;
490 /* Function: alureFreeDeviceNames
492 * Frees the device name array returned from alureGetDeviceNames.
495 * <alureGetDeviceNames>
497 ALURE_API ALvoid ALURE_APIENTRY alureFreeDeviceNames(const ALCchar **names)
501 for(ALCuint i = 0;names[i];i++)
502 delete[] const_cast<ALCchar*>(names[i]);
508 /* Function: alureInitDevice
510 * Opens the named device, creates a context with the given attributes, and
511 * sets that context as current. The name and attribute list would be the same
512 * as what's passed to alcOpenDevice and alcCreateContext respectively.
518 * <alureShutdownDevice>
520 ALURE_API ALboolean ALURE_APIENTRY alureInitDevice(const ALCchar *name, const ALCint *attribs)
522 ALCdevice *device = alcOpenDevice(name);
527 SetError("Device open failed");
531 ALCcontext *context = alcCreateContext(device, attribs);
532 if(!context || alcMakeContextCurrent(context) == ALC_FALSE)
535 alcDestroyContext(context);
536 alcCloseDevice(device);
538 SetError("Context setup failed");
546 /* Function: alureShutdownDevice
548 * Destroys the current context and closes its associated device.
556 ALURE_API ALboolean ALURE_APIENTRY alureShutdownDevice(void)
558 ALCcontext *context = alcGetCurrentContext();
559 ALCdevice *device = alcGetContextsDevice(context);
560 if(!context || !device)
563 SetError("Failed to get current device");
567 if(alcMakeContextCurrent(NULL) == ALC_FALSE)
570 SetError("Failed to unset current context");
574 alcDestroyContext(context);
575 alcCloseDevice(device);
582 /* Function: alureGetSampleFormat
584 * Retrieves an OpenAL format for the given sample format. If bits is non-0,
585 * floatbits must be 0, and if floatbits is non-0, bits must be 0. The
586 * application should not rely on any particular format enum being returned as
587 * it is dependant on the available extensions. The returned format will be
588 * valid for the current context. Requires an active context.
591 * An OpenAL format enum for the given sample format, or AL_NONE if one can't
594 ALURE_API ALenum ALURE_APIENTRY alureGetSampleFormat(ALuint channels, ALuint bits, ALuint floatbits)
596 if(alGetError() != AL_NO_ERROR)
598 SetError("Existing OpenAL error");
602 if(bits && floatbits)
604 SetError("Both bit-types specified");
609 return GetSampleFormat(channels, bits, false);
610 return GetSampleFormat(channels, floatbits, true);
614 /* Function: alureInstallDecodeCallbacks
616 * Installs callbacks to enable ALURE to handle more file types. The index is
617 * the order that each given set of callbacks will be tried, starting at the
618 * most negative number (INT_MIN) and going up. Negative indices will be tried
619 * before the built-in decoders, and positive indices will be tried after.
620 * Installing callbacks onto the same index multiple times will remove the
621 * previous callbacks, and removing old callbacks won't affect any opened files
622 * using them (they'll continue to use the old functions until properly closed,
623 * although newly opened files will use the new ones). Passing NULL for all
624 * callbacks is a valid way to remove an installed set, otherwise certain
625 * callbacks must be specified. Callbacks that are not specified will assume
629 * open_file - This callback is expected to open the named file and prepare it
630 * for decoding. If the callbacks cannot decode the file, NULL
631 * should be returned to indicate failure. Upon success, a non-NULL
632 * handle must be returned, which will be used as a unique
633 * identifier for the decoder instance. This callback is required
634 * if open_memory is not specified.
635 * open_memory - This callback behaves the same as open_file, except it takes a
636 * memory segment for input instead of a filename. The given
637 * memory will remain valid while the instance is open. This
638 * callback is required if open_file is not specified.
639 * get_format - This callback is used to retrieve the format of the decoded
640 * data for the given instance. It is the responsibility of the
641 * function to make sure the returned format is valid for the
642 * current AL context (eg. don't return AL_FORMAT_QUAD16 if the
643 * AL_EXT_MCFORMATS extension isn't available). Returning 0 for
644 * samplerate or blocksize, or returning AL_NONE for format, will
645 * cause a failure. Returning AL_FALSE indicates failure. This
646 * callback is required.
647 * decode - This callback is called to get more decoded data. Up to the
648 * specified amount of bytes should be written to the data pointer.
649 * The number of bytes written should be a multiple of the block size,
650 * otherwise an OpenAL error may occur during buffering. The function
651 * should return the number of bytes written. This callback is
653 * rewind - This callback is for rewinding the instance so that the next decode
654 * calls for it will get audio data from the start of the sound file.
655 * If the stream fails to rewind, AL_FALSE should be returned.
656 * close - This callback is called at the end of processing for a particular
657 * instance. The handle will not be used further and any associated
658 * data may be deleted.
663 ALURE_API ALboolean ALURE_APIENTRY alureInstallDecodeCallbacks(ALint index,
664 void* (*open_file)(const ALchar *filename),
665 void* (*open_memory)(const ALubyte *data, ALuint length),
666 ALboolean (*get_format)(void *instance, ALenum *format, ALuint *samplerate, ALuint *blocksize),
667 ALuint (*decode)(void *instance, ALubyte *data, ALuint bytes),
668 ALboolean (*rewind)(void *instance),
669 void (*close)(void *instance))
671 if(!open_file && !open_memory && !get_format && !decode && !rewind && !close)
673 std::map<ALint,UserCallbacks>::iterator i = InstalledCallbacks.find(index);
674 if(i != InstalledCallbacks.end())
675 InstalledCallbacks.erase(i);
679 if((!open_file && !open_memory) || !get_format || !decode)
681 SetError("Missing callback functions");
686 newcb.open_file = open_file;
687 newcb.open_mem = open_memory;
688 newcb.get_fmt = get_format;
689 newcb.decode = decode;
690 newcb.rewind = rewind;
693 InstalledCallbacks[index] = newcb;
699 /* Function: alureSleep
701 * Rests the calling thread for the given number of seconds.
706 ALURE_API ALboolean ALURE_APIENTRY alureSleep(ALfloat duration)
710 SetError("Invalid duration");
714 ALuint seconds = (ALuint)duration;
715 ALdouble rest = duration - (ALdouble)seconds;
717 #ifdef HAVE_NANOSLEEP
719 struct timespec t, remainingTime;
720 t.tv_sec = (time_t)seconds;
721 t.tv_nsec = (long)(rest*1000000000);
723 while(nanosleep(&t, &remainingTime) < 0 && errno == EINTR)
726 #elif defined(HAVE_WINDOWS_H)
733 Sleep((DWORD)(rest * 1000));
741 /* Function: alureGetProcAddress
743 * Returns a pointer for the named ALURE function.
748 * *Version Added*: 1.1
750 ALURE_API void* ALURE_APIENTRY alureGetProcAddress(const ALchar *funcname)
752 static const struct {
756 #define ADD_FUNCTION(x) { #x, (void*)x },
757 ADD_FUNCTION(alureGetVersion)
758 ADD_FUNCTION(alureGetErrorString)
759 ADD_FUNCTION(alureGetDeviceNames)
760 ADD_FUNCTION(alureFreeDeviceNames)
761 ADD_FUNCTION(alureInitDevice)
762 ADD_FUNCTION(alureShutdownDevice)
763 ADD_FUNCTION(alureGetSampleFormat)
764 ADD_FUNCTION(alureSleep)
765 ADD_FUNCTION(alureCreateBufferFromFile)
766 ADD_FUNCTION(alureCreateBufferFromMemory)
767 ADD_FUNCTION(alureBufferDataFromFile)
768 ADD_FUNCTION(alureBufferDataFromMemory)
769 ADD_FUNCTION(alureCreateStreamFromFile)
770 ADD_FUNCTION(alureCreateStreamFromMemory)
771 ADD_FUNCTION(alureCreateStreamFromStaticMemory)
772 ADD_FUNCTION(alureCreateStreamFromCallback)
773 ADD_FUNCTION(alureGetStreamLength)
774 ADD_FUNCTION(alureRewindStream)
775 ADD_FUNCTION(alureDestroyStream)
776 ADD_FUNCTION(alureSetStreamOrder)
777 ADD_FUNCTION(alureSetStreamPatchset)
778 ADD_FUNCTION(alureInstallDecodeCallbacks)
779 ADD_FUNCTION(alureSetIOCallbacks)
780 ADD_FUNCTION(alureGetProcAddress)
781 ADD_FUNCTION(alurePlaySourceStream)
782 ADD_FUNCTION(alurePlaySource)
783 ADD_FUNCTION(alureStopSource)
789 for(i = 0;FunctionList[i].name;i++)
791 if(strcmp(FunctionList[i].name, funcname) == 0)
795 if(!FunctionList[i].name)
796 SetError("Function not found");
797 return FunctionList[i].func;