[Bf-blender-cvs] [29ebb56] master: Audaspace: support the device list returned by the new audaspace library.
Jörg Müller
noreply at git.blender.org
Tue Jul 28 14:10:32 CEST 2015
Commit: 29ebb56f4d8b99ca3038c7a3d0ed794ef77ee7f9
Author: Jörg Müller
Date: Fri Jul 24 15:44:17 2015 +0200
Branches: master
https://developer.blender.org/rB29ebb56f4d8b99ca3038c7a3d0ed794ef77ee7f9
Audaspace: support the device list returned by the new audaspace library.
- use the device names returned from the library.
- system settings UI changed as new audaspace might contain longer and more device names.
===================================================================
M release/scripts/startup/bl_ui/space_userpref.py
M source/blender/blenkernel/BKE_sound.h
M source/blender/blenkernel/intern/sound.c
M source/blender/editors/interface/resources.c
M source/blender/makesrna/intern/rna_userdef.c
M source/creator/creator.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index f53df65..6be24a8 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -411,9 +411,9 @@ class USERPREF_PT_system(Panel):
col.separator()
col.label(text="Sound:")
- col.row().prop(system, "audio_device", expand=True)
+ col.row().prop(system, "audio_device", expand=False)
sub = col.column()
- sub.active = system.audio_device != 'NONE'
+ sub.active = system.audio_device != 'NONE' and system.audio_device != 'Null'
#sub.prop(system, "use_preview_images")
sub.prop(system, "audio_channels", text="Channels")
sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index fc543b8..f221f58 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -59,8 +59,7 @@ void BKE_sound_init_main(struct Main *bmain);
void BKE_sound_exit(void);
-void BKE_sound_force_device(int device);
-int BKE_sound_define_from_str(const char *str);
+void BKE_sound_force_device(const char *device);
struct bSound *BKE_sound_new_file(struct Main *main, const char *filename);
@@ -142,6 +141,8 @@ void *BKE_sound_get_factory(void *sound);
float BKE_sound_get_length(struct bSound *sound);
+char** BKE_sound_get_device_names(void);
+
bool BKE_sound_is_jack_supported(void);
#endif /* __BKE_SOUND_H__ */
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index b81839f..0914986 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -66,8 +66,9 @@
#include "BKE_scene.h"
#ifdef WITH_AUDASPACE
-/* evil global ;-) */
+/* evil globals ;-) */
static int sound_cfra;
+static char** audio_device_names = NULL;
#endif
bSound *BKE_sound_new_file(struct Main *bmain, const char *filename)
@@ -130,7 +131,7 @@ void BKE_sound_free(bSound *sound)
#ifdef WITH_AUDASPACE
-static int force_device = -1;
+static const char* force_device = NULL;
#ifdef WITH_JACK
static void sound_sync_callback(void *data, int mode, float time)
@@ -153,21 +154,7 @@ static void sound_sync_callback(void *data, int mode, float time)
}
#endif
-int BKE_sound_define_from_str(const char *str)
-{
- if (BLI_strcaseeq(str, "NULL"))
- return 0;
- if (BLI_strcaseeq(str, "SDL"))
- return 1;
- if (BLI_strcaseeq(str, "OPENAL"))
- return 2;
- if (BLI_strcaseeq(str, "JACK"))
- return 3;
-
- return -1;
-}
-
-void BKE_sound_force_device(int device)
+void BKE_sound_force_device(const char *device)
{
force_device = device;
}
@@ -197,24 +184,19 @@ void BKE_sound_init(struct Main *bmain)
specs.format = U.audioformat;
specs.rate = U.audiorate;
- if (force_device >= 0)
- device = force_device;
-
- switch(device)
+ if (force_device == NULL)
{
- case 1:
- device_name = "SDL";
- break;
- case 2:
- device_name = "OpenAL";
- break;
- case 3:
- device_name = "Jack";
- break;
- default:
- device_name = "Null";
- break;
+ int i;
+ char** names = BKE_sound_get_device_names();
+ device_name = names[0];
+
+ // make sure device is within the bounds of the array
+ for(i = 0; names[i]; i++)
+ if(i == device)
+ device_name = names[i];
}
+ else
+ device_name = force_device;
if (buffersize < 128)
buffersize = 1024;
@@ -254,6 +236,17 @@ void BKE_sound_exit_once(void)
AUD_exit(sound_device);
sound_device = NULL;
AUD_exitOnce();
+
+#ifdef WITH_SYSTEM_AUDASPACE
+ if(audio_device_names != NULL)
+ {
+ int i;
+ for(i = 0; audio_device_names[i]; i++)
+ free(audio_device_names[i]);
+ free(audio_device_names);
+ audio_device_names = NULL;
+ }
+#endif
}
/* XXX unused currently */
@@ -841,6 +834,23 @@ float BKE_sound_get_length(bSound *sound)
return info.length;
}
+char** BKE_sound_get_device_names(void)
+{
+ if(audio_device_names == NULL)
+ {
+#ifdef WITH_SYSTEM_AUDASPACE
+ audio_device_names = AUD_getDeviceNames();
+#else
+ static const char* names[] = {
+ "Null", "SDL", "OpenAL", "Jack"
+ };
+ audio_device_names = (char**)names;
+#endif
+ }
+
+ return audio_device_names;
+}
+
bool BKE_sound_is_jack_supported(void)
{
#ifdef WITH_SYSTEM_AUDASPACE
@@ -854,7 +864,6 @@ bool BKE_sound_is_jack_supported(void)
#include "BLI_utildefines.h"
-int BKE_sound_define_from_str(const char *UNUSED(str)) { return -1; }
void BKE_sound_force_device(int UNUSED(device)) {}
void BKE_sound_init_once(void) {}
void BKE_sound_init(struct Main *UNUSED(bmain)) {}
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index e831144..a7eb335 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -2641,6 +2641,12 @@ void init_userdef_do_versions(void)
if (U.image_draw_method == 0)
U.image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE;
+ // keep the following until the new audaspace is default to be built with
+#ifdef WITH_SYSTEM_AUDASPACE
+ // we default to the first audio device
+ U.audiodevice = 0;
+#endif
+
/* funny name, but it is GE stuff, moves userdef stuff to engine */
// XXX space_set_commmandline_options();
/* this timer uses U */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index b2af13a..1392009 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -127,6 +127,7 @@ EnumPropertyItem navigation_mode_items[] = {
# include "sdlew.h"
#endif
+
static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
{
WM_main_add_notifier(NC_WINDOW, NULL);
@@ -610,6 +611,17 @@ static EnumPropertyItem *rna_userdef_audio_device_itemf(bContext *UNUSED(C), Poi
int totitem = 0;
EnumPropertyItem *item = NULL;
+#ifdef WITH_SYSTEM_AUDASPACE
+ int i;
+
+ char** names = BKE_sound_get_device_names();
+
+ for(i = 0; names[i]; i++)
+ {
+ EnumPropertyItem new_item = {i, names[i], 0, names[i], names[i]};
+ RNA_enum_item_add(&item, &totitem, &new_item);
+ }
+#else
/* NONE */
RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
@@ -633,6 +645,7 @@ static EnumPropertyItem *rna_userdef_audio_device_itemf(bContext *UNUSED(C), Poi
}
index++;
#endif
+#endif
RNA_enum_item_end(&item, &totitem);
*r_free = true;
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 37e767b..e1c777f 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -824,7 +824,7 @@ static int no_glsl(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(dat
static int no_audio(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
{
- BKE_sound_force_device(0);
+ BKE_sound_force_device("Null");
return 0;
}
@@ -835,7 +835,7 @@ static int set_audio(int argc, const char **argv, void *UNUSED(data))
exit(1);
}
- BKE_sound_force_device(BKE_sound_define_from_str(argv[1]));
+ BKE_sound_force_device(argv[1]);
return 1;
}
More information about the Bf-blender-cvs
mailing list