From 49c1c0386f136a78f82a6b7601b3f06bb90e48b8 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 17 Aug 2021 17:56:31 +0200 Subject: [PATCH] pw-cat: fix raw read raw read needs bytes, so use the stride to calculate it from frames. Move ulaw/alaw to packed formats. --- spa/include/spa/param/audio/raw.h | 6 +++--- spa/include/spa/param/audio/type-info.h | 6 +++--- spa/plugins/audioconvert/fmt-ops-c.c | 4 ++-- src/tools/pw-cat.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spa/include/spa/param/audio/raw.h b/spa/include/spa/param/audio/raw.h index 13b45334f..0aa83dd8e 100644 --- a/spa/include/spa/param/audio/raw.h +++ b/spa/include/spa/param/audio/raw.h @@ -79,6 +79,9 @@ enum spa_audio_format { SPA_AUDIO_FORMAT_F64_LE, SPA_AUDIO_FORMAT_F64_BE, + SPA_AUDIO_FORMAT_ULAW, + SPA_AUDIO_FORMAT_ALAW, + /* planar formats */ SPA_AUDIO_FORMAT_START_Planar = 0x200, SPA_AUDIO_FORMAT_U8P, @@ -93,9 +96,6 @@ enum spa_audio_format { /* other formats start here */ SPA_AUDIO_FORMAT_START_Other = 0x400, - SPA_AUDIO_FORMAT_ULAW, - SPA_AUDIO_FORMAT_ALAW, - /* Aliases */ /* DSP formats */ diff --git a/spa/include/spa/param/audio/type-info.h b/spa/include/spa/param/audio/type-info.h index c53636117..9fd1dd95b 100644 --- a/spa/include/spa/param/audio/type-info.h +++ b/spa/include/spa/param/audio/type-info.h @@ -73,6 +73,9 @@ static const struct spa_type_info spa_type_audio_format[] = { { SPA_AUDIO_FORMAT_F64_LE, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "F64LE", NULL }, { SPA_AUDIO_FORMAT_F64_BE, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "F64BE", NULL }, + { SPA_AUDIO_FORMAT_ULAW, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "ULAW", NULL }, + { SPA_AUDIO_FORMAT_ALAW, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "ALAW", NULL }, + { SPA_AUDIO_FORMAT_U8P, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "U8P", NULL }, { SPA_AUDIO_FORMAT_S16P, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S16P", NULL }, { SPA_AUDIO_FORMAT_S24_32P, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S24_32P", NULL }, @@ -82,9 +85,6 @@ static const struct spa_type_info spa_type_audio_format[] = { { SPA_AUDIO_FORMAT_F64P, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "F64P", NULL }, { SPA_AUDIO_FORMAT_S8P, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S8P", NULL }, - { SPA_AUDIO_FORMAT_ULAW, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "ULAW", NULL }, - { SPA_AUDIO_FORMAT_ALAW, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "ALAW", NULL }, - #if __BYTE_ORDER == __BIG_ENDIAN { SPA_AUDIO_FORMAT_S16_OE, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S16OE", NULL }, { SPA_AUDIO_FORMAT_S16, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S16", NULL }, diff --git a/spa/plugins/audioconvert/fmt-ops-c.c b/spa/plugins/audioconvert/fmt-ops-c.c index cf14c7eb6..c21602172 100644 --- a/spa/plugins/audioconvert/fmt-ops-c.c +++ b/spa/plugins/audioconvert/fmt-ops-c.c @@ -215,7 +215,7 @@ void conv_alaw_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[], uint32_t n_samples) { - const int8_t *s = src[0]; + const uint8_t *s = src[0]; float **d = (float **) dst; uint32_t i, j, n_channels = conv->n_channels; @@ -229,7 +229,7 @@ void conv_ulaw_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[], uint32_t n_samples) { - const int8_t *s = src[0]; + const uint8_t *s = src[0]; float **d = (float **) dst; uint32_t i, j, n_channels = conv->n_channels; diff --git a/src/tools/pw-cat.c b/src/tools/pw-cat.c index 6d07abd7d..f123201a7 100644 --- a/src/tools/pw-cat.c +++ b/src/tools/pw-cat.c @@ -287,7 +287,7 @@ static int sf_playback_fill_x8(struct data *d, void *dest, unsigned int n_frames { sf_count_t rn; - rn = sf_read_raw(d->file, dest, n_frames); + rn = sf_read_raw(d->file, dest, n_frames * d->stride); return (int)rn; } @@ -371,7 +371,7 @@ static int sf_record_fill_x8(struct data *d, void *src, unsigned int n_frames) { sf_count_t rn; - rn = sf_write_raw(d->file, src, n_frames); + rn = sf_write_raw(d->file, src, n_frames * d->stride); return (int)rn; }