changeset 1393:d872ca28881f

merge
author Cristi Magherusan <majeru@atheme-project.org>
date Sat, 28 Jul 2007 01:30:34 +0300
parents e6f5685f71a1 (current diff) 58f74efbe943 (diff)
children 2e25c7a29ac2
files
diffstat 2 files changed, 31 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/cdaudio-ng/cdaudio-ng.c	Sat Jul 28 01:26:17 2007 +0300
+++ b/src/cdaudio-ng/cdaudio-ng.c	Sat Jul 28 01:30:34 2007 +0300
@@ -1,8 +1,3 @@
-
-/*
-	todo:
-		- about dialog
-*/
 
 #include <string.h>
 #include <stdlib.h>
@@ -24,7 +19,6 @@
 #include <audacious/i18n.h>
 #include <audacious/configdb.h>
 #include <audacious/plugin.h>
-//#include <audacious/playback.h>	// todo: this should be available soon (by 1.4)
 #include <audacious/util.h>
 #include <audacious/output.h>
 #include "config.h"
@@ -208,7 +202,8 @@
 		if (cdio_get_media_changed(pcdio) && pcdio != NULL) {
 			if (debug)
 				printf("cdaudio-ng: cd changed, rescanning\n");
-			cdaudio_scan_dir(CDDA_DEFAULT);
+			if (cdaudio_scan_dir(CDDA_DEFAULT) == NULL)
+				pcdio = NULL;
 		}
 
 		if (pcdio == NULL) {
@@ -274,7 +269,8 @@
 			cleanup_on_error();
 			return NULL;
 		}
-		cdio_free_device_list(ppcd_drives);
+		if (ppcd_drives != NULL && *ppcd_drives != NULL)
+			cdio_free_device_list(ppcd_drives);
 	}
 
 		/* limit read speed */
@@ -468,6 +464,13 @@
 		cdaudio_scan_dir(CDDA_DEFAULT);
 	}
 
+	if (trackinfo == NULL) {
+		if (debug)
+			printf("cdaudio-ng: no cd information can be retrieved, aborting\n");
+		pinputplayback->playing = FALSE;
+		return;
+	}
+
 	int trackno = find_trackno_from_filename(pinputplayback->filename);
 	if (trackno < firsttrackno || trackno > lasttrackno) {
 		fprintf(stderr, "cdaudio-ng: trackno %d is out of range [%d..%d]\n", trackno, firsttrackno, lasttrackno);
@@ -479,6 +482,11 @@
 	playing_track = trackno;
 	is_paused = FALSE;
 
+	char *title = xmms_get_titlestring(xmms_get_gentitle_format(), create_tuple_from_trackinfo(pinputplayback->filename));
+
+	inputplugin.set_info(title, calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn), 1411200, 44100, 2);
+	free(title);
+
 	if (use_dae) {
 		if (debug)
 			printf("cdaudio-ng: using digital audio extraction\n");
@@ -520,11 +528,6 @@
 			return;
 		}
 	}
-
-	char *title = xmms_get_titlestring(xmms_get_gentitle_format(), create_tuple_from_trackinfo(pinputplayback->filename));
-
-	inputplugin.set_info(title, calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn), 128000, 44100, 2);
-	free(title);
 }
 
 void cdaudio_stop(InputPlayback *pinputplayback)
@@ -742,6 +745,9 @@
 
 TitleInput *create_tuple_from_trackinfo(char *filename)
 {
+	if (trackinfo == NULL)
+		return NULL;
+
 	TitleInput *tuple = bmp_title_input_new();
 	int trackno = find_trackno_from_filename(filename);
 
@@ -773,6 +779,8 @@
 	gboolean output_paused = FALSE;
 	int read_error_counter = 0;
 
+	//pdae_params->endlsn += 75 * 3;
+
 	while (pdae_params->pplayback->playing) {
 			/* handle pause status */
 		if (is_paused) {
@@ -808,13 +816,16 @@
 			/* compute the actual number of sectors to read */
 		int lsncount = CDDA_DAE_FRAMES <= (pdae_params->endlsn - pdae_params->currlsn + 1) ? CDDA_DAE_FRAMES : (pdae_params->endlsn - pdae_params->currlsn + 1);
 			/* check too see if we have reached the end of the song */
-		if (lsncount <= 0)
+		if (lsncount <= 0) {
+			sleep(3);
 			break;
+		}
 
 		if (cdio_read_audio_sectors(pcdio, buffer, pdae_params->currlsn, lsncount) != DRIVER_OP_SUCCESS) {
 			fprintf(stderr, "cdaudio-ng: failed to read audio sector\n");
 			read_error_counter++;
 			if (read_error_counter >= 2) {
+				read_error_counter = 0;
 				fprintf(stderr, "cdaudio-ng: this cd can no longer be played, stopping\n");
 				break;
 			}
@@ -869,7 +880,6 @@
 {
 	if (playing_track != -1) {
 		playing_track = -1;
-		playback_stop();
 	}
 
 	if (trackinfo != NULL) {
--- a/src/wma/wma.c	Sat Jul 28 01:26:17 2007 +0300
+++ b/src/wma/wma.c	Sat Jul 28 01:30:34 2007 +0300
@@ -364,8 +364,8 @@
     AVPacket pkt;
     
     g_static_mutex_lock(&wma_mutex);
-    while(wma_decode){
-
+    while(playback->playing)
+    {
 	if(wma_seekpos != -1)
 	{
 	    av_seek_frame(ic, wma_idx, wma_seekpos * 1000000LL);
@@ -394,8 +394,7 @@
             if(pkt.data) av_free_packet(&pkt);
         }
     }
-    while(wma_decode && playback->output->buffer_playing()) xmms_usleep(30000);
-    wma_decode = 0;
+    while(playback->playing && playback->output->buffer_playing()) xmms_usleep(30000);
     playback->playing = 0;
     if(wma_s_outbuf) g_free(wma_s_outbuf);
     if(wma_outbuf) g_free(wma_outbuf);
@@ -403,7 +402,6 @@
     if(c) avcodec_close(c);
     if(ic) av_close_input_file(ic);
     g_static_mutex_unlock(&wma_mutex);
-    g_thread_exit(NULL);
     return(NULL);
 }
 
@@ -412,7 +410,7 @@
     char *filename = playback->filename;
     AVCodec *codec;
     
-    if(av_open_input_file(&ic, str_twenty_to_space(filename), NULL, 0, NULL) < 0) return;
+    if(av_open_input_file(&ic, filename, NULL, 0, NULL) < 0) return;
 
     for(wma_idx = 0; wma_idx < ic->nb_streams; wma_idx++) {
         c = &ic->streams[wma_idx]->codec;
@@ -443,7 +441,8 @@
     wma_seekpos = -1;
     wma_decode = 1;
     playback->playing = 1;
-    wma_decode_thread = g_thread_create((GThreadFunc)wma_play_loop, playback, TRUE, NULL);
+    wma_decode_thread = g_thread_self();
+    wma_play_loop(playback);
 }
 
 static void wma_stop(InputPlayback *playback)