[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26477] trunk/blender/source: -setaudio argument to force an audio device.

Martin Poirier theeth at yahoo.com
Sun Jan 31 19:32:21 CET 2010


Revision: 26477
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26477
Author:   theeth
Date:     2010-01-31 19:32:19 +0100 (Sun, 31 Jan 2010)

Log Message:
-----------
-setaudio argument to force an audio device.

This also means that only -s and -S are accepted to set start frame and scene (before, it would accept anything that started with s or S, you could have done blender -b file.blend -super 1 -Science "scene 2").

We really need better argument parsing...

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_sound.h
    trunk/blender/source/blender/blenkernel/intern/sound.c
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/source/blender/blenkernel/BKE_sound.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_sound.h	2010-01-31 18:06:50 UTC (rev 26476)
+++ trunk/blender/source/blender/blenkernel/BKE_sound.h	2010-01-31 18:32:19 UTC (rev 26477)
@@ -42,6 +42,7 @@
 void sound_exit();
 
 void sound_force_device(int device);
+int sound_define_from_str(char *str);
 
 struct bSound* sound_new_file(struct Main *main, char* filename);
 

Modified: trunk/blender/source/blender/blenkernel/intern/sound.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sound.c	2010-01-31 18:06:50 UTC (rev 26476)
+++ trunk/blender/source/blender/blenkernel/intern/sound.c	2010-01-31 18:32:19 UTC (rev 26477)
@@ -33,6 +33,20 @@
 
 static int force_device = -1;
 
+int sound_define_from_str(char *str)
+{
+	if (BLI_strcaseeq(str, "NULL"))
+		return AUD_NULL_DEVICE;
+	if (BLI_strcaseeq(str, "SDL"))
+		return AUD_SDL_DEVICE;
+	if (BLI_strcaseeq(str, "OPENAL"))
+		return AUD_OPENAL_DEVICE;
+	if (BLI_strcaseeq(str, "JACK"))
+		return AUD_JACK_DEVICE;
+
+	return -1;
+}
+
 void sound_force_device(int device)
 {
 	force_device = device;

Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c	2010-01-31 18:06:50 UTC (rev 26476)
+++ trunk/blender/source/creator/creator.c	2010-01-31 18:32:19 UTC (rev 26477)
@@ -221,6 +221,8 @@
 	printf ("  -nojoystick\tDisable joystick support\n");
 	printf ("  -noglsl\tDisable GLSL shading\n");
 	printf ("  -noaudio\tForce sound system to None\n");
+	printf ("  -setaudio\tForce sound system to a specific device\n");
+	printf ("    \tNULL SDL OPENAL JACK\n");
 	printf ("  -h\t\tPrint this help text\n");
 	printf ("  -y\t\tDisable automatic python script execution (pydrivers, pyconstraints, pynodes)\n");
 	printf ("  -P <filename>\tRun the given Python script (filename or Blender Text)\n");
@@ -476,7 +478,7 @@
 					break;
 				case 'n':
 				case 'N':
-					if (BLI_strcasecmp(argv[a], "-nojoystick") == 0) {
+					if (BLI_strcaseeq(argv[a], "-nojoystick")) {
 						/**
 						 	don't initialize joysticks if user doesn't want to use joysticks
 							failed joystick initialization delays over 5 seconds, before game engine start
@@ -484,11 +486,18 @@
 						SYS_WriteCommandLineInt(syshandle,"nojoystick",1);
 						if (G.f & G_DEBUG) printf("disabling nojoystick\n");
 					}
-					else if (BLI_strcasecmp(argv[a], "-noglsl") == 0)
+					else if (BLI_strcaseeq(argv[a], "-noglsl"))
 						GPU_extensions_disable();
-					else if (BLI_strcasecmp(argv[a], "-noaudio") == 0)
+					else if (BLI_strcaseeq(argv[a], "-noaudio"))
 						sound_force_device(0);
 					break;
+				case 's':
+				case 'S':
+					if (BLI_strcaseeq(argv[a], "-setaudio") && a + 1 < argc) {
+						a++;
+						sound_force_device(sound_define_from_str(argv[a]));
+					}
+					break;
 				}
 			}
 		}
@@ -526,9 +535,16 @@
 					break;
 				case 'n':
 				case 'N':
-					if (BLI_strcasecmp(argv[a], "-noaudio") == 0)
+					if (BLI_strcaseeq(argv[a], "-noaudio"))
 						sound_force_device(0);
 					break;
+				case 's':
+				case 'S':
+					if (BLI_strcaseeq(argv[a], "-setaudio") && a + 1 < argc) {
+						a++;
+						sound_force_device(sound_define_from_str(argv[a]));
+					}
+					break;
 				}
 			}
 		}
@@ -664,20 +680,30 @@
 				}
 				break;
 			case 'S':
-				if(++a < argc) {
-					set_scene_name(argv[a]);
+				if (BLI_strcaseeq(argv[a], "-setaudio") && a + 1 < argc) {
+					a++; /* already taken care of, just need to swallow the next argument */
 				}
+				else if (argv[a][2] == '\0') {
+					if(++a < argc) {
+						set_scene_name(argv[a]);
+					}
+				}
 				break;
 			case 's':
-				a++;
-				if (CTX_data_scene(C)) {
-					Scene *scene= CTX_data_scene(C);
-					if (a < argc) {
-						int frame = atoi(argv[a]);
-						(scene->r.sfra) = MIN2(MAXFRAME, MAX2(1, frame));
+				if (BLI_strcaseeq(argv[a], "-setaudio") && a + 1 < argc) {
+					a++; /* already taken care of, just need to swallow the next argument */
+				}
+				else if (argv[a][2] == '\0') {
+					a++;
+					if (CTX_data_scene(C)) {
+						Scene *scene= CTX_data_scene(C);
+						if (a < argc) {
+							int frame = atoi(argv[a]);
+							(scene->r.sfra) = MIN2(MAXFRAME, MAX2(1, frame));
+						}
+					} else {
+						printf("\nError: no blend loaded. cannot use '-s'.\n");
 					}
-				} else {
-					printf("\nError: no blend loaded. cannot use '-s'.\n");
 				}
 				break;
 			case 'e':





More information about the Bf-blender-cvs mailing list