]> git.proxmox.com Git - qemu.git/blobdiff - audio/mixeng.c
Merge remote-tracking branch 'origin/master' into staging
[qemu.git] / audio / mixeng.c
index 34cc1aeee4af795a02dd85423e183d06d7729821..4a9e8ebe2afe75cb941f9787975f26422563f12c 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include "vl.h"
+#include "qemu-common.h"
+#include "audio.h"
 
 #define AUDIO_CAP "mixeng"
 #include "audio_int.h"
 
-#define NOVOL
-
 /* 8 bit */
 #define ENDIAN_CONVERSION natural
 #define ENDIAN_CONVERT(v) (v)
 #undef IN_T
 #undef SHIFT
 
-/* Unsigned 16 bit */
+/* Unsigned 32 bit */
 #define IN_T uint32_t
 #define IN_MIN 0
 #define IN_MAX UINT32_MAX
@@ -291,7 +290,7 @@ struct rate {
     uint64_t opos;
     uint64_t opos_inc;
     uint32_t ipos;              /* position in the input stream (integer) */
-    st_sample_t ilast;          /* last sample in the input stream */
+    struct st_sample ilast;          /* last sample in the input stream */
 };
 
 /*
@@ -330,7 +329,32 @@ void st_rate_stop (void *opaque)
     qemu_free (opaque);
 }
 
-void mixeng_clear (st_sample_t *buf, int len)
+void mixeng_clear (struct st_sample *buf, int len)
+{
+    memset (buf, 0, len * sizeof (struct st_sample));
+}
+
+void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *vol)
 {
-    memset (buf, 0, len * sizeof (st_sample_t));
+#ifdef CONFIG_MIXEMU
+    if (vol->mute) {
+        mixeng_clear (buf, len);
+        return;
+    }
+
+    while (len--) {
+#ifdef FLOAT_MIXENG
+        buf->l = buf->l * vol->l;
+        buf->r = buf->r * vol->r;
+#else
+        buf->l = (buf->l * vol->l) >> 32;
+        buf->r = (buf->r * vol->r) >> 32;
+#endif
+        buf += 1;
+    }
+#else
+    (void) buf;
+    (void) len;
+    (void) vol;
+#endif
 }