Ring Daemon 16.0.0
Loading...
Searching...
No Matches
audioloop.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * Inspired by tonegenerator of
5 * Laurielle Lea <laurielle.lea@savoirfairelinux.com> (2004)
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20#pragma once
21
22#include "ring_types.h"
23#include "noncopyable.h"
24#include "audio_format.h"
25#include "media_buffer.h"
26
27extern "C" {
28#include <libavutil/frame.h>
29}
30
36namespace jami {
37
39{
40public:
41 AudioLoop(AudioFormat format);
42
44 {
45 std::swap(buffer_, o.buffer_);
46 std::swap(pos_, o.pos_);
47 return *this;
48 }
49
50 virtual ~AudioLoop();
51
59 void getNext(AVFrame* output, bool mute);
60 std::unique_ptr<AudioFrame> getNext(size_t samples = 0, bool mute = false);
61
62 void seek(double relative_position);
63
67 void reset() { pos_ = 0; }
68
73 size_t getSize() const { return buffer_->nb_samples; }
74 AudioFormat getFormat() const { return format_; }
75
76protected:
80
82 size_t pos_ {0};
83
84private:
86 virtual void onBufferFinish();
87};
88
89} // namespace jami
AudioLoop & operator=(AudioLoop &&o) noexcept
Definition audioloop.h:43
AudioFormat getFormat() const
Definition audioloop.h:74
size_t getSize() const
Accessor to the size of the buffer.
Definition audioloop.h:73
void reset()
Reset the pointer position.
Definition audioloop.h:67
virtual ~AudioLoop()
Definition audioloop.cpp:41
size_t pos_
current position, set to 0, when initialize
Definition audioloop.h:82
void seek(double relative_position)
Definition audioloop.cpp:45
AudioFormat format_
Definition audioloop.h:77
libjami::FrameBuffer buffer_
The data buffer.
Definition audioloop.h:79
void getNext(AVFrame *output, bool mute)
Get the next fragment of the tone the function change the intern position, and will loop.
Definition audioloop.cpp:51
void emitSignal(Args... args)
Definition ring_signal.h:64
std::unique_ptr< AVFrame, AVFrame_deleter > FrameBuffer
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30
Structure to hold sample rate and channel number associated with audio data.