1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CHUNK_H
#define MPD_CHUNK_H
#include "replay_gain_info.h"
#ifndef NDEBUG
#include "audio_format.h"
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <libavutil/frame.h>
enum {
CHUNK_SIZE = 4096,
};
struct audio_format;
/**
* A chunk of music data. Its format is defined by the
* music_pipe_append() caller.
*/
struct music_chunk {
/** the next chunk in a linked list */
struct music_chunk *next;
/**
* An optional chunk which should be mixed into this chunk.
* This is used for cross-fading.
*/
struct music_chunk *other;
/**
* The current mix ratio for cross-fading: 1.0 means play 100%
* of this chunk, 0.0 means play 100% of the "other" chunk.
*/
float mix_ratio;
/** current bit rate of the source file */
uint16_t bit_rate;
/** the time stamp within the song */
float times;
/**
* An optional tag associated with this chunk (and the
* following chunks); appears at song boundaries. The tag
* object is owned by this chunk, and must be freed when this
* chunk is deinitialized in music_chunk_free()
*/
struct tag *tag;
/**
* Replay gain information associated with this chunk.
* Only valid if the serial is not 0.
*/
struct replay_gain_info replay_gain_info;
/**
* A serial number for checking if replay gain info has
* changed since the last chunk. The magic value 0 indicates
* that there is no replay gain info available.
*/
unsigned replay_gain_serial;
/** the audio frame */
AVFrame *frame;
#ifndef NDEBUG
struct audio_format audio_format;
#endif
};
void
music_chunk_init(struct music_chunk *chunk);
struct music_chunk *music_chunk_alloc(void);
void
music_chunk_free(struct music_chunk *chunk);
static inline bool
music_chunk_is_empty(const struct music_chunk *chunk)
{
return !chunk->frame && chunk->tag == NULL;
}
#ifndef NDEBUG
/**
* Checks if the audio format if the chunk is equal to the specified
* audio_format.
*/
bool
music_chunk_check_format(const struct music_chunk *chunk,
const struct audio_format *audio_format);
#endif
#endif
|