[Mplayer-cvslog] CVS: main/libao2 ao_nas.c,1.8,1.9

Arpi of Ize arpi at mplayerhq.hu
Mon Oct 7 03:51:05 CEST 2002


Update of /cvsroot/mplayer/main/libao2
In directory mail:/var/tmp.root/cvs-serv20589

Modified Files:
	ao_nas.c 
Log Message:
libaf compliance (ao_data) fix by Tobias Diedrich <td at sim.uni-hannover.de>


Index: ao_nas.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_nas.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ao_nas.c	6 Oct 2002 17:31:36 -0000	1.8
+++ ao_nas.c	7 Oct 2002 01:50:49 -0000	1.9
@@ -311,23 +311,30 @@
 	return AuNone;
 }
 
-static unsigned char nas_aformat_to_auformat(unsigned int format)
+static unsigned int nas_aformat_to_auformat(unsigned int format)
 {
+	unsigned int res=format << 8;
 	switch (format) {
-	case	AFMT_U8:	return AuFormatLinearUnsigned8;
-	case	AFMT_S8:	return AuFormatLinearSigned8;
-	case	AFMT_U16_LE:	return AuFormatLinearUnsigned16LSB;
-	case	AFMT_U16_BE:	return AuFormatLinearUnsigned16MSB;
+	case	AFMT_U8:
+		return res + AuFormatLinearUnsigned8;
+	case	AFMT_S8:
+		return res + AuFormatLinearSigned8;
+	case	AFMT_U16_LE:
+		return res + AuFormatLinearUnsigned16LSB;
+	case	AFMT_U16_BE:
+		return res + AuFormatLinearUnsigned16MSB;
 #ifndef WORDS_BIGENDIAN
-	case AFMT_AC3:
+	default:
 #endif
-	case	AFMT_S16_LE:	return AuFormatLinearSigned16LSB;
+	case	AFMT_S16_LE:
+		return (AFMT_S16_LE << 8) + AuFormatLinearSigned16LSB;
 #ifdef WORDS_BIGENDIAN
-	case AFMT_AC3:
+	default:
 #endif
-	case	AFMT_S16_BE:	return AuFormatLinearSigned16MSB;
-	case	AFMT_MU_LAW:	return AuFormatULAW8;
-	default: return 0;
+	case	AFMT_S16_BE:
+		return (AFMT_S16_BE << 8) + AuFormatLinearSigned16MSB;
+	case	AFMT_MU_LAW:
+		return res + AuFormatULAW8;
 	}
 }
 
@@ -352,16 +359,12 @@
 	mp_msg(MSGT_AO, MSGL_V, "ao2: %d Hz  %d chans  %s\n",rate,channels,
 		audio_out_format_name(format));
 
-	if (!auformat) {
-		mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: init(): Unsupported format -> nosound\n");
-		return 0;
-	}
-
 	nas_data->client_buffer_size = NAS_BUFFER_SIZE*2;
 	nas_data->client_buffer = malloc(nas_data->client_buffer_size);
 	nas_data->server_buffer_size = NAS_BUFFER_SIZE;
 	nas_data->server_buffer = malloc(nas_data->server_buffer_size);
 
+	ao_data.format = auformat >> 8;
 	ao_data.samplerate = rate;
 	ao_data.channels = channels;
 	ao_data.buffersize = NAS_BUFFER_SIZE * 2;
@@ -373,29 +376,36 @@
 		return 0;
 	}
 
-	if (!(server = getenv("AUDIOSERVER")))
-		server = getenv("DISPLAY");
-
-	if (!server) // default to tcp/localhost:8000
-		server = "tcp/localhost:8000";
+	if (!(server = getenv("AUDIOSERVER")) &&
+	    !(server = getenv("DISPLAY"))) {
+		mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: init(): AUDIOSERVER environment variable not set -> nosound\n");
+		return 0;
+	}
 
 	mp_msg(MSGT_AO, MSGL_V, "ao_nas: init(): Using audioserver %s\n", server);
 
 	nas_data->aud = AuOpenServer(server, 0, NULL, 0, NULL, NULL);
-	if (!nas_data->aud){ 
+	if (!nas_data->aud) { 
 		mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: init(): Can't open nas audio server -> nosound\n");
 		return 0;
 	}
 
-	nas_data->dev = nas_find_device(nas_data->aud, channels);
-	if ((nas_data->dev == AuNone) || (!(nas_data->flow = AuCreateFlow(nas_data->aud, NULL)))) {
-		mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: init(): Can't find a device serving that many channels -> nosound\n");
+	while (channels>1) {
+		nas_data->dev = nas_find_device(nas_data->aud, channels);
+		if (nas_data->dev != AuNone &&
+		    (nas_data->flow = AuCreateFlow(nas_data->aud, NULL) != 0))
+			break;
+		channels--;
+	}
+
+	if (nas_data->flow == 0) {
+		mp_msg(MSGT_AO, MSGL_ERR, "ao_nas: init(): Can't find a suitable output device -> nosound\n");
 		AuCloseServer(nas_data->aud);
 		nas_data->aud = 0;
 		return 0;
 	}
 
-	AuMakeElementImportClient(elms, rate, auformat, channels, AuTrue,
+	AuMakeElementImportClient(elms, rate, auformat & 0xff, channels, AuTrue,
 				NAS_BUFFER_SIZE / bytes_per_sample,
 				(NAS_BUFFER_SIZE - NAS_FRAG_SIZE) / bytes_per_sample,
 				0, NULL);




More information about the MPlayer-cvslog mailing list