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

Issue 1419013005: Hide ACMCodecDB::codec_settings_ behind an accessor (Closed)

Created:
5 years, 1 month ago by kwiberg-webrtc
Modified:
5 years, 1 month ago
Reviewers:
tommi, hlundin-webrtc
CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com, hlundin-webrtc, peah-webrtc, kwiberg-webrtc, tlegrand-webrtc, the sun
Base URL:
https://chromium.googlesource.com/external/webrtc.git@master
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

Hide ACMCodecDB::codec_settings_ behind an accessor BUG=webrtc:5028 Committed: https://crrev.com/de94d08d57820fb1b67a31354e867a26aebb17d3 Cr-Commit-Position: refs/heads/master@{#10494}

Patch Set 1 : #

Total comments: 3

Patch Set 2 : ICanHasNumChannels? #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+20 lines, -3 lines) Patch
M webrtc/modules/audio_coding/main/acm2/acm_codec_database.h View 1 chunk +1 line, -1 line 0 comments Download
M webrtc/modules/audio_coding/main/acm2/codec_manager.cc View 1 1 chunk +8 lines, -2 lines 3 comments Download
M webrtc/modules/audio_coding/main/acm2/rent_a_codec.h View 1 1 chunk +3 lines, -0 lines 0 comments Download
M webrtc/modules/audio_coding/main/acm2/rent_a_codec.cc View 1 1 chunk +8 lines, -0 lines 0 comments Download

Messages

