示例#1
0
文件: dsound.c 项目: 3dseals/furseal
void *DSoundLoad(void)
{
    if(!ds_handle)
    {
#ifdef _WIN32
        ds_handle = LoadLibraryA("dsound.dll");
        if(ds_handle == NULL)
        {
            AL_PRINT("Failed to load dsound.dll\n");
            return NULL;
        }

#define LOAD_FUNC(f) do { \
    p##f = (void*)GetProcAddress((HMODULE)ds_handle, #f); \
    if(p##f == NULL) \
    { \
        FreeLibrary(ds_handle); \
        ds_handle = NULL; \
        AL_PRINT("Could not load %s from dsound.dll\n", #f); \
        return NULL; \
    } \
} while(0)
#else
        ds_handle = (void*)0xDEADBEEF;
#define LOAD_FUNC(f) p##f = f
#endif

LOAD_FUNC(DirectSoundCreate);
LOAD_FUNC(DirectSoundEnumerateA);
#undef LOAD_FUNC
    }
    return ds_handle;
}
示例#2
0
static ALCboolean DSoundLoad(void)
{
    if(!ds_handle)
    {
        ds_handle = LoadLib("dsound.dll");
        if(ds_handle == NULL)
        {
            ERR("Failed to load dsound.dll\n");
            return ALC_FALSE;
        }

#define LOAD_FUNC(f) do {                                                     \
    p##f = GetSymbol(ds_handle, #f);                                          \
    if(p##f == NULL) {                                                        \
        CloseLib(ds_handle);                                                  \
        ds_handle = NULL;                                                     \
        return ALC_FALSE;                                                     \
    }                                                                         \
} while(0)
        LOAD_FUNC(DirectSoundCreate);
        LOAD_FUNC(DirectSoundEnumerateA);
        LOAD_FUNC(DirectSoundCaptureCreate);
        LOAD_FUNC(DirectSoundCaptureEnumerateA);
#undef LOAD_FUNC
    }
    return ALC_TRUE;
}
示例#3
0
static ALCboolean pa_load(void)
{
    PaError err;

#ifdef HAVE_DYNLOAD
    if(!pa_handle)
    {
#ifdef _WIN32
# define PALIB "portaudio.dll"
#elif defined(__APPLE__) && defined(__MACH__)
# define PALIB "libportaudio.2.dylib"
#elif defined(__OpenBSD__)
# define PALIB "libportaudio.so"
#else
# define PALIB "libportaudio.so.2"
#endif

        pa_handle = LoadLib(PALIB);
        if(!pa_handle)
            return ALC_FALSE;

#define LOAD_FUNC(f) do {                                                     \
    p##f = GetSymbol(pa_handle, #f);                                          \
    if(p##f == NULL)                                                          \
    {                                                                         \
        CloseLib(pa_handle);                                                  \
        pa_handle = NULL;                                                     \
        return ALC_FALSE;                                                     \
    }                                                                         \
} while(0)
        LOAD_FUNC(Pa_Initialize);
        LOAD_FUNC(Pa_Terminate);
        LOAD_FUNC(Pa_GetErrorText);
        LOAD_FUNC(Pa_StartStream);
        LOAD_FUNC(Pa_StopStream);
        LOAD_FUNC(Pa_OpenStream);
        LOAD_FUNC(Pa_CloseStream);
        LOAD_FUNC(Pa_GetDefaultOutputDevice);
        LOAD_FUNC(Pa_GetDefaultInputDevice);
        LOAD_FUNC(Pa_GetStreamInfo);
#undef LOAD_FUNC

        if((err=Pa_Initialize()) != paNoError)
        {
            ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err));
            CloseLib(pa_handle);
            pa_handle = NULL;
            return ALC_FALSE;
        }
    }
#else
    if((err=Pa_Initialize()) != paNoError)
    {
        ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err));
        return ALC_FALSE;
    }
