BtEngineSDK will be released soon

BtEngineSDK will be coming to Unity Asset Store soon in 2016!

3 Comments on BtEngineSDK will be released soon

  1. Hello! Cool post, amazing!!!

  2. #ifndef MYPLAYAUDIO_H
    #define MYPLAYAUDIO_H
    #include
    #include
    #include

    #include
    #include
    #include
    #include
    #include

    class MyPlayAudio
    {
    public:
    static void play(const std::string& file, unsigned long fwdSound = SND_FILENAME | SND_SYNC)
    {
    #ifdef UNICODE
    std::wstring stemp = std::wstring(file.begin(), file.end());
    LPCWSTR sw = stemp.c_str();
    if (PlaySound(sw, NULL, fwdSound))
    #else
    if (PlaySound(file.c_str(), NULL, fwdSound))
    #endif
    {
    std::cout << "Playing audio…" << std::endl;
    }
    else
    {
    std::cerr << "Failed to play the audio!" << std::endl;
    }
    }

    private:
    inline static std::queue soundQueue;
    inline static std::mutex queueMutex;
    inline static std::condition_variable cv;
    inline static int stopPlaying = 0; //0: no stop, 1: stop only when finish queue, 2: stop immediately after finish current sound
    inline static std::thread soundThread;
    inline static bool isThreadRunning = false;
    inline static std::mutex initMutex;

    static void soundPlayerThread()
    {
    while (true)
    {
    std::unique_lock lock(queueMutex);

    cv.wait(lock, [] { return !soundQueue.empty() || stopPlaying; });

    if ((stopPlaying == 1 && soundQueue.empty()) || stopPlaying == 2)
    break;

    std::string soundFile = soundQueue.front();
    soundQueue.pop();
    lock.unlock();
    play(soundFile);
    }
    }
    public:
    static void queueSound(const std::string& soundFile)
    {
    std::lock_guard lock(queueMutex);
    soundQueue.push(soundFile);
    cv.notify_one();
    }
    static void startSoundPlayer(bool detach = true)
    {
    std::lock_guard lock(initMutex);
    if (!isThreadRunning)
    {
    soundThread = std::thread(soundPlayerThread);
    if (detach) soundThread.detach();
    isThreadRunning = true;
    }
    }
    static void stopSoundPlayer(bool finishQueue = true)
    {
    {
    std::lock_guard lock(queueMutex);
    if (finishQueue)
    stopPlaying = 1;
    else
    stopPlaying = 2;
    }
    cv.notify_one();
    if (soundThread.joinable())
    soundThread.join();
    isThreadRunning = false;
    }

    };

    #endif

  3. template
    class GenericLinkedListMap
    {
    public:
    static void push(NodeType* head, NodeType* cur,
    std::function getNxt, std::function getPre)
    {
    //implementation to push cur node to the end of list
    }
    static void insert(NodeType* pre, NodeType* cur,
    std::function getNxt, std::function getPre)
    {
    //implementation to insert cur node to be the next node of pre
    }
    static void remove(NodeType* head, NodeType* cur,
    std::function getNxt, std::function getPre)
    {
    //implementation to remove cur node from list
    }
    static void modify(NodeType* cur)
    {

    }

    };

Leave a comment

Your email address will not be published.


*