summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@users.sourceforge.net>2004-04-05 20:01:24 +0000
committerBastien Nocera <hadess@users.sourceforge.net>2004-04-05 20:01:24 +0000
commit7c56dc4a7f9bcfa9b0a117e29deafe03193c52cd (patch)
treec4177ed332a9a7baa3ea8f9861550b240f509102
parent4eb1d7669e8322e74f468039cf76fe02287dd510 (diff)
downloadxine-lib-7c56dc4a7f9bcfa9b0a117e29deafe03193c52cd.tar.gz
xine-lib-7c56dc4a7f9bcfa9b0a117e29deafe03193c52cd.tar.bz2
- add XINE_MSG_AUDIO_OUT_UNAVAILABLE event to warn when the audio device is
busy. CVS patchset: 6333 CVS date: 2004/04/05 20:01:24
-rw-r--r--ChangeLog1
-rw-r--r--include/xine.h.in3
-rw-r--r--src/xine-engine/audio_out.c40
3 files changed, 34 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index b48e6c883..91731951e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
* guess codeset for OSD if nl_langinfo(CODESET) is missing or not working
* new option - list of domains, where don't use proxy
* fix possible crashes in front-ends that create and delete streams
+ * send a message to the front-end when the audio device is busy
* revert changes to the DVD plugin that made it impossible to play mounted
DVDs
diff --git a/include/xine.h.in b/include/xine.h.in
index 80c7e033f..23e52c660 100644
--- a/include/xine.h.in
+++ b/include/xine.h.in
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine.h.in,v 1.117 2004/03/16 20:50:08 mroi Exp $
+ * $Id: xine.h.in,v 1.118 2004/04/05 20:01:27 hadess Exp $
*
* public xine-lib (libxine) interface and documentation
*
@@ -1645,6 +1645,7 @@ typedef struct {
#define XINE_MSG_LIBRARY_LOAD_ERROR 8 /* (library/decoder) */
#define XINE_MSG_ENCRYPTED_SOURCE 9 /* none */
#define XINE_MSG_SECURITY 10 /* (security message) */
+#define XINE_MSG_AUDIO_OUT_UNAVAILABLE 11 /* none */
/* opaque xine_event_queue_t */
typedef struct xine_event_queue_s xine_event_queue_t;
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c
index 884980281..fd258f844 100644
--- a/src/xine-engine/audio_out.c
+++ b/src/xine-engine/audio_out.c
@@ -17,7 +17,7 @@
* along with self program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: audio_out.c,v 1.169 2004/03/16 12:25:05 mroi Exp $
+ * $Id: audio_out.c,v 1.170 2004/04/05 20:01:27 hadess Exp $
*
* 22-8-2001 James imported some useful AC3 sections from the previous alsa driver.
* (c) 2001 Andy Lo A Foe <andy@alsaplayer.org>
@@ -998,9 +998,26 @@ static void *ao_loop (void *this_gen) {
pthread_mutex_lock( &this->driver_lock );
delay = this->driver->delay(this->driver);
}
- } else
+ pthread_mutex_unlock( &this->driver_lock );
+ } else {
+ xine_stream_t *stream;
delay = 0;
- pthread_mutex_unlock( &this->driver_lock );
+
+ pthread_mutex_unlock( &this->driver_lock );
+ xprintf(this->xine, XINE_VERBOSITY_LOG,
+ _("audio_oss_out: delay calculation impossible with an unavailable audio device\n"));
+
+ pthread_mutex_lock(&this->xine->streams_lock);
+ for (stream = xine_list_first_content(this->xine->streams);
+ stream; stream = xine_list_next_content(this->xine->streams))
+ {
+ _x_message (stream, XINE_MSG_AUDIO_OUT_UNAVAILABLE, NULL);
+ /* This is necessary for the message to get to the front-end at some
+ * point before another message is sent */
+ sched_yield();
+ }
+ pthread_mutex_unlock(&this->xine->streams_lock);
+ }
cur_time = this->clock->get_current_time (this->clock);
@@ -1110,10 +1127,14 @@ static void *ao_loop (void *this_gen) {
#endif
lprintf ("loop: writing %d samples to sound device\n", out_buf->num_frames);
-
- pthread_mutex_lock( &this->driver_lock );
- result = this->driver->write (this->driver, out_buf->mem, out_buf->num_frames );
- pthread_mutex_unlock( &this->driver_lock );
+
+ if (this->driver_open) {
+ pthread_mutex_lock( &this->driver_lock );
+ result = this->driver->write (this->driver, out_buf->mem, out_buf->num_frames );
+ pthread_mutex_unlock( &this->driver_lock );
+ } else {
+ result = 0;
+ }
if( result < 0 ) {
/* FIXME: USB device unplugged.
@@ -1248,7 +1269,6 @@ static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mod
}
output_sample_rate=this->driver->open(this->driver,bits,(this->force_rate ? this->force_rate : rate),mode);
- this->driver_open = 1;
} else
output_sample_rate = this->input.rate;
@@ -1256,7 +1276,9 @@ static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mod
this->driver_open = 0;
xprintf (this->xine, XINE_VERBOSITY_DEBUG, "open failed!\n");
return 0;
- };
+ } else {
+ this->driver_open = 1;
+ }
xprintf (this->xine, XINE_VERBOSITY_DEBUG, "output sample rate %d\n", output_sample_rate);