#endif
    return ALC_TRUE;
}
示例#4
0
bool PortBackendFactory::init()
{
    PaError err;

#ifdef HAVE_DYNLOAD
    if(!pa_handle)
    {
#ifdef _WIN32
# define PALIB "portaudio.dll"
#elif defined(__APPLE__) && defined(__MACH__)
# define PALIB "libportaudio.2.dylib"
#elif defined(__OpenBSD__)
# define PALIB "libportaudio.so"
#else
# define PALIB "libportaudio.so.2"
#endif

        pa_handle = LoadLib(PALIB);
        if(!pa_handle)
            return false;

#define LOAD_FUNC(f) do {                                                     \
    p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(pa_handle, #f));        \
    if(p##f == nullptr)                                                       \
    {                                                                         \
        CloseLib(pa_handle);                                                  \
        pa_handle = nullptr;                                                  \
        return false;                                                         \
    }                                                                         \
} while(0)
        LOAD_FUNC(Pa_Initialize);
        LOAD_FUNC(Pa_Terminate);
        LOAD_FUNC(Pa_GetErrorText);
        LOAD_FUNC(Pa_StartStream);
        LOAD_FUNC(Pa_StopStream);
        LOAD_FUNC(Pa_OpenStream);
        LOAD_FUNC(Pa_CloseStream);
        LOAD_FUNC(Pa_GetDefaultOutputDevice);
        LOAD_FUNC(Pa_GetDefaultInputDevice);
        LOAD_FUNC(Pa_GetStreamInfo);
#undef LOAD_FUNC

        if((err=Pa_Initialize()) != paNoError)
        {
            ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err));
            CloseLib(pa_handle);
            pa_handle = nullptr;
            return false;
        }
    }
#else
    if((err=Pa_Initialize()) != paNoError)
    {
        ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err));
        return false;
    }
#endif
    return true;
}
示例#5
0
void RegisterLibCommands(void)
{
    KppBuildFunctionDynamic(LOAD_FUNC(IDF_VBXSETPROP), KpiVBXOpsLH,
                            EVAL_ARGS, CAT_WND | RET_STR);
    KppBuildFunctionDynamic(LOAD_FUNC(IDF_VBXREFRESH), KpiVBXOpsLH,
                            EVAL_ARGS, CAT_WND | RET_STR);
    KppBuildFunctionDynamic(LOAD_FUNC(IDF_VBXGETPROP), KpiVBXOpsLH,
                            EVAL_ARGS, CAT_WND | RET_STR);
}
示例#6
0
void pa_load(void)
{
    const char *str;
    PaError err;

    if(load_count == 0)
    {
#ifdef HAVE_DLFCN_H
#if defined(__APPLE__) && defined(__MACH__)
# define PALIB "libportaudio.2.dylib"
#else
# define PALIB "libportaudio.so.2"
#endif
        pa_handle = dlopen(PALIB, RTLD_NOW);
        if(!pa_handle)
            return;
        dlerror();

#define LOAD_FUNC(f) do { \
    p##f = (typeof(f)*)dlsym(pa_handle, #f); \
    if((str=dlerror()) != NULL) \
    { \
        dlclose(pa_handle); \
        pa_handle = NULL; \
        AL_PRINT("Could not load %s from "PALIB": %s\n", #f, str); \
        return; \
    } \
} while(0)
#else
        str = NULL;
        pa_handle = (void*)0xDEADBEEF;
#define LOAD_FUNC(f) p##f = f
#endif

LOAD_FUNC(Pa_Initialize);
LOAD_FUNC(Pa_Terminate);
LOAD_FUNC(Pa_GetErrorText);
LOAD_FUNC(Pa_StartStream);
LOAD_FUNC(Pa_StopStream);
LOAD_FUNC(Pa_OpenStream);
LOAD_FUNC(Pa_CloseStream);
LOAD_FUNC(Pa_GetDefaultOutputDevice);
LOAD_FUNC(Pa_GetStreamInfo);

#undef LOAD_FUNC

        if((err=pPa_Initialize()) != paNoError)
        {
            AL_PRINT("Pa_Initialize() returned an error: %s\n", pPa_GetErrorText(err));
#ifdef HAVE_DLFCN_H
            dlclose(pa_handle);
#endif
            pa_handle = NULL;
            return;
        }
    }

    ++load_count;
}
示例#7
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_getattr(const char *path, struct stat *st)
{
    int res;

    LOAD_FUNC("getattr")
    lua_pushstring(L_VM, path);
    obj_pcall(1, 11, 0);
    err_pcall(res);

    res = lua_tointeger(L_VM, -11);

    st->st_mode = lua_tointeger(L_VM, -10);
    st->st_ino  = lua_tointeger(L_VM, -9);
    st->st_rdev = lua_tointeger(L_VM, -8);
    st->st_dev  = lua_tointeger(L_VM, -8);
    st->st_nlink= lua_tointeger(L_VM, -7);
    st->st_uid  = lua_tointeger(L_VM, -6);
    st->st_gid  = lua_tointeger(L_VM, -5);
    st->st_size = lua_tointeger(L_VM, -4);
    st->st_atime= lua_tointeger(L_VM, -3);
    st->st_mtime= lua_tointeger(L_VM, -2);
    st->st_ctime= lua_tointeger(L_VM, -1);

    /* Fill in fields not provided by Python lstat() */
    st->st_blksize= 4096;
    st->st_blocks= (st->st_size + 511)/512;

    EPILOGUE(11)

    return res;
}
示例#8
0
    static void Init()
    {
#ifdef _WIN32
#define SNDFILE_LIB "libsndfile-1.dll"
#elif defined(__APPLE__)
#define SNDFILE_LIB "libsndfile.1.dylib"
#else
#define SNDFILE_LIB "libsndfile.so.1"
#endif
        sndfile_handle = OpenLib(SNDFILE_LIB);
        if(!sndfile_handle) return;

        LOAD_FUNC(sndfile_handle, sf_close);
        LOAD_FUNC(sndfile_handle, sf_open_virtual);
        LOAD_FUNC(sndfile_handle, sf_readf_short);
        LOAD_FUNC(sndfile_handle, sf_seek);
    }
