Skip to content

Commit

Permalink
Client|Audio: Added audio::System (stub) for the client
Browse files Browse the repository at this point in the history
All audio subsystem functionality should be moved here.
  • Loading branch information
danij-deng committed Aug 6, 2015
1 parent 48c60c2 commit 47053fa
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 1 deletion.
50 changes: 50 additions & 0 deletions doomsday/apps/client/include/audio/system.h
@@ -0,0 +1,50 @@
/** @file audio/system.h Audio subsystem.
*
* @authors Copyright © 2015 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>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 2 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</small>
*/

#ifndef CLIENT_AUDIO_SYSTEM_H
#define CLIENT_AUDIO_SYSTEM_H

#include <de/System>

namespace audio {

/**
* Client audio subsystem.
*
* Singleton: there can only be one instance of the audio system at a time.
*
* @ingroup audio
*/
class System : public de::System
{
public:
static System &get();

public:
System();

// Systems observe the passage of time.
void timeChanged(de::Clock const &) override;

private:
DENG2_PRIVATE(d)
};

} // namespace audio

#endif // CLIENT_AUDIO_SYSTEM_H
7 changes: 6 additions & 1 deletion doomsday/apps/client/include/dd_main.h
Expand Up @@ -29,6 +29,7 @@
#include <doomsday/plugins.h>
#include <doomsday/Games>

#include "audio/system.h"
#include "resource/resourcesystem.h"
#include "world/worldsystem.h"
#include "ui/infine/infinesystem.h"
Expand Down Expand Up @@ -59,11 +60,15 @@ void App_Error(char const *error, ...);

void App_AbnormalShutdown(char const *error);

ResourceSystem &App_ResourceSystem();
/// Returns the application's global audio::System.
audio::System &App_AudioSystem();

/// Returns the application's global InFineSystem.
InFineSystem &App_InFineSystem();

/// Returns the application's global ResourceSystem.
ResourceSystem &App_ResourceSystem();

/// Returns the application's global WorldSystem.
WorldSystem &App_WorldSystem();

Expand Down
55 changes: 55 additions & 0 deletions doomsday/apps/client/src/audio/system.cpp
@@ -0,0 +1,55 @@
/** @file system.cpp Audio subsystem module.
*
* @authors Copyright © 2015 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>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 2 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</small>
*/

#include "audio/system.h"

#include <de/App>

using namespace de;

namespace audio {

static audio::System *theAudioSystem = nullptr;

DENG2_PIMPL(System)
{
Instance(Public *i) : Base(i)
{
theAudioSystem = thisPublic;
}
~Instance()
{
theAudioSystem = nullptr;
}
};

System::System() : d(new Instance(this))
{}

void System::timeChanged(Clock const &)
{
// Nothing to do.
}

audio::System &System::get()
{
DENG2_ASSERT(theAudioSystem);
return *theAudioSystem;
}

} // namespace audio
5 changes: 5 additions & 0 deletions doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -570,6 +570,11 @@ void App_AbnormalShutdown(char const *message)
exit(1);
}

::audio::System &App_AudioSystem()
{
return ::audio::System::get();
}

ResourceSystem &App_ResourceSystem()
{
return static_cast<ResourceSystem &>(res::System::get());
Expand Down
2 changes: 2 additions & 0 deletions doomsday/apps/server/CMakeLists.txt
Expand Up @@ -28,6 +28,7 @@ set (SHARED_WITH_CLIENT
${src}/include/audio/s_cache.h
${src}/include/audio/s_environ.h
${src}/include/audio/s_main.h
${src}/include/audio/system.h
${src}/include/color.h
${src}/include/con_config.h
${src}/include/dd_def.h
Expand Down Expand Up @@ -121,6 +122,7 @@ set (SHARED_WITH_CLIENT
${src}/src/api_uri.cpp
${src}/src/audio/s_cache.cpp
${src}/src/audio/s_main.cpp
${src}/src/audio/system.cpp
${src}/src/color.cpp
${src}/src/con_config.cpp
${src}/src/dd_loop.cpp
Expand Down

0 comments on commit 47053fa

Please sign in to comment.