summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2007-06-04 20:59:09 +0100
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2007-06-04 20:59:09 +0100
commit33e68bd91eb35951cfb9b5748c028f3936331cff (patch)
tree64e082ac978853a0fe55ce6a3da96b49714f76f2
parent53c578ab41a18686c99b7168dc6e7de4479fb74f (diff)
parent6d72cf30f29689035eddbe95d35fd39fcf5d70ca (diff)
downloadxine-lib-33e68bd91eb35951cfb9b5748c028f3936331cff.tar.gz
xine-lib-33e68bd91eb35951cfb9b5748c028f3936331cff.tar.bz2
Merge Matthias Kretz's changes.
-rw-r--r--contrib/Makefile.am13
-rw-r--r--src/audio_out/audio_alsa_out.c12
-rw-r--r--src/xine-engine/audio_out.c28
-rw-r--r--src/xine-engine/load_plugins.c32
-rw-r--r--src/xine-engine/xine_internal.h2
5 files changed, 71 insertions, 16 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 2258d2fd2..a61af87e0 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -70,16 +70,19 @@ configure_options =\
--disable-shared --enable-static --disable-demuxers --disable-muxers --disable-strip \
--enable-gpl --enable-pthreads --disable-ffmpeg --disable-ffserver --disable-ffplay
-if DEBUG_BUILD
-configure_options += --enable-debug
-else
+# --enable-debug --disable-opts breaks the build of ffmpeg on x86:
+# i386/mpegvideo_mmx_template.c:108: error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
+# pending a real fix --enable-debug for libxine does not enable debugging options for ffmpeg for now
+#if DEBUG_BUILD
+#configure_options += --enable-debug
+#else
configure_options += --disable-debug
-endif
+#endif
if PROFILING_BUILD
configure_options += --enable-gprof
endif
if DISABLE_OPTIMIZATIONS
-configure_options += --disable-opts
+#configure_options += --disable-opts
endif
if HAVE_MLIB
configure_options += --enable-sunmlib
diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c
index 6ad78da2a..ce3e7fb2b 100644
--- a/src/audio_out/audio_alsa_out.c
+++ b/src/audio_out/audio_alsa_out.c
@@ -752,6 +752,9 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) {
if (res < 0)
return 0;
state = snd_pcm_state(this->audio_fd);
+ } else if (state == SND_PCM_STATE_DISCONNECTED) {
+ /* the device is gone. audio_out.c handles it if we return something < 0 */
+ return -1;
}
if (state == SND_PCM_STATE_XRUN) {
#ifdef LOG_DEBUG
@@ -784,11 +787,11 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) {
#endif
snd_pcm_status(this->audio_fd, pcm_stat);
if ( snd_pcm_status_get_avail(pcm_stat) < number_of_frames) {
- wait_result = snd_pcm_wait(this->audio_fd, 1000000);
+ wait_result = snd_pcm_wait(this->audio_fd, 1000);
#ifdef LOG_DEBUG
printf("audio_alsa_out:write:loop:wait_result=%d\n",wait_result);
#endif
- if (wait_result < 0) return 0;
+ if (wait_result <= 0) return 0;
}
}
if (this->mmap != 0) {
@@ -808,7 +811,10 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) {
return 0;
continue;
}
- if ( (state != SND_PCM_STATE_PREPARED) &&
+ if (state == SND_PCM_STATE_DISCONNECTED) {
+ /* the device is gone. audio_out.c handles it if we return something < 0 */
+ return -1;
+ } else if ( (state != SND_PCM_STATE_PREPARED) &&
(state != SND_PCM_STATE_RUNNING) &&
(state != SND_PCM_STATE_DRAINING) ) {
xprintf(this->class->xine, XINE_VERBOSITY_DEBUG,
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c
index 66e28d80d..75cef4ce6 100644
--- a/src/xine-engine/audio_out.c
+++ b/src/xine-engine/audio_out.c
@@ -1211,13 +1211,27 @@ static void *ao_loop (void *this_gen) {
}
if( result < 0 ) {
- /* FIXME: USB device unplugged.
- * We should get the card into a closed state here, that involves closing
- * the PCM as well as the MIXER.
- * Maybe we should pause the stream until the USB device is plugged in again.
- * Return values 0 happen even if usb not unplugged, so needs further investigation.
- */
- xprintf(this->xine, XINE_VERBOSITY_LOG, _("write to sound card failed. Was a USB device unplugged ?\n"));
+ /* 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;
+ 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 */
}
lprintf ("loop: next buf from fifo\n");
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index ca1f87c7a..750ec21e7 100644
--- a/src/xine-engine/load_plugins.c
+++ b/src/xine-engine/load_plugins.c
@@ -1721,6 +1721,38 @@ static ao_driver_t *_load_audio_driver (xine_t *this, plugin_node_t *node,
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 --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index 208ef7647..fc142d44b 100644
--- a/src/xine-engine/xine_internal.h
+++ b/src/xine-engine/xine_internal.h
@@ -500,7 +500,7 @@ vo_driver_t *_x_load_video_output_plugin(xine_t *this,
* 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;