Przeglądaj źródła

LibAudio: Add a formatter for `Audio::Sample`

Useful for debugging.
Jelle Raaijmakers 3 lat temu
rodzic
commit
ae0ca35541
1 zmienionych plików z 13 dodań i 0 usunięć
  1. 13 0
      Userland/Libraries/LibAudio/Sample.h

+ 13 - 0
Userland/Libraries/LibAudio/Sample.h

@@ -7,6 +7,7 @@
 
 #pragma once
 
+#include <AK/Format.h>
 #include <AK/Math.h>
 
 namespace Audio {
@@ -146,3 +147,15 @@ struct Sample {
 };
 
 }
+
+namespace AK {
+
+template<>
+struct Formatter<Audio::Sample> : Formatter<FormatString> {
+    ErrorOr<void> format(FormatBuilder& builder, Audio::Sample const& value)
+    {
+        return Formatter<FormatString>::format(builder, "[{}, {}]", value.left, value.right);
+    }
+};
+
+}