summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXANTRONIX Development2022-02-01 13:16:28 -0500
committerXANTRONIX Development2022-02-01 13:16:28 -0500
commitd10d683326161d6570eb4b905dc645a95551869f (patch)
tree2b40d3aa2eef0447419debe1c0b2e3113db0f876
parentcdb4eb396109e1659bfbb1c289279f41dd60f0b0 (diff)
downloadxas-d10d683326161d6570eb4b905dc645a95551869f.tar.gz
xas-d10d683326161d6570eb4b905dc645a95551869f.tar.bz2
xas-d10d683326161d6570eb4b905dc645a95551869f.zip
Reduce reliance on duplicate hardcoded constants
-rw-r--r--include/xas/riff.h5
-rw-r--r--src/riff.c11
2 files changed, 11 insertions, 5 deletions
diff --git a/include/xas/riff.h b/include/xas/riff.h
index 693aa9a..6e097c3 100644
--- a/include/xas/riff.h
+++ b/include/xas/riff.h
@@ -6,6 +6,11 @@
#include <xas/audio.h>
+#define XAS_RIFF_HEADER_MAIN_ID "RIFF"
+#define XAS_RIFF_HEADER_WAVE_ID "WAVE"
+#define XAS_RIFF_HEADER_WAVE_FMT_ID "fmt "
+#define XAS_RIFF_HEADER_WAVE_DATA_ID "data"
+
#define XAS_RIFF_WAVE_DEFAULT_TYPE 1
#pragma pack(1)
diff --git a/src/riff.c b/src/riff.c
index fc4e4c3..77def32 100644
--- a/src/riff.c
+++ b/src/riff.c
@@ -19,19 +19,20 @@ static int header_write(xas_riff *riff) {
xas_riff_wave_header header = {
.riff = {
{
- .id = "RIFF",
+ .id = XAS_RIFF_HEADER_MAIN_ID,
.size = sizeof(xas_riff_main_chunk)
+ sizeof(xas_riff_wave_chunk)
+ riff->size
},
- .type = "WAVE"
+ .type = XAS_RIFF_HEADER_WAVE_ID,
},
.wave = {
{
- .id = "fmt ",
- .size = 16
+ .id = XAS_RIFF_HEADER_WAVE_FMT_ID,
+ .size = sizeof(xas_riff_wave_chunk)
+ - sizeof(xas_riff_chunk)
},
.type = XAS_RIFF_WAVE_DEFAULT_TYPE,
@@ -43,7 +44,7 @@ static int header_write(xas_riff *riff) {
},
{
- .id = "data",
+ .id = XAS_RIFF_HEADER_WAVE_DATA_ID,
.size = riff->size
}
};