forked from bartvdbraak/blender
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.
This commit is contained in:
parent
a0cbebf404
commit
29ebb56f4d
@ -411,9 +411,9 @@ class USERPREF_PT_system(Panel):
|
|||||||
col.separator()
|
col.separator()
|
||||||
|
|
||||||
col.label(text="Sound:")
|
col.label(text="Sound:")
|
||||||
col.row().prop(system, "audio_device", expand=True)
|
col.row().prop(system, "audio_device", expand=False)
|
||||||
sub = col.column()
|
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, "use_preview_images")
|
||||||
sub.prop(system, "audio_channels", text="Channels")
|
sub.prop(system, "audio_channels", text="Channels")
|
||||||
sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
|
sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
|
||||||
|
@ -59,8 +59,7 @@ void BKE_sound_init_main(struct Main *bmain);
|
|||||||
|
|
||||||
void BKE_sound_exit(void);
|
void BKE_sound_exit(void);
|
||||||
|
|
||||||
void BKE_sound_force_device(int device);
|
void BKE_sound_force_device(const char *device);
|
||||||
int BKE_sound_define_from_str(const char *str);
|
|
||||||
|
|
||||||
struct bSound *BKE_sound_new_file(struct Main *main, const char *filename);
|
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);
|
float BKE_sound_get_length(struct bSound *sound);
|
||||||
|
|
||||||
|
char** BKE_sound_get_device_names(void);
|
||||||
|
|
||||||
bool BKE_sound_is_jack_supported(void);
|
bool BKE_sound_is_jack_supported(void);
|
||||||
|
|
||||||
#endif /* __BKE_SOUND_H__ */
|
#endif /* __BKE_SOUND_H__ */
|
||||||
|
@ -66,8 +66,9 @@
|
|||||||
#include "BKE_scene.h"
|
#include "BKE_scene.h"
|
||||||
|
|
||||||
#ifdef WITH_AUDASPACE
|
#ifdef WITH_AUDASPACE
|
||||||
/* evil global ;-) */
|
/* evil globals ;-) */
|
||||||
static int sound_cfra;
|
static int sound_cfra;
|
||||||
|
static char** audio_device_names = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bSound *BKE_sound_new_file(struct Main *bmain, const char *filename)
|
bSound *BKE_sound_new_file(struct Main *bmain, const char *filename)
|
||||||
@ -130,7 +131,7 @@ void BKE_sound_free(bSound *sound)
|
|||||||
|
|
||||||
#ifdef WITH_AUDASPACE
|
#ifdef WITH_AUDASPACE
|
||||||
|
|
||||||
static int force_device = -1;
|
static const char* force_device = NULL;
|
||||||
|
|
||||||
#ifdef WITH_JACK
|
#ifdef WITH_JACK
|
||||||
static void sound_sync_callback(void *data, int mode, float time)
|
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
|
#endif
|
||||||
|
|
||||||
int BKE_sound_define_from_str(const char *str)
|
void BKE_sound_force_device(const char *device)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
force_device = device;
|
force_device = device;
|
||||||
}
|
}
|
||||||
@ -197,24 +184,19 @@ void BKE_sound_init(struct Main *bmain)
|
|||||||
specs.format = U.audioformat;
|
specs.format = U.audioformat;
|
||||||
specs.rate = U.audiorate;
|
specs.rate = U.audiorate;
|
||||||
|
|
||||||
if (force_device >= 0)
|
if (force_device == NULL)
|
||||||
device = force_device;
|
|
||||||
|
|
||||||
switch(device)
|
|
||||||
{
|
{
|
||||||
case 1:
|
int i;
|
||||||
device_name = "SDL";
|
char** names = BKE_sound_get_device_names();
|
||||||
break;
|
device_name = names[0];
|
||||||
case 2:
|
|
||||||
device_name = "OpenAL";
|
// make sure device is within the bounds of the array
|
||||||
break;
|
for(i = 0; names[i]; i++)
|
||||||
case 3:
|
if(i == device)
|
||||||
device_name = "Jack";
|
device_name = names[i];
|
||||||
break;
|
|
||||||
default:
|
|
||||||
device_name = "Null";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
device_name = force_device;
|
||||||
|
|
||||||
if (buffersize < 128)
|
if (buffersize < 128)
|
||||||
buffersize = 1024;
|
buffersize = 1024;
|
||||||
@ -254,6 +236,17 @@ void BKE_sound_exit_once(void)
|
|||||||
AUD_exit(sound_device);
|
AUD_exit(sound_device);
|
||||||
sound_device = NULL;
|
sound_device = NULL;
|
||||||
AUD_exitOnce();
|
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 */
|
/* XXX unused currently */
|
||||||
@ -841,6 +834,23 @@ float BKE_sound_get_length(bSound *sound)
|
|||||||
return info.length;
|
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)
|
bool BKE_sound_is_jack_supported(void)
|
||||||
{
|
{
|
||||||
#ifdef WITH_SYSTEM_AUDASPACE
|
#ifdef WITH_SYSTEM_AUDASPACE
|
||||||
@ -854,7 +864,6 @@ bool BKE_sound_is_jack_supported(void)
|
|||||||
|
|
||||||
#include "BLI_utildefines.h"
|
#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_force_device(int UNUSED(device)) {}
|
||||||
void BKE_sound_init_once(void) {}
|
void BKE_sound_init_once(void) {}
|
||||||
void BKE_sound_init(struct Main *UNUSED(bmain)) {}
|
void BKE_sound_init(struct Main *UNUSED(bmain)) {}
|
||||||
|
@ -2641,6 +2641,12 @@ void init_userdef_do_versions(void)
|
|||||||
if (U.image_draw_method == 0)
|
if (U.image_draw_method == 0)
|
||||||
U.image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE;
|
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 */
|
/* funny name, but it is GE stuff, moves userdef stuff to engine */
|
||||||
// XXX space_set_commmandline_options();
|
// XXX space_set_commmandline_options();
|
||||||
/* this timer uses U */
|
/* this timer uses U */
|
||||||
|
@ -127,6 +127,7 @@ EnumPropertyItem navigation_mode_items[] = {
|
|||||||
# include "sdlew.h"
|
# include "sdlew.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
|
static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
|
||||||
{
|
{
|
||||||
WM_main_add_notifier(NC_WINDOW, NULL);
|
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;
|
int totitem = 0;
|
||||||
EnumPropertyItem *item = NULL;
|
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 */
|
/* NONE */
|
||||||
RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
|
RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
|
||||||
|
|
||||||
@ -632,6 +644,7 @@ static EnumPropertyItem *rna_userdef_audio_device_itemf(bContext *UNUSED(C), Poi
|
|||||||
RNA_enum_item_add(&item, &totitem, &audio_device_items[index]);
|
RNA_enum_item_add(&item, &totitem, &audio_device_items[index]);
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RNA_enum_item_end(&item, &totitem);
|
RNA_enum_item_end(&item, &totitem);
|
||||||
|
@ -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))
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,7 +835,7 @@ static int set_audio(int argc, const char **argv, void *UNUSED(data))
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BKE_sound_force_device(BKE_sound_define_from_str(argv[1]));
|
BKE_sound_force_device(argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user