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

Unified Diff: examples/audio_play_test/play_tone.cc

Issue 1986303002: Motown: Use new TimelineTransform and related definitions (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixes per feedback. Created 4 years, 7 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
« no previous file with comments | « examples/audio_play_test/BUILD.gn ('k') | examples/audio_play_test/play_wav.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/audio_play_test/play_tone.cc
diff --git a/examples/audio_play_test/play_tone.cc b/examples/audio_play_test/play_tone.cc
index 3a0ebc1a19d8610278e403ba6dd753514f769ae8..025bdbb0385b49877d1567963b0e16dd3bd29c97 100644
--- a/examples/audio_play_test/play_tone.cc
+++ b/examples/audio_play_test/play_tone.cc
@@ -16,7 +16,7 @@
#include "mojo/services/media/common/cpp/circular_buffer_media_pipe_adapter.h"
#include "mojo/services/media/common/cpp/linear_transform.h"
#include "mojo/services/media/common/cpp/local_time.h"
-#include "mojo/services/media/common/interfaces/rate_control.mojom.h"
+#include "mojo/services/media/common/interfaces/timelines.mojom.h"
namespace mojo {
namespace media {
@@ -52,8 +52,8 @@ class PlayToneApp : public ApplicationDelegate {
void OnConnectionError(const std::string& connection_name);
AudioServerPtr audio_server_;
- AudioTrackPtr audio_track_;
- RateControlPtr rate_control_;
+ AudioTrackPtr audio_track_;
+ TimelineConsumerPtr timeline_consumer_;
std::unique_ptr<CircularBufferMediaPipeAdapter> audio_pipe_;
bool clock_started_ = false;
@@ -64,7 +64,7 @@ class PlayToneApp : public ApplicationDelegate {
};
void PlayToneApp::Quit() {
- rate_control_.reset();
+ timeline_consumer_.reset();
audio_pipe_.reset();
audio_track_.reset();
audio_server_.reset();
@@ -115,11 +115,12 @@ void PlayToneApp::Initialize(ApplicationImpl* app) {
// TODO(johngro): do something useful with our capabilities description.
sink_desc.reset();
- // Grab the rate control interface for our audio renderer.
- audio_track_->GetRateControl(GetProxy(&rate_control_));
- rate_control_.set_connection_error_handler([this]() {
- OnConnectionError("rate_control");
- });
+ // Grab the timeline consumer interface for our audio renderer.
+ MediaTimelineControlSitePtr timeline_control_site;
+ audio_track_->GetTimelineControlSite(GetProxy(&timeline_control_site));
+ timeline_control_site->GetTimelineConsumer(GetProxy(&timeline_consumer_));
+ timeline_consumer_.set_connection_error_handler(
+ [this]() { OnConnectionError("timeline_consumer"); });
// Configure our sink for 16-bit 48KHz mono.
AudioTrackConfigurationPtr cfg = AudioTrackConfiguration::New();
@@ -204,20 +205,11 @@ void PlayToneApp::GenerateToneCbk(MediaResult res) {
}
if (!clock_started_) {
- // In theory, this could be done at compile time using std::ratio, but
- // std::ratio is prohibited.
- LinearTransform::Ratio audio_rate(SAMP_FREQ, 1);
- LinearTransform::Ratio local_time_rate(LocalDuration::period::num,
- LocalDuration::period::den);
- LinearTransform::Ratio rate;
- bool success = LinearTransform::Ratio::Compose(local_time_rate,
- audio_rate,
- &rate);
- MOJO_DCHECK(success); // assert that there was no loss of precision.
-
- MOJO_LOG(INFO) << "Setting rate " << rate;
-
- rate_control_->SetRate(rate.numerator, rate.denominator);
+ MOJO_LOG(INFO) << "Setting rate 1/1";
+
+ timeline_consumer_->SetTimelineTransform(
+ kUnspecifiedTime, 1, 1, kUnspecifiedTime, kUnspecifiedTime,
+ [](bool completed) {});
clock_started_ = true;
}
}
« no previous file with comments | « examples/audio_play_test/BUILD.gn ('k') | examples/audio_play_test/play_wav.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698