# HG changeset patch
# User Matthias Kretz <[EMAIL PROTECTED]>
# Date 1180992647 -7200
# Node ID 2fc230fb08618903ef228e0612f90bb6cc09f114
# Parent  956dd4cfadac32e0ee510c1b4d460ad9a23ea16e
fallback to none output when the device is unplugged

diff -r 2fc230fb08618903ef228e0612f90bb6cc09f114 -r 
956dd4cfadac32e0ee510c1b4d460ad9a23ea16e src/xine-engine/audio_out.c
--- a/src/xine-engine/audio_out.c       Mon Jun 04 23:30:47 2007 +0200
+++ b/src/xine-engine/audio_out.c       Mon Jun 04 23:30:16 2007 +0200
@@ -1213,11 +1213,23 @@ static void *ao_loop (void *this_gen) {
       if( result < 0 ) {
         /* device unplugged. */
         xprintf(this->xine, XINE_VERBOSITY_LOG, _("write to sound card failed. 
Assuming the device was unplugged.\n"));
+        _x_message (in_buf->stream, XINE_MSG_AUDIO_OUT_UNAVAILABLE, NULL);
 
         pthread_mutex_lock( &this->driver_lock );
-        if(this->driver_open)
-          this->driver->close(this->driver);  
-        this->driver_open = 0;
+        if(this->driver_open) {
+          this->driver->close(this->driver);
+          this->driver_open = 0;
+          this->driver->exit(this->driver);
+          this->driver = _x_load_audio_output_plugin (this->xine, "none");
+          if (this->driver && !in_buf->stream->emergency_brake &&
+              ao_change_settings(this,
+                in_buf->format.bits,
+                in_buf->format.rate,
+                in_buf->format.mode) == 0) {
+            in_buf->stream->emergency_brake = 1;
+            _x_message (in_buf->stream, XINE_MSG_AUDIO_OUT_UNAVAILABLE, NULL);
+          }
+        }
         pthread_mutex_unlock( &this->driver_lock );
         /* closing the driver will result in XINE_MSG_AUDIO_OUT_UNAVAILABLE to 
be emitted */
       }
diff -r 2fc230fb08618903ef228e0612f90bb6cc09f114 -r 
956dd4cfadac32e0ee510c1b4d460ad9a23ea16e src/xine-engine/load_plugins.c
--- a/src/xine-engine/load_plugins.c    Mon Jun 04 23:30:47 2007 +0200
+++ b/src/xine-engine/load_plugins.c    Mon Jun 04 23:30:16 2007 +0200
@@ -1681,6 +1681,38 @@ static ao_driver_t *_load_audio_driver (
   return driver;
 }
 
+ao_driver_t *_x_load_audio_output_plugin (xine_t *this, const char *id)
+{
+  plugin_node_t      *node;
+  ao_driver_t        *driver = NULL;
+  ao_info_t          *ao_info;
+  plugin_catalog_t   *catalog = this->plugin_catalog;
+  int                 list_id, list_size;
+
+  pthread_mutex_lock (&catalog->lock);
+
+  list_size = xine_sarray_size 
(this->plugin_catalog->plugin_lists[PLUGIN_AUDIO_OUT - 1]);
+  for (list_id = 0; list_id < list_size; list_id++) {
+
+    node = xine_sarray_get 
(this->plugin_catalog->plugin_lists[PLUGIN_AUDIO_OUT - 1], list_id);
+
+    ao_info = (ao_info_t *)node->info->special_info;
+
+    if (!strcasecmp(node->info->id, id)) {
+      driver = _load_audio_driver (this, node, NULL);
+      break;
+    }
+  }
+
+  pthread_mutex_unlock (&catalog->lock);
+
+  if (!driver) {
+    xprintf (this, XINE_VERBOSITY_LOG,
+        _("load_plugins: failed to load audio output plugin <%s>\n"), id);
+  }
+  return driver;
+}
+
 xine_audio_port_t *xine_open_audio_driver (xine_t *this, const char *id,
                                           void *data) {
 
diff -r 2fc230fb08618903ef228e0612f90bb6cc09f114 -r 
956dd4cfadac32e0ee510c1b4d460ad9a23ea16e src/xine-engine/xine_internal.h
--- a/src/xine-engine/xine_internal.h   Mon Jun 04 23:30:47 2007 +0200
+++ b/src/xine-engine/xine_internal.h   Mon Jun 04 23:30:16 2007 +0200
@@ -484,7 +484,7 @@ vo_driver_t *_x_load_video_output_plugin
  * load a specific audio output plugin
  */
 
-ao_driver_t *_x_load_audio_output_plugin (xine_t *self, char *id) 
XINE_PROTECTED;
+ao_driver_t *_x_load_audio_output_plugin (xine_t *self, const char *id) 
XINE_PROTECTED;
 
 
 void _x_set_speed (xine_stream_t *stream, int speed) XINE_PROTECTED;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Xine-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xine-cvslog

Reply via email to