/*
  Copyright (C) 2010-2011  Charles Pence <charles@charlespence.net>
  Copyright (C) 1996-1997  Id Software, Inc.

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOUND_SERVICE_H__
#define SOUND_SERVICE_H__

namespace sound
{

class Mixer;

class Service
{
public:
    // Start the sound service
    void Initialize();
    
    // Shut down the sound service
    void Shutdown();
    
private:
    // The thread procedure, wait and update
    void ThreadProc();
    
    void PlaySound(int entity_num, int entity_channel, unsigned soundindex, vec3_t origin, float vol, float attenuation);
    void PlayStaticSound(unsigned soundindex, vec3_t origin, float vol, float attenuation);
    
    void PlayMusic(int track);
    void PauseMusic(bool pause);
    
    bool Play_f(const std::string &cmd);
    bool PlayVol_f(const std::string &cmd);
    bool StopSound_f(const std::string &cmd);
    
    bool initialized_;
    
    boost::thread thread_;
    boost::mutex thread_lock_;
    bool thread_run_;
    
    Mixer *mixer_;
    Mix_Music *music_;
};

}




#endif /* SOUND_SERVICE_H__ */
