| 206 | } |
| 207 | |
| 208 | void |
| 209 | FlacEncoder::SendTag(const Tag &tag) |
| 210 | { |
| 211 | /* re-initialize encoder since flac_encoder_finish resets everything */ |
| 212 | flac_encoder_setup(fse, compression, oggflac, audio_format); |
| 213 | |
| 214 | FLAC__StreamMetadata *metadata = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); |
| 215 | FLAC__StreamMetadata_VorbisComment_Entry entry; |
| 216 | |
| 217 | for (const auto &item : tag) { |
| 218 | char name[64]; |
| 219 | ToUpperASCII(name, tag_item_names[item.type], sizeof(name)); |
| 220 | FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, name, item.value); |
| 221 | FLAC__metadata_object_vorbiscomment_append_comment(metadata, entry, false); |
| 222 | } |
| 223 | |
| 224 | FLAC__stream_encoder_set_metadata(fse,&metadata,1); |
| 225 | |
| 226 | auto init_status = FLAC__stream_encoder_init_ogg_stream(fse, |
| 227 | nullptr, WriteCallback, |
| 228 | nullptr, nullptr, nullptr, |
| 229 | this); |
| 230 | |
| 231 | FLAC__metadata_object_delete(metadata); |
| 232 | |
| 233 | if (init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) |
| 234 | throw FmtRuntimeError("failed to initialize encoder: {}", |
| 235 | FLAC__StreamEncoderInitStatusString[init_status]); |
| 236 | } |
| 237 | |
| 238 | template<typename T> |
| 239 | static std::span<const FLAC__int32> |
nothing calls this directly
no test coverage detected