Closed Bug 1276570 Opened 8 years ago Closed 8 years ago

Split MediaDecoderReader::TargetQueues into bit-field flags

Categories

(Core :: Audio/Video: Playback, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: u480271, Assigned: u480271)

References

Details

Attachments

(1 file)

Change VIDEO_ONLY and AUDIO_VIDEO into "or"-able bit-fields.
From review comments to bug 1276495:

I would prefer bit flags like:
enum TargetQueues {
  VIDEO = 0x1,
  AUDIO = 0x2
};

and code like:
if (flag & MediaDecoderReader::VIDEO) {
  // do something about video
}
if (flag & MediaDecoderReader::AUDIO) {
  // do something about audio
}
Assignee: nobody → dglastonbury
Status: NEW → ASSIGNED
(In reply to Dan Glastonbury :kamidphish from comment #1)
> From review comments to bug 1276495:
> 
> I would prefer bit flags like:
> enum TargetQueues {
>   VIDEO = 0x1,
>   AUDIO = 0x2
> };

For more type safety:

EnumSet<TargetQueues> flags;

if (flag.contains(MediaDecoderReader::VIDEO)) {
  // do something about video
}
if (flag.contains(MediaDecoderReader::AUDIO)) {
  // do something about audio
}
Comment on attachment 8758552 [details]
Bug 1276570: Replace TargetQueues enum with bitwise-or flags.

https://reviewboard.mozilla.org/r/56800/#review53518

::: dom/media/MediaDecoderReader.cpp:135
(Diff revision 1)
>  size_t MediaDecoderReader::SizeOfAudioQueueInFrames()
>  {
>    return mAudioQueue.GetSize();
>  }
>  
> -nsresult MediaDecoderReader::ResetDecode(TargetQueues aQueues /*= AUDIO_VIDEO*/)
> +nsresult MediaDecoderReader::ResetDecode(uint32_t aQueues)

Why changing the type from TargetQueues to uint32_t?
Attachment #8758552 - Flags: review?(jwwang)
Please use EnumSet to provide type safety.
Comment on attachment 8758552 [details]
Bug 1276570: Replace TargetQueues enum with bitwise-or flags.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/56800/diff/1-2/
Attachment #8758552 - Attachment description: MozReview Request: Bug 1276570: Replace TargetQueues enum with bitwise-or flags. r?jwwang → Bug 1276570: Replace TargetQueues enum with bitwise-or flags.
Attachment #8758552 - Flags: review?(jwwang)
https://reviewboard.mozilla.org/r/56800/#review53518

> Why changing the type from TargetQueues to uint32_t?

Because you can't assign TargetQueues::AUDIO | TargetQueues::VIDEO to TargetQueues.
(In reply to JW Wang [:jwwang] from comment #5)
> Please use EnumSet to provide type safety.

JW, I switched to using EnumSet. I spoke with jya and decided to change the name too.

Instead of introducing yet-another-enum for specifying audio or video, I've made an EnumSet from TrackInfo::TrackType. Consequently, I've changed TargetQueues to be TrackSet, representing the set of tracks to be reset.
Attachment #8758552 - Flags: review?(jwwang) → review+
Comment on attachment 8758552 [details]
Bug 1276570: Replace TargetQueues enum with bitwise-or flags.

https://reviewboard.mozilla.org/r/56800/#review54272

::: dom/media/MediaDecoderStateMachine.cpp:2392
(Diff revision 2)
> -  mVideoCompleted = false;
> +    mVideoCompleted = false;
> -  VideoQueue().Reset();
> +    VideoQueue().Reset();
> +  }
>  
> -  if (aQueues == MediaDecoderReader::AUDIO_VIDEO) {
> +  if (aTracks.contains(TrackInfo::kAudioTrack)) {
>      // Stop the audio thread. Otherwise, MediaSink might be accessing AudioQueue

Assert aTracks.contains(TrackInfo::kVideoTrack) in this if statement because we don't support reset audio only for now.
Comment on attachment 8758552 [details]
Bug 1276570: Replace TargetQueues enum with bitwise-or flags.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/56800/diff/2-3/
Pushed by dglastonbury@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/09e6e28c8197
Replace TargetQueues enum with bitwise-or flags. r=jwwang
https://hg.mozilla.org/mozilla-central/rev/09e6e28c8197
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: