Add Chromium-only Blender WebEngine parity work
This commit is contained in:
165
blender-5.2.0/extern/audaspace/include/devices/DeviceManager.h
vendored
Normal file
165
blender-5.2.0/extern/audaspace/include/devices/DeviceManager.h
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file DeviceManager.h
|
||||
* @ingroup devices
|
||||
* The DeviceManager class.
|
||||
*/
|
||||
|
||||
#include "Audaspace.h"
|
||||
#include "respec/Specification.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class IDevice;
|
||||
class IDeviceFactory;
|
||||
class ICaptureDeviceFactory;
|
||||
class I3DDevice;
|
||||
class IReader;
|
||||
|
||||
/**
|
||||
* This class manages all device plugins and maintains a device if asked to do so.
|
||||
*
|
||||
* This enables applications to access their output device without having to carry
|
||||
* it through the whole application.
|
||||
*/
|
||||
class AUD_API DeviceManager
|
||||
{
|
||||
private:
|
||||
static std::unordered_map<std::string, std::shared_ptr<IDeviceFactory>> m_factories;
|
||||
|
||||
static std::shared_ptr<IDevice> m_device;
|
||||
static std::unordered_map<std::string, std::shared_ptr<ICaptureDeviceFactory>> m_capture_factories;
|
||||
|
||||
// delete copy constructor and operator=
|
||||
DeviceManager(const DeviceManager&) = delete;
|
||||
DeviceManager& operator=(const DeviceManager&) = delete;
|
||||
DeviceManager() = delete;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Registers a device factory.
|
||||
*
|
||||
* This method is mostly used by plugin developers to add their device implementation
|
||||
* for general use by the library end users.
|
||||
* @param name A representative name for the device.
|
||||
* @param factory The factory that creates the device.
|
||||
*/
|
||||
static void registerDevice(const std::string &name, std::shared_ptr<IDeviceFactory> factory);
|
||||
|
||||
/**
|
||||
* Returns the factory for a specific device.
|
||||
* @param name The representative name of the device.
|
||||
* @return The factory if it was found, or nullptr otherwise.
|
||||
*/
|
||||
static std::shared_ptr<IDeviceFactory> getDeviceFactory(const std::string &name);
|
||||
|
||||
/**
|
||||
* Returns the default device based on the priorities of the registered factories.
|
||||
* @return The default device or nullptr if no factory has been registered.
|
||||
*/
|
||||
static std::shared_ptr<IDeviceFactory> getDefaultDeviceFactory();
|
||||
|
||||
|
||||
/**
|
||||
* Sets a device that should be handled by the manager.
|
||||
*
|
||||
* If a device is currently being handled it will be released.
|
||||
* @param device The device the manager should take care of.
|
||||
*/
|
||||
static void setDevice(std::shared_ptr<IDevice> device);
|
||||
|
||||
/**
|
||||
* Opens a device which will then be handled by the manager.
|
||||
*
|
||||
* If a device is currently being handled it will be released.
|
||||
* @param name The representative name of the device.
|
||||
*/
|
||||
static void openDevice(const std::string &name);
|
||||
|
||||
/**
|
||||
* Opens the default device which will then be handled by the manager.
|
||||
*
|
||||
* The device to open is selected based on the priority of the registered factories.
|
||||
* If a device is currently being handled it will be released.
|
||||
*/
|
||||
static void openDefaultDevice();
|
||||
|
||||
/**
|
||||
* Releases the currently handled device.
|
||||
*/
|
||||
static void releaseDevice();
|
||||
|
||||
/**
|
||||
* Returns the currently handled device.
|
||||
* @return The handled device or nullptr if no device has been registered.
|
||||
*/
|
||||
static std::shared_ptr<IDevice> getDevice();
|
||||
|
||||
/**
|
||||
* Returns the currently handled 3D device.
|
||||
* @return The handled device or nullptr if no device has been registered
|
||||
* or the registered device is not an I3DDevice.
|
||||
*/
|
||||
static std::shared_ptr<I3DDevice> get3DDevice();
|
||||
|
||||
/**
|
||||
* Returns a list of available devices.
|
||||
* @return A list of strings with the names of available devices.
|
||||
*/
|
||||
static std::vector<std::string> getAvailableDeviceNames();
|
||||
|
||||
/**
|
||||
* Returns a list of available capture devices.
|
||||
* @return A list of strings with the names of available capture devices.
|
||||
*/
|
||||
static std::vector<std::string> getAvailableCaptureDeviceNames();
|
||||
|
||||
/**
|
||||
* Returns the factory for a specific capture device.
|
||||
* @param name The representative name of the capture device.
|
||||
* @return The factory if it was found, or nullptr otherwise.
|
||||
*/
|
||||
static std::shared_ptr<ICaptureDeviceFactory> getCaptureDeviceFactory(const std::string& name);
|
||||
|
||||
/**
|
||||
* Registers a capture device factory.
|
||||
* @param name A representative name for the capture device.
|
||||
* @param factory The factory that creates the capture reader.
|
||||
*/
|
||||
static void registerCaptureDevice(const std::string& name, std::shared_ptr<ICaptureDeviceFactory> factory);
|
||||
|
||||
/**
|
||||
* Opens an input capture reader.
|
||||
* @param name The capture device name.
|
||||
* @param specs The desired specification.
|
||||
* @param buffersize The capture buffer size in samples.
|
||||
*/
|
||||
static std::shared_ptr<IReader> openCaptureDevice(const std::string& name,
|
||||
Specs specs,
|
||||
int buffersize = AUD_DEFAULT_BUFFER_SIZE);
|
||||
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
142
blender-5.2.0/extern/audaspace/include/devices/I3DDevice.h
vendored
Normal file
142
blender-5.2.0/extern/audaspace/include/devices/I3DDevice.h
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file I3DDevice.h
|
||||
* @ingroup devices
|
||||
* Defines the I3DDevice interface as well as the different distance models.
|
||||
*/
|
||||
|
||||
#include "util/Math3D.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Possible distance models for the 3D device.
|
||||
*
|
||||
* The distance models supported are the same as documented in the [OpenAL Specification](http://openal.org/).
|
||||
*/
|
||||
enum DistanceModel
|
||||
{
|
||||
DISTANCE_MODEL_INVALID = 0,
|
||||
DISTANCE_MODEL_INVERSE,
|
||||
DISTANCE_MODEL_INVERSE_CLAMPED,
|
||||
DISTANCE_MODEL_LINEAR,
|
||||
DISTANCE_MODEL_LINEAR_CLAMPED,
|
||||
DISTANCE_MODEL_EXPONENT,
|
||||
DISTANCE_MODEL_EXPONENT_CLAMPED
|
||||
};
|
||||
|
||||
/**
|
||||
* @interface I3DDevice
|
||||
* The I3DDevice interface represents an output device for 3D sound.
|
||||
*
|
||||
* The interface has been modelled after the OpenAL 1.1 API,
|
||||
* see the [OpenAL Specification](http://openal.org/) for lots of details.
|
||||
*/
|
||||
class AUD_API I3DDevice
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Retrieves the listener location.
|
||||
* \return The listener location.
|
||||
*/
|
||||
virtual Vector3 getListenerLocation() const=0;
|
||||
|
||||
/**
|
||||
* Sets the listener location.
|
||||
* \param location The new location.
|
||||
* \note The location is not updated with the velocity and
|
||||
* remains constant until the next call of this method.
|
||||
*/
|
||||
virtual void setListenerLocation(const Vector3& location)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the listener velocity.
|
||||
* \return The listener velocity.
|
||||
*/
|
||||
virtual Vector3 getListenerVelocity() const=0;
|
||||
|
||||
/**
|
||||
* Sets the listener velocity.
|
||||
* \param velocity The new velocity.
|
||||
* \note This velocity does not change the position of the listener
|
||||
* over time, it is simply used for the calculation of the doppler effect.
|
||||
*/
|
||||
virtual void setListenerVelocity(const Vector3& velocity)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the listener orientation.
|
||||
* \return The listener orientation as quaternion.
|
||||
*/
|
||||
virtual Quaternion getListenerOrientation() const=0;
|
||||
|
||||
/**
|
||||
* Sets the listener orientation.
|
||||
* \param orientation The new orientation as quaternion.
|
||||
* \note The coordinate system used is right handed and the listener
|
||||
* by default is oriented looking in the negative z direction with the
|
||||
* positive y axis as up direction.
|
||||
*/
|
||||
virtual void setListenerOrientation(const Quaternion& orientation)=0;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the speed of sound.
|
||||
* This value is needed for doppler effect calculation.
|
||||
* \return The speed of sound.
|
||||
*/
|
||||
virtual float getSpeedOfSound() const=0;
|
||||
|
||||
/**
|
||||
* Sets the speed of sound.
|
||||
* This value is needed for doppler effect calculation.
|
||||
* \param speed The new speed of sound.
|
||||
*/
|
||||
virtual void setSpeedOfSound(float speed)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the doppler factor.
|
||||
* This value is a scaling factor for the velocity vectors of sources and
|
||||
* listener which is used while calculating the doppler effect.
|
||||
* \return The doppler factor.
|
||||
*/
|
||||
virtual float getDopplerFactor() const=0;
|
||||
|
||||
/**
|
||||
* Sets the doppler factor.
|
||||
* This value is a scaling factor for the velocity vectors of sources and
|
||||
* listener which is used while calculating the doppler effect.
|
||||
* \param factor The new doppler factor.
|
||||
*/
|
||||
virtual void setDopplerFactor(float factor)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the distance model.
|
||||
* \return The distance model.
|
||||
*/
|
||||
virtual DistanceModel getDistanceModel() const=0;
|
||||
|
||||
/**
|
||||
* Sets the distance model.
|
||||
* \param model distance model.
|
||||
*/
|
||||
virtual void setDistanceModel(DistanceModel model)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
232
blender-5.2.0/extern/audaspace/include/devices/I3DHandle.h
vendored
Normal file
232
blender-5.2.0/extern/audaspace/include/devices/I3DHandle.h
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file I3DHandle.h
|
||||
* @ingroup devices
|
||||
* The I3DHandle interface.
|
||||
*/
|
||||
|
||||
#include "util/Math3D.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* @interface I3DHandle
|
||||
* The I3DHandle interface represents a playback handle for 3D sources.
|
||||
* If the playback IDevice class also implements the I3DDevice interface
|
||||
* then all playback IHandle instances also implement this interface.
|
||||
*
|
||||
* The interface has been modelled after the OpenAL 1.1 API,
|
||||
* see the [OpenAL Specification](http://openal.org/) for lots of details.
|
||||
*/
|
||||
class AUD_API I3DHandle
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the handle.
|
||||
*/
|
||||
virtual ~I3DHandle() {}
|
||||
|
||||
/**
|
||||
* Retrieves the location of the source.
|
||||
* \return The location.
|
||||
*/
|
||||
virtual Vector3 getLocation()=0;
|
||||
|
||||
/**
|
||||
* Sets the location of the source.
|
||||
* \param location The new location.
|
||||
* \return Whether the action succeeded.
|
||||
* \note The location is not updated with the velocity and
|
||||
* remains constant until the next call of this method.
|
||||
*/
|
||||
virtual bool setLocation(const Vector3& location)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the velocity of the source.
|
||||
* \return The velocity.
|
||||
*/
|
||||
virtual Vector3 getVelocity()=0;
|
||||
|
||||
/**
|
||||
* Sets the velocity of the source.
|
||||
* \param velocity The new velocity.
|
||||
* \return Whether the action succeeded.
|
||||
* \note This velocity does not change the position of the listener
|
||||
* over time, it is simply used for the calculation of the doppler effect.
|
||||
*/
|
||||
virtual bool setVelocity(const Vector3& velocity)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the orientation of the source.
|
||||
* \return The orientation as quaternion.
|
||||
*/
|
||||
virtual Quaternion getOrientation()=0;
|
||||
|
||||
/**
|
||||
* Sets the orientation of the source.
|
||||
* \param orientation The new orientation as quaternion.
|
||||
* \return Whether the action succeeded.
|
||||
* \note The coordinate system used is right handed and the source
|
||||
* by default is oriented looking in the negative z direction with the
|
||||
* positive y axis as up direction.
|
||||
* \note This setting currently only affects sounds with non-default cone settings.
|
||||
*/
|
||||
virtual bool setOrientation(const Quaternion& orientation)=0;
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the source location, velocity and orientation are relative
|
||||
* to the listener.
|
||||
* \return Whether the source is relative.
|
||||
*/
|
||||
virtual bool isRelative()=0;
|
||||
|
||||
/**
|
||||
* Sets whether the source location, velocity and orientation are relative
|
||||
* to the listener.
|
||||
* \param relative Whether the source is relative.
|
||||
* \return Whether the action succeeded.
|
||||
* \note The default value is true as this setting is used to play sounds ordinarily without 3D.
|
||||
*/
|
||||
virtual bool setRelative(bool relative)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the maximum volume of a source.
|
||||
* \return The maximum volume.
|
||||
*/
|
||||
virtual float getVolumeMaximum()=0;
|
||||
|
||||
/**
|
||||
* Sets the maximum volume of a source.
|
||||
* \param volume The new maximum volume.
|
||||
* \return Whether the action succeeded.
|
||||
*/
|
||||
virtual bool setVolumeMaximum(float volume)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the minimum volume of a source.
|
||||
* \return The minimum volume.
|
||||
*/
|
||||
virtual float getVolumeMinimum()=0;
|
||||
|
||||
/**
|
||||
* Sets the minimum volume of a source.
|
||||
* \param volume The new minimum volume.
|
||||
* \return Whether the action succeeded.
|
||||
*/
|
||||
virtual bool setVolumeMinimum(float volume)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the maximum distance of a source.
|
||||
* If a source is further away from the reader than this distance, the
|
||||
* volume will automatically be set to 0.
|
||||
* \return The maximum distance.
|
||||
*/
|
||||
virtual float getDistanceMaximum()=0;
|
||||
|
||||
/**
|
||||
* Sets the maximum distance of a source.
|
||||
* If a source is further away from the reader than this distance, the
|
||||
* volume will automatically be set to 0.
|
||||
* \param distance The new maximum distance.
|
||||
* \return Whether the action succeeded.
|
||||
*/
|
||||
virtual bool setDistanceMaximum(float distance)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the reference distance of a source.
|
||||
* \return The reference distance.
|
||||
*/
|
||||
virtual float getDistanceReference()=0;
|
||||
|
||||
/**
|
||||
* Sets the reference distance of a source.
|
||||
* \param distance The new reference distance.
|
||||
* \return Whether the action succeeded.
|
||||
*/
|
||||
virtual bool setDistanceReference(float distance)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the attenuation of a source.
|
||||
* \return The attenuation.
|
||||
*/
|
||||
virtual float getAttenuation()=0;
|
||||
|
||||
/**
|
||||
* Sets the attenuation of a source.
|
||||
* This value is used for distance calculation.
|
||||
* \param factor The new attenuation.
|
||||
* \return Whether the action succeeded.
|
||||
*/
|
||||
virtual bool setAttenuation(float factor)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the outer opening angle of the cone of a source.
|
||||
* \return The outer angle of the cone.
|
||||
* \note This angle is defined in degrees.
|
||||
*/
|
||||
virtual float getConeAngleOuter()=0;
|
||||
|
||||
/**
|
||||
* Sets the outer opening angle of the cone of a source.
|
||||
* \param angle The new outer angle of the cone.
|
||||
* \return Whether the action succeeded.
|
||||
* \note This angle is defined in degrees.
|
||||
*/
|
||||
virtual bool setConeAngleOuter(float angle)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the inner opening angle of the cone of a source.
|
||||
* The volume inside this cone is unaltered.
|
||||
* \return The inner angle of the cone.
|
||||
* \note This angle is defined in degrees.
|
||||
*/
|
||||
virtual float getConeAngleInner()=0;
|
||||
|
||||
/**
|
||||
* Sets the inner opening angle of the cone of a source.
|
||||
* The volume inside this cone is unaltered.
|
||||
* \param angle The new inner angle of the cone.
|
||||
* \return Whether the action succeeded.
|
||||
* \note This angle is defined in degrees.
|
||||
*/
|
||||
virtual bool setConeAngleInner(float angle)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the outer volume of the cone of a source.
|
||||
* The volume between inner and outer angle is interpolated between inner
|
||||
* volume and this value.
|
||||
* \return The outer volume of the cone.
|
||||
* \note The general volume of the handle still applies on top of this.
|
||||
*/
|
||||
virtual float getConeVolumeOuter()=0;
|
||||
|
||||
/**
|
||||
* Sets the outer volume of the cone of a source.
|
||||
* The volume between inner and outer angle is interpolated between inner
|
||||
* volume and this value.
|
||||
* \param volume The new outer volume of the cone.
|
||||
* \return Whether the action succeeded.
|
||||
* \note The general volume of the handle still applies on top of this.
|
||||
*/
|
||||
virtual bool setConeVolumeOuter(float volume)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
46
blender-5.2.0/extern/audaspace/include/devices/ICaptureDeviceFactory.h
vendored
Normal file
46
blender-5.2.0/extern/audaspace/include/devices/ICaptureDeviceFactory.h
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file ICaptureDeviceFactory.h
|
||||
* @ingroup devices
|
||||
* The ICaptureDeviceFactory interface.
|
||||
*/
|
||||
|
||||
#include "Audaspace.h"
|
||||
#include "respec/Specification.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class IReader;
|
||||
|
||||
/**
|
||||
* @interface ICaptureDeviceFactory
|
||||
* The ICaptureDeviceFactory interface opens an input capture device.
|
||||
*/
|
||||
class AUD_API ICaptureDeviceFactory
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the capture device factory.
|
||||
*/
|
||||
virtual ~ICaptureDeviceFactory() {}
|
||||
|
||||
/**
|
||||
* Opens an audio capture device.
|
||||
* \param specs The desired specification.
|
||||
* \param buffersize The capture buffer size in samples.
|
||||
* \exception Exception Thrown if the audio device cannot be opened.
|
||||
*/
|
||||
virtual std::shared_ptr<IReader> openDevice(Specs specs, int buffersize)=0;
|
||||
|
||||
/**
|
||||
* Sets a name for the capture device.
|
||||
* \param name The internal name for the capture device.
|
||||
*/
|
||||
virtual void setName(const std::string &name)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
130
blender-5.2.0/extern/audaspace/include/devices/IDevice.h
vendored
Normal file
130
blender-5.2.0/extern/audaspace/include/devices/IDevice.h
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file IDevice.h
|
||||
* @ingroup devices
|
||||
* The IDevice interface.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "respec/Specification.h"
|
||||
#include "util/ILockable.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class IHandle;
|
||||
class IReader;
|
||||
class ISound;
|
||||
|
||||
/**
|
||||
* @interface IDevice
|
||||
* The IDevice interface represents an output device for sound sources.
|
||||
* Output devices may be several backends such as platform independand like
|
||||
* SDL or OpenAL or platform specific like ALSA, but they may also be
|
||||
* files, RAM buffers or other types of streams.
|
||||
* \warning Thread safety must be insured so that no reader is being called
|
||||
* twice at the same time.
|
||||
*/
|
||||
class IDevice : public ILockable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the device.
|
||||
*/
|
||||
virtual ~IDevice() {}
|
||||
|
||||
/**
|
||||
* Returns the specification of the device.
|
||||
*/
|
||||
virtual DeviceSpecs getSpecs() const=0;
|
||||
|
||||
/**
|
||||
* Plays a sound source.
|
||||
* \param reader The reader to play.
|
||||
* \param keep When keep is true the sound source will not be deleted but
|
||||
* set to paused when its end has been reached.
|
||||
* \return Returns a handle with which the playback can be controlled.
|
||||
* This is nullptr if the sound couldn't be played back.
|
||||
* \exception Exception Thrown if there's an unexpected (from the
|
||||
* device side) error during creation of the reader.
|
||||
*/
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false)=0;
|
||||
|
||||
/**
|
||||
* Plays a sound source.
|
||||
* \param sound The sound to create the reader for the sound source.
|
||||
* \param keep When keep is true the sound source will not be deleted but
|
||||
* set to paused when its end has been reached.
|
||||
* \return Returns a handle with which the playback can be controlled.
|
||||
* This is nullptr if the sound couldn't be played back.
|
||||
* \exception Exception Thrown if there's an unexpected (from the
|
||||
* device side) error during creation of the reader.
|
||||
*/
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false)=0;
|
||||
|
||||
/**
|
||||
* Stops all playing sounds.
|
||||
*/
|
||||
virtual void stopAll()=0;
|
||||
|
||||
/**
|
||||
* Locks the device.
|
||||
* Used to make sure that between lock and unlock, no buffers are read, so
|
||||
* that it is possible to start, resume, pause, stop or seek several
|
||||
* playback handles simultaneously.
|
||||
* \warning Make sure the locking time is as small as possible to avoid
|
||||
* playback delays that result in unexpected noise and cracks.
|
||||
*/
|
||||
virtual void lock()=0;
|
||||
|
||||
/**
|
||||
* Unlocks the previously locked device.
|
||||
*/
|
||||
virtual void unlock()=0;
|
||||
|
||||
/**
|
||||
* Retrieves the overall device volume.
|
||||
* \return The overall device volume.
|
||||
*/
|
||||
virtual float getVolume() const=0;
|
||||
|
||||
/**
|
||||
* Sets the overall device volume.
|
||||
* \param volume The overall device volume.
|
||||
*/
|
||||
virtual void setVolume(float volume) = 0;
|
||||
|
||||
/**
|
||||
* The syncFunction is called when a synchronization event happens.
|
||||
* The function awaits three parameters. The first one is a user defined
|
||||
* pointer, the second informs about whether playback is on and the third
|
||||
* is the current playback time in seconds.
|
||||
*/
|
||||
typedef void (*syncFunction)(void*, int, float);
|
||||
|
||||
virtual void seekSynchronizer(double time) = 0;
|
||||
virtual double getSynchronizerPosition() = 0;
|
||||
virtual void playSynchronizer() = 0;
|
||||
virtual void stopSynchronizer() = 0;
|
||||
virtual void setSyncCallback(syncFunction function, void* data) = 0;
|
||||
virtual int isSynchronizerPlaying() = 0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
77
blender-5.2.0/extern/audaspace/include/devices/IDeviceFactory.h
vendored
Normal file
77
blender-5.2.0/extern/audaspace/include/devices/IDeviceFactory.h
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file IDeviceFactory.h
|
||||
* @ingroup devices
|
||||
* The IDeviceFactory interface.
|
||||
*/
|
||||
|
||||
#include "respec/Specification.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* @interface IDeviceFactory
|
||||
* The IDeviceFactory interface opens an output device.
|
||||
*/
|
||||
class AUD_API IDeviceFactory
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the device factory.
|
||||
*/
|
||||
virtual ~IDeviceFactory() {}
|
||||
|
||||
/**
|
||||
* Opens an audio device for playback.
|
||||
* \exception Exception Thrown if the audio device cannot be opened.
|
||||
*/
|
||||
virtual std::shared_ptr<IDevice> openDevice()=0;
|
||||
|
||||
/**
|
||||
* Returns the priority of the device to be the default device for a system.
|
||||
* The higher the priority the more likely it is for this device to be used as the default device.
|
||||
* \return Priority to be the default device.
|
||||
*/
|
||||
virtual int getPriority()=0;
|
||||
|
||||
/**
|
||||
* Sets the wanted device specifications for opening the device.
|
||||
* \param specs The wanted audio specification.
|
||||
*/
|
||||
virtual void setSpecs(DeviceSpecs specs)=0;
|
||||
|
||||
/**
|
||||
* Sets the size for the internal playback buffers.
|
||||
* The bigger the buffersize, the less likely clicks happen,
|
||||
* but the latency increases too.
|
||||
* \param buffersize The size of the internal buffer.
|
||||
*/
|
||||
virtual void setBufferSize(int buffersize)=0;
|
||||
|
||||
/**
|
||||
* Sets a name for the device.
|
||||
* \param name The internal name for the device.
|
||||
*/
|
||||
virtual void setName(const std::string &name)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
189
blender-5.2.0/extern/audaspace/include/devices/IHandle.h
vendored
Normal file
189
blender-5.2.0/extern/audaspace/include/devices/IHandle.h
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file IHandle.h
|
||||
* @ingroup devices
|
||||
* Defines the IHandle interface as well as possible states of the handle.
|
||||
*/
|
||||
|
||||
#include "Audaspace.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/// Status of a playback handle.
|
||||
enum Status
|
||||
{
|
||||
STATUS_INVALID = 0, /// Invalid handle. Maybe due to stopping.
|
||||
STATUS_PLAYING, /// Sound is playing.
|
||||
STATUS_PAUSED, /// Sound is being paused.
|
||||
STATUS_STOPPED /// Sound is stopped but kept in the device.
|
||||
};
|
||||
|
||||
/**
|
||||
* The stopCallback is called when a handle reaches the end of the stream and
|
||||
* thus gets stopped. A user defined pointer is supplied to the callback.
|
||||
*/
|
||||
typedef void (*stopCallback)(void*);
|
||||
|
||||
/**
|
||||
* @interface IHandle
|
||||
* The IHandle interface represents a playback handles of a specific device.
|
||||
*/
|
||||
class AUD_API IHandle
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destroys the handle.
|
||||
*/
|
||||
virtual ~IHandle() {}
|
||||
|
||||
/**
|
||||
* Pauses a played back sound.
|
||||
* \return
|
||||
* - true if the sound has been paused.
|
||||
* - false if the sound isn't playing back or the handle is invalid.
|
||||
*/
|
||||
virtual bool pause()=0;
|
||||
|
||||
/**
|
||||
* Resumes a paused sound.
|
||||
* \return
|
||||
* - true if the sound has been resumed.
|
||||
* - false if the sound isn't paused or the handle is invalid.
|
||||
*/
|
||||
virtual bool resume()=0;
|
||||
|
||||
/**
|
||||
* Stops a played back or paused sound. The handle is definitely invalid
|
||||
* afterwards.
|
||||
* \return
|
||||
* - true if the sound has been stopped.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool stop()=0;
|
||||
|
||||
/**
|
||||
* Gets the behaviour of the device for a played back sound when the sound
|
||||
* doesn't return any more samples.
|
||||
* \return
|
||||
* - true if the source will be paused when it's end is reached
|
||||
* - false if the handle won't kept or is invalid.
|
||||
*/
|
||||
virtual bool getKeep()=0;
|
||||
|
||||
/**
|
||||
* Sets the behaviour of the device for a played back sound when the sound
|
||||
* doesn't return any more samples.
|
||||
* \param keep True when the source should be paused and not deleted.
|
||||
* \return
|
||||
* - true if the behaviour has been changed.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool setKeep(bool keep)=0;
|
||||
|
||||
/**
|
||||
* Seeks in a played back sound.
|
||||
* \param position The new position from where to play back, in seconds.
|
||||
* \return
|
||||
* - true if the handle is valid.
|
||||
* - false if the handle is invalid.
|
||||
* \warning Whether the seek works or not depends on the sound source.
|
||||
*/
|
||||
virtual bool seek(double position)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the current playback position of a sound.
|
||||
* \return The playback position in seconds, or 0.0 if the handle is
|
||||
* invalid.
|
||||
*/
|
||||
virtual double getPosition()=0;
|
||||
|
||||
/**
|
||||
* Returns the status of a played back sound.
|
||||
* \return
|
||||
* - STATUS_INVALID if the sound has stopped or the handle is
|
||||
*. invalid
|
||||
* - STATUS_PLAYING if the sound is currently played back.
|
||||
* - STATUS_PAUSED if the sound is currently paused.
|
||||
* - STATUS_STOPPED if the sound finished playing and is still
|
||||
* kept in the device.
|
||||
* \see Status
|
||||
*/
|
||||
virtual Status getStatus()=0;
|
||||
|
||||
/**
|
||||
* Retrieves the volume of a playing sound.
|
||||
* \return The volume.
|
||||
*/
|
||||
virtual float getVolume()=0;
|
||||
|
||||
/**
|
||||
* Sets the volume of a playing sound.
|
||||
* \param volume The volume.
|
||||
* \return
|
||||
* - true if the handle is valid.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool setVolume(float volume)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the pitch of a playing sound.
|
||||
* \return The pitch.
|
||||
*/
|
||||
virtual float getPitch()=0;
|
||||
|
||||
/**
|
||||
* Sets the pitch of a playing sound.
|
||||
* \param pitch The pitch.
|
||||
* \return
|
||||
* - true if the handle is valid.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool setPitch(float pitch)=0;
|
||||
|
||||
/**
|
||||
* Retrieves the loop count of a playing sound.
|
||||
* A negative value indicates infinity.
|
||||
* \return The remaining loop count.
|
||||
*/
|
||||
virtual int getLoopCount()=0;
|
||||
|
||||
/**
|
||||
* Sets the loop count of a playing sound.
|
||||
* A negative value indicates infinity.
|
||||
* \param count The new loop count.
|
||||
* \return
|
||||
* - true if the handle is valid.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool setLoopCount(int count)=0;
|
||||
|
||||
/**
|
||||
* Sets the callback function that's called when the end of a playing sound
|
||||
* is reached.
|
||||
* \param callback The callback function.
|
||||
* \param data The data that should be passed to the callback function.
|
||||
* \return
|
||||
* - true if the handle is valid.
|
||||
* - false if the handle is invalid.
|
||||
*/
|
||||
virtual bool setStopCallback(stopCallback callback = 0, void* data = 0)=0;
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
131
blender-5.2.0/extern/audaspace/include/devices/MixingThreadDevice.h
vendored
Normal file
131
blender-5.2.0/extern/audaspace/include/devices/MixingThreadDevice.h
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file MixingThreadDevice.h
|
||||
* @ingroup device
|
||||
* The MixingThreadDevice class.
|
||||
*/
|
||||
|
||||
#include <condition_variable>
|
||||
#include <thread>
|
||||
|
||||
#include "devices/SoftwareDevice.h"
|
||||
#include "util/RingBuffer.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* This device extends the SoftwareDevice with code for running mixing in a separate thread.
|
||||
*/
|
||||
class AUD_PLUGIN_API MixingThreadDevice : public SoftwareDevice
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Whether there is currently playback.
|
||||
*/
|
||||
volatile bool m_playback{false};
|
||||
|
||||
/**
|
||||
* The deinterleaving buffer.
|
||||
*/
|
||||
Buffer m_mixingBuffer;
|
||||
|
||||
/**
|
||||
* The mixing ring buffer.
|
||||
*/
|
||||
RingBuffer m_ringBuffer;
|
||||
|
||||
/**
|
||||
* Whether the device is valid.
|
||||
*/
|
||||
bool m_valid{false};
|
||||
|
||||
/**
|
||||
* The mixing thread.
|
||||
*/
|
||||
std::thread m_mixingThread;
|
||||
|
||||
/**
|
||||
* Mutex for mixing.
|
||||
*/
|
||||
std::mutex m_mixingLock;
|
||||
|
||||
/**
|
||||
* Condition for mixing.
|
||||
*/
|
||||
std::condition_variable m_mixingCondition;
|
||||
|
||||
/**
|
||||
* Updates the ring buffer.
|
||||
*/
|
||||
AUD_LOCAL void updateRingBuffer();
|
||||
|
||||
// delete copy constructor and operator=
|
||||
MixingThreadDevice(const MixingThreadDevice&) = delete;
|
||||
MixingThreadDevice& operator=(const MixingThreadDevice&) = delete;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Starts the streaming thread.
|
||||
* @param buffersize Size of the ring buffer in bytes.
|
||||
*/
|
||||
void startMixingThread(size_t buffersize);
|
||||
|
||||
/**
|
||||
* Notify the mixing thread.
|
||||
*/
|
||||
void notifyMixingThread();
|
||||
|
||||
/**
|
||||
* Get ring buffer for reading.
|
||||
*/
|
||||
inline RingBuffer& getRingBuffer()
|
||||
{
|
||||
return m_ringBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the thread is running or not.
|
||||
*/
|
||||
inline bool isMixingThreadRunning()
|
||||
{
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
virtual void playing(bool playing);
|
||||
|
||||
/**
|
||||
* Called every iteration in the mixing thread before mixing.
|
||||
*/
|
||||
virtual void preMixingWork(bool playing);
|
||||
|
||||
/**
|
||||
* Empty default constructor. To setup the device call the function create()
|
||||
* and to uninitialize call destroy().
|
||||
*/
|
||||
MixingThreadDevice();
|
||||
|
||||
/**
|
||||
* Stops all playback and notifies the mixing thread to stop.
|
||||
* \warning The device has to be unlocked to not run into a deadlock.
|
||||
*/
|
||||
void stopMixingThread();
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
102
blender-5.2.0/extern/audaspace/include/devices/NULLDevice.h
vendored
Normal file
102
blender-5.2.0/extern/audaspace/include/devices/NULLDevice.h
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file NULLDevice.h
|
||||
* @ingroup devices
|
||||
* The NULLDevice class.
|
||||
*/
|
||||
|
||||
#include "devices/IDevice.h"
|
||||
#include "devices/IHandle.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class IReader;
|
||||
|
||||
/**
|
||||
* This device plays nothing.
|
||||
* It is similar to the linux device /dev/null.
|
||||
*/
|
||||
class AUD_API NULLDevice : public IDevice
|
||||
{
|
||||
private:
|
||||
class AUD_LOCAL NULLHandle : public IHandle
|
||||
{
|
||||
private:
|
||||
// delete copy constructor and operator=
|
||||
NULLHandle(const NULLHandle&) = delete;
|
||||
NULLHandle& operator=(const NULLHandle&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
NULLHandle();
|
||||
|
||||
virtual ~NULLHandle() {}
|
||||
virtual bool pause();
|
||||
virtual bool resume();
|
||||
virtual bool stop();
|
||||
virtual bool getKeep();
|
||||
virtual bool setKeep(bool keep);
|
||||
virtual bool seek(double position);
|
||||
virtual double getPosition();
|
||||
virtual Status getStatus();
|
||||
virtual float getVolume();
|
||||
virtual bool setVolume(float volume);
|
||||
virtual float getPitch();
|
||||
virtual bool setPitch(float pitch);
|
||||
virtual int getLoopCount();
|
||||
virtual bool setLoopCount(int count);
|
||||
virtual bool setStopCallback(stopCallback callback = 0, void* data = 0);
|
||||
};
|
||||
|
||||
// delete copy constructor and operator=
|
||||
NULLDevice(const NULLDevice&) = delete;
|
||||
NULLDevice& operator=(const NULLDevice&) = delete;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a new NULLDevice.
|
||||
*/
|
||||
NULLDevice();
|
||||
|
||||
virtual ~NULLDevice();
|
||||
|
||||
virtual DeviceSpecs getSpecs() const;
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false);
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false);
|
||||
virtual void stopAll();
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual float getVolume() const;
|
||||
virtual void setVolume(float volume);
|
||||
|
||||
virtual void seekSynchronizer(double time);
|
||||
virtual double getSynchronizerPosition();
|
||||
virtual void playSynchronizer();
|
||||
virtual void stopSynchronizer();
|
||||
virtual void setSyncCallback(syncFunction function, void* data);
|
||||
virtual int isSynchronizerPlaying();
|
||||
|
||||
/**
|
||||
* Registers this plugin.
|
||||
*/
|
||||
static void registerPlugin();
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
82
blender-5.2.0/extern/audaspace/include/devices/ReadDevice.h
vendored
Normal file
82
blender-5.2.0/extern/audaspace/include/devices/ReadDevice.h
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file ReadDevice.h
|
||||
* @ingroup devices
|
||||
* The ReadDevice class.
|
||||
*/
|
||||
|
||||
#include "devices/SoftwareDevice.h"
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* This device enables to let the user read raw data out of it.
|
||||
*/
|
||||
class AUD_API ReadDevice : public SoftwareDevice
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Whether the device is currently playing back.
|
||||
*/
|
||||
bool m_playing;
|
||||
|
||||
// delete copy constructor and operator=
|
||||
ReadDevice(const ReadDevice&) = delete;
|
||||
ReadDevice& operator=(const ReadDevice&) = delete;
|
||||
|
||||
protected:
|
||||
virtual void AUD_LOCAL playing(bool playing);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a new read device.
|
||||
* \param specs The wanted audio specification.
|
||||
*/
|
||||
ReadDevice(DeviceSpecs specs);
|
||||
|
||||
/**
|
||||
* Creates a new read device.
|
||||
* \param specs The wanted audio specification.
|
||||
*/
|
||||
ReadDevice(Specs specs);
|
||||
|
||||
/**
|
||||
* Closes the device.
|
||||
*/
|
||||
virtual ~ReadDevice();
|
||||
|
||||
/**
|
||||
* Reads the next bytes into the supplied buffer.
|
||||
* \param buffer The target buffer.
|
||||
* \param length The length in samples to be filled.
|
||||
* \return True if the reading succeeded, false if there are no sounds
|
||||
* played back currently, in that case the buffer is filled with
|
||||
* silence.
|
||||
*/
|
||||
bool read(data_t* buffer, int length);
|
||||
|
||||
/**
|
||||
* Changes the output specification.
|
||||
* \param specs The new audio data specification.
|
||||
*/
|
||||
void changeSpecs(Specs specs);
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
384
blender-5.2.0/extern/audaspace/include/devices/SoftwareDevice.h
vendored
Normal file
384
blender-5.2.0/extern/audaspace/include/devices/SoftwareDevice.h
vendored
Normal file
@@ -0,0 +1,384 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file SoftwareDevice.h
|
||||
* @ingroup devices
|
||||
* The SoftwareDevice class.
|
||||
*/
|
||||
|
||||
#include "devices/IDevice.h"
|
||||
#include "devices/IHandle.h"
|
||||
#include "devices/I3DDevice.h"
|
||||
#include "devices/I3DHandle.h"
|
||||
#include "util/Buffer.h"
|
||||
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
class Mixer;
|
||||
class PitchReader;
|
||||
class ResampleReader;
|
||||
class ChannelMapperReader;
|
||||
|
||||
/**
|
||||
* The software device is a generic device with software mixing.
|
||||
* It is a base class for all software mixing classes.
|
||||
* Classes implementing this have to:
|
||||
* - Implement the playing function.
|
||||
* - Prepare the m_specs, m_mixer variables.
|
||||
* - Call the create and destroy functions.
|
||||
* - Call the mix function to retrieve their audio data.
|
||||
*/
|
||||
class AUD_API SoftwareDevice : public IDevice, public I3DDevice
|
||||
{
|
||||
protected:
|
||||
/// Saves the data for playback.
|
||||
class AUD_API SoftwareHandle : public IHandle, public I3DHandle
|
||||
{
|
||||
private:
|
||||
// delete copy constructor and operator=
|
||||
SoftwareHandle(const SoftwareHandle&) = delete;
|
||||
SoftwareHandle& operator=(const SoftwareHandle&) = delete;
|
||||
|
||||
public:
|
||||
/// The reader source.
|
||||
std::shared_ptr<IReader> m_reader;
|
||||
|
||||
/// The pitch reader in between.
|
||||
std::shared_ptr<PitchReader> m_pitch;
|
||||
|
||||
/// The resample reader in between.
|
||||
std::shared_ptr<ResampleReader> m_resampler;
|
||||
|
||||
/// The channel mapper reader in between.
|
||||
std::shared_ptr<ChannelMapperReader> m_mapper;
|
||||
|
||||
/// Whether the source is being read for the first time.
|
||||
bool m_first_reading;
|
||||
|
||||
/// Whether to keep the source if end of it is reached.
|
||||
bool m_keep;
|
||||
|
||||
/// The user set pitch of the source.
|
||||
float m_user_pitch;
|
||||
|
||||
/// The user set volume of the source.
|
||||
float m_user_volume;
|
||||
|
||||
/// The user set panning for non-3D sources
|
||||
float m_user_pan;
|
||||
|
||||
/// The calculated final volume of the source.
|
||||
float m_volume;
|
||||
|
||||
/// The previous calculated final volume of the source.
|
||||
float m_old_volume;
|
||||
|
||||
/// The loop count of the source.
|
||||
int m_loopcount;
|
||||
|
||||
/// Location in 3D Space.
|
||||
Vector3 m_location;
|
||||
|
||||
/// Velocity in 3D Space.
|
||||
Vector3 m_velocity;
|
||||
|
||||
/// Orientation in 3D Space.
|
||||
Quaternion m_orientation;
|
||||
|
||||
/// Whether the position to the listener is relative or absolute
|
||||
bool m_relative;
|
||||
|
||||
/// Maximum volume.
|
||||
float m_volume_max;
|
||||
|
||||
/// Minimum volume.
|
||||
float m_volume_min;
|
||||
|
||||
/// Maximum distance.
|
||||
float m_distance_max;
|
||||
|
||||
/// Reference distance;
|
||||
float m_distance_reference;
|
||||
|
||||
/// Attenuation
|
||||
float m_attenuation;
|
||||
|
||||
/// Cone outer angle.
|
||||
float m_cone_angle_outer;
|
||||
|
||||
/// Cone inner angle.
|
||||
float m_cone_angle_inner;
|
||||
|
||||
/// Cone outer volume.
|
||||
float m_cone_volume_outer;
|
||||
|
||||
/// Rendering flags
|
||||
int m_flags;
|
||||
|
||||
/// The stop callback.
|
||||
stopCallback m_stop;
|
||||
|
||||
/// Stop callback data.
|
||||
void* m_stop_data;
|
||||
|
||||
/// Current status of the handle
|
||||
Status m_status;
|
||||
|
||||
/// Own device.
|
||||
SoftwareDevice* m_device;
|
||||
|
||||
/**
|
||||
* This method is for internal use only.
|
||||
* @param keep Whether the sound should be marked stopped or paused.
|
||||
* @return Whether the action succeeded.
|
||||
*/
|
||||
bool pause(bool keep);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a new software handle.
|
||||
* \param device The device this handle is from.
|
||||
* \param reader The reader to play.
|
||||
* \param pitch The pitch reader.
|
||||
* \param resampler The resampling reader.
|
||||
* \param mapper The channel mapping reader.
|
||||
* \param keep Whether to keep the handle when the sound ends.
|
||||
*/
|
||||
SoftwareHandle(SoftwareDevice* device, std::shared_ptr<IReader> reader, std::shared_ptr<PitchReader> pitch, std::shared_ptr<ResampleReader> resampler, std::shared_ptr<ChannelMapperReader> mapper, bool keep);
|
||||
|
||||
/**
|
||||
* Updates the handle's playback parameters.
|
||||
*/
|
||||
void update();
|
||||
|
||||
/**
|
||||
* Sets the audio output specification of the readers.
|
||||
* \param specs The output specification.
|
||||
*/
|
||||
void setSpecs(Specs specs);
|
||||
|
||||
virtual ~SoftwareHandle() {}
|
||||
virtual bool pause();
|
||||
virtual bool resume();
|
||||
virtual bool stop();
|
||||
virtual bool getKeep();
|
||||
virtual bool setKeep(bool keep);
|
||||
virtual bool seek(double position);
|
||||
virtual double getPosition();
|
||||
virtual Status getStatus();
|
||||
virtual float getVolume();
|
||||
virtual bool setVolume(float volume);
|
||||
virtual float getPitch();
|
||||
virtual bool setPitch(float pitch);
|
||||
virtual int getLoopCount();
|
||||
virtual bool setLoopCount(int count);
|
||||
virtual bool setStopCallback(stopCallback callback = 0, void* data = 0);
|
||||
|
||||
virtual Vector3 getLocation();
|
||||
virtual bool setLocation(const Vector3& location);
|
||||
virtual Vector3 getVelocity();
|
||||
virtual bool setVelocity(const Vector3& velocity);
|
||||
virtual Quaternion getOrientation();
|
||||
virtual bool setOrientation(const Quaternion& orientation);
|
||||
virtual bool isRelative();
|
||||
virtual bool setRelative(bool relative);
|
||||
virtual float getVolumeMaximum();
|
||||
virtual bool setVolumeMaximum(float volume);
|
||||
virtual float getVolumeMinimum();
|
||||
virtual bool setVolumeMinimum(float volume);
|
||||
virtual float getDistanceMaximum();
|
||||
virtual bool setDistanceMaximum(float distance);
|
||||
virtual float getDistanceReference();
|
||||
virtual bool setDistanceReference(float distance);
|
||||
virtual float getAttenuation();
|
||||
virtual bool setAttenuation(float factor);
|
||||
virtual float getConeAngleOuter();
|
||||
virtual bool setConeAngleOuter(float angle);
|
||||
virtual float getConeAngleInner();
|
||||
virtual bool setConeAngleInner(float angle);
|
||||
virtual float getConeVolumeOuter();
|
||||
virtual bool setConeVolumeOuter(float volume);
|
||||
};
|
||||
|
||||
/**
|
||||
* The specification of the device.
|
||||
*/
|
||||
DeviceSpecs m_specs;
|
||||
|
||||
/**
|
||||
* The mixer.
|
||||
*/
|
||||
std::shared_ptr<Mixer> m_mixer;
|
||||
|
||||
/**
|
||||
* Resampling quality.
|
||||
*/
|
||||
ResampleQuality m_quality;
|
||||
|
||||
/**
|
||||
* Initializes member variables.
|
||||
*/
|
||||
void create();
|
||||
|
||||
/**
|
||||
* Uninitializes member variables.
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* Mixes the next samples into the buffer.
|
||||
* \param buffer The target buffer.
|
||||
* \param length The length in samples to be filled.
|
||||
*/
|
||||
void mix(data_t* buffer, int length);
|
||||
|
||||
/**
|
||||
* This function tells the device, to start or pause playback.
|
||||
* \param playing True if device should playback.
|
||||
* \note This method is only called when the device is locked.
|
||||
*/
|
||||
virtual void playing(bool playing)=0;
|
||||
|
||||
/**
|
||||
* Sets the audio output specification of the device.
|
||||
* \param specs The output specification.
|
||||
*/
|
||||
void setSpecs(Specs specs);
|
||||
|
||||
/**
|
||||
* Sets the audio output specification of the device.
|
||||
* \param specs The output specification.
|
||||
*/
|
||||
void setSpecs(DeviceSpecs specs);
|
||||
|
||||
/**
|
||||
* Empty default constructor. To setup the device call the function create()
|
||||
* and to uninitialize call destroy().
|
||||
*/
|
||||
SoftwareDevice();
|
||||
|
||||
private:
|
||||
/**
|
||||
* The reading buffer.
|
||||
*/
|
||||
Buffer m_buffer;
|
||||
|
||||
/**
|
||||
* The list of sounds that are currently playing.
|
||||
*/
|
||||
std::list<std::shared_ptr<SoftwareHandle> > m_playingSounds;
|
||||
|
||||
/**
|
||||
* The list of sounds that are currently paused.
|
||||
*/
|
||||
std::list<std::shared_ptr<SoftwareHandle> > m_pausedSounds;
|
||||
|
||||
/**
|
||||
* Whether there is currently playback.
|
||||
*/
|
||||
bool m_playback;
|
||||
|
||||
/**
|
||||
* The mutex for locking.
|
||||
*/
|
||||
std::recursive_mutex m_mutex;
|
||||
|
||||
/**
|
||||
* The overall volume of the device.
|
||||
*/
|
||||
float m_volume;
|
||||
|
||||
/// Listener location.
|
||||
Vector3 m_location;
|
||||
|
||||
/// Listener velocity.
|
||||
Vector3 m_velocity;
|
||||
|
||||
/// Listener orientation.
|
||||
Quaternion m_orientation;
|
||||
|
||||
/// Speed of Sound.
|
||||
float m_speed_of_sound;
|
||||
|
||||
/// Doppler factor.
|
||||
float m_doppler_factor;
|
||||
|
||||
/// Distance model.
|
||||
DistanceModel m_distance_model;
|
||||
|
||||
/// Rendering flags
|
||||
int m_flags;
|
||||
|
||||
/// Synchronizer.
|
||||
uint64_t m_synchronizerPosition{0};
|
||||
int m_synchronizerState{0};
|
||||
|
||||
// delete copy constructor and operator=
|
||||
SoftwareDevice(const SoftwareDevice&) = delete;
|
||||
SoftwareDevice& operator=(const SoftwareDevice&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Sets the panning of a specific handle.
|
||||
* \param handle The handle to set the panning from.
|
||||
* \param pan The new panning value, should be in the range [-2, 2].
|
||||
*/
|
||||
static void setPanning(IHandle* handle, float pan);
|
||||
|
||||
/**
|
||||
* Sets the resampling quality.
|
||||
* \param quality Resampling quality vs performance setting.
|
||||
*/
|
||||
void setQuality(ResampleQuality quality);
|
||||
|
||||
virtual DeviceSpecs getSpecs() const;
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<IReader> reader, bool keep = false);
|
||||
virtual std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, bool keep = false);
|
||||
virtual void stopAll();
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual float getVolume() const;
|
||||
virtual void setVolume(float volume);
|
||||
|
||||
virtual Vector3 getListenerLocation() const;
|
||||
virtual void setListenerLocation(const Vector3& location);
|
||||
virtual Vector3 getListenerVelocity() const;
|
||||
virtual void setListenerVelocity(const Vector3& velocity);
|
||||
virtual Quaternion getListenerOrientation() const;
|
||||
virtual void setListenerOrientation(const Quaternion& orientation);
|
||||
virtual float getSpeedOfSound() const;
|
||||
virtual void setSpeedOfSound(float speed);
|
||||
virtual float getDopplerFactor() const;
|
||||
virtual void setDopplerFactor(float factor);
|
||||
virtual DistanceModel getDistanceModel() const;
|
||||
virtual void setDistanceModel(DistanceModel model);
|
||||
|
||||
virtual void seekSynchronizer(double time);
|
||||
virtual double getSynchronizerPosition();
|
||||
virtual void playSynchronizer();
|
||||
virtual void stopSynchronizer();
|
||||
virtual void setSyncCallback(syncFunction function, void* data);
|
||||
virtual int isSynchronizerPlaying();
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
95
blender-5.2.0/extern/audaspace/include/devices/ThreadedDevice.h
vendored
Normal file
95
blender-5.2.0/extern/audaspace/include/devices/ThreadedDevice.h
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2009-2016 Jörg Müller
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file ThreadedDevice.h
|
||||
* @ingroup plugin
|
||||
* The ThreadedDevice class.
|
||||
*/
|
||||
|
||||
#include "devices/SoftwareDevice.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* This device extends the SoftwareDevice with code for running mixing in a separate thread.
|
||||
*/
|
||||
class AUD_PLUGIN_API ThreadedDevice : public SoftwareDevice
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* Whether there is currently playback.
|
||||
*/
|
||||
bool m_playing;
|
||||
|
||||
/**
|
||||
* Whether the current playback should stop.
|
||||
*/
|
||||
bool m_stop;
|
||||
|
||||
/**
|
||||
* The streaming thread.
|
||||
*/
|
||||
std::thread m_thread;
|
||||
|
||||
/**
|
||||
* Starts the streaming thread.
|
||||
*/
|
||||
AUD_LOCAL void start();
|
||||
|
||||
/**
|
||||
* Streaming thread main function.
|
||||
*/
|
||||
AUD_LOCAL virtual void runMixingThread()=0;
|
||||
|
||||
// delete copy constructor and operator=
|
||||
ThreadedDevice(const ThreadedDevice&) = delete;
|
||||
ThreadedDevice& operator=(const ThreadedDevice&) = delete;
|
||||
|
||||
protected:
|
||||
virtual void playing(bool playing);
|
||||
|
||||
/**
|
||||
* Empty default constructor. To setup the device call the function create()
|
||||
* and to uninitialize call destroy().
|
||||
*/
|
||||
ThreadedDevice();
|
||||
|
||||
/**
|
||||
* Indicates that the mixing thread should be stopped.
|
||||
* \return Whether the mixing thread should be stopping.
|
||||
* \warning For thread safety, the device needs to be locked, when this method is called.
|
||||
*/
|
||||
inline bool shouldStop() { return m_stop; }
|
||||
|
||||
/**
|
||||
* This method needs to be called when the mixing thread is stopping.
|
||||
* \warning For thread safety, the device needs to be locked, when this method is called.
|
||||
*/
|
||||
inline void doStop() { m_stop = m_playing = false; }
|
||||
|
||||
/**
|
||||
* Stops all playback and notifies the mixing thread to stop.
|
||||
* \warning The device has to be unlocked to not run into a deadlock.
|
||||
*/
|
||||
void stopMixingThread();
|
||||
};
|
||||
|
||||
AUD_NAMESPACE_END
|
||||
Reference in New Issue
Block a user