]> code.delx.au - pulseaudio/blobdiff - src/modules/module-alsa-sink.c
Handle when ALSA tweaks our sample spec so much that the frame size changes.
[pulseaudio] / src / modules / module-alsa-sink.c
index 2fea58917a2429a7cd48a432a64888c043a3da4b..6f8f270d85bf11c0bd6f72002c3c5df3f1349772 100644 (file)
@@ -3,6 +3,9 @@
 /***
   This file is part of PulseAudio.
 
+  Copyright 2004-2006 Lennart Poettering
+  Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
   by the Free Software Foundation; either version 2 of the License,
@@ -156,7 +159,11 @@ static void do_write(struct userdata *u) {
                 memchunk = &u->memchunk;
         }
 
-        assert(memchunk->memblock && memchunk->memblock->data && memchunk->length && memchunk->memblock->length && (memchunk->length % u->frame_size) == 0);
+        assert(memchunk->memblock);
+        assert(memchunk->memblock->data);
+        assert(memchunk->length);
+        assert(memchunk->memblock->length);
+        assert((memchunk->length % u->frame_size) == 0);
 
         if ((frames = snd_pcm_writei(u->pcm_handle, (uint8_t*) memchunk->memblock->data + memchunk->index, memchunk->length / u->frame_size)) < 0) {
             if (frames == -EAGAIN)
@@ -412,6 +419,9 @@ int pa__init(pa_core *c, pa_module*m) {
         goto fail;
     }
 
+    /* ALSA might tweak the sample spec, so recalculate the frame size */
+    frame_size = pa_frame_size(&ss);
+
     if (ss.channels != map.channels)
         /* Seems ALSA didn't like the channel number, so let's fix the channel map */
         pa_channel_map_init_auto(&map, ss.channels, PA_CHANNEL_MAP_ALSA);