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

Unified Diff: components/copresence/mediums/audio/audio_player.h

Issue 637223011: Redesign the copresence audio handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: components/copresence/mediums/audio/audio_player.h
diff --git a/components/copresence/mediums/audio/audio_player.h b/components/copresence/mediums/audio/audio_player.h
index e2bb64dce169199347dcdc50533b369ff5f49429..3c92e5dc0bd38d789f06ea23ca96bcb0a98ccbe1 100644
--- a/components/copresence/mediums/audio/audio_player.h
+++ b/components/copresence/mediums/audio/audio_player.h
@@ -7,88 +7,36 @@
#include <vector>
-#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/synchronization/lock.h"
-#include "media/audio/audio_io.h"
namespace media {
-class AudioBus;
class AudioBusRefCounted;
}
namespace copresence {
-// The AudioPlayer class will play a set of samples till it is told to stop.
-class AudioPlayer : public media::AudioOutputStream::AudioSourceCallback {
+// The AudioPlayerImpl class will play a set of samples till it is told to stop.
+class AudioPlayer {
public:
- AudioPlayer();
-
// Initializes the object. Do not use this object before calling this method.
- virtual void Initialize();
+ virtual void Initialize() = 0;
// Play the given samples. These samples will keep on being played in a loop
// till we explicitly tell the player to stop playing.
- virtual void Play(const scoped_refptr<media::AudioBusRefCounted>& samples);
+ virtual void Play(
+ const scoped_refptr<media::AudioBusRefCounted>& samples) = 0;
// Stop playing.
- virtual void Stop();
+ virtual void Stop() = 0;
// Cleans up and deletes this object. Do not use object after this call.
- virtual void Finalize();
-
- bool IsPlaying();
+ virtual void Finalize() = 0;
- // Takes ownership of the stream.
- void set_output_stream_for_testing(
- media::AudioOutputStream* output_stream_for_testing) {
- output_stream_for_testing_.reset(output_stream_for_testing);
- }
+ virtual bool IsPlaying() = 0;
protected:
- ~AudioPlayer() override;
- void set_is_playing(bool is_playing) { is_playing_ = is_playing; }
-
- private:
- friend class AudioPlayerTest;
- FRIEND_TEST_ALL_PREFIXES(AudioPlayerTest, BasicPlayAndStop);
- FRIEND_TEST_ALL_PREFIXES(AudioPlayerTest, OutOfOrderPlayAndStopMultiple);
-
- // Methods to do our various operations; all of these need to be run on the
- // audio thread.
- void InitializeOnAudioThread();
- void PlayOnAudioThread(
- const scoped_refptr<media::AudioBusRefCounted>& samples);
- void StopOnAudioThread();
- void StopAndCloseOnAudioThread();
- void FinalizeOnAudioThread();
-
- // AudioOutputStream::AudioSourceCallback overrides:
- // Following methods could be called from *ANY* thread.
- int OnMoreData(media::AudioBus* dest, uint32 total_bytes_delay) override;
- void OnError(media::AudioOutputStream* stream) override;
-
- // Flushes the audio loop, making sure that any queued operations are
- // performed.
- void FlushAudioLoopForTesting();
-
- bool is_playing_;
-
- // Self-deleting object.
- media::AudioOutputStream* stream_;
-
- scoped_ptr<media::AudioOutputStream> output_stream_for_testing_;
-
- // All fields below here are protected by this lock.
- base::Lock state_lock_;
-
- scoped_refptr<media::AudioBusRefCounted> samples_;
-
- // Index to the frame in the samples that we need to play next.
- int frame_index_;
-
- DISALLOW_COPY_AND_ASSIGN(AudioPlayer);
+ virtual ~AudioPlayer() {}
};
} // namespace copresence
« no previous file with comments | « components/copresence/mediums/audio/audio_manager_unittest.cc ('k') | components/copresence/mediums/audio/audio_player.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698