summaryrefslogtreecommitdiff
path: root/chromium/media/base/scopedfd_helper.cc
blob: 8dcf3dc1f16eb4d858a307b0045f437e484d0647 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <unistd.h>

#include <vector>

#include "base/check.h"
#include "base/posix/eintr_wrapper.h"
#include "media/base/scopedfd_helper.h"

namespace media {

std::vector<base::ScopedFD> DuplicateFDs(
    const std::vector<base::ScopedFD>& fds) {
  std::vector<base::ScopedFD> ret;

  for (auto& fd : fds) {
    base::ScopedFD dup_fd = base::ScopedFD(HANDLE_EINTR(dup(fd.get())));
    PCHECK(dup_fd.is_valid());
    ret.push_back(std::move(dup_fd));
  }

  return ret;
}

}  // namespace media