提交 a0d43268 编写于 作者: J Ján Tomko

Use a separate buffer for <sound> subelements

Convert virDomainSoundDefFormat to use a separate buffer
for subelements.
上级 0c1d8632
......@@ -23174,38 +23174,32 @@ virDomainSoundDefFormat(virBufferPtr buf,
unsigned int flags)
{
const char *model = virDomainSoundModelTypeToString(def->model);
bool children = false;
virBuffer childBuf = VIR_BUFFER_INITIALIZER;
size_t i;
virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2);
if (!model) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected sound model %d"), def->model);
return -1;
}
virBufferAsprintf(buf, "<sound model='%s'", model);
for (i = 0; i < def->ncodecs; i++)
virDomainSoundCodecDefFormat(&childBuf, def->codecs[i]);
for (i = 0; i < def->ncodecs; i++) {
if (!children) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
children = true;
}
virDomainSoundCodecDefFormat(buf, def->codecs[i]);
if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) {
virBufferFreeAndReset(&childBuf);
return -1;
}
if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
if (!children) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
children = true;
}
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1;
}
if (virBufferCheckError(&childBuf) < 0)
return -1;
if (children) {
virBufferAdjustIndent(buf, -2);
virBufferAsprintf(buf, "<sound model='%s'", model);
if (virBufferUse(&childBuf)) {
virBufferAddLit(buf, ">\n");
virBufferAddBuffer(buf, &childBuf);
virBufferAddLit(buf, "</sound>\n");
} else {
virBufferAddLit(buf, "/>\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册