Ring Daemon
Loading...
Searching...
No Matches
audioloop.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 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 "noncopyable.h"
23#include "audio_format.h"
24#include "media_buffer.h"
25
26extern "C" {
27#include <libavutil/frame.h>
28}
29
35namespace jami {
36
38{
39public:
40 AudioLoop(AudioFormat format);
41
43 {
44 std::swap(buffer_, o.buffer_);
45 std::swap(pos_, o.pos_);
46 return *this;
47 }
48
49 virtual ~AudioLoop();
50
58 void getNext(AVFrame* output, bool mute);
59 std::unique_ptr<AudioFrame> getNext(size_t samples = 0, bool mute = false);
60
61 void seek(double relative_position);
62
66 void reset() { pos_ = 0; }
67
72 size_t getSize() const { return buffer_->nb_samples; }
73 AudioFormat getFormat() const { return format_; }
74
75protected:
79
81 size_t pos_ {0};
82
83private:
85 virtual void onBufferFinish();
86};
87
88} // namespace jami
AudioLoop & operator=(AudioLoop &&o) noexcept
Definition audioloop.h:42
AudioFormat getFormat() const
Definition audioloop.h:73
size_t getSize() const
Accessor to the size of the buffer.
Definition audioloop.h:72
void reset()
Reset the pointer position.
Definition audioloop.h:66
virtual ~AudioLoop()
Definition audioloop.cpp:40
size_t pos_
current position, set to 0, when initialize
Definition audioloop.h:81
void seek(double relative_position)
Definition audioloop.cpp:43
AudioFormat format_
Definition audioloop.h:76
libjami::FrameBuffer buffer_
The data buffer.
Definition audioloop.h:78
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:49
void emitSignal(Args... args)
Definition jami_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.