mirror of https://github.com/auygun/kaliber.git
Move AudioSinkDelegate into AudioSink
This commit is contained in:
parent
a39efa5d3c
commit
76fb19ab3a
|
@ -8,7 +8,7 @@
|
|||
#include <unordered_map>
|
||||
|
||||
#include "base/closure.h"
|
||||
#include "engine/audio/audio_sink_delegate.h"
|
||||
#include "engine/audio/audio_sink.h"
|
||||
|
||||
namespace base {
|
||||
class TaskRunner;
|
||||
|
@ -22,7 +22,7 @@ class AudioBus;
|
|||
// Mix and render audio with low overhead. A platform specific AudioSink
|
||||
// implementation is expected to periodically call RenderAudio() in a background
|
||||
// thread.
|
||||
class AudioMixer : public AudioSinkDelegate {
|
||||
class AudioMixer : public AudioSink::Delegate {
|
||||
public:
|
||||
AudioMixer();
|
||||
~AudioMixer();
|
||||
|
@ -91,7 +91,7 @@ class AudioMixer : public AudioSinkDelegate {
|
|||
|
||||
bool audio_enabled_ = true;
|
||||
|
||||
// AudioSinkDelegate implementation
|
||||
// AudioSink::Delegate implementation
|
||||
int GetChannelCount() final { return kChannelCount; }
|
||||
void RenderAudio(float* output_buffer, size_t num_frames) final;
|
||||
|
||||
|
|
|
@ -4,9 +4,19 @@
|
|||
namespace eng {
|
||||
|
||||
// Models an audio sink sending mixed audio to the audio driver. Audio data from
|
||||
// the mixer source is delivered on a pull model using AudioSinkDelegate.
|
||||
// the mixer source is delivered on a pull model using Delegate.
|
||||
class AudioSink {
|
||||
public:
|
||||
class Delegate {
|
||||
public:
|
||||
Delegate() = default;
|
||||
virtual ~Delegate() = default;
|
||||
|
||||
virtual int GetChannelCount() = 0;
|
||||
|
||||
virtual void RenderAudio(float* output_buffer, size_t num_frames) = 0;
|
||||
};
|
||||
|
||||
AudioSink() = default;
|
||||
virtual ~AudioSink() = default;
|
||||
|
||||
|
|
|
@ -5,13 +5,12 @@
|
|||
#include <alsa/asoundlib.h>
|
||||
|
||||
#include "base/log.h"
|
||||
#include "engine/audio/audio_sink_delegate.h"
|
||||
|
||||
using namespace base;
|
||||
|
||||
namespace eng {
|
||||
|
||||
AudioSinkAlsa::AudioSinkAlsa(AudioSinkDelegate* delegate)
|
||||
AudioSinkAlsa::AudioSinkAlsa(AudioSink::Delegate* delegate)
|
||||
: delegate_(delegate) {}
|
||||
|
||||
AudioSinkAlsa::~AudioSinkAlsa() {
|
||||
|
|
|
@ -10,11 +10,9 @@ typedef struct _snd_pcm snd_pcm_t;
|
|||
|
||||
namespace eng {
|
||||
|
||||
class AudioSinkDelegate;
|
||||
|
||||
class AudioSinkAlsa final : public AudioSink {
|
||||
public:
|
||||
AudioSinkAlsa(AudioSinkDelegate* delegate);
|
||||
AudioSinkAlsa(AudioSink::Delegate* delegate);
|
||||
~AudioSinkAlsa() final;
|
||||
|
||||
bool Initialize() final;
|
||||
|
@ -36,7 +34,7 @@ class AudioSinkAlsa final : public AudioSink {
|
|||
size_t sample_rate_ = 0;
|
||||
size_t period_size_ = 0;
|
||||
|
||||
AudioSinkDelegate* delegate_ = nullptr;
|
||||
AudioSink::Delegate* delegate_ = nullptr;
|
||||
|
||||
void StartAudioThread();
|
||||
void TerminateAudioThread();
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef ENGINE_AUDIO_AUDIO_SINK_DELEGATE_H
|
||||
#define ENGINE_AUDIO_AUDIO_SINK_DELEGATE_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace eng {
|
||||
|
||||
class AudioSinkDelegate {
|
||||
public:
|
||||
AudioSinkDelegate() = default;
|
||||
virtual ~AudioSinkDelegate() = default;
|
||||
|
||||
virtual int GetChannelCount() = 0;
|
||||
|
||||
virtual void RenderAudio(float* output_buffer, size_t num_frames) = 0;
|
||||
};
|
||||
|
||||
} // namespace eng
|
||||
|
||||
#endif // ENGINE_AUDIO_AUDIO_SINK_DELEGATE_H
|
|
@ -1,14 +1,13 @@
|
|||
#include "engine/audio/audio_sink_oboe.h"
|
||||
|
||||
#include "base/log.h"
|
||||
#include "engine/audio/audio_sink_delegate.h"
|
||||
#include "third_party/oboe/include/oboe/Oboe.h"
|
||||
|
||||
using namespace base;
|
||||
|
||||
namespace eng {
|
||||
|
||||
AudioSinkOboe::AudioSinkOboe(AudioSinkDelegate* delegate)
|
||||
AudioSinkOboe::AudioSinkOboe(AudioSink::Delegate* delegate)
|
||||
: callback_(std::make_unique<StreamCallback>(this)), delegate_(delegate) {}
|
||||
|
||||
AudioSinkOboe::~AudioSinkOboe() {
|
||||
|
|
|
@ -10,11 +10,9 @@
|
|||
|
||||
namespace eng {
|
||||
|
||||
class AudioSinkDelegate;
|
||||
|
||||
class AudioSinkOboe final : public AudioSink {
|
||||
public:
|
||||
AudioSinkOboe(AudioSinkDelegate* delegate);
|
||||
AudioSinkOboe(AudioSink::Delegate* delegate);
|
||||
~AudioSinkOboe() final;
|
||||
|
||||
bool Initialize() final;
|
||||
|
@ -44,7 +42,7 @@ class AudioSinkOboe final : public AudioSink {
|
|||
oboe::ManagedStream stream_;
|
||||
std::unique_ptr<StreamCallback> callback_;
|
||||
|
||||
AudioSinkDelegate* delegate_ = nullptr;
|
||||
AudioSink::Delegate* delegate_ = nullptr;
|
||||
|
||||
bool RestartStream();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue