Page MenuHomeFreeBSD

D47638.id146593.diff
No OneTemporary

D47638.id146593.diff

diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -1011,6 +1011,7 @@
{ "u32le", NULL, NULL, AFMT_U32_LE },
{ "u32be", NULL, NULL, AFMT_U32_BE },
{ "ac3", NULL, NULL, AFMT_AC3 },
+ { "float", NULL, NULL, AFMT_FLOAT },
{ NULL, NULL, NULL, 0 }
};
diff --git a/sys/dev/sound/pcm/feeder_format.c b/sys/dev/sound/pcm/feeder_format.c
--- a/sys/dev/sound/pcm/feeder_format.c
+++ b/sys/dev/sound/pcm/feeder_format.c
@@ -57,6 +57,29 @@
uint8_t reservoir[FEEDFORMAT_RESERVOIR];
};
+/*
+ * float <-> s32le converter.
+ */
+static __inline intpcm_t
+intpcm_read_float(uint8_t *src)
+{
+ intpcm_t v;
+
+ fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX);
+ v = INTPCM32_T(*(float *)src * (float)PCM_S32_MAX);
+ fpu_kern_leave(curthread, NULL);
+
+ return (v);
+}
+
+static __inline void
+intpcm_write_float(uint8_t *dst, intpcm_t v)
+{
+ fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX);
+ *(float *)dst = (float)v / (float)PCM_S32_MAX;
+ fpu_kern_leave(curthread, NULL);
+}
+
/*
* dummy ac3/dts passthrough, etc.
* XXX assume as s16le.
@@ -101,6 +124,10 @@
FEEDFORMAT_ENTRY(U, 16, BE),
FEEDFORMAT_ENTRY(U, 24, BE),
FEEDFORMAT_ENTRY(U, 32, BE),
+ {
+ AFMT_FLOAT,
+ intpcm_read_float, intpcm_write_float
+ },
{
AFMT_MU_LAW,
intpcm_read_ulaw, intpcm_write_ulaw
diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -148,13 +148,14 @@
(((var)<(low))? (low) : ((var)>(high))? (high) : (var))
/* make figuring out what a format is easier. got AFMT_STEREO already */
-#define AFMT_32BIT (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE)
+#define AFMT_32BIT (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE | \
+ AFMT_FLOAT)
#define AFMT_24BIT (AFMT_S24_LE | AFMT_S24_BE | AFMT_U24_LE | AFMT_U24_BE)
#define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)
#define AFMT_G711 (AFMT_MU_LAW | AFMT_A_LAW)
#define AFMT_8BIT (AFMT_G711 | AFMT_U8 | AFMT_S8)
#define AFMT_SIGNED (AFMT_S32_LE | AFMT_S32_BE | AFMT_S24_LE | AFMT_S24_BE | \
- AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)
+ AFMT_S16_LE | AFMT_S16_BE | AFMT_S8 | AFMT_FLOAT)
#define AFMT_BIGENDIAN (AFMT_S32_BE | AFMT_U32_BE | AFMT_S24_BE | AFMT_U24_BE | \
AFMT_S16_BE | AFMT_U16_BE)
diff --git a/sys/sys/soundcard.h b/sys/sys/soundcard.h
--- a/sys/sys/soundcard.h
+++ b/sys/sys/soundcard.h
@@ -184,6 +184,7 @@
#define AFMT_S24_BE 0x00020000 /* Big endian signed 24-bit */
#define AFMT_U24_LE 0x00040000 /* Little endian unsigned 24-bit */
#define AFMT_U24_BE 0x00080000 /* Big endian unsigned 24-bit */
+#define AFMT_FLOAT 0x10000000 /* 32-bit floating point */
/* Machine dependent AFMT_* definitions. */
#if BYTE_ORDER == LITTLE_ENDIAN

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 7:04 PM (35 m, 54 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14683057
Default Alt Text
D47638.id146593.diff (2 KB)

Event Timeline