title: How to toggle closed captions in Leanback ExoPlayer?
body: <p>I am developing an Android app for TV using the <code>Leanback</code> library. I have an <code>HLS</code> video stream with an <code>srt</code> subtitle from a URI. I am using <code>ExoPlayer</code> version <code>2.5.4</code> as used in this <a href="https://github.com/googlesamples/leanback-showcase/blob/master/app/src/main/java/android/support/v17/leanback/supportleanbackshowcase/app/media/VideoConsumptionExampleWithExoPlayerFragment.java" rel="nofollow noreferrer">example app</a>. I created my <code>MediaSource</code> using:</p>
  
  <pre><code>private MediaSource onCreateMediaSource(Uri uri, Uri subtitleUri) {
      String userAgent = Util.getUserAgent(mContext, "ExoPlayerAdapter");
      MediaSource videoSource = new HlsMediaSource(uri,
              new DefaultDataSourceFactory(mContext, userAgent),
              null,
              null);
      Format subtitleFormat = Format.createTextSampleFormat(
              "1", MimeTypes.APPLICATION_SUBRIP, 0, "en");
      MediaSource subtitleSource = new SingleSampleMediaSource(
              subtitleUri,
              new DefaultDataSourceFactory(mContext, userAgent),
              subtitleFormat, C.TIME_UNSET);
  
      MergingMediaSource mergedSource =
              new MergingMediaSource(videoSource, subtitleSource);
      return mergedSource;
  }
  </code></pre>
  
  <p>In my <code>PlaybackTransportControlGlue</code>, I have a <code>PlaybackControlsRow.ClosedCaptioningAction</code>. When this button is clicked, what do I write in the action dispatcher to toggle the closed captions?</p>
  
  <p>I tried this:</p>
  
  <pre><code>@Override
  public void onActionClicked(Action action) {
      if (action == mClosedCaptioningAction) {
          DefaultTrackSelector trackSelector = mAdapter.getTrackSelector();
          int rendererIndex = 0;
          if (mClosedCaptioningAction.getIndex() == PlaybackControlsRow.ClosedCaptioningAction.INDEX_ON) {
              MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
              TrackGroupArray textGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
              int groupIndex = 0;
  
              trackSelector.setRendererDisabled(rendererIndex, false);
              MappingTrackSelector.SelectionOverride override =
                      new MappingTrackSelector.SelectionOverride(mTrackFactory, groupIndex, 0);
              trackSelector.setSelectionOverride(rendererIndex, textGroups, override);
          } else {
              trackSelector.setRendererDisabled(rendererIndex, true);
              trackSelector.clearSelectionOverrides();
          }
      }
      super.onActionClicked(action);
  }
  </code></pre>
  
  <p>I got this error:</p>
  
  <pre><code>E/gralloc: unregister FBM buffer
  </code></pre>