Path: blob/master/servers/audio/audio_driver_dummy.h
10277 views
/**************************************************************************/1/* audio_driver_dummy.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "servers/audio_server.h"3334#include "core/os/mutex.h"35#include "core/os/thread.h"36#include "core/templates/safe_refcount.h"3738class AudioDriverDummy : public AudioDriver {39Thread thread;40Mutex mutex;4142int32_t *samples_in = nullptr;4344static void thread_func(void *p_udata);4546uint32_t buffer_frames = 4096;47int32_t mix_rate = -1;48SpeakerMode speaker_mode = SPEAKER_MODE_STEREO;4950int channels;5152SafeFlag active;53SafeFlag exit_thread;5455bool use_threads = true;5657static AudioDriverDummy *singleton;5859public:60virtual const char *get_name() const override {61return "Dummy";62}6364virtual Error init() override;65virtual void start() override;66virtual int get_mix_rate() const override;67virtual SpeakerMode get_speaker_mode() const override;6869virtual void lock() override;70virtual void unlock() override;71virtual void finish() override;7273void set_use_threads(bool p_use_threads);74void set_speaker_mode(SpeakerMode p_mode);75void set_mix_rate(int p_rate);7677uint32_t get_channels() const;7879void mix_audio(int p_frames, int32_t *p_buffer);8081static AudioDriverDummy *get_dummy_singleton() { return singleton; }8283AudioDriverDummy();84~AudioDriverDummy() {}85};868788