AudioFormat: add method WithMask(), shortcut for ApplyMask()

This commit is contained in:
Max Kellermann 2016-12-13 20:55:48 +01:00
parent 8cb160b1f8
commit 6c818bb37a
4 changed files with 11 additions and 6 deletions

View File

@ -159,6 +159,13 @@ struct AudioFormat {
void ApplyMask(AudioFormat mask);
gcc_pure
AudioFormat WithMask(AudioFormat mask) const {
AudioFormat result = *this;
result.ApplyMask(mask);
return result;
}
/**
* Returns the size of each (mono) sample in bytes.
*/

View File

@ -64,8 +64,7 @@ DecoderControl::SetReady(const AudioFormat audio_format,
assert(audio_format.IsValid());
in_audio_format = audio_format;
out_audio_format = audio_format;
out_audio_format.ApplyMask(configured_audio_format);
out_audio_format = audio_format.WithMask(configured_audio_format);
seekable = _seekable;
total_time = _duration;

View File

@ -159,8 +159,7 @@ AudioOutput::Open()
assert(filter_audio_format.IsValid());
out_audio_format = filter_audio_format;
out_audio_format.ApplyMask(config_audio_format);
out_audio_format = filter_audio_format.WithMask(config_audio_format);
mutex.unlock();

View File

@ -49,8 +49,8 @@ try {
const auto in_audio_format = ParseAudioFormat(argv[1], false);
const auto out_audio_format_mask = ParseAudioFormat(argv[2], false);
auto out_audio_format = in_audio_format;
out_audio_format.ApplyMask(out_audio_format_mask);
const auto out_audio_format =
in_audio_format.WithMask(out_audio_format_mask);
const size_t in_frame_size = in_audio_format.GetFrameSize();