Total messages: 17 (7 generated)
kwiberg-webrtc
PTAL
5 years, 1 month ago (2015-11-02 07:11:38 UTC) #4
hlundin-webrtc
LGTM with a comment. https://codereview.webrtc.org/1419013005/diff/20001/webrtc/modules/audio_coding/main/acm2/codec_manager.cc File webrtc/modules/audio_coding/main/acm2/codec_manager.cc (right): https://codereview.webrtc.org/1419013005/diff/20001/webrtc/modules/audio_coding/main/acm2/codec_manager.cc#newcode68 webrtc/modules/audio_coding/main/acm2/codec_manager.cc:68: return cid ? RentACodec::SupportedNumChannels(*cid, send_codec.channels) ...
5 years, 1 month ago (2015-11-03 08:48:56 UTC) #5
kwiberg-webrtc
https://codereview.webrtc.org/1419013005/diff/20001/webrtc/modules/audio_coding/main/acm2/codec_manager.cc File webrtc/modules/audio_coding/main/acm2/codec_manager.cc (right): https://codereview.webrtc.org/1419013005/diff/20001/webrtc/modules/audio_coding/main/acm2/codec_manager.cc#newcode68 webrtc/modules/audio_coding/main/acm2/codec_manager.cc:68: return cid ? RentACodec::SupportedNumChannels(*cid, send_codec.channels) On 2015/11/03 08:48:55, hlundin-webrtc ...
5 years, 1 month ago (2015-11-03 09:32:03 UTC) #6
hlundin-webrtc
https://codereview.webrtc.org/1419013005/diff/20001/webrtc/modules/audio_coding/main/acm2/codec_manager.cc File webrtc/modules/audio_coding/main/acm2/codec_manager.cc (right): https://codereview.webrtc.org/1419013005/diff/20001/webrtc/modules/audio_coding/main/acm2/codec_manager.cc#newcode68 webrtc/modules/audio_coding/main/acm2/codec_manager.cc:68: return cid ? RentACodec::SupportedNumChannels(*cid, send_codec.channels) On 2015/11/03 09:32:03, kwiberg-webrtc ...
5 years, 1 month ago (2015-11-03 10:00:47 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1419013005/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1419013005/40001
5 years, 1 month ago (2015-11-03 12:53:12 UTC) #11
commit-bot: I haz the power
Committed patchset #2 (id:40001)
5 years, 1 month ago (2015-11-03 13:46:14 UTC) #12
commit-bot: I haz the power
Patchset 2 (id:??) landed as https://crrev.com/de94d08d57820fb1b67a31354e867a26aebb17d3 Cr-Commit-Position: refs/heads/master@{#10494}
5 years, 1 month ago (2015-11-03 13:46:25 UTC) #13
tommi
https://codereview.webrtc.org/1419013005/diff/40001/webrtc/modules/audio_coding/main/acm2/codec_manager.cc File webrtc/modules/audio_coding/main/acm2/codec_manager.cc (right): https://codereview.webrtc.org/1419013005/diff/40001/webrtc/modules/audio_coding/main/acm2/codec_manager.cc#newcode73 webrtc/modules/audio_coding/main/acm2/codec_manager.cc:73: if (!*supported_num_channels) { Are these 8 lines, basically doing ...
5 years, 1 month ago (2015-11-03 14:20:19 UTC) #15
kwiberg-webrtc
https://codereview.webrtc.org/1419013005/diff/40001/webrtc/modules/audio_coding/main/acm2/codec_manager.cc File webrtc/modules/audio_coding/main/acm2/codec_manager.cc (right): https://codereview.webrtc.org/1419013005/diff/40001/webrtc/modules/audio_coding/main/acm2/codec_manager.cc#newcode73 webrtc/modules/audio_coding/main/acm2/codec_manager.cc:73: if (!*supported_num_channels) { On 2015/11/03 14:20:19, tommi (webrtc) wrote: ...
5 years, 1 month ago (2015-11-03 15:13:27 UTC) #16
tommi
5 years, 1 month ago (2015-11-03 16:50:01 UTC) #17
Message was sent while issue was closed.
https://codereview.webrtc.org/1419013005/diff/40001/webrtc/modules/audio_codi...
File webrtc/modules/audio_coding/main/acm2/codec_manager.cc (right):

https://codereview.webrtc.org/1419013005/diff/40001/webrtc/modules/audio_codi...
webrtc/modules/audio_coding/main/acm2/codec_manager.cc:73: if
(!*supported_num_channels) {
On 2015/11/03 15:13:27, kwiberg-webrtc wrote:
> On 2015/11/03 14:20:19, tommi (webrtc) wrote:
> > Are these 8 lines, basically doing the same as the below 4 lines?
> >
> >   auto cid = RentACodec::CodecIdFromIndex(codec_id);
> >   if (!cid)
> >     return -1;
> >   if (!RentACodec::IsSupportedNumChannels(*cid, send_codec.channels)) {
> >
> > If so, then I don't think that's really a good reason for using
> > lambdas and/or rtc::Maybe. As is, the code is a lot harder to read
> > then the above 4 lines.
> 
> Almost. Without the lambda, it looks like this if I'm not mistaken:
> 
>   auto cid = RentACodec::CodecIdFromIndex(codec_id);
>   if (!cid)
>     return -1;
>   auto supported_num_channels = RentACodec::IsSupportedNumChannels(
>                                     *cid, send_codec.channels);
>   if (!supported_num_channels)
>     return -1;
>   if (!*supported_num_channels) {
> 
> But one may be tempted to argue that it's not worth distinguishing
> between the cases where we fail because the codec_id is invalid and
> the one where the requested number of channels wasn't supported. In
> that case, something like this ought to work:
> 
>   auto cid = RentACodec::CodecIdFromIndex(codec_id);
>   if (!cid || !RentACodec::IsSupportedNumChannels(
>                   *cid, send_codec.channels).value_or(false)) {
> 
> Note how this conflates three error sources: CodecIdFromIndex failing,
> IsSupportedNumChannels failing, and IsSupportedNumChannels returning
> false.
> 
> (The seemingly excessive number of calls that can fail here is the
> result of an in-progress refactoring. This is what it looks like after
> I've used Maybe to expose all the places where things could possibly
> go wrong, but before I've done anything about it.)
> 
> > As is, the reader needs to know about operator overloading in
> > rtc::Maybe
> 
> That's true anyway, since we call functions that return Maybe.

Somehow I missed that |auto| was rtc::Maybe too.  So, we are creating one
temporary rtc::Maybe and returning another inside the lambda. Should the
variable name have been maybe_cid?  I ask since it's not guaranteed to be a cid.
 This is a nit, but I think it would improve readability.  (Fine to disregard
since the CL is already committed)

> > as well as figure out why we need a lambda when there's nothing
> > async or callback-ish going on.
> 
> To limit the scope of cid. I could possibly be made to admit that
> avoiding leaking cid into the surrounding scope might not be worth the
> extra complexity of the lambda here.
> 
> > I'm also a little on the fence about the point at which the lambda
> > gets evaluated and how that is clear from the code.
> 
> That's easy: it's evaluated by the parenthesis pair on line 70,
> without ever being bound to a name. Only its return value is bound.
> Think of it as a way to return a value out of a block. (It looks a lot
> prettier if you allow default captures for lambdas that can't escape
> the scope in which they're defined, which the Chromium style guide
> still doesn't.)

Ah sorry, I did notice that actually the first time I glanced over the code, but
the second time I must have read }(); as }; and then was wondering if the
evaluation could actually occur inside the overloaded operators.

Powered by Google App Engine
This is Rietveld 408576698