Resolve deprecation warnings by replacing use of sprintf with FmtBuffer
This commit is contained in:
parent
e0df0b6d74
commit
f248fe2dec
|
@ -22,8 +22,7 @@
|
||||||
#include "SampleFormat.hxx"
|
#include "SampleFormat.hxx"
|
||||||
#include "pcm/AudioFormat.hxx"
|
#include "pcm/AudioFormat.hxx"
|
||||||
#include "lib/fmt/RuntimeError.hxx"
|
#include "lib/fmt/RuntimeError.hxx"
|
||||||
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
#include <cinttypes>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -81,9 +80,8 @@ MakeAudioBufferSource(AudioFormat &audio_format,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char abuffer_args[256];
|
const auto abuffer_args = FmtBuffer<256>(
|
||||||
sprintf(abuffer_args,
|
"sample_rate={}:sample_fmt={}:channel_layout={:#x}:time_base=1/{}",
|
||||||
"sample_rate=%u:sample_fmt=%s:channel_layout=0x%" PRIx64 ":time_base=1/%u",
|
|
||||||
audio_format.sample_rate,
|
audio_format.sample_rate,
|
||||||
av_get_sample_fmt_name(src_format),
|
av_get_sample_fmt_name(src_format),
|
||||||
ToFfmpegChannelLayout(audio_format.channels),
|
ToFfmpegChannelLayout(audio_format.channels),
|
||||||
|
@ -119,9 +117,8 @@ MakeAformat(AudioFormat &audio_format,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char args[256];
|
const auto args = FmtBuffer<256>(
|
||||||
sprintf(args,
|
"sample_rates={}:sample_fmts={}:channel_layouts={:#x}",
|
||||||
"sample_rates=%u:sample_fmts=%s:channel_layouts=0x%" PRIx64,
|
|
||||||
audio_format.sample_rate,
|
audio_format.sample_rate,
|
||||||
av_get_sample_fmt_name(dest_format),
|
av_get_sample_fmt_name(dest_format),
|
||||||
ToFfmpegChannelLayout(audio_format.channels));
|
ToFfmpegChannelLayout(audio_format.channels));
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "fs/FileSystem.hxx"
|
#include "fs/FileSystem.hxx"
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "lib/fmt/SystemError.hxx"
|
#include "lib/fmt/SystemError.hxx"
|
||||||
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
@ -71,10 +72,9 @@ public:
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char buffer[64];
|
const auto s = FmtBuffer<64>("{}\n", pid);
|
||||||
sprintf(buffer, "%lu\n", (unsigned long)pid);
|
|
||||||
|
|
||||||
write(fd, buffer, strlen(buffer));
|
write(fd, s.c_str(), strlen(s.c_str()));
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue