[Cast] Add BufferIdManager [chromium/src : master]

2 views
Skip to first unread message

Ryan Keane (Gerrit)

unread,
Dec 9, 2020, 10:15:54 PM12/9/20
to Alex Leung, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org

Attention is currently required from: Alex Leung.

Ryan Keane would like Alex Leung to review this change.

View Change

[Cast] Add BufferIdManager

This CL introduces the concept of a "BufferId", or a unique ID assigned
to each PushBuffer call. Additionally, it introduces the BufferIdManager
class, a utility class used to approximate these IDs at a given time.

This functionality is required for audio-audio sync as defined in:
go/cast-media-chromium-runtime

Bug: b/171495618
Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
---
M chromecast/media/cma/BUILD.gn
M chromecast/media/cma/backend/proxy/BUILD.gn
A chromecast/media/cma/backend/proxy/buffer_id_manager.cc
A chromecast/media/cma/backend/proxy/buffer_id_manager.h
A chromecast/media/cma/backend/proxy/buffer_id_manager_unittest.cc
5 files changed, 285 insertions(+), 0 deletions(-)


To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 3
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Attention: Alex Leung <alex...@google.com>
Gerrit-MessageType: newchange

Ryan Keane (Gerrit)

unread,
Dec 9, 2020, 10:16:04 PM12/9/20
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Alex Leung.

View Change

1 comment:

  • Patchset:

    • Patch Set #3:

      @alexleung Please confirm that the logic is in-sync with what you expect on the other side of the RPC

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 3
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Attention: Alex Leung <alex...@google.com>
Gerrit-Comment-Date: Thu, 10 Dec 2020 03:15:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

Alex Leung (Gerrit)

unread,
Dec 10, 2020, 11:28:46 AM12/10/20
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Ryan Keane.

View Change

3 comments:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 3
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Thu, 10 Dec 2020 16:28:31 +0000

Ryan Keane (Gerrit)

unread,
Dec 10, 2020, 2:14:11 PM12/10/20
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Alex Leung.

Patch set 4:Commit-Queue +1

View Change

3 comments:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

    • Done

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • Is this a requirement for the other side, or just a suggestion here? IMHO having a monotonically increasing ID could make some debugging easier. Alternatively, to that point, WDYT about making this an instance variable but initializing it to a random number?

      My goal here is to avoid having the same PushBuffer ID show up twice, so that debug logs never have that added complexity

    • Done

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 4
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Attention: Alex Leung <alex...@google.com>
Gerrit-Comment-Date: Thu, 10 Dec 2020 19:14:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Alex Leung <alex...@google.com>
Gerrit-MessageType: comment

Alex Leung (Gerrit)

unread,
Dec 10, 2020, 2:16:40 PM12/10/20
to Yuchen Liu, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Ryan Keane

Attention is currently required from: Yuchen Liu, Ryan Keane.

Alex Leung would like Yuchen Liu to review this change authored by Ryan Keane.

View Change

[Cast] Add BufferIdManager

This CL introduces the concept of a "BufferId", or a unique ID assigned
to each PushBuffer call. Additionally, it introduces the BufferIdManager
class, a utility class used to approximate these IDs at a given time.

This functionality is required for audio-audio sync as defined in:
go/cast-media-chromium-runtime

Bug: b/171495618
Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
---
M chromecast/media/cma/BUILD.gn
M chromecast/media/cma/backend/proxy/BUILD.gn
A chromecast/media/cma/backend/proxy/buffer_id_manager.cc
A chromecast/media/cma/backend/proxy/buffer_id_manager.h
A chromecast/media/cma/backend/proxy/buffer_id_manager_unittest.cc
5 files changed, 310 insertions(+), 0 deletions(-)


To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 4
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-MessageType: newchange

Alex Leung (Gerrit)

unread,
Dec 10, 2020, 2:16:48 PM12/10/20
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Yuchen Liu, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Yuchen Liu, Ryan Keane.

View Change

1 comment:

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 4
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Thu, 10 Dec 2020 19:16:37 +0000

Yuchen Liu (Gerrit)

unread,
Dec 10, 2020, 7:09:57 PM12/10/20
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Ryan Keane.

View Change

5 comments:

  • Patchset:

    • Patch Set #4:

      The patch lg, but it's worth to see how will it be used in other changes.

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

    • Patch Set #4, Line 46:

          // The ID of the current buffer.
      BufferId id;

      // The time in seconds of playback (as number of buffers of playback divided
      // by number of buffer per second) for this buffer. This must be kept track
      // of rather than the number of bytes in the source buffer to allow for
      // changes to the audio config part way through playback.
      double playback_time_in_seconds;

      Give them some initial value.

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • Patch Set #4, Line 41: BufferIdQueue g_buffer_id_qeueue;

      nit: you can make this a singleton with base::NoDestructor.

    • Patch Set #4, Line 43:

      // Helper to convert from Chromium callback type (OnceCallback) to Chromecast's
      // TaskRunner's Task type.
      class OnceCallbackTask : public TaskRunner::Task {
      public:
      OnceCallbackTask(base::OnceClosure callback)
      : callback_(std::move(callback)) {}

      ~OnceCallbackTask() override = default;

      private:
      // TaskRunner::Task overrides:
      void Run() override { std::move(callback_).Run(); }

      base::OnceClosure callback_;
      };

      I think I see this in another change as well. Consider move them to a common file.

    • Patch Set #4, Line 83: double

      static_cast.

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 4
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Fri, 11 Dec 2020 00:09:45 +0000

Ryan Keane (Gerrit)

unread,
Dec 10, 2020, 9:04:16 PM12/10/20
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Yuchen Liu.

Patch set 5:Commit-Queue +1

View Change

5 comments:

  • Patchset:

    • Patch Set #4:

      The patch lg, but it's worth to see how will it be used in other changes.

    • +1. Sorry about that. Hadn't intended to send it out for full review until I had the follow-up patch up too.

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

    • Patch Set #4, Line 46:

          // The ID of the current buffer.
      BufferId id;

      // The time in seconds of playback (as number of buffers of playback divided
      // by number of buffer per second) for this buffer. This must be kept track
      // of rather than the number of bytes in the source buffer to allow for
      // changes to the audio config part way through playback.
      double playback_time_in_seconds;

      Give them some initial value.

    • Done. Giving them an invalid default value that I DCHECK against later

      Do you think it's worth defining a kInvalidBufferId kInvalidPlaybackTime as BufferInfo constants in the header file? I couldn't decide and went with no for now because I haven't run across that pattern much in chromecast/ code.

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • Patch Set #4, Line 41: BufferIdQueue g_buffer_id_qeueue;

      nit: you can make this a singleton with base::NoDestructor.

    • Done

    • Patch Set #4, Line 43:

      // Helper to convert from Chromium callback type (OnceCallback) to Chromecast's
      // TaskRunner's Task type.
      class OnceCallbackTask : public TaskRunner::Task {
      public:
      OnceCallbackTask(base::OnceClosure callback)
      : callback_(std::move(callback)) {}

      ~OnceCallbackTask() override = default;

      private:
      // TaskRunner::Task overrides:
      void Run() override { std::move(callback_).Run(); }

      base::OnceClosure callback_;
      };

      I think I see this in another change as well. Consider move them to a common file.

    • Yeah, this is duplicated. Was planning to ask where you suggested for the common code

      IMHO it would make sense in chromecast/base/task_runner_utils.h or similar (right next to task_runner_impl.h), but not fully sure about the file structure chromecast/ uses

    • Done

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 5
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Comment-Date: Fri, 11 Dec 2020 02:04:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Yuchen Liu <yuc...@chromium.org>
Gerrit-MessageType: comment

Ryan Keane (Gerrit)

unread,
Dec 22, 2020, 10:22:56 PM12/22/20
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Alex Leung, Yuchen Liu.

Patch set 6:Commit-Queue +1

View Change

1 comment:

  • Patchset:

    • Patch Set #6:

      Added a child CL that shows how this class will be used

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 6
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Attention: Alex Leung <alex...@google.com>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Comment-Date: Wed, 23 Dec 2020 03:22:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Ryan Keane (Gerrit)

unread,
Jan 12, 2021, 5:41:24 PM1/12/21
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Alex Leung, Yuchen Liu.

View Change

1 comment:

  • Patchset:

    • Patch Set #6:

      Ping. PTAL. The follow-up CL can come later, but this one needs to get in before I can address b/176252973 or b/175701705

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 6
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Alex Leung <alex...@google.com>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Comment-Date: Tue, 12 Jan 2021 22:41:13 +0000

Yuchen Liu (Gerrit)

unread,
Jan 19, 2021, 4:58:08 PM1/19/21
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Alex Leung, Ryan Keane.

View Change

4 comments:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

    • Patch Set #6, Line 53: playback_time_in_seconds

      The rest of the codes are using microseconds, recommend keep consistency with others. Also, why not use number of buffers instead of time?

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • Patch Set #6, Line 29: return static_cast<int64_t>(next_id_ & kBufferIdMask);

      Is this to handle overflow? If using uint64_t everywhere, it should be handled automatically.

    • Patch Set #6, Line 34: next_id_++;

      Do you need a lock here? If this is supposed to be called from a single thread, add a thread checker to enforce that.

    • Patch Set #6, Line 85: push

      emplace?

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 6
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Alex Leung <alex...@google.com>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Tue, 19 Jan 2021 21:57:56 +0000

Alex Leung (Gerrit)

unread,
Jan 19, 2021, 5:12:48 PM1/19/21
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Yuchen Liu, Ryan Keane.

View Change