示例#9
0
int
VIVANTE_VideoInit(_THIS)
{
    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;

#if SDL_VIDEO_DRIVER_VIVANTE_VDK
    videodata->vdk_private = vdkInitialize();
    if (!videodata->vdk_private) {
        return SDL_SetError("vdkInitialize() failed");
    }
#else
    videodata->egl_handle = SDL_LoadObject("libEGL.so.1");
    if (!videodata->egl_handle) {
        videodata->egl_handle = SDL_LoadObject("libEGL.so");
        if (!videodata->egl_handle) {
            return -1;
        }
    }
#define LOAD_FUNC(NAME) \
    videodata->NAME = SDL_LoadFunction(videodata->egl_handle, #NAME); \
    if (!videodata->NAME) return -1;

    LOAD_FUNC(fbGetDisplay);
    LOAD_FUNC(fbGetDisplayByIndex);
    LOAD_FUNC(fbGetDisplayGeometry);
    LOAD_FUNC(fbGetDisplayInfo);
    LOAD_FUNC(fbDestroyDisplay);
    LOAD_FUNC(fbCreateWindow);
    LOAD_FUNC(fbGetWindowGeometry);
    LOAD_FUNC(fbGetWindowInfo);
    LOAD_FUNC(fbDestroyWindow);
#endif

    if (VIVANTE_SetupPlatform(_this) < 0) {
        return -1;
    }

    if (VIVANTE_AddVideoDisplays(_this) < 0) {
        return -1;
    }

    VIVANTE_UpdateDisplayScale(_this);

#ifdef SDL_INPUT_LINUXEV
    if (SDL_EVDEV_Init() < 0) {
        return -1;
    }
#endif

    return 0;
}
示例#10
0
文件: fuse.c 项目: LuaAndC/luafuse
static void l_signal(int i)
{						/* assert(i==SIGALRM); */

    int res;
     
    signal(i,SIG_DFL); /* reset */

    LOAD_FUNC("pulse")
    obj_pcall(0, 1, 0);
    err_pcall(res);
    EPILOGUE(1)
}
示例#11
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_rmdir(const char *path)
{
    int res;

    LOAD_FUNC("rmdir")
    lua_pushstring(L_VM, path);
    obj_pcall(1, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);
    
    return res;
}
示例#12
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_removexattr(const char *path, const char *name)
{
    int res;

    LOAD_FUNC("removexattr")
    lua_pushstring(L_VM, path);
    lua_pushstring(L_VM, name);
    obj_pcall(2, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);

    return res;
}
示例#13
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_fsyncdir(const char *path, int isdatasync, struct fuse_file_info *fi)
{
    int res;

    LOAD_FUNC("syncdir")
    lua_pushstring(L_VM, path);
    lua_pushboolean(L_VM, isdatasync);
    lua_rawgeti(L_VM, LUA_REGISTRYINDEX, fi->fh); 
    obj_pcall(3, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);
    return res;
}
示例#14
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_link(const char *from, const char *to)
{
    int res;

    LOAD_FUNC("link")
    lua_pushstring(L_VM, from);
    lua_pushstring(L_VM, to);
    obj_pcall(2, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);

    return res;
}
示例#15
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_flush(const char *path, struct fuse_file_info *fi)
{
    int res;

    LOAD_FUNC("flush")
    lua_pushstring(L_VM, path);
    lua_rawgeti(L_VM, LUA_REGISTRYINDEX, fi->fh); 
    obj_pcall(2, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);

    return res;
}
示例#16
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_access(const char *path, int mask)
{
    int res;

    LOAD_FUNC("access")
    lua_pushstring(L_VM, path);
    lua_pushnumber(L_VM, mask);
    obj_pcall(2, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);

    return res;
}
示例#17
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_truncate(const char *path, off_t size)
{
    int res;

    LOAD_FUNC("truncate")
    lua_pushstring(L_VM, path);
    lua_pushnumber(L_VM, size);
    obj_pcall(2, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);

    return res;
}
示例#18
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_chmod(const char *path, mode_t mode)
{
    int res;

    LOAD_FUNC("chmod")
    lua_pushstring(L_VM, path);
    lua_pushnumber(L_VM, mode);
    obj_pcall(2, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);

    return res;
}
示例#19
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_utime(const char *path, struct utimbuf *buf)
{
    int res;

    LOAD_FUNC("utime")
    lua_pushstring(L_VM, path);
    lua_pushnumber(L_VM, buf->actime);
    lua_pushnumber(L_VM, buf->modtime);
    obj_pcall(3, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);

    return res;
}
示例#20
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_chown(const char *path, uid_t uid, gid_t gid)
{
    int res;

    LOAD_FUNC("chown")
    lua_pushstring(L_VM, path);
    lua_pushnumber(L_VM, uid);
    lua_pushnumber(L_VM, gid);
    obj_pcall(3, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);

    return res;
}
示例#21
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_open(const char *path, struct fuse_file_info *fi)
{
    int res;
    int fd;

    LOAD_FUNC("open")
    lua_pushstring(L_VM, path);
    lua_pushnumber(L_VM, fi->flags);
    obj_pcall(2, 2, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -2);
    fi->fh = luaL_ref(L_VM, LUA_REGISTRYINDEX);
    EPILOGUE(1);

    return res;
}
示例#22
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_ftruncate(const char *path, off_t size,
                         struct fuse_file_info *fi)
{
    int res;

    LOAD_FUNC("ftruncate")
    lua_pushstring(L_VM, path);
    lua_pushnumber(L_VM, size);
    lua_rawgeti(L_VM, LUA_REGISTRYINDEX, fi->fh); 
    obj_pcall(3, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);

    return res;
}
示例#23
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_mknod(const char *path, mode_t mode, dev_t rdev)
{
    int res;
    int fifo = S_ISFIFO(mode);

    LOAD_FUNC("mknod")
    lua_pushstring(L_VM, path);
    lua_pushnumber(L_VM, mode);
    lua_pushnumber(L_VM, rdev);
    obj_pcall(3, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);

    EPILOGUE(1);

    return res;
}
示例#24
0
文件: fuse.c 项目: LuaAndC/luafuse
/* xattr operations are optional and can safely be left unimplemented */
static int xmp_setxattr(const char *path, const char *name, const char *value,
                        size_t size, int flags)
{
    int res;

    LOAD_FUNC("setxattr")
    lua_pushstring(L_VM, path);
    lua_pushstring(L_VM, name);
    lua_pushlstring(L_VM, value, size);
    lua_pushnumber(L_VM, flags);
    obj_pcall(4, 1, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -1);
    EPILOGUE(1);

    return res;
}
示例#25
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_write(const char *path, const char *buf, size_t size,
                     off_t offset, struct fuse_file_info *fi)
{
    int res;
    int written;

    LOAD_FUNC("write")
    lua_pushstring(L_VM, path);
    lua_pushlstring(L_VM, buf, size);
    lua_pushnumber(L_VM, offset);
    lua_rawgeti(L_VM, LUA_REGISTRYINDEX, fi->fh); 
    obj_pcall(4, 1, 0);
    err_pcall(res);
    written = lua_tointeger(L_VM, -1);
    EPILOGUE(1)

    return written;
}
示例#26
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_opendir(const char *path, struct fuse_file_info *fi)
{
    int res;

    LOAD_FUNC("opendir")
    lua_pushstring(L_VM, path);
    obj_pcall(1, 2, 0);
    err_pcall(res);

    res = lua_tointeger(L_VM, -2);

    /* save the return as reference */
    fi->fh = luaL_ref(L_VM, LUA_REGISTRYINDEX);

    EPILOGUE(1);

    return res;
}
示例#27
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_listxattr(const char *path, char *list, size_t size)
{
    int res;
    size_t l;
    const char *o;

    LOAD_FUNC("listxattr")
    lua_pushstring(L_VM, path);
    lua_pushnumber(L_VM, size);
    obj_pcall(2, 2, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -2);
    o = lua_tolstring(L_VM, -1, &l);
    if (o) memcpy(list, o, min(l,size));
    EPILOGUE(2);

    return o ? (size > 0  ? min(l,size) : l) : res;
}
示例#28
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_readlink(const char *path, char *buf, size_t size)
{
    int res;
    size_t l;
    const char *str;

    LOAD_FUNC("readlink")
    lua_pushstring(L_VM, path);
    obj_pcall(1, 2, 0);
    err_pcall(res);

    res = lua_tointeger(L_VM, -2);
    str = lua_tolstring(L_VM, -1, &l);
    memcpy(buf, str, min(l,size-1));
    buf[min(l,size-1)]='\0';

    EPILOGUE(2);

    return res;
}
示例#29
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_statfs(const char *path, struct statvfs *st)
{
    int res;

    LOAD_FUNC("statfs")
    lua_pushstring(L_VM, path);
    obj_pcall(1, 7, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -7);
    st->f_bsize = lua_tointeger(L_VM, -6);
    st->f_blocks = lua_tointeger(L_VM, -5);
    st->f_bfree  = lua_tointeger(L_VM, -4);
    st->f_bavail = lua_tointeger(L_VM, -3);
    st->f_files  = lua_tointeger(L_VM, -2);
    st->f_ffree  = lua_tointeger(L_VM, -1);

    EPILOGUE(7);

    return res;
}
示例#30
0
文件: fuse.c 项目: LuaAndC/luafuse
static int xmp_read(const char *path, char *buf, size_t size, off_t offset,
                    struct fuse_file_info *fi)
{
    int res;
    const char* o;
    size_t l;

    LOAD_FUNC("read")
    lua_pushstring(L_VM, path);
    lua_pushnumber(L_VM, size);
    lua_pushnumber(L_VM, offset);
    lua_rawgeti(L_VM, LUA_REGISTRYINDEX, fi->fh); 
    obj_pcall(4, 2, 0);
    err_pcall(res);
    res = lua_tointeger(L_VM, -2);
    o = lua_tolstring(L_VM, -1, &l);
    if (o) memcpy(buf, o, min(l,size));
    EPILOGUE(2)

    return o ? min(l,size) : res;
}