misc/winutils/include/libavutil/audio_fifo.h
author Wuzzy <Wuzzy2@mail.ru>
Wed, 08 Aug 2018 14:38:54 +0200
changeset 13642 3d14950641a4
parent 7813 7ac83d79b897
permissions -rw-r--r--
Refactor text color variable names, export 2 color values to Lua
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7813
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     1
/*
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     2
 * Audio FIFO
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     3
 * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     4
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     5
 * This file is part of Libav.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     6
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     7
 * Libav is free software; you can redistribute it and/or
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     8
 * modify it under the terms of the GNU Lesser General Public
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     9
 * License as published by the Free Software Foundation; either
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    10
 * version 2.1 of the License, or (at your option) any later version.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    11
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    12
 * Libav is distributed in the hope that it will be useful,
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    15
 * Lesser General Public License for more details.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    16
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    17
 * You should have received a copy of the GNU Lesser General Public
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    18
 * License along with Libav; if not, write to the Free Software
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    20
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    21
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    22
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    23
 * @file
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    24
 * Audio FIFO Buffer
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    25
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    26
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    27
#ifndef AVUTIL_AUDIO_FIFO_H
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    28
#define AVUTIL_AUDIO_FIFO_H
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    29
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    30
#include "avutil.h"
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    31
#include "fifo.h"
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    32
#include "samplefmt.h"
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    33
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    34
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    35
 * @addtogroup lavu_audio
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    36
 * @{
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    37
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    38
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    39
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    40
 * Context for an Audio FIFO Buffer.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    41
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    42
 * - Operates at the sample level rather than the byte level.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    43
 * - Supports multiple channels with either planar or packed sample format.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    44
 * - Automatic reallocation when writing to a full buffer.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    45
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    46
typedef struct AVAudioFifo AVAudioFifo;
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    47
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    48
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    49
 * Free an AVAudioFifo.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    50
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    51
 * @param af  AVAudioFifo to free
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    52
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    53
void av_audio_fifo_free(AVAudioFifo *af);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    54
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    55
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    56
 * Allocate an AVAudioFifo.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    57
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    58
 * @param sample_fmt  sample format
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    59
 * @param channels    number of channels
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    60
 * @param nb_samples  initial allocation size, in samples
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    61
 * @return            newly allocated AVAudioFifo, or NULL on error
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    62
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    63
AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    64
                                 int nb_samples);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    65
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    66
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    67
 * Reallocate an AVAudioFifo.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    68
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    69
 * @param af          AVAudioFifo to reallocate
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    70
 * @param nb_samples  new allocation size, in samples
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    71
 * @return            0 if OK, or negative AVERROR code on failure
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    72
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    73
int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    74
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    75
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    76
 * Write data to an AVAudioFifo.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    77
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    78
 * The AVAudioFifo will be reallocated automatically if the available space
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    79
 * is less than nb_samples.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    80
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    81
 * @see enum AVSampleFormat
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    82
 * The documentation for AVSampleFormat describes the data layout.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    83
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    84
 * @param af          AVAudioFifo to write to
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    85
 * @param data        audio data plane pointers
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    86
 * @param nb_samples  number of samples to write
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    87
 * @return            number of samples actually written, or negative AVERROR
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    88
 *                    code on failure.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    89
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    90
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    91
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    92
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    93
 * Read data from an AVAudioFifo.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    94
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    95
 * @see enum AVSampleFormat
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    96
 * The documentation for AVSampleFormat describes the data layout.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    97
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    98
 * @param af          AVAudioFifo to read from
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    99
 * @param data        audio data plane pointers
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   100
 * @param nb_samples  number of samples to read
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   101
 * @return            number of samples actually read, or negative AVERROR code
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   102
 *                    on failure.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   103
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   104
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   105
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   106
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   107
 * Drain data from an AVAudioFifo.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   108
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   109
 * Removes the data without reading it.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   110
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   111
 * @param af          AVAudioFifo to drain
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   112
 * @param nb_samples  number of samples to drain
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   113
 * @return            0 if OK, or negative AVERROR code on failure
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   114
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   115
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   116
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   117
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   118
 * Reset the AVAudioFifo buffer.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   119
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   120
 * This empties all data in the buffer.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   121
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   122
 * @param af  AVAudioFifo to reset
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   123
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   124
void av_audio_fifo_reset(AVAudioFifo *af);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   125
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   126
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   127
 * Get the current number of samples in the AVAudioFifo available for reading.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   128
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   129
 * @param af  the AVAudioFifo to query
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   130
 * @return    number of samples available for reading
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   131
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   132
int av_audio_fifo_size(AVAudioFifo *af);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   133
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   134
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   135
 * Get the current number of samples in the AVAudioFifo available for writing.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   136
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   137
 * @param af  the AVAudioFifo to query
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   138
 * @return    number of samples available for writing
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   139
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   140
int av_audio_fifo_space(AVAudioFifo *af);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   141
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   142
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   143
 * @}
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   144
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   145
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   146
#endif /* AVUTIL_AUDIO_FIFO_H */