FFmpegfs Fuse Multi Media Filesystem 2.19
Loading...
Searching...
No Matches
ffmpeg_audiofifo.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017-2026 by Norbert Schlia (nschlia@oblivion-software.de)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 */
9
17#ifndef FFMPEG_AUDIOFIFO_H
18#define FFMPEG_AUDIOFIFO_H
19
20#pragma once
21
22#include "ffmpeg_utils.h"
23
24struct AVAudioFifo;
25
33{
34public:
39
46 FFmpeg_AudioFifo(AVSampleFormat sample_fmt, int channels, int nb_samples = 1);
47
52
53 FFmpeg_AudioFifo(const FFmpeg_AudioFifo&) = delete;
54 FFmpeg_AudioFifo& operator=(const FFmpeg_AudioFifo&) = delete;
55
60 FFmpeg_AudioFifo(FFmpeg_AudioFifo&& fifo) noexcept;
61
67 FFmpeg_AudioFifo& operator=(FFmpeg_AudioFifo&& fifo) noexcept;
68
76 int alloc(AVSampleFormat sample_fmt, int channels, int nb_samples = 1);
77
81 void reset();
82
87 bool empty() const;
88
93 int size() const;
94
100 int realloc(int nb_samples);
101
108 int write(void **data, int nb_samples);
109
116 int read(void **data, int nb_samples);
117
122 AVAudioFifo* get();
123
128 const AVAudioFifo* get() const;
129
134 AVAudioFifo* release();
135
139 operator AVAudioFifo*();
140
144 operator const AVAudioFifo*() const;
145
146private:
147 AVAudioFifo * m_fifo;
148};
149
150#endif // FFMPEG_AUDIOFIFO_H
RAII wrapper for AVAudioFifo.
int write(void **data, int nb_samples)
Write audio samples into the FIFO.
FFmpeg_AudioFifo()
Construct an empty FIFO wrapper.
AVAudioFifo * release()
Release ownership without freeing the FIFO.
void reset()
Free the owned FIFO and reset the wrapper to empty.
AVAudioFifo * m_fifo
Pointer to underlying AVAudioFifo.
AVAudioFifo * get()
Get the owned FFmpeg FIFO pointer.
int read(void **data, int nb_samples)
Read audio samples from the FIFO.
bool empty() const
Check whether the wrapper currently owns a FIFO.
~FFmpeg_AudioFifo()
Release the owned FIFO, if any.
int size() const
Return the number of samples currently stored in the FIFO.
int realloc(int nb_samples)
Resize the FIFO allocation.
int alloc(AVSampleFormat sample_fmt, int channels, int nb_samples=1)
Allocate a new audio FIFO, replacing any existing one.
Various FFmpegfs utility functions.