MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / flac_encoder_setup

Function flac_encoder_setup

src/encoder/plugins/FlacEncoderPlugin.cxx:111–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111static void
112flac_encoder_setup(FLAC__StreamEncoder *fse, unsigned compression, bool oggflac,
113 const AudioFormat &audio_format)
114{
115 unsigned bits_per_sample;
116
117 switch (audio_format.format) {
118 case SampleFormat::S8:
119 bits_per_sample = 8;
120 break;
121
122 case SampleFormat::S16:
123 bits_per_sample = 16;
124 break;
125
126 default:
127 bits_per_sample = 24;
128 }
129
130 if (!FLAC__stream_encoder_set_compression_level(fse, compression))
131 throw FmtRuntimeError("error setting flac compression to {}",
132 compression);
133
134 if (!FLAC__stream_encoder_set_channels(fse, audio_format.channels))
135 throw FmtRuntimeError("error setting flac channels num to {}",
136 audio_format.channels);
137
138 if (!FLAC__stream_encoder_set_bits_per_sample(fse, bits_per_sample))
139 throw FmtRuntimeError("error setting flac bit format to {}",
140 bits_per_sample);
141
142 if (!FLAC__stream_encoder_set_sample_rate(fse,
143 audio_format.sample_rate))
144 throw FmtRuntimeError("error setting flac sample rate to {}",
145 audio_format.sample_rate);
146
147 if (oggflac && !FLAC__stream_encoder_set_ogg_serial_number(fse,
148 GenerateSerial()))
149 throw std::runtime_error{"error setting ogg serial number"};
150}
151
152FlacEncoder::FlacEncoder(AudioFormat _audio_format, FLAC__StreamEncoder *_fse, unsigned _compression, bool _oggflac, bool _oggchaining)
153 :Encoder(_oggchaining),

Callers 2

OpenMethod · 0.85
SendTagMethod · 0.85

Calls 1

GenerateSerialFunction · 0.85

Tested by

no test coverage detected