refactor(core): use std error_code conditions
This commit is contained in:
@@ -213,7 +213,10 @@ Status write_all(int fd, std::span<const std::uint8_t> bytes) {
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
return unexpected_error(ERR_IO, std::strerror(errno));
|
||||
const auto error = errno;
|
||||
return unexpected_error(
|
||||
std::error_code(error, std::generic_category()),
|
||||
"failed to write to ffmpeg process stdin");
|
||||
}
|
||||
if (result == 0) {
|
||||
return unexpected_error(ERR_IO, "short write to ffmpeg process stdin");
|
||||
@@ -530,14 +533,20 @@ private:
|
||||
Result<Session> spawn_session(const std::string &url) const {
|
||||
int stdin_pipe[2]{-1, -1};
|
||||
if (pipe(stdin_pipe) != 0) {
|
||||
return unexpected_error(ERR_IO, "failed to create ffmpeg stdin pipe: " + std::string(std::strerror(errno)));
|
||||
const auto error = errno;
|
||||
return unexpected_error(
|
||||
std::error_code(error, std::generic_category()),
|
||||
"failed to create ffmpeg stdin pipe");
|
||||
}
|
||||
|
||||
const auto child = fork();
|
||||
if (child < 0) {
|
||||
const auto error = errno;
|
||||
close(stdin_pipe[0]);
|
||||
close(stdin_pipe[1]);
|
||||
return unexpected_error(ERR_CHILD_PROCESS, "failed to fork ffmpeg child: " + std::string(std::strerror(errno)));
|
||||
return unexpected_error(
|
||||
std::error_code(error, std::generic_category()),
|
||||
"failed to fork ffmpeg child");
|
||||
}
|
||||
|
||||
if (child == 0) {
|
||||
@@ -626,7 +635,10 @@ private:
|
||||
return {};
|
||||
}
|
||||
if (wait_result < 0) {
|
||||
return unexpected_error(ERR_CHILD_PROCESS, "failed to poll ffmpeg child: " + std::string(std::strerror(errno)));
|
||||
const auto error = errno;
|
||||
return unexpected_error(
|
||||
std::error_code(error, std::generic_category()),
|
||||
"failed to poll ffmpeg child");
|
||||
}
|
||||
|
||||
if (session.stdin_fd >= 0) {
|
||||
|
||||
Reference in New Issue
Block a user