Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJörg Müller <nexyon@gmail.com>2015-07-24 16:44:17 +0300
committerJörg Müller <nexyon@gmail.com>2015-07-28 15:01:53 +0300
commit29ebb56f4d8b99ca3038c7a3d0ed794ef77ee7f9 (patch)
tree32f1dae9ea80dd3c1843f5cc00ecceea23da5dc4 /source
parenta0cbebf404d6c46e59b090e7217ce39d7e760809 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_sound.h5
-rw-r--r--source/blender/blenkernel/intern/sound.c77
-rw-r--r--source/blender/editors/interface/resources.c6
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c13
-rw-r--r--source/creator/creator.c4
5 files changed, 67 insertions, 38 deletions
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index fc543b887e4..f221f588db3 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 b81839f80fb..091498653e6 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 e8311443123..a7eb33561b4 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 b2af13aa106..1392009a30d 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 37e767b2eb1..e1c777f8136 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;
}