Adopt absl::string_view in modules/audio_processing/

Bug: webrtc:13579
Change-Id: Idb05a64cfd16aed68d40cd427a6b516caa5e2077
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/269387
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37800}
diff --git a/modules/audio_processing/logging/apm_data_dumper.h b/modules/audio_processing/logging/apm_data_dumper.h
index 9c2ac3b..4ab6baa 100644
--- a/modules/audio_processing/logging/apm_data_dumper.h
+++ b/modules/audio_processing/logging/apm_data_dumper.h
@@ -13,19 +13,20 @@
 
 #include <stdint.h>
 #include <stdio.h>
-#include <string.h>
 
-#include <string>
 #if WEBRTC_APM_DEBUG_DUMP == 1
 #include <memory>
+#include <string>
 #include <unordered_map>
 #endif
 
+#include "absl/strings/string_view.h"
 #include "absl/types/optional.h"
 #include "api/array_view.h"
 #if WEBRTC_APM_DEBUG_DUMP == 1
 #include "common_audio/wav_file.h"
 #include "rtc_base/checks.h"
+#include "rtc_base/string_utils.h"
 #endif
 
 // Check to verify that the define is properly set.
@@ -87,10 +88,10 @@
   }
 
   // Set an optional output directory.
-  static void SetOutputDirectory(const std::string& output_dir) {
+  static void SetOutputDirectory(absl::string_view output_dir) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
     RTC_CHECK_LT(output_dir.size(), kOutputDirMaxLength);
-    strncpy(output_dir_, output_dir.c_str(), output_dir.size());
+    rtc::strcpyn(output_dir_, output_dir.size(), output_dir);
 #endif
   }
 
@@ -104,7 +105,9 @@
 
   // Methods for performing dumping of data of various types into
   // various formats.
-  void DumpRaw(const char* name, double v, int dump_set = kDefaultDumpSet) {
+  void DumpRaw(absl::string_view name,
+               double v,
+               int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
     if (dump_set_to_use_ && *dump_set_to_use_ != dump_set)
       return;
@@ -116,7 +119,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                size_t v_length,
                const double* v,
                int dump_set = kDefaultDumpSet) {
@@ -131,7 +134,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                rtc::ArrayView<const double> v,
                int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
@@ -144,7 +147,9 @@
 #endif
   }
 
-  void DumpRaw(const char* name, float v, int dump_set = kDefaultDumpSet) {
+  void DumpRaw(absl::string_view name,
+               float v,
+               int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
     if (dump_set_to_use_ && *dump_set_to_use_ != dump_set)
       return;
@@ -156,7 +161,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                size_t v_length,
                const float* v,
                int dump_set = kDefaultDumpSet) {
@@ -171,7 +176,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                rtc::ArrayView<const float> v,
                int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
@@ -184,7 +189,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name, bool v, int dump_set = kDefaultDumpSet) {
+  void DumpRaw(absl::string_view name, bool v, int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
     if (dump_set_to_use_ && *dump_set_to_use_ != dump_set)
       return;
@@ -195,7 +200,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                size_t v_length,
                const bool* v,
                int dump_set = kDefaultDumpSet) {
@@ -213,7 +218,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                rtc::ArrayView<const bool> v,
                int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
@@ -226,7 +231,9 @@
 #endif
   }
 
-  void DumpRaw(const char* name, int16_t v, int dump_set = kDefaultDumpSet) {
+  void DumpRaw(absl::string_view name,
+               int16_t v,
+               int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
     if (dump_set_to_use_ && *dump_set_to_use_ != dump_set)
       return;
@@ -238,7 +245,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                size_t v_length,
                const int16_t* v,
                int dump_set = kDefaultDumpSet) {
@@ -253,7 +260,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                rtc::ArrayView<const int16_t> v,
                int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
@@ -266,7 +273,9 @@
 #endif
   }
 
-  void DumpRaw(const char* name, int32_t v, int dump_set = kDefaultDumpSet) {
+  void DumpRaw(absl::string_view name,
+               int32_t v,
+               int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
     if (dump_set_to_use_ && *dump_set_to_use_ != dump_set)
       return;
@@ -278,7 +287,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                size_t v_length,
                const int32_t* v,
                int dump_set = kDefaultDumpSet) {
@@ -293,7 +302,9 @@
 #endif
   }
 
-  void DumpRaw(const char* name, size_t v, int dump_set = kDefaultDumpSet) {
+  void DumpRaw(absl::string_view name,
+               size_t v,
+               int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
     if (dump_set_to_use_ && *dump_set_to_use_ != dump_set)
       return;
@@ -305,7 +316,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                size_t v_length,
                const size_t* v,
                int dump_set = kDefaultDumpSet) {
@@ -320,7 +331,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                rtc::ArrayView<const int32_t> v,
                int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
@@ -333,7 +344,7 @@
 #endif
   }
 
-  void DumpRaw(const char* name,
+  void DumpRaw(absl::string_view name,
                rtc::ArrayView<const size_t> v,
                int dump_set = kDefaultDumpSet) {
 #if WEBRTC_APM_DEBUG_DUMP == 1
@@ -344,7 +355,7 @@
 #endif
   }
 
-  void DumpWav(const char* name,
+  void DumpWav(absl::string_view name,
                size_t v_length,
                const float* v,
                int sample_rate_hz,
@@ -362,7 +373,7 @@
 #endif
   }
 
-  void DumpWav(const char* name,
+  void DumpWav(absl::string_view name,
                rtc::ArrayView<const float> v,
                int sample_rate_hz,
                int num_channels,
@@ -389,8 +400,8 @@
       raw_files_;
   std::unordered_map<std::string, std::unique_ptr<WavWriter>> wav_files_;
 
-  FILE* GetRawFile(const char* name);
-  WavWriter* GetWavFile(const char* name,
+  FILE* GetRawFile(absl::string_view name);
+  WavWriter* GetWavFile(absl::string_view name,
                         int sample_rate_hz,
                         int num_channels,
                         WavFile::SampleFormat format);