adhd: Replace the use of master_dev to main_dev

Ableist language like master should be removed.
Replace the use of master_dev to main_dev.

BUG=b:167649426
TEST=Built and run CRAS successfully.

Change-Id: I78924e49c624540969bcac87f20bff2ce53253af
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2739023
Reviewed-by: En-Shuo Hsu <enshuo@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Commit-Queue: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Tested-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
diff --git a/cras/src/server/cras_rstream.c b/cras/src/server/cras_rstream.c
index 5ff33a5..3c0a0ce 100644
--- a/cras/src/server/cras_rstream.c
+++ b/cras/src/server/cras_rstream.c
@@ -292,8 +292,8 @@
 	stream->cb_threshold = config->cb_threshold;
 	stream->client = config->client;
 	stream->shm = NULL;
-	stream->master_dev.dev_id = NO_DEVICE;
-	stream->master_dev.dev_ptr = NULL;
+	stream->main_dev.dev_id = NO_DEVICE;
+	stream->main_dev.dev_ptr = NULL;
 	stream->num_missed_cb = 0;
 	stream->is_pinned = (config->dev_idx != NO_DEVICE);
 	stream->pinned_dev_idx = config->dev_idx;
@@ -431,12 +431,12 @@
 	if (buffer_share_add_id(rstream->buf_state, dev_id, dev_ptr) == 0)
 		rstream->num_attached_devs++;
 
-	/* TODO(hychao): Handle master device assignment for complicated
+	/* TODO(hychao): Handle main device assignment for complicated
 	 * routing case.
 	 */
-	if (rstream->master_dev.dev_id == NO_DEVICE) {
-		rstream->master_dev.dev_id = dev_id;
-		rstream->master_dev.dev_ptr = dev_ptr;
+	if (rstream->main_dev.dev_id == NO_DEVICE) {
+		rstream->main_dev.dev_id = dev_id;
+		rstream->main_dev.dev_ptr = dev_ptr;
 	}
 }
 
@@ -445,18 +445,18 @@
 	if (buffer_share_rm_id(rstream->buf_state, dev_id) == 0)
 		rstream->num_attached_devs--;
 
-	if (rstream->master_dev.dev_id == dev_id) {
+	if (rstream->main_dev.dev_id == dev_id) {
 		int i;
 		struct id_offset *o;
 
-		/* Choose the first device id as master. */
-		rstream->master_dev.dev_id = NO_DEVICE;
-		rstream->master_dev.dev_ptr = NULL;
+		/* Choose the first device id as a main device. */
+		rstream->main_dev.dev_id = NO_DEVICE;
+		rstream->main_dev.dev_ptr = NULL;
 		for (i = 0; i < rstream->buf_state->id_sz; i++) {
 			o = &rstream->buf_state->wr_idx[i];
 			if (o->used) {
-				rstream->master_dev.dev_id = o->id;
-				rstream->master_dev.dev_ptr = o->data;
+				rstream->main_dev.dev_id = o->id;
+				rstream->main_dev.dev_ptr = o->data;
 				break;
 			}
 		}
diff --git a/cras/src/server/cras_rstream.h b/cras/src/server/cras_rstream.h
index 3bf7df0..d57c13b 100644
--- a/cras/src/server/cras_rstream.h
+++ b/cras/src/server/cras_rstream.h
@@ -20,12 +20,12 @@
 struct cras_rclient;
 struct dev_mix;
 
-/* Holds informations about the master active device.
+/* Holds informations about the main active device.
  * Members:
- *    dev_id - id of the master device.
- *    dev_ptr - pointer to the master device.
+ *    dev_id - id of the main device.
+ *    dev_ptr - pointer to the main device.
  */
-struct master_dev_info {
+struct main_dev_info {
 	int dev_id;
 	void *dev_ptr;
 };
@@ -42,7 +42,7 @@
  *    fd - Socket for requesting and sending audio buffer events.
  *    buffer_frames - Buffer size in frames.
  *    cb_threshold - Callback client when this much is left.
- *    master_dev_info - The info of the master device this stream attaches to.
+ *    main_dev_info - The info of the main device this stream attaches to.
  *    is_draining - The stream is draining and waiting to be removed.
  *    client - The client who uses this stream.
  *    shm - shared memory
@@ -74,7 +74,7 @@
 	size_t buffer_frames;
 	size_t cb_threshold;
 	int is_draining;
-	struct master_dev_info master_dev;
+	struct main_dev_info main_dev;
 	struct cras_rclient *client;
 	struct cras_audio_shm *shm;
 	struct cras_audio_area *audio_area;
diff --git a/cras/src/server/dev_io.c b/cras/src/server/dev_io.c
index ddaaeb2..b311b22 100644
--- a/cras/src/server/dev_io.c
+++ b/cras/src/server/dev_io.c
@@ -54,10 +54,10 @@
 /* The gap time to avoid repeated error close request to main thread. */
 static const int ERROR_CLOSE_GAP_TIME_SECS = 10;
 
-/* Gets the master device which the stream is attached to. */
-static inline struct cras_iodev *get_master_dev(const struct dev_stream *stream)
+/* Gets the main device which the stream is attached to. */
+static inline struct cras_iodev *get_main_dev(const struct dev_stream *stream)
 {
-	return (struct cras_iodev *)stream->stream->master_dev.dev_ptr;
+	return (struct cras_iodev *)stream->stream->main_dev.dev_ptr;
 }
 
 /* Updates the estimated sample rate of open device to all attached
@@ -67,12 +67,12 @@
 				  struct open_dev *odev_list,
 				  bool self_rate_need_update)
 {
-	struct cras_iodev *master_dev;
+	struct cras_iodev *main_dev;
 	struct cras_iodev *dev = adev->dev;
 	struct cras_iodev *tracked_dev = NULL;
 	struct dev_stream *dev_stream;
 	double dev_rate_ratio;
-	double master_dev_rate_ratio;
+	double main_dev_rate_ratio;
 
 	/*
 	 * If there is an output device on the same sound card running with the same
@@ -101,24 +101,24 @@
 		return;
 
 	DL_FOREACH (dev->streams, dev_stream) {
-		master_dev = get_master_dev(dev_stream);
-		if (master_dev == NULL) {
-			syslog(LOG_ERR, "Fail to find master open dev.");
+		main_dev = get_main_dev(dev_stream);
+		if (main_dev == NULL) {
+			syslog(LOG_ERR, "Fail to find main open dev.");
 			continue;
 		}
 
 		if (tracked_dev) {
 			dev_rate_ratio =
 				cras_iodev_get_est_rate_ratio(tracked_dev);
-			master_dev_rate_ratio = dev_rate_ratio;
+			main_dev_rate_ratio = dev_rate_ratio;
 		} else {
 			dev_rate_ratio = cras_iodev_get_est_rate_ratio(dev);
-			master_dev_rate_ratio =
-				cras_iodev_get_est_rate_ratio(master_dev);
+			main_dev_rate_ratio =
+				cras_iodev_get_est_rate_ratio(main_dev);
 		}
 
 		dev_stream_set_dev_rate(dev_stream, dev->format->frame_rate,
-					dev_rate_ratio, master_dev_rate_ratio,
+					dev_rate_ratio, main_dev_rate_ratio,
 					adev->coarse_rate_adjust);
 	}
 }
diff --git a/cras/src/server/dev_stream.c b/cras/src/server/dev_stream.c
index 2473b1a..be5a6da 100644
--- a/cras/src/server/dev_stream.c
+++ b/cras/src/server/dev_stream.c
@@ -157,9 +157,9 @@
 
 void dev_stream_set_dev_rate(struct dev_stream *dev_stream,
 			     unsigned int dev_rate, double dev_rate_ratio,
-			     double master_rate_ratio, int coarse_rate_adjust)
+			     double main_rate_ratio, int coarse_rate_adjust)
 {
-	if (dev_stream->dev_id == dev_stream->stream->master_dev.dev_id) {
+	if (dev_stream->dev_id == dev_stream->stream->main_dev.dev_id) {
 		cras_fmt_conv_set_linear_resample_rates(dev_stream->conv,
 							dev_rate, dev_rate);
 		cras_frames_to_time_precise(
@@ -167,9 +167,8 @@
 			dev_stream->stream->format.frame_rate * dev_rate_ratio,
 			&dev_stream->stream->sleep_interval_ts);
 	} else {
-		double new_rate =
-			dev_rate * dev_rate_ratio / master_rate_ratio +
-			coarse_rate_adjust_step * coarse_rate_adjust;
+		double new_rate = dev_rate * dev_rate_ratio / main_rate_ratio +
+				  coarse_rate_adjust_step * coarse_rate_adjust;
 		cras_fmt_conv_set_linear_resample_rates(dev_stream->conv,
 							dev_rate, new_rate);
 	}
diff --git a/cras/src/server/dev_stream.h b/cras/src/server/dev_stream.h
index a424751..6b34d5d 100644
--- a/cras/src/server/dev_stream.h
+++ b/cras/src/server/dev_stream.h
@@ -72,21 +72,21 @@
 /*
  * Update the estimated sample rate of the device. For multiple active
  * devices case, the linear resampler will be configured by the estimated
- * rate ration of the master device and the current active device the
+ * rate ration of the main device and the current active device the
  * rstream attaches to.
  *
  * Args:
  *    dev_stream - The structure holding the stream.
  *    dev_rate - The sample rate device is using.
  *    dev_rate_ratio - The ratio of estimated rate and used rate.
- *    master_rate_ratio - The ratio of estimated rate and used rate of
- *        master device.
+ *    main_rate_ratio - The ratio of estimated rate and used rate of
+ *        main device.
  *    coarse_rate_adjust - The flag to indicate the direction device
  *        sample rate should adjust to.
  */
 void dev_stream_set_dev_rate(struct dev_stream *dev_stream,
 			     unsigned int dev_rate, double dev_rate_ratio,
-			     double master_rate_ratio, int coarse_rate_adjust);
+			     double main_rate_ratio, int coarse_rate_adjust);
 
 /*
  * Renders count frames from shm into dst.  Updates count if anything is
diff --git a/cras/src/tests/audio_thread_unittest.cc b/cras/src/tests/audio_thread_unittest.cc
index 34d8347..93045e0 100644
--- a/cras/src/tests/audio_thread_unittest.cc
+++ b/cras/src/tests/audio_thread_unittest.cc
@@ -1271,7 +1271,7 @@
 void dev_stream_set_dev_rate(struct dev_stream* dev_stream,
                              unsigned int dev_rate,
                              double dev_rate_ratio,
-                             double master_rate_ratio,
+                             double main_rate_ratio,
                              int coarse_rate_adjust) {}
 
 void dev_stream_update_frames(const struct dev_stream* dev_stream) {}
diff --git a/cras/src/tests/dev_io_stubs.cc b/cras/src/tests/dev_io_stubs.cc
index 805fae3..d97dde5 100644
--- a/cras/src/tests/dev_io_stubs.cc
+++ b/cras/src/tests/dev_io_stubs.cc
@@ -152,9 +152,9 @@
   dev->largest_cb_level = std::max(stream->rstream->cb_threshold,
                                    static_cast<size_t>(dev->max_cb_level));
 
-  if (stream->rstream->master_dev.dev_id == NO_DEVICE) {
-    stream->rstream->master_dev.dev_id = dev->info.idx;
-    stream->rstream->master_dev.dev_ptr = dev.get();
+  if (stream->rstream->main_dev.dev_id == NO_DEVICE) {
+    stream->rstream->main_dev.dev_id = dev->info.idx;
+    stream->rstream->main_dev.dev_ptr = dev.get();
   }
 }
 
diff --git a/cras/src/tests/dev_io_unittest.cc b/cras/src/tests/dev_io_unittest.cc
index 69a8096..2dbf344 100644
--- a/cras/src/tests/dev_io_unittest.cc
+++ b/cras/src/tests/dev_io_unittest.cc
@@ -33,7 +33,7 @@
 struct set_dev_rate_data {
   unsigned int dev_rate;
   double dev_rate_ratio;
-  double master_rate_ratio;
+  double main_rate_ratio;
   int coarse_rate_adjust;
 };
 std::unordered_map<struct dev_stream*, set_dev_rate_data> set_dev_rate_map;
@@ -402,12 +402,12 @@
 void dev_stream_set_dev_rate(struct dev_stream* dev_stream,
                              unsigned int dev_rate,
                              double dev_rate_ratio,
-                             double master_rate_ratio,
+                             double main_rate_ratio,
                              int coarse_rate_adjust) {
   set_dev_rate_data new_data;
   new_data.dev_rate = dev_rate;
   new_data.dev_rate_ratio = dev_rate_ratio;
-  new_data.master_rate_ratio = master_rate_ratio;
+  new_data.main_rate_ratio = main_rate_ratio;
   new_data.coarse_rate_adjust = coarse_rate_adjust;
 
   set_dev_rate_map[dev_stream] = new_data;
diff --git a/cras/src/tests/dev_stream_unittest.cc b/cras/src/tests/dev_stream_unittest.cc
index b8c2717..700376f 100644
--- a/cras/src/tests/dev_stream_unittest.cc
+++ b/cras/src/tests/dev_stream_unittest.cc
@@ -547,13 +547,13 @@
   dev_stream_destroy(dev_stream);
 }
 
-TEST_F(CreateSuite, SetDevRateNotMasterDev) {
+TEST_F(CreateSuite, SetDevRateNotMainDev) {
   struct dev_stream* dev_stream;
   unsigned int dev_id = 9;
 
   rstream_.format = fmt_s16le_48;
   rstream_.direction = CRAS_STREAM_INPUT;
-  rstream_.master_dev.dev_id = 4;
+  rstream_.main_dev.dev_id = 4;
   config_format_converter_conv = reinterpret_cast<struct cras_fmt_conv*>(0x33);
   dev_stream = dev_stream_create(&rstream_, dev_id, &fmt_s16le_44_1,
                                  (void*)0x55, &cb_ts, NULL);
@@ -575,14 +575,14 @@
   dev_stream_destroy(dev_stream);
 }
 
-TEST_F(CreateSuite, SetDevRateMasterDev) {
+TEST_F(CreateSuite, SetDevRateMainDev) {
   struct dev_stream* dev_stream;
   unsigned int dev_id = 9;
   unsigned int expected_ts_nsec;
 
   rstream_.format = fmt_s16le_48;
   rstream_.direction = CRAS_STREAM_INPUT;
-  rstream_.master_dev.dev_id = dev_id;
+  rstream_.main_dev.dev_id = dev_id;
   config_format_converter_conv = reinterpret_cast<struct cras_fmt_conv*>(0x33);
   dev_stream = dev_stream_create(&rstream_, dev_id, &fmt_s16le_44_1,
                                  (void*)0x55, &cb_ts, NULL);