当前位置: 首页>>代码示例>>C++>>正文


C++ RtMidiIn::isError方法代码示例

本文整理汇总了C++中RtMidiIn::isError方法的典型用法代码示例。如果您正苦于以下问题:C++ RtMidiIn::isError方法的具体用法?C++ RtMidiIn::isError怎么用?C++ RtMidiIn::isError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RtMidiIn的用法示例。


在下文中一共展示了RtMidiIn::isError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rtmidi_in_cancel_callback

void rtmidi_in_cancel_callback (RtMidiInPtr device)
{
#if defined(__NO_EXCEPTIONS__)
    RtMidiIn* rtm = (RtMidiIn*) device->ptr;
    rtm->resetError();
    rtm->cancelCallback ();
    if (rtm->isError()) {
        device->ok  = false;
        device->msg = rtm->getError().what ();
    }
    else {
        delete (CallbackProxyUserData*) device->data;
        device->data = 0;
    }
#else
    try {
        ((RtMidiIn*) device->ptr)->cancelCallback ();
        delete (CallbackProxyUserData*) device->data;
        device->data = 0;
    } catch (const RtMidiError & err) {
        device->ok  = false;
        device->msg = err.what ();
    }
#endif
}
开发者ID:jwurzer,项目名称:rtmidi,代码行数:25,代码来源:rtmidi_c.cpp

示例2: rtmidi_in_get_message

double rtmidi_in_get_message (RtMidiInPtr device, 
                              unsigned char *message,
                              size_t *size)
{
#if defined(__NO_EXCEPTIONS__)
    // FIXME: use allocator to achieve efficient buffering
    std::vector<unsigned char> v;
    RtMidiIn* rtm = (RtMidiIn*) device->ptr;
    rtm->resetError();
    double ret = rtm->getMessage (&v);
    if (rtm->isError()) {
        device->ok  = false;
        device->msg = rtm->getError().what ();
        return -1;
    }

    if (v.size () > 0 && v.size() <= *size) {
        memcpy (message, v.data (), (int) v.size ());
    }

    *size = v.size();
    return ret;
#else
    try {
        // FIXME: use allocator to achieve efficient buffering
        std::vector<unsigned char> v;
        double ret = ((RtMidiIn*) device->ptr)->getMessage (&v);

        if (v.size () > 0 && v.size() <= *size) {
            memcpy (message, v.data (), (int) v.size ());
        }

        *size = v.size();
        return ret;
    } 
    catch (const RtMidiError & err) {
        device->ok  = false;
        device->msg = err.what ();
        return -1;
    }
    catch (...) {
        device->ok  = false;
        device->msg = "Unknown error";
        return -1;
    }
#endif
}
开发者ID:jwurzer,项目名称:rtmidi,代码行数:47,代码来源:rtmidi_c.cpp

示例3: rtmidi_in_create

RtMidiInPtr rtmidi_in_create (enum RtMidiApi api, const char *clientName, unsigned int queueSizeLimit)
{
    std::string name = clientName;
    RtMidiWrapper* wrp = new RtMidiWrapper;
    
#if defined(__NO_EXCEPTIONS__)
    RtMidiIn* rIn = new RtMidiIn ((RtMidi::Api) api, name, queueSizeLimit);
    if (rIn->isError()) {
        wrp->ptr = 0;
        wrp->data = 0;
        wrp->ok  = false;
        wrp->msg = rIn->getError().what ();
    }
    else {
        wrp->ptr = (void*) rIn;
        wrp->data = 0;
        wrp->ok  = true;
        wrp->msg = "";
    }
#else
    try {
        RtMidiIn* rIn = new RtMidiIn ((RtMidi::Api) api, name, queueSizeLimit);
        
        wrp->ptr = (void*) rIn;
        wrp->data = 0;
        wrp->ok  = true;
        wrp->msg = "";

    } catch (const RtMidiError & err) {
        wrp->ptr = 0;
        wrp->data = 0;
        wrp->ok  = false;
        wrp->msg = err.what ();
    }
#endif

    return wrp;
}
开发者ID:jwurzer,项目名称:rtmidi,代码行数:38,代码来源:rtmidi_c.cpp

示例4: rtmidi_in_create_default

/* RtMidiIn API */
RtMidiInPtr rtmidi_in_create_default ()
{
    RtMidiWrapper* wrp = new RtMidiWrapper;

#if defined(__NO_EXCEPTIONS__)
    RtMidiIn* rIn = new RtMidiIn ();
    if (rIn->isError()) {
        wrp->ptr = 0;
        wrp->data = 0;
        wrp->ok  = false;
        wrp->msg = rIn->getError().what ();
    }
    else {
        wrp->ptr = (void*) rIn;
        wrp->data = 0;
        wrp->ok  = true;
        wrp->msg = "";
    }
#else
    try {
        RtMidiIn* rIn = new RtMidiIn ();
        
        wrp->ptr = (void*) rIn;
        wrp->data = 0;
        wrp->ok  = true;
        wrp->msg = "";
    
    } catch (const RtMidiError & err) {
        wrp->ptr = 0;
        wrp->data = 0;
        wrp->ok  = false;
        wrp->msg = err.what ();
    }
#endif

    return wrp;
}
开发者ID:jwurzer,项目名称:rtmidi,代码行数:38,代码来源:rtmidi_c.cpp

示例5: rtmidi_in_set_callback

void rtmidi_in_set_callback (RtMidiInPtr device, RtMidiCCallback callback, void *userData)
{
    device->data = (void*) new CallbackProxyUserData (callback, userData);
#if defined(__NO_EXCEPTIONS__)
    RtMidiIn* rtm = (RtMidiIn*) device->ptr;
    rtm->resetError();
    rtm->setCallback (callback_proxy, device->data);
    if (rtm->isError()) {
        device->ok  = false;
        device->msg = rtm->getError().what ();
        delete (CallbackProxyUserData*) device->data;
        device->data = 0;
    }
#else
    try {
        ((RtMidiIn*) device->ptr)->setCallback (callback_proxy, device->data);
    } catch (const RtMidiError & err) {
        device->ok  = false;
        device->msg = err.what ();
        delete (CallbackProxyUserData*) device->data;
        device->data = 0;
    }
#endif
}
开发者ID:jwurzer,项目名称:rtmidi,代码行数:24,代码来源:rtmidi_c.cpp

示例6: rtmidi_in_get_current_api

enum RtMidiApi rtmidi_in_get_current_api (RtMidiPtr device)
{
#if defined(__NO_EXCEPTIONS__)
    RtMidiIn* rtm = (RtMidiIn*) device->ptr;
    rtm->resetError();
    RtMidiApi curApi = (RtMidiApi) rtm->getCurrentApi ();
    if (rtm->isError()) {
        device->ok  = false;
        device->msg = rtm->getError().what ();
        return RT_MIDI_API_UNSPECIFIED;
    }
    return curApi;
#else
    try {
        return (RtMidiApi) ((RtMidiIn*) device->ptr)->getCurrentApi ();
    
    } catch (const RtMidiError & err) {
        device->ok  = false;
        device->msg = err.what ();

        return RT_MIDI_API_UNSPECIFIED;
    }
#endif
}
开发者ID:jwurzer,项目名称:rtmidi,代码行数:24,代码来源:rtmidi_c.cpp


注:本文中的RtMidiIn::isError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。