4 comments:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

    • The rest of the codes are using microseconds, recommend keep consistency with others. […]

      +1. I would use microseconds or base::TimeDelta.

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 6
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Tue, 19 Jan 2021 22:12:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

Ryan Keane (Gerrit)

unread,
Jan 20, 2021, 7:20:49 PM1/20/21
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Alex Leung, Yuchen Liu.

Patch set 7:Commit-Queue +1

View Change

8 comments:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

    • Patch Set #6, Line 53: playback_time_in_seconds

      The rest of the codes are using microseconds, recommend keep consistency with others

    • Done. Updating to microseconds (over TimeDelta for consistency)

      Initially used seconds to avoid some of the weirdness that goes along with floating point math (the config gives us samples_per_second not millisecond), but in practice this shouldn't be a problem given we only need this class to be approximate, so readability can take priority

    • why not use number of buffers instead of time

    • It's tracked in time rather than buffer count to account for a SetConfig call to update the buffers per second. Per CmaBackendProxy, this must be supported.

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • // Helper to convert from Chromium callback type (OnceCallback) to Chromecast's
      // TaskRunner's Task type.
      class OnceCallbackTask : public TaskRunner::Task {
      public:
      OnceCallbackTask(base::OnceClosure callback)
      : callback_(std::move(callback)) {}

      ~OnceCallbackTask() override = default;

      private:
      // TaskRunner::Task overrides:
      void Run() override { std::move(callback_).Run(); }

      base::OnceClosure callback_;
      };

    • Yeah, this is duplicated. Was planning to ask where you suggested for the common code […]

      Will do this in a follow-up CL immediately after this one, so that discussions of where the code should go don't delay checking this one in - this CL is blocking a few others for me

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • Is this to handle overflow? If using uint64_t everywhere, it should be handled automatically.

    • The gRPC API requires a int64_t rather than a uint64_t, so this is the only place it's used. This was the cleanest way I could come up with to handle the overflow case.

    • Do you need a lock here? If this is supposed to be called from a single thread, add a thread checker […]

      Good catch! Added checker

      After thinking a bit, I think a sequence checker would be safer - Only one CmaBackendProxy will exist at a time, but there's no reason they would need to be created on the same thread for different instances

    • It is intentionally uint64_t here to allow for overflow without crashing

      Adding comment

    • Patch Set #6, Line 42: base::NoDestructor<BufferIdQueue> g_buffer_id_qeueue;

      I think we should have a new queue per stream / session.

    • The reason I use a singleton here is because all this class is responsible for is pulling out the next-available BufferId (It's not the queue that stores the playback time data). So with a singleton, one session will pick up where the last left off rather than restarting at zero.

      Because the other end of the gRPC does not care about the starting buffer id, this shouldn't have any downsides. But the benefit is it allows for simpler debugability. E.g if we cast twice and are logging the buffer ID (I am sure we will be during debugging) we won't need to guess as which session is associated with the PushBuffer call

      Alternatively:

      • We can have a per-session instance, but initialize it to start at a random uint64_t
      • We could add a "MultizoneSessionID" GUID (or similar) to each call. We wouldn't use it cast-core side except for logging purposes, but it would give a different way to differentiate different sessions

      WDYT?

    • Done. Had to add a ctor to the struct though which I find a bit sketchy - but agree it's probably worth it for the free performance improvement of emplace over push.

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 7
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Alex Leung <alex...@google.com>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Comment-Date: Thu, 21 Jan 2021 00:20:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Alex Leung <alex...@google.com>
Comment-In-Reply-To: Yuchen Liu <yuc...@chromium.org>
Comment-In-Reply-To: Ryan Keane <rwk...@google.com>
Gerrit-MessageType: comment

Alex Leung (Gerrit)

unread,
Jan 20, 2021, 7:27:56 PM1/20/21
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Yuchen Liu, Ryan Keane.

View Change

1 comment:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • Patch Set #6, Line 42: base::NoDestructor<BufferIdQueue> g_buffer_id_qeueue;

      The reason I use a singleton here is because all this class is responsible for is pulling out the ne […]

      The nice thing about having a per-session instance is that there would be a detectable gap in the buffer id's between the tracks. My sample implementation has it restarting at 0 each time and that's quite easy for debugging. Starting at zero is not necessary but does help avoid the wrapping scenario since a max int64_t of buffers is a "very long" time. That said, the server should correctly handle the wrapping scenario.

      If you do not want to start at zero, I think a random uint64_t should work. Although, enforcing that the first buffer sent after a Stop() command is 0 is also a nice way to sanity check that the state of server and client match.

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 7
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Thu, 21 Jan 2021 00:27:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alex Leung <alex...@google.com>

Ryan Keane (Gerrit)

unread,
Jan 20, 2021, 11:04:55 PM1/20/21
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Alex Leung, Yuchen Liu.

Patch set 8:Commit-Queue +1

View Change

1 comment:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • The nice thing about having a per-session instance is that there would be a detectable gap in the buffer id's between the tracks.

      I'm worried that there are bugs where this would be difficult to use - e.g. if we get 100 id=0 buffers in a row, that could be a bug in a lot of places and logging the buffer ID wouldn't actually help us find it at all (which IMHO is the main point of logs). Though I think your suggestion for a random buffer id should fix that.

    • Although, enforcing that the first buffer sent after a Stop() command is 0 is also a nice way to sanity check that the state of server and client match.

    • For this reason, I'm actually *against* starting at zero - this will be a public API, so we need to know that the server side will handle calls regardless of how the client chooses to start the PushBuffer ID.

      random uint64_t should work

      Done

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 8
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Alex Leung <alex...@google.com>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Comment-Date: Thu, 21 Jan 2021 04:04:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

Ryan Keane (Gerrit)

unread,
Jan 20, 2021, 11:12:24 PM1/20/21
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Alex Leung, Yuchen Liu.

Patch set 9:Commit-Queue +1

View Change

1 comment:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • Patch Set #6, Line 34: next_id_++;

      Good catch! Added checker […]

      After Alex's follow-up comment, I've moved it to the parent class as this class is now per-instance.

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 9
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Alex Leung <alex...@google.com>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Comment-Date: Thu, 21 Jan 2021 04:12:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Yuchen Liu <yuc...@chromium.org>

Ryan Keane (Gerrit)

unread,
Jan 22, 2021, 4:09:38 AM1/22/21
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Alex Leung, Yuchen Liu.

Patch set 10:Commit-Queue +1

View Change

1 comment:

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 10
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Alex Leung <alex...@google.com>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Comment-Date: Fri, 22 Jan 2021 09:09:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Alex Leung (Gerrit)

unread,
Jan 22, 2021, 4:06:50 PM1/22/21
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Yuchen Liu, Ryan Keane.

View Change

1 comment:

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 10
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Fri, 22 Jan 2021 21:06:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

Yuchen Liu (Gerrit)

unread,
Jan 22, 2021, 5:53:29 PM1/22/21
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Ryan Keane.

View Change

3 comments:

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 10
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Fri, 22 Jan 2021 22:53:13 +0000

Ryan Keane (Gerrit)

unread,
Jan 22, 2021, 6:32:45 PM1/22/21
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org

Attention is currently required from: Ryan Keane.

Ryan Keane uploaded patch set #12 to this change.

View Change

[Cast] Add BufferIdManager

This CL introduces the concept of a "BufferId", or a unique ID assigned
to each PushBuffer call. Additionally, it introduces the BufferIdManager
class, a utility class used to approximate these IDs at a given time.

This functionality is required for audio-audio sync as defined in:
go/cast-media-chromium-runtime

Bug: internal b/171495618

Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
---
M chromecast/media/cma/BUILD.gn
M chromecast/media/cma/backend/proxy/BUILD.gn
A chromecast/media/cma/backend/proxy/buffer_id_manager.cc
A chromecast/media/cma/backend/proxy/buffer_id_manager.h
A chromecast/media/cma/backend/proxy/buffer_id_manager_unittest.cc
5 files changed, 347 insertions(+), 0 deletions(-)

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 12
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-MessageType: newpatchset

Ryan Keane (Gerrit)

unread,
Jan 22, 2021, 6:33:52 PM1/22/21
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Yuchen Liu.

Patch set 12:Commit-Queue +1

View Change

4 comments:

  • Commit Message:

    • Done

  • Patchset:

    • Patch Set #12:

      Still investigating the weird UT failure - it passes when run locally

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • Done

    • It shouldn't be needed here. The BufferIdQueue is now just an instance variable inside BufferIdManager, and all public methods of the BufferIdQueue have a sequence checker

      Though I can change that to a thread checker if you prefer - just didn't see any reason for the extra restriction

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 12
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
Gerrit-Comment-Date: Fri, 22 Jan 2021 23:33:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

Yuchen Liu (Gerrit)

unread,
Jan 22, 2021, 6:35:37 PM1/22/21
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Ryan Keane.

Patch set 12:Code-Review +1

View Change

1 comment:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 12
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Fri, 22 Jan 2021 23:35:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Yuchen Liu <yuc...@chromium.org>

mark a. foltz (Gerrit)

unread,
Jan 22, 2021, 8:12:05 PM1/22/21
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Ryan Keane.

View Change

12 comments:

  • Patchset:

    • Patch Set #12:

      I had a few coding style comments - I didn't have time to dig into the algorithm in the design doc, sorry if that answers some of the questions below. I found it a little hard to follow the intention from the API documentation alone.

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

    • Patch Set #12, Line 24: // Tracks the Ids of buffers sent over the gRPC.

      Can you be a little more specific - which gRPC API is used, and which direction are the buffers sent

    • Patch Set #12, Line 33: // Sets the audio config to use for future buffer pushes.

      I'm not quite sure how this fits in with the Assign/Get APIs below. Does calling this increment the buffer ID?

    • Patch Set #12, Line 37: // be called prior to the first call to SetAudioConfig().

      This method is only called with a frame_size; how does this object know which buffer it applies to?

    • Patch Set #12, Line 42: // difference due to a slight mismatch.

      By "user" do you mean the end user, or the caller of this API?

    • Patch Set #12, Line 58: uint64_t next_id_;

      This is unsigned, while BufferIdManager::BufferId is signed. Are negative BufferIds ok?

    • Patch Set #12, Line 71: // allow for changes to the audio config part way through playback.

      Is this actually a duration? It sounds like it's measuring the intended duration to play out a certain number of buffers.

    • Patch Set #12, Line 82: void RepeatedlyPruneBufferInfos();

      Using a task is okay, but you could also prune when a new buffer is pushed onto the end of the queue. Since you are already pruning when buffer IDs are assigned, do you need the extra repeated task?

    • Patch Set #12, Line 87: // Number of bytes per second of media playback. This will change each time

      bytes per *microsecond*

      This is going to be well below 1.0 if the buffers have compressed media. 128 kpbs / 1000000 us = 0.016 bytes/us

      Not a big deal, just wanted to point it out.

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • Patch Set #12, Line 23: constexpr int kMicrosecondsPerSecond = 1000000;

      FWIW, this is also defined in base/time.h

    • Patch Set #12, Line 27: class OnceCallbackTask : public TaskRunner::Task {

      This looks copied from proxy_call_translator.cc. Please pull it out into a separate file so it's not duplicated.

    • Patch Set #12, Line 48: return static_cast<int64_t>(next_id_ & kBufferIdMask);

      So next_id_ will wrap around from 0x7FFFFFFF to 0x00000000... Is that OK?

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 12
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Sat, 23 Jan 2021 01:11:49 +0000

Ryan Keane (Gerrit)

unread,
Jan 27, 2021, 2:00:03 PM1/27/21
to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Yuchen Liu, mark a. foltz, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: mark a. foltz.

Patch set 13:Commit-Queue +1

View Change

11 comments:

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

    • Patch Set #12, Line 24: // Tracks the Ids of buffers sent over the gRPC.

      Can you be a little more specific - which gRPC API is used, and which direction are the buffers sent

    • Done. Extensively updated the documentation

      PTAL and let me know if this is clearer. Closing comment so please open a new one if not

    • I'm not quite sure how this fits in with the Assign/Get APIs below. […]

      Documentation updated

      This is to calculate the number of bytes per (micro)second that are played out.

    • Patch Set #12, Line 37: // be called prior to the first call to SetAudioConfig().

      This method is only called with a frame_size; how does this object know which buffer it applies to?

    • Documentation updated

      The trick here is that we don't actually need to know the frame it's associated with. We just need to know the ID of the currently playing frame (approximately). The other side of the gRPC is responsible for storing this association. So to calculate that, we just look at amount of time of pending data in the underlying decoder, and do some math with the number of bytes per second to calculate it

    • Patch Set #12, Line 42: // difference due to a slight mismatch.

      By "user" do you mean the end user, or the caller of this API?

    • Documentation updated

      This is referring to the end-user of the product using this runtime

    • This is unsigned, while BufferIdManager::BufferId is signed. […]

      Negative BufferIds are never expected / are invalid, but int64_t was chosen for the type of the ID on the gRPC. Not ideal, but its workable.

    • Is this actually a duration? It sounds like it's measuring the intended duration to play out a cert […]

      Documentation updated - this is a duration.

      A duration type should not be used here for consistency with other Cma code

    • Using a task is okay, but you could also prune when a new buffer is pushed onto the end of the queue […]

      Updated as suggested

      Good point. I was originally only pruning when we call GetCurrentlyProcessingBuffer(), which is relatively infrequent. But doing so on AssignBuffer too is cleaner and lets us remove the task.

    • bytes per *microsecond* […]

      +1. I originally coded it as per-second, but reviewers in previous iterations asked me to change to microseconds instead.

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.cc:

    • FWIW, this is also defined in base/time. […]

      Done. Good to know!

    • This looks copied from proxy_call_translator.cc. […]

      I mentioned in a previous comment, but I will do this as a follow-up CL to avoid blocking this CL on where-should-this-file-live discussions

      Though per your previous comment, I was able to remove the use of tasks entirely, so no longer needed

    • So next_id_ will wrap around from 0x7FFFFFFF to 0x00000000... […]

      Yes, this is intentional. Validated with @alexleung that the other side of the gRPC handles this correctly

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 13
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: mark a. foltz <mfo...@chromium.org>
Gerrit-Comment-Date: Wed, 27 Jan 2021 18:59:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: mark a. foltz <mfo...@chromium.org>
Gerrit-MessageType: comment

mark a. foltz (Gerrit)

unread,
Jan 28, 2021, 4:32:23 PM1/28/21
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Ryan Keane.

Patch set 14:Code-Review +1

View Change

10 comments:

  • Patchset:

    • Patch Set #14:

      Code looks good, a few requests to clarify documentation.

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

    • Patch Set #14, Line 23: // an increasing BufferId (with the exception of wrap-around of wrap-around of

      wrap-around is repeated

    • Patch Set #14, Line 25: // runtime and any playback on the other side of the gRPC Channel.

      I don't think Cast Core itself is responsible for playback "on the other side" of the gRPC channel. Maybe adjust the wording here?

    • Patch Set #14, Line 33: // of playback data currently pending in the AudioDecoder's internal queue.

      I wonder if the BufferIds could just be assigned by counting the total number of bytes that have been placed into PushBuffer calls - essentially a high water mark for the amount of data sent over gRPC.

      However, it sounds like it's important for the buffer IDs to be computed based on the pending duration of audio pushed into the AudioDecoder.

      FWIW, the design doc mostly talks about using PTS for A/A sync, and doesn't mention buffer IDs. Maybe I missed that section.

    • Patch Set #14, Line 44: BufferIdManager(CmaBackend::AudioDecoder* audio_decoder);

      Please document lifetime assumption of |audio_decoder|.

    • Patch Set #14, Line 55: // not be called prior to the first call to SetAudioConfig().

      Perhaps this class should take an initial audio config in its ctor. I don't feel strongly though - depends on the calling pattern.

    • Patch Set #14, Line 58: // Returns the APPROXIMATE BufferId which is currently being processed. Note

      Can you specify what is doing the processing?

    • Patch Set #14, Line 86: // The duration of time in microseconds of playback (as number of buffers of

      It sounds like this is computed across multiple buffers, but is only valid for this buffer. Can you clarify?

    • Patch Set #14, Line 87: // playback divided by number of buffer per second) for this buffer. This

      buffers per microsecond?

  • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

    • Patch Set #12, Line 58: uint64_t next_id_;

      Negative BufferIds are never expected / are invalid, but int64_t was chosen for the type of the ID o […]

      Can you mention the gRPC dependency in the documentation for BufferId? Otherwise it's not clear why there's a difference.

To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
Gerrit-Change-Number: 2580782
Gerrit-PatchSet: 14
Gerrit-Owner: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Alex Leung <alex...@google.com>
Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
Gerrit-Attention: Ryan Keane <rwk...@google.com>
Gerrit-Comment-Date: Thu, 28 Jan 2021 21:32:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Ryan Keane <rwk...@google.com>

Chromium LUCI CQ (Gerrit)

unread,
Jan 29, 2021, 3:14:04 AM1/29/21
to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Alex Leung, chromium...@chromium.org

CQ is trying the patch.

Note: The patchset #16 "Merge in Master" sent to CQ was uploaded after this CL was CR+1-ed.
Reviewer, please verify there is nothing unexpected https://chromium-review.googlesource.com/c/2580782/16

Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/chromium-review.googlesource.com/2580782/16

Bot data: {"action": "start", "triggered_at": "2021-01-29T08:13:54.0Z", "revision": "8a4f56c8e036f5bcc9bacc923328ebc95a45f18c"}

View Change

    To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: master
    Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
    Gerrit-Change-Number: 2580782
    Gerrit-PatchSet: 16
    Gerrit-Owner: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Alex Leung <alex...@google.com>
    Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
    Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
    Gerrit-Comment-Date: Fri, 29 Jan 2021 08:14:02 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Ryan Keane (Gerrit)

    unread,
    Jan 29, 2021, 3:14:05 AM1/29/21
    to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Alex Leung, Chromium LUCI CQ, chromium...@chromium.org

    Patch set 16:Commit-Queue +2

    View Change

    8 comments:

    • File chromecast/media/cma/backend/proxy/buffer_id_manager.h:

      • Patch Set #14, Line 23: // an increasing BufferId (with the exception of wrap-around of wrap-around of

        wrap-around is repeated

      • Done

      • I don't think Cast Core itself is responsible for playback "on the other side" of the gRPC channel. […]

        Done

      • I wonder if the BufferIds could just be assigned by counting the total number of bytes that have bee […]

        The doc is pretty out-of-date at this point. Though also the design seems to still be in-flux (e.g. we had some pretty big changes to the gRPC on Friday), so I think it's worth waiting to update it until later

        FWIW I chatted with Alex a while back and we decided this was the best option

      • Patch Set #14, Line 44: BufferIdManager(CmaBackend::AudioDecoder* audio_decoder);

        Please document lifetime assumption of |audio_decoder|.

      • Done

      • Perhaps this class should take an initial audio config in its ctor. […]

        The AudioConfig isn't set yet at the time of this object's creation - the CmaBackend::AudioDecoder that owns this object has a similar SetConfig() method called at runtime.

        We could do lazy initialization, but IMHO this is adding unneeded complexity - especially when we already need a SetConfig method to support updates to the config later in the object's lifetime.

      • Patch Set #14, Line 58: // Returns the APPROXIMATE BufferId which is currently being processed. Note

        Can you specify what is doing the processing?

      • Done

      • It sounds like this is computed across multiple buffers, but is only valid for this buffer. […]

        Done

      • Patch Set #14, Line 87: // playback divided by number of buffer per second) for this buffer. This

        buffers per microsecond?

      • Done

    To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: master
    Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
    Gerrit-Change-Number: 2580782
    Gerrit-PatchSet: 16
    Gerrit-Owner: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Alex Leung <alex...@google.com>
    Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
    Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
    Gerrit-Comment-Date: Fri, 29 Jan 2021 08:13:54 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes

    Chromium LUCI CQ (Gerrit)

    unread,
    Jan 29, 2021, 3:16:33 AM1/29/21
    to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Alex Leung, chromium...@chromium.org

    Chromium LUCI CQ submitted this change.

    View Change

    Approvals: mark a. foltz: Looks good to me Yuchen Liu: Looks good to me Ryan Keane: Commit
    [Cast] Add BufferIdManager

    This CL introduces the concept of a "BufferId", or a unique ID assigned
    to each PushBuffer call. Additionally, it introduces the BufferIdManager
    class, a utility class used to approximate these IDs at a given time.

    This functionality is required for audio-audio sync as defined in:
    go/cast-media-chromium-runtime

    Bug: internal b/171495618
    Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2580782
    Commit-Queue: Ryan Keane <rwk...@google.com>
    Reviewed-by: mark a. foltz <mfo...@chromium.org>
    Reviewed-by: Yuchen Liu <yuc...@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#848436}

    ---
    M chromecast/media/cma/BUILD.gn
    M chromecast/media/cma/backend/proxy/BUILD.gn
    A chromecast/media/cma/backend/proxy/buffer_id_manager.cc
    A chromecast/media/cma/backend/proxy/buffer_id_manager.h
    A chromecast/media/cma/backend/proxy/buffer_id_manager_unittest.cc
    5 files changed, 326 insertions(+), 0 deletions(-)


    To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: master
    Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
    Gerrit-Change-Number: 2580782
    Gerrit-PatchSet: 17
    Gerrit-Owner: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Alex Leung <alex...@google.com>
    Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
    Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
    Gerrit-MessageType: merged

    Findit (Gerrit)

    unread,
    Jan 29, 2021, 3:48:19 AM1/29/21
    to Chromium LUCI CQ, Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, mark a. foltz, Yuchen Liu, Alex Leung, chromium...@chromium.org

    Findit has created a revert of this change.

    View Change

    To view, visit change 2580782. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: master
    Gerrit-Change-Id: I3bec4b6d442bc86f22d78bf7ce155e2f65f7090c
    Gerrit-Change-Number: 2580782
    Gerrit-PatchSet: 17
    Gerrit-Owner: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Alex Leung <alex...@google.com>
    Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
    Gerrit-Reviewer: mark a. foltz <mfo...@chromium.org>
    Gerrit-MessageType: revert

    Ryan Keane (Gerrit)

    unread,
    Jan 29, 2021, 3:58:47 AM1/29/21
    to Yuchen Liu, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org

    Attention is currently required from: Yuchen Liu.

    Ryan Keane would like Yuchen Liu to review this change.

    View Change

    [Cast] Add BufferIdManager

    This CL introduces the concept of a "BufferId", or a unique ID assigned
    to each PushBuffer call. Additionally, it introduces the BufferIdManager
    class, a utility class used to approximate these IDs at a given time.

    This functionality is required for audio-audio sync as defined in:
    go/cast-media-chromium-runtime

    This CL un-reverts CL:
    https://chromium-review.googlesource.com/c/chromium/src/+/2580782
    The issue was that a buildbot runs the unit tests on a non-debug build,
    so a DCHECK doesn't fail the bot run.

    Bug: internal b/171495618
    Change-Id: Iaeb529f0a11ce57264e47e6e9ae4392bf9ad15b0

    ---
    M chromecast/media/cma/BUILD.gn
    M chromecast/media/cma/backend/proxy/BUILD.gn
    A chromecast/media/cma/backend/proxy/buffer_id_manager.cc
    A chromecast/media/cma/backend/proxy/buffer_id_manager.h
    A chromecast/media/cma/backend/proxy/buffer_id_manager_unittest.cc
    5 files changed, 322 insertions(+), 0 deletions(-)


    To view, visit change 2658378. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: master
    Gerrit-Change-Id: Iaeb529f0a11ce57264e47e6e9ae4392bf9ad15b0
    Gerrit-Change-Number: 2658378
    Gerrit-PatchSet: 1
    Gerrit-Owner: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
    Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
    Gerrit-MessageType: newchange

    Ryan Keane (Gerrit)

    unread,
    Jan 29, 2021, 3:58:56 AM1/29/21
    to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Yuchen Liu, chromium...@chromium.org

    Attention is currently required from: Yuchen Liu.

    Patch set 1:Commit-Queue +1

    View Change

    1 comment:

    • Patchset:

      • Patch Set #1:

        The previous change got reverted due to a buildbot running on a non-debug build. This CL should fix that

    To view, visit change 2658378. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: master
    Gerrit-Change-Id: Iaeb529f0a11ce57264e47e6e9ae4392bf9ad15b0
    Gerrit-Change-Number: 2658378
    Gerrit-PatchSet: 1
    Gerrit-Owner: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
    Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
    Gerrit-Attention: Yuchen Liu <yuc...@chromium.org>
    Gerrit-Comment-Date: Fri, 29 Jan 2021 08:58:43 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Yuchen Liu (Gerrit)

    unread,
    Feb 1, 2021, 2:31:46 PM2/1/21
    to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Chromium LUCI CQ, chromium...@chromium.org

    Attention is currently required from: Ryan Keane.

    Patch set 1:Code-Review +1

    View Change

      To view, visit change 2658378. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: chromium/src
      Gerrit-Branch: master
      Gerrit-Change-Id: Iaeb529f0a11ce57264e47e6e9ae4392bf9ad15b0
      Gerrit-Change-Number: 2658378
      Gerrit-PatchSet: 1
      Gerrit-Owner: Ryan Keane <rwk...@google.com>
      Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
      Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
      Gerrit-Attention: Ryan Keane <rwk...@google.com>
      Gerrit-Comment-Date: Mon, 01 Feb 2021 19:31:13 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      Gerrit-MessageType: comment

      Ryan Keane (Gerrit)

      unread,
      Feb 1, 2021, 2:32:27 PM2/1/21
      to alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Yuchen Liu, Chromium LUCI CQ, chromium...@chromium.org

      Attention is currently required from: Ryan Keane.

      Patch set 1:Commit-Queue +2

      View Change

        To view, visit change 2658378. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: chromium/src
        Gerrit-Branch: master
        Gerrit-Change-Id: Iaeb529f0a11ce57264e47e6e9ae4392bf9ad15b0
        Gerrit-Change-Number: 2658378
        Gerrit-PatchSet: 1
        Gerrit-Owner: Ryan Keane <rwk...@google.com>
        Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
        Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
        Gerrit-Attention: Ryan Keane <rwk...@google.com>
        Gerrit-Comment-Date: Mon, 01 Feb 2021 19:31:49 +0000

        Chromium LUCI CQ (Gerrit)

        unread,
        Feb 1, 2021, 2:59:54 PM2/1/21
        to Ryan Keane, alokp...@chromium.org, feature-me...@chromium.org, halliwe...@chromium.org, lcwu+...@chromium.org, Yuchen Liu, chromium...@chromium.org

        Chromium LUCI CQ submitted this change.

        View Change

        Approvals: Yuchen Liu: Looks good to me Ryan Keane: Commit
        [Cast] Add BufferIdManager

        This CL introduces the concept of a "BufferId", or a unique ID assigned
        to each PushBuffer call. Additionally, it introduces the BufferIdManager
        class, a utility class used to approximate these IDs at a given time.

        This functionality is required for audio-audio sync as defined in:
        go/cast-media-chromium-runtime

        This CL un-reverts CL:
        https://chromium-review.googlesource.com/c/chromium/src/+/2580782
        The issue was that a buildbot runs the unit tests on a non-debug build,
        so a DCHECK doesn't fail the bot run.

        Bug: internal b/171495618
        Change-Id: Iaeb529f0a11ce57264e47e6e9ae4392bf9ad15b0
        Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2658378
        Reviewed-by: Yuchen Liu <yuc...@chromium.org>
        Commit-Queue: Ryan Keane <rwk...@google.com>
        Cr-Commit-Position: refs/heads/master@{#849225}

        ---
        M chromecast/media/cma/BUILD.gn
        M chromecast/media/cma/backend/proxy/BUILD.gn
        A chromecast/media/cma/backend/proxy/buffer_id_manager.cc
        A chromecast/media/cma/backend/proxy/buffer_id_manager.h
        A chromecast/media/cma/backend/proxy/buffer_id_manager_unittest.cc
        5 files changed, 322 insertions(+), 0 deletions(-)


        To view, visit change 2658378. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: chromium/src
        Gerrit-Branch: master
        Gerrit-Change-Id: Iaeb529f0a11ce57264e47e6e9ae4392bf9ad15b0
        Gerrit-Change-Number: 2658378
        Gerrit-PatchSet: 2
        Gerrit-Owner: Ryan Keane <rwk...@google.com>
        Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Ryan Keane <rwk...@google.com>
        Gerrit-Reviewer: Yuchen Liu <yuc...@chromium.org>
        Gerrit-MessageType: merged
        Reply all
        Reply to author
        Forward
        0 new messages