summaryrefslogtreecommitdiff
path: root/src/xine-engine/audio_out.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xine-engine/audio_out.c')
-rw-r--r--src/xine-engine/audio_out.c62
1 files changed, 38 insertions, 24 deletions
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c
index d39c99aba..75cef4ce6 100644
--- a/src/xine-engine/audio_out.c
+++ b/src/xine-engine/audio_out.c
@@ -16,16 +16,18 @@
* You should have received a copy of the GNU General Public License
* along with self program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/**
+ * @file
+ * @brief xine-lib audio output implementation
+ *
+ * @date 2001-08-20 First implementation of Audio sync and Audio driver separation.
+ * (c) 2001 James Courtier-Dutton <james@superbug.demon.co.uk>
+ * @date 2001-08-22 James imported some useful AC3 sections from the previous
+ * ALSA driver. (c) 2001 Andy Lo A Foe <andy@alsaplayer.org>
*
- * $Id: audio_out.c,v 1.210 2007/04/01 00:52:36 dgp85 Exp $
*
- * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver.
- * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org>
- * 20-8-2001 First implementation of Audio sync and Audio driver separation.
- * (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk
- */
-
-/*
* General Programming Guidelines: -
* New concept of an "audio_frame".
* An audio_frame consists of all the samples required to fill every
@@ -576,18 +578,16 @@ static void audio_filter_compress (aos_t *this, int16_t *mem, int num_frames) {
}
static void audio_filter_amp (aos_t *this, void *buf, int num_frames) {
-
- int i;
- int num_channels;
double amp_factor;
-
- num_channels = _x_ao_mode2channels (this->input.mode);
- if (!num_channels)
+ int i;
+ const int total_frames = num_frames * _x_ao_mode2channels (this->input.mode);
+
+ if (!total_frames)
return;
amp_factor=this->amp_factor;
if (this->amp_mute || amp_factor == 0) {
- memset (buf, 0, num_frames * num_channels * (this->input.bits / 8));
+ memset (buf, 0, total_frames * (this->input.bits / 8));
return;
}
@@ -595,7 +595,7 @@ static void audio_filter_amp (aos_t *this, void *buf, int num_frames) {
int16_t test;
int8_t *mem = (int8_t *) buf;
- for (i=0; i<num_frames*num_channels; i++) {
+ for (i=0; i<total_frames; i++) {
test = mem[i] * amp_factor;
/* Force limit on amp_factor to prevent clipping */
if (test < INT8_MIN) {
@@ -612,7 +612,7 @@ static void audio_filter_amp (aos_t *this, void *buf, int num_frames) {
int32_t test;
int16_t *mem = (int16_t *) buf;
- for (i=0; i<num_frames*num_channels; i++) {
+ for (i=0; i<total_frames; i++) {
test = mem[i] * amp_factor;
/* Force limit on amp_factor to prevent clipping */
if (test < INT16_MIN) {
@@ -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");