Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a3c0758 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Convert mask types from uint32_t to enum type

This applies to the following types:

- audio_gain_mode_t;
- audio_flags_mask_t;
- audio_channel_representation_t;
- audio_channel_mask_t;
- audio_devices_t.

Enum types are distinct thus proper overloading on the type
is possible in C++. Also, assignments to enum types are
less prone to errors.

Bug: 169889714
Test: basic audio functionality
Tag: #refactor
Change-Id: I7b064b282ce9f533f91ef13a4852b3e9f308f6c0
parent 3896bdd9
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ struct a2dp_audio_device {

struct a2dp_config {
  uint32_t rate;
  uint32_t channel_mask;
  audio_channel_mask_t channel_mask;
  bool is_stereo_to_mono;  // True if fetching Stereo and mixing into Mono
  int format;
};
@@ -1115,12 +1115,13 @@ size_t audio_a2dp_hw_stream_compute_buffer_size(
  return buffer_sz;
}

static uint32_t out_get_channels(const struct audio_stream* stream) {
static audio_channel_mask_t out_get_channels(
    const struct audio_stream* stream) {
  struct a2dp_stream_out* out = (struct a2dp_stream_out*)stream;

  DEBUG("channels 0x%" PRIx32, out->common.cfg.channel_mask);

  return out->common.cfg.channel_mask;
  return (audio_channel_mask_t)out->common.cfg.channel_mask;
}

static audio_format_t out_get_format(const struct audio_stream* stream) {
@@ -1439,11 +1440,11 @@ static size_t in_get_buffer_size(
  return 320;
}

static uint32_t in_get_channels(const struct audio_stream* stream) {
static audio_channel_mask_t in_get_channels(const struct audio_stream* stream) {
  struct a2dp_stream_in* in = (struct a2dp_stream_in*)stream;

  FNLOG();
  return in->common.cfg.channel_mask;
  return (audio_channel_mask_t)in->common.cfg.channel_mask;
}

static audio_format_t in_get_format(
+5 −4
Original line number Diff line number Diff line
@@ -1076,12 +1076,13 @@ size_t audio_ha_hw_stream_compute_buffer_size(
  return buffer_sz;
}

static uint32_t out_get_channels(const struct audio_stream* stream) {
static audio_channel_mask_t out_get_channels(
    const struct audio_stream* stream) {
  struct ha_stream_out* out = (struct ha_stream_out*)stream;

  DEBUG("channels 0x%" PRIx32, out->common.cfg.channel_mask);

  return out->common.cfg.channel_mask;
  return (audio_channel_mask_t)out->common.cfg.channel_mask;
}

static audio_format_t out_get_format(const struct audio_stream* stream) {
@@ -1381,11 +1382,11 @@ static size_t in_get_buffer_size(
  return 320;
}

static uint32_t in_get_channels(const struct audio_stream* stream) {
static audio_channel_mask_t in_get_channels(const struct audio_stream* stream) {
  struct ha_stream_in* in = (struct ha_stream_in*)stream;

  FNLOG();
  return in->common.cfg.channel_mask;
  return (audio_channel_mask_t)in->common.cfg.channel_mask;
}

static audio_format_t in_get_format(