Audaspace  1.3.0
A high level audio library.
NULLDevice.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright 2009-2016 Jörg Müller
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 #pragma once
18 
25 #include "devices/IDevice.h"
26 #include "devices/IHandle.h"
27 
29 
30 class IReader;
31 
36 class AUD_API NULLDevice : public IDevice
37 {
38 private:
39  class AUD_LOCAL NULLHandle : public IHandle
40  {
41  private:
42  // delete copy constructor and operator=
43  NULLHandle(const NULLHandle&) = delete;
44  NULLHandle& operator=(const NULLHandle&) = delete;
45 
46  public:
47 
48  NULLHandle();
49 
50  virtual ~NULLHandle() {}
51  virtual bool pause();
52  virtual bool resume();
53  virtual bool stop();
54  virtual bool getKeep();
55  virtual bool setKeep(bool keep);
56  virtual bool seek(float position);
57  virtual float getPosition();
58  virtual Status getStatus();
59  virtual float getVolume();
60  virtual bool setVolume(float volume);
61  virtual float getPitch();
62  virtual bool setPitch(float pitch);
63  virtual int getLoopCount();
64  virtual bool setLoopCount(int count);
65  virtual bool setStopCallback(stopCallback callback = 0, void* data = 0);
66  };
67 
68  // delete copy constructor and operator=
69  NULLDevice(const NULLDevice&) = delete;
70  NULLDevice& operator=(const NULLDevice&) = delete;
71 
72 public:
77 
78  virtual ~NULLDevice();
79 
80  virtual DeviceSpecs getSpecs() const;
81  virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false);
82  virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false);
83  virtual void stopAll();
84  virtual void lock();
85  virtual void unlock();
86  virtual float getVolume() const;
87  virtual void setVolume(float volume);
89 
93  static void registerPlugin();
94 };
95 
NULLDevice
This device plays nothing.
Definition: NULLDevice.h:37
NULLDevice::getVolume
virtual float getVolume() const
Retrieves the overall device volume.
stopCallback
void(* stopCallback)(void *)
The stopCallback is called when a handle reaches the end of the stream and thus gets stopped.
Definition: IHandle.h:42
DeviceSpecs
Specification of a sound device.
Definition: Specification.h:120
ISynchronizer
This class enables global synchronization of several audio applications if supported.
Definition: ISynchronizer.h:39
IReader
This class represents a sound source as stream or as buffer which can be read for example by another ...
Definition: IReader.h:35
NULLDevice::play
virtual std::shared_ptr< IHandle > play(std::shared_ptr< ISound > sound, bool keep=false)
Plays a sound source.
NULLDevice::play
virtual std::shared_ptr< IHandle > play(std::shared_ptr< IReader > reader, bool keep=false)
Plays a sound source.
NULLDevice::getSynchronizer
virtual ISynchronizer * getSynchronizer()
Retrieves the synchronizer for this device, which enables accurate synchronization between audio play...
IDevice.h
The IDevice interface.
AUD_LOCAL
#define AUD_LOCAL
Used for hiding symbols from export in the shared library.
Definition: Audaspace.h:80
NULLDevice::lock
virtual void lock()
Locks the device.
IDevice
The IDevice interface represents an output device for sound sources.
Definition: IDevice.h:47
NULLDevice::getSpecs
virtual DeviceSpecs getSpecs() const
Returns the specification of the device.
AUD_NAMESPACE_END
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition: Audaspace.h:119
NULLDevice::stopAll
virtual void stopAll()
Stops all playing sounds.
NULLDevice::setVolume
virtual void setVolume(float volume)
Sets the overall device volume.
NULLDevice::NULLDevice
NULLDevice()
Creates a new NULLDevice.
IHandle
The IHandle interface represents a playback handles of a specific device.
Definition: IHandle.h:49
AUD_NAMESPACE_BEGIN
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition: Audaspace.h:116
IHandle.h
Defines the IHandle interface as well as possible states of the handle.
AUD_API
#define AUD_API
Used for exporting symbols in the shared library.
Definition: Audaspace.h:93
NULLDevice::registerPlugin
static void registerPlugin()
Registers this plugin.
NULLDevice::unlock
virtual void unlock()
Unlocks the previously locked device.
Status
Status
Status of a playback handle.
Definition: IHandle.h:31