Index: /trunk/src/VBox/Devices/Audio/alsaaudio.c
===================================================================
--- /trunk/src/VBox/Devices/Audio/alsaaudio.c	(revision 1946)
+++ /trunk/src/VBox/Devices/Audio/alsaaudio.c	(revision 1947)
@@ -98,6 +98,6 @@
     audfmt_e fmt;
     int nchannels;
-    unsigned int buffer_size;
-    unsigned int period_size;
+    unsigned long buffer_size;
+    unsigned long period_size;
 };
 
@@ -269,9 +269,10 @@
     snd_pcm_t *handle;
     snd_pcm_hw_params_t *hw_params;
-    int err;
+    int err, dir;
     unsigned int freq, nchannels;
     const char *pcm_name = in ? conf.pcm_name_in : conf.pcm_name_out;
     unsigned int period_size, buffer_size;
-    snd_pcm_uframes_t obt_buffer_size;
+    snd_pcm_uframes_t period_size_f, buffer_size_f;
+    snd_pcm_uframes_t obt_buffer_size, obt_period_size;
     const char *typ = in ? "ADC" : "DAC";
 
@@ -279,4 +280,6 @@
     period_size = req->period_size;
     buffer_size = req->buffer_size;
+    period_size_f = (snd_pcm_uframes_t)period_size;
+    buffer_size_f = (snd_pcm_uframes_t)buffer_size;
     nchannels = req->nchannels;
 
@@ -415,9 +418,8 @@
         }
         else {
-            int dir;
             snd_pcm_uframes_t minval;
 
-            if (period_size) {
-                minval = period_size;
+            if (period_size_f) {
+                minval = period_size_f;
                 dir = 0;
 
@@ -440,5 +442,5 @@
                 else {
                     dolog("minimal period size %ld\n", minval);
-                    if (period_size < minval) {
+                    if (period_size_f < minval) {
                         if ((in && conf.period_size_in_overriden)
                             || (!in && conf.period_size_out_overriden)) {
@@ -446,8 +448,8 @@
                                    "than minmal period size(%ld)\n",
                                    typ,
-                                   period_size,
+                                   period_size_f,
                                    minval);
                         }
-                        period_size = minval;
+                        period_size_f = minval;
                     }
                 }
@@ -457,5 +459,5 @@
                     handle,
                     hw_params,
-                    period_size,
+                    period_size_f,
                     0
                     );
@@ -464,16 +466,16 @@
                     handle,
                     hw_params,
-                    (snd_pcm_uframes_t*)&period_size,
+                    &period_size_f,
                     0
                     );
 #endif
-                dolog("PERIOD_SIZE %d\n", period_size);
+                dolog("PERIOD_SIZE %d\n", period_size_f);
                 if (err < 0) {
 #ifndef VBOX
                     alsa_logerr2 (err, typ, "Failed to set period size %d\n",
-                                  period_size);
+                                  period_size_f);
 #else
                     LogRel(("ALSA: Failed to set period size %d (%s)\n",
-                            period_size, snd_strerror(err)));
+                            period_size_f, snd_strerror(err)));
 #endif
                     goto err;
@@ -484,8 +486,8 @@
             /* Calculate default buffer size here since it might have been changed
              * in the _near functions */
-            buffer_size = 4 * period_size;
-#endif
-
-            minval = buffer_size;
+            buffer_size_f = 4 * period_size_f;
+#endif
+
+            minval = buffer_size_f;
             err = snd_pcm_hw_params_get_buffer_size_min (
                 hw_params,
@@ -501,5 +503,5 @@
             }
             else {
-                if (buffer_size < minval) {
+                if (buffer_size_f < minval) {
                     if ((in && conf.buffer_size_in_overriden)
                         || (!in && conf.buffer_size_out_overriden)) {
@@ -508,9 +510,9 @@
                             "than minimal buffer size(%ld)\n",
                             typ,
-                            buffer_size,
+                            buffer_size_f,
                             minval
                             );
                     }
-                    buffer_size = minval;
+                    buffer_size_f = minval;
                 }
             }
@@ -519,14 +521,14 @@
                 handle,
                 hw_params,
-                (snd_pcm_uframes_t*)&buffer_size
+                &buffer_size_f
                 );
-            dolog("BUFFER_SIZE %d\n", buffer_size);
+            dolog("BUFFER_SIZE %d\n", buffer_size_f);
             if (err < 0) {
 #ifndef VBOX
                 alsa_logerr2 (err, typ, "Failed to set buffer size %d\n",
-                              buffer_size);
+                              buffer_size_f);
 #else
                 LogRel(("ALSA: Failed to set buffer size %d (%s)\n",
-                        buffer_size, snd_strerror(err)));
+                        buffer_size_f, snd_strerror(err)));
 #endif
                 goto err;
@@ -559,6 +561,13 @@
 
 #ifdef VBOX
-    LogRel(("ALSA: %s frequency %dHz, period size %d, buffer size %d\n",
-             typ, req->freq, period_size, obt_buffer_size));
+    dir = 0;
+    err = snd_pcm_hw_params_get_period_size (hw_params, &obt_period_size, &dir);
+    if (err < 0)
+    {
+        LogRel(("ALSA: Failed to get period size\n"));
+	goto err;
+    }
+    LogRel(("ALSA: %s frequency %dHz, period size %ld, buffer size %ld\n",
+             typ, req->freq, obt_period_size, obt_buffer_size));
 #endif
 
