Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(469)

Side by Side Diff: components/audio_modem/audio_player_impl.h

Issue 2131993002: Delete the audio modem and copresence private APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eol
Patch Set: Sync again Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/audio_modem/audio_player.h ('k') | components/audio_modem/audio_player_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_AUDIO_MODEM_AUDIO_PLAYER_IMPL_H_
6 #define COMPONENTS_AUDIO_MODEM_AUDIO_PLAYER_IMPL_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11 #include <vector>
12
13 #include "base/gtest_prod_util.h"
14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/synchronization/lock.h"
17 #include "components/audio_modem/audio_player.h"
18 #include "media/audio/audio_io.h"
19
20 namespace media {
21 class AudioBus;
22 class AudioBusRefCounted;
23 }
24
25 namespace audio_modem {
26
27 // The AudioPlayerImpl class will play a set of samples till it is told to stop.
28 class AudioPlayerImpl final
29 : public AudioPlayer,
30 public media::AudioOutputStream::AudioSourceCallback {
31 public:
32 AudioPlayerImpl();
33
34 // AudioPlayer overrides:
35 void Initialize() override;
36 void Play(const scoped_refptr<media::AudioBusRefCounted>& samples) override;
37 void Stop() override;
38 void Finalize() override;
39
40 // Takes ownership of the stream.
41 void set_output_stream_for_testing(
42 media::AudioOutputStream* output_stream_for_testing) {
43 output_stream_for_testing_.reset(output_stream_for_testing);
44 }
45
46 private:
47 friend class AudioPlayerTest;
48 FRIEND_TEST_ALL_PREFIXES(AudioPlayerTest, BasicPlayAndStop);
49 FRIEND_TEST_ALL_PREFIXES(AudioPlayerTest, OutOfOrderPlayAndStopMultiple);
50
51 ~AudioPlayerImpl() override;
52
53 // Methods to do our various operations; all of these need to be run on the
54 // audio thread.
55 void InitializeOnAudioThread();
56 void PlayOnAudioThread(
57 const scoped_refptr<media::AudioBusRefCounted>& samples);
58 void StopOnAudioThread();
59 void StopAndCloseOnAudioThread();
60 void FinalizeOnAudioThread();
61
62 // AudioOutputStream::AudioSourceCallback overrides:
63 // Following methods could be called from *ANY* thread.
64 int OnMoreData(media::AudioBus* dest,
65 uint32_t total_bytes_delay,
66 uint32_t frames_skipped) override;
67 void OnError(media::AudioOutputStream* stream) override;
68
69 bool is_playing_;
70
71 // Self-deleting object.
72 media::AudioOutputStream* stream_;
73
74 std::unique_ptr<media::AudioOutputStream> output_stream_for_testing_;
75
76 // All fields below here are protected by this lock.
77 base::Lock state_lock_;
78
79 scoped_refptr<media::AudioBusRefCounted> samples_;
80
81 // Index to the frame in the samples that we need to play next.
82 int frame_index_;
83
84 DISALLOW_COPY_AND_ASSIGN(AudioPlayerImpl);
85 };
86
87 } // namespace audio_modem
88
89 #endif // COMPONENTS_AUDIO_MODEM_AUDIO_PLAYER_IMPL_H_
OLDNEW
« no previous file with comments | « components/audio_modem/audio_player.h ('k') | components/audio_modem/audio_player_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698