Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Divice init failed and format not supported error  (Read 2965 times)

0 Members and 1 Guest are viewing this topic.

Rokner

  • Newbie
  • *
  • Posts: 3
    • View Profile
Divice init failed and format not supported error
« on: October 29, 2015, 12:26:14 pm »
So I started learning sfml really soon so I'm new here. I encountered a problem with playing audio. Here is the full error I get :
"AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80004005
Failed to open the audio device
Failed to open sound file (format not supported) "

Here is the code I use for playing music:

class ServiceLocator
{
public:
   static IAudioProvider* GetAudio() { return _audioProvider; }const

   static void RegisterServiceLocator(IAudioProvider *provider)
   {
      _audioProvider = provider;
   }

private:
   static IAudioProvider *_audioProvider;
};

//...

void SFMLSoundProvider::PlaySong(std::string filename, bool looping)
{      
        _music.openFromFile(filename);
        _music.setLoop(looping);
        _music.play();
}

//...

void Game::Start(void)
{
        if (_gameState != Uninitialized)
                return;

        _mainWindow.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "Pang!");

        SFMLSoundProvider soundProvider;
        ServiceLocator::RegisterServiceLocator(&soundProvider);

        ServiceLocator::GetAudio()->PlaySound("music\\Techno-Celebration.wav");

        _gameState = Game::ShowingSplash;

        while (!IsExiting())
        {
                GameLoop();
        }

        _mainWindow.close();
}
 

I don't have problem with my audio devices. And I think I have everything linked correctly because everything else is working. And I have the OpenAl.dll in the correct directory.

mkalex777

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: Divice init failed and format not supported error
« Reply #1 on: October 29, 2015, 01:08:19 pm »
are you sure that your WAV container not consists of MP3 stream? Because WAV is just a container file which may contains any format. But there is no support for MP3 in SFML.
You can convert your file into OGG with online converter: http://audio.online-convert.com/convert-to-ogg

Rokner

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Divice init failed and format not supported error
« Reply #2 on: October 29, 2015, 01:11:21 pm »
Oh my gosh thanks a lot that was the problem. Thank you so much.