unique_ptr and StateManager for my basic SFML game, I got error from command screen

0
void GameManager::pushMenuState()
{
    states.push_back(std::move(std::make_unique<MenuState>(window)));//std::make_unique<MenuState>(window)
}

void GameManager::pushPlayState()
{
    states.push_back(std::move(std::make_unique<PlayState>(window)));//std::make_unique<PlayState>(window)
}
/*-------------------------------------------------*/
void GameManager::popState()
{
    states.erase(states.begin());
}
////////////////////////////////////////////////////


void GameManager::Update()
{
    while(window->isOpen())
    {
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
        {
            isMenu=false;
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
        {
            isMenu=true;

        }
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
        if(isMenu)
        {
            if(states.empty())
                pushMenuState();
            else if(states.size()<=1&&states.front()->getStateType()!=State::MENU)
                pushMenuState();
            
            if(states.size()>1&&states.front()->getStateType()!=State::MENU)
                popState();
            states.back()->Update(window);

        }
////////////////////////////////////////////////////////////////////////////////////////////////////////
        else
        {
            if(states.empty())
                pushPlayState();
            else if(states.size()<=1&&states.front()->getStateType()!=State::PLAY)
                pushPlayState();
            
            if(states.size()>1&&states.front()->getStateType()!=State::PLAY)
                popState();
            states.back()->Update(window);
        }
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

    }


}

It's my code. First I am on menu state. I am pressing "D" for switch play state. it is working. But when I want to go menu state again I pressed "S", I got error from command prompt, error not coming from IDE:

Error description: AL_INVALID_OPERATION The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundStream.cpp(317). Expression: alSourcePlay(m_source) Error description: AL_INVALID_OPERATION The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundStream.cpp(329). Expression: alGetSourcei(m_source, AL_BUFFERS_PROCESSED, &nbProcessed) Error description: AL_INVALID_OPERATION The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundSource.cpp(196). Expression: alGetSourcei(m_source, AL_SOURCE_STATE, &status) Error description: AL_INVALID_OPERATION The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundSource.cpp(196). Expression: alGetSourcei(m_source, AL_SOURCE_STATE, &status) Error description: AL_INVALID_OPERATION The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundStream.cpp(317). Expression: alSourcePlay(m_source) Error description: AL_INVALID_OPERATION The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundStream.cpp(329). Expression: alGetSourcei(m_source, AL_BUFFERS_PROCESSED, &nbProcessed) Error description: AL_INVALID_OPERATION The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundSource.cpp(196). Expression: alGetSourcei(m_source, AL_SOURCE_STATE, &status) Error description: AL_INVALID_OPERATION The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundSource.cpp(196). Expression: alGetSourcei(m_source, AL_SOURCE_STATE, &status) Error de Process returned -1073741819 (0xC0000005) execution time : 4.611 s Press any key to continue.

Why I got that? what is the problem about pushing states?

c++
state
sfml
unique-ptr

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0