From 1b9b9983f7cfef6be6850189e099b78e69e467fb Mon Sep 17 00:00:00 2001
From: Markus Henschel <markus.henschel@yager.de>
Date: Mon, 28 Oct 2013 21:14:46 +0100
Subject: [PATCH] reset buffer position in stop instead of play and fix
 calculation of current sample position

---
 addons/audio/dsound.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/addons/audio/dsound.cpp b/addons/audio/dsound.cpp
index e51a614..2bd7a10 100644
--- a/addons/audio/dsound.cpp
+++ b/addons/audio/dsound.cpp
@@ -472,8 +472,7 @@ static int _dsound_start_voice(ALLEGRO_VOICE *voice)
 
    ALLEGRO_DEBUG("Starting voice\n");
 
-   if (!voice->is_streaming) {
-      ex_data->ds8_buffer->SetCurrentPosition(0);
+   if (!voice->is_streaming) {     
       hr = ex_data->ds8_buffer->Play(0, 0, 0);
       if (FAILED(hr)) {
          ALLEGRO_ERROR("Streaming voice failed to start\n");
@@ -545,6 +544,7 @@ static int _dsound_stop_voice(ALLEGRO_VOICE* voice)
    if (!voice->is_streaming) {
       ALLEGRO_DEBUG("Stopping non-streaming voice\n");
       ex_data->ds8_buffer->Stop();
+	   ex_data->ds8_buffer->SetCurrentPosition(0);
       ALLEGRO_INFO("Non-streaming voice stopped\n");
       return 0;
    }
@@ -604,7 +604,7 @@ static unsigned int _dsound_get_voice_position(const ALLEGRO_VOICE *voice)
       return 0;
    }
 
-   return play_pos / (ex_data->channels / (ex_data->bits_per_sample/8));
+   return play_pos / (ex_data->channels * (ex_data->bits_per_sample/8));
 }
 
 /* The set_voice_position method should set the voice's playback position,
-- 
1.8.3.msysgit.0

