commit d88751e1242d0d59861f9d14660de22db78f0be8
Author: Martin Kittel <martin@egon.zuhause.de>
Date:   Mon Dec 21 21:13:07 2009 +0100

    DVD: pass down new audio stream number to dvdnav vm when changing audio stream via osd

diff --git a/mythtv/libs/libmythdvdnav/dvdnav/dvdnav.c b/mythtv/libs/libmythdvdnav/dvdnav/dvdnav.c
index c03c78b..df4039e 100644
--- a/mythtv/libs/libmythdvdnav/dvdnav/dvdnav.c
+++ b/mythtv/libs/libmythdvdnav/dvdnav/dvdnav.c
@@ -1061,6 +1061,27 @@ int8_t dvdnav_get_active_audio_stream(dvdnav_t *this) {
   return retval;
 }
 
+int8_t dvdnav_set_active_audio_stream(dvdnav_t *this, int8_t stream) {
+  int8_t        retval;
+
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
+
+  pthread_mutex_lock(&this->vm_lock);
+  if (!this->vm->state.pgc) {
+    printerr("No current PGC.");
+    pthread_mutex_unlock(&this->vm_lock);
+    return -1;
+  }
+
+  retval = vm_set_audio_active_stream(this->vm, stream);
+  pthread_mutex_unlock(&this->vm_lock);
+
+  return retval;
+}
+
 int8_t dvdnav_get_active_spu_stream(dvdnav_t *this) {
   int8_t        retval;
 
diff --git a/mythtv/libs/libmythdvdnav/dvdnav/dvdnav.h b/mythtv/libs/libmythdvdnav/dvdnav/dvdnav.h
index f183d4d..1e4c825 100644
--- a/mythtv/libs/libmythdvdnav/dvdnav/dvdnav.h
+++ b/mythtv/libs/libmythdvdnav/dvdnav/dvdnav.h
@@ -627,6 +627,11 @@ dvdnav_status_t dvdnav_get_spu_attr(dvdnav_t *self, uint8_t audio_mum, subp_attr
 int8_t dvdnav_get_active_audio_stream(dvdnav_t *self);
 
 /*
+ * Set active audio stream
+ */
+int8_t dvdnav_set_active_audio_stream(dvdnav_t *self, int8_t stream);
+
+/*
  * Get active spu stream.
  */
 int8_t dvdnav_get_active_spu_stream(dvdnav_t *self);
diff --git a/mythtv/libs/libmythdvdnav/dvdnav/vm/vm.c b/mythtv/libs/libmythdvdnav/dvdnav/vm/vm.c
index 15448a0..c8f25eb 100644
--- a/mythtv/libs/libmythdvdnav/dvdnav/vm/vm.c
+++ b/mythtv/libs/libmythdvdnav/dvdnav/vm/vm.c
@@ -775,6 +775,19 @@ int vm_get_audio_active_stream(vm_t *vm) {
   return streamN;
 }
 
+int vm_set_audio_active_stream(vm_t *vm, int audioN) {
+
+    if (audioN >= 8)
+      return -1;
+
+    /* verify that stream exists */
+    if(! (vm->state).pgc->audio_control[audioN] & (1<<15))
+        return -1;
+
+    (vm->state).AST_REG = audioN;
+    return 0;
+}
+
 int vm_get_subp_active_stream(vm_t *vm, int mode) {
   int subpN;
   int streamN;
diff --git a/mythtv/libs/libmythdvdnav/dvdnav/vm/vm.h b/mythtv/libs/libmythdvdnav/dvdnav/vm/vm.h
index 9edcff8..c015596 100644
--- a/mythtv/libs/libmythdvdnav/dvdnav/vm/vm.h
+++ b/mythtv/libs/libmythdvdnav/dvdnav/vm/vm.h
@@ -153,6 +153,7 @@ int vm_get_current_title_part(vm_t *vm, int *title_result, int *part_result);
 int vm_get_audio_stream(vm_t *vm, int audioN);
 int vm_get_subp_stream(vm_t *vm, int subpN, int mode);
 int vm_get_audio_active_stream(vm_t *vm);
+int vm_set_audio_active_stream(vm_t *vm, int audioN);
 int vm_get_subp_active_stream(vm_t *vm, int mode);
 void vm_get_angle_info(vm_t *vm, int *current, int *num_avail);
 #if 0
diff --git a/mythtv/libs/libmythtv/DVDRingBuffer.cpp b/mythtv/libs/libmythtv/DVDRingBuffer.cpp
index ec22f1a..30c66a6 100644
--- a/mythtv/libs/libmythtv/DVDRingBuffer.cpp
+++ b/mythtv/libs/libmythtv/DVDRingBuffer.cpp
@@ -1166,6 +1166,7 @@ void DVDRingBufferPriv::SetTrack(uint type, int trackNo)
     {
         m_curAudioTrack = trackNo;
         m_autoselectaudio = false;
+        dvdnav_set_active_audio_stream(m_dvdnav, trackNo);
     }
 }
 

