[xiph-cvs] cvs commit: vorbis-plugins/xmms vorbis.c

Michael Smith msmith at xiph.org
Wed Oct 4 05:36:37 PDT 2000



msmith      00/10/04 05:36:37

  Modified:    xmms     vorbis.c
  Log:
  Deal gracefully with being unable to open the output device (patch from Guillaume Cottenceau)

Revision  Changes    Path
1.2       +19 -6     vorbis-plugins/xmms/vorbis.c

Index: vorbis.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-plugins/xmms/vorbis.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- vorbis.c	2000/09/07 00:43:21	1.1
+++ vorbis.c	2000/10/04 12:36:37	1.2
@@ -30,6 +30,7 @@
 static int vorbis_time(void);
 static void vorbis_get_song_info(char *filename, char **title, int *length);
 static gchar *vorbis_generate_title(vorbis_comment *comment, char *fn);
+static gboolean audio_error = FALSE;
 
 InputPlugin vorbis_ip =
 {
@@ -102,6 +103,7 @@
 static void
 *vorbis_play_loop(void *arg)
 {
+   gboolean output_opened = FALSE;
    char *filename = (char *)arg;
    char pcmout[4096];
    vorbis_comment *comment;
@@ -221,8 +223,16 @@
                              /* This resets the seek slider!  Thus we save the timeoffset
                                 below to add back to the slider when we hit the next link
                                 of a chain.*/
-			     vorbis_ip.output->close_audio();
-			     vorbis_ip.output->open_audio(FMT_S16_LE, vi->rate, vi->channels);
+				 if(output_opened && !audio_error)
+			     	vorbis_ip.output->close_audio();
+				 output_opened = TRUE;
+			     if(!vorbis_ip.output->open_audio(FMT_S16_LE, vi->rate, vi->channels))
+				 {
+					 audio_error = TRUE;
+					 pthread_mutex_unlock(&vf_mutex);
+					 vorbis_eos = 1;
+					 goto play_cleanup;
+				 }
                              timeoffset=ov_time_tell(&vf);
 
                              /* set total play time, bitrate, rate, and channels of current
@@ -273,7 +283,8 @@
              xmms_usleep(20000);
      }
    }
-   vorbis_ip.output->close_audio();
+   if(output_opened && !audio_error)
+		vorbis_ip.output->close_audio();
    /* fall through intentional */
 
  play_cleanup:
@@ -323,9 +334,11 @@
 static int
 vorbis_time(void)
 {
-  if(vorbis_eos && !vorbis_ip.output->buffer_playing())
-	  return -1;
-  return timeoffset * 1000 + vorbis_ip.output->output_time();
+	if(audio_error)
+		return -2;
+	if(vorbis_eos && !vorbis_ip.output->buffer_playing())
+		return -1;
+	return timeoffset * 1000 + vorbis_ip.output->output_time();
 }
 
 static void

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list