-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio_sync_reader.h
70 lines (53 loc) · 2.08 KB
/
audio_sync_reader.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 2012 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.
#ifndef CHROMIUM_MEDIA_LIB_AUDIO_SYNC_READER_H_
#define CHROMIUM_MEDIA_LIB_AUDIO_SYNC_READER_H_
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include "base/macros.h"
#include "base/sync_socket.h"
#include "media/audio/audio_output_controller.h"
#include "media/base/audio_bus.h"
#if defined(OS_POSIX)
#include "base/file_descriptor_posix.h"
#endif
namespace base {
class SharedMemory;
}
namespace media {
class AudioSyncReader : public AudioOutputController::SyncReader {
public:
~AudioSyncReader() override;
// Returns null on failure.
static std::unique_ptr<AudioSyncReader> Create(
const media::AudioParameters& params);
base::SharedMemory* shared_memory() const { return shared_memory_.get(); }
std::unique_ptr<base::CancelableSyncSocket> TakeForeignSocket();
// media::AudioOutputController::SyncReader implementations.
void RequestMoreData(base::TimeDelta delay,
base::TimeTicks delay_timestamp,
int prior_frames_skipped) override;
void Read(media::AudioBus* dest) override;
void Close() override;
private:
AudioSyncReader(const media::AudioParameters& params,
std::unique_ptr<base::SharedMemory> shared_memory,
std::unique_ptr<base::CancelableSyncSocket> socket,
std::unique_ptr<base::CancelableSyncSocket> foreign_socket);
bool WaitUntilDataIsReady();
std::unique_ptr<base::SharedMemory> shared_memory_;
std::unique_ptr<base::CancelableSyncSocket> socket_;
std::unique_ptr<base::CancelableSyncSocket> foreign_socket_;
std::unique_ptr<media::AudioBus> output_bus_;
const int packet_size_;
size_t renderer_callback_count_;
size_t renderer_missed_callback_count_;
size_t trailing_renderer_missed_callback_count_;
const base::TimeDelta maximum_wait_time_;
uint32_t buffer_index_;
DISALLOW_COPY_AND_ASSIGN(AudioSyncReader);
};
}
#endif // CHROMIUM_MEDIA_LIB_AUDIO_SYNC_READER_H_