[xiph-cvs] cvs commit: vorbis-tools/ogg123 ogg123rc-example ogg123.c

Jack Moffitt jack at xiph.org
Mon Oct 30 17:06:22 PST 2000



jack        00/10/30 17:06:22

  Modified:    ogg123   ogg123.c
  Added:       ogg123   ogg123rc-example
  Log:
  added support for a .ogg123rc file so that you can specify a default device :)
  an example is provided.
  
  jack.

Revision  Changes    Path
1.8       +36 -1     vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ogg123.c	2000/10/30 21:33:05	1.7
+++ ogg123.c	2000/10/31 01:06:22	1.8
@@ -14,7 +14,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.7 2000/10/30 21:33:05 jack Exp $
+ last mod: $Id: ogg123.c,v 1.8 2000/10/31 01:06:22 jack Exp $
 
  ********************************************************************/
 
@@ -169,6 +169,39 @@
   fprintf (o, "  -z, --shuffle  shuffle play\n");
 }
 
+int get_default_device(void)
+{
+	FILE *fp;
+	char filename[NAME_MAX];
+	char line[100];
+	char *device = NULL;
+	int i;
+
+	strncpy(filename, getenv("HOME"), NAME_MAX);
+	strcat(filename, "/.ogg123rc");
+
+	fp = fopen(filename, "r");
+	if (fp) {
+		if (fgets(line, 100, fp)) {
+			if (strncmp(line, "default_device=", 15) == 0) {
+				device = &line[15];
+				for (i = 0; i < strlen(device); i++)
+					if (device[i] == '\n' || device[i] == '\r')
+						device[i] = 0;
+			}
+		}
+		fclose(fp);
+	}
+
+	if (device) {
+		fprintf(stderr, "device short name = %s\n", device);
+		fprintf(stderr, "device_id is = %d\n", ao_get_driver_id(device));
+		return ao_get_driver_id(device);
+	}
+
+	return -1;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -182,6 +215,8 @@
   int bits, rate, channels;
 
   ao_initialize();
+
+  temp_driver_id = get_default_device();
 
   while (-1 != (ret = getopt_long (argc, argv, "d:hqk:o:vV:z",
                                    long_options, &option_index)))

1.1                  vorbis-tools/ogg123/ogg123rc-example

Index: ogg123rc-example
===================================================================
default_device=oss

--- >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