diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-06-23 21:30:56 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-06-23 21:30:56 +0400 |
commit | 413bc87e4f18bb46eeb2f2f52b5278d182b51de8 (patch) | |
tree | 6d67ac820f672bd132ebb628381b0a793403ff7c /source/blender/blenkernel/intern/sound.c | |
parent | cc246eaca7bc385738658672e66a5bca8872d5a1 (diff) | |
parent | e7c6b535b0140876ef1b5650c7b259093f07c4b3 (diff) |
Merge with trunk r37757.
Diffstat (limited to 'source/blender/blenkernel/intern/sound.c')
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 150 |
1 files changed, 94 insertions, 56 deletions
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 9b86b8752db..eb8703877ba 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -21,7 +21,9 @@ #include "DNA_screen_types.h" #include "DNA_sound_types.h" -#include "AUD_C-API.h" +#ifdef WITH_AUDASPACE +# include "AUD_C-API.h" +#endif #include "BKE_utildefines.h" #include "BKE_global.h" @@ -36,6 +38,66 @@ static int force_device = -1; + +struct bSound* sound_new_file(struct Main *bmain, const char *filename) +{ + bSound* sound = NULL; + + char str[FILE_MAX]; + char *path; + + int len; + + strcpy(str, filename); + + path = /*bmain ? bmain->name :*/ G.main->name; + + BLI_path_abs(str, path); + + len = strlen(filename); + while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') + len--; + + sound = alloc_libblock(&bmain->sound, ID_SO, filename+len); + BLI_strncpy(sound->name, filename, FILE_MAX); +// XXX unused currently sound->type = SOUND_TYPE_FILE; + + sound_load(bmain, sound); + + if(!sound->playback_handle) + { + free_libblock(&bmain->sound, sound); + sound = NULL; + } + + return sound; +} + +void sound_free(struct bSound* sound) +{ + if (sound->packedfile) + { + freePackedFile(sound->packedfile); + sound->packedfile = NULL; + } + +#ifdef WITH_AUDASPACE + if(sound->handle) + { + AUD_unload(sound->handle); + sound->handle = NULL; + sound->playback_handle = NULL; + } + + if(sound->cache) + { + AUD_unload(sound->cache); + } +#endif // WITH_AUDASPACE +} + +#ifdef WITH_AUDASPACE + #ifdef WITH_JACK static void sound_sync_callback(void* data, int mode, float time) { @@ -124,40 +186,6 @@ void sound_exit(void) AUD_exit(); } -struct bSound* sound_new_file(struct Main *bmain, const char *filename) -{ - bSound* sound = NULL; - - char str[FILE_MAX]; - char *path; - - int len; - - strcpy(str, filename); - - path = /*bmain ? bmain->name :*/ G.main->name; - - BLI_path_abs(str, path); - - len = strlen(filename); - while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') - len--; - - sound = alloc_libblock(&bmain->sound, ID_SO, filename+len); - BLI_strncpy(sound->name, filename, FILE_MAX); -// XXX unused currently sound->type = SOUND_TYPE_FILE; - - sound_load(bmain, sound); - - if(!sound->playback_handle) - { - free_libblock(&bmain->sound, sound); - sound = NULL; - } - - return sound; -} - // XXX unused currently #if 0 struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source) @@ -302,27 +330,6 @@ void sound_load(struct Main *bmain, struct bSound* sound) } } -void sound_free(struct bSound* sound) -{ - if (sound->packedfile) - { - freePackedFile(sound->packedfile); - sound->packedfile = NULL; - } - - if(sound->handle) - { - AUD_unload(sound->handle); - sound->handle = NULL; - sound->playback_handle = NULL; - } - - if(sound->cache) - { - AUD_unload(sound->cache); - } -} - static float sound_get_volume(Scene* scene, Sequence* sequence, float time) { AnimData *adt= BKE_animdata_from_id(&scene->id); @@ -547,3 +554,34 @@ void* sound_get_factory(void* sound) { return ((struct bSound*) sound)->playback_handle; } + +#else // WITH_AUDASPACE + +#include "BLI_utildefines.h" + +int sound_define_from_str(const char *UNUSED(str)) { return -1;} +void sound_force_device(int UNUSED(device)) {} +void sound_init_once(void) {} +void sound_init(struct Main *UNUSED(bmain)) {} +void sound_exit(void) {} +void sound_cache(struct bSound* UNUSED(sound), int UNUSED(ignore)) { } +void sound_delete_cache(struct bSound* UNUSED(sound)) {} +void sound_load(struct Main *UNUSED(bmain), struct bSound* UNUSED(sound)) {} +void sound_create_scene(struct Scene *UNUSED(scene)) {} +void sound_destroy_scene(struct Scene *UNUSED(scene)) {} +void sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {} +void* sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; } +void* sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; } +void sound_remove_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle)) {} +void sound_mute_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), char UNUSED(mute)) {} +void sound_move_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {} +static void sound_start_play_scene(struct Scene *UNUSED(scene)) {} +void sound_play_scene(struct Scene *UNUSED(scene)) {} +void sound_stop_scene(struct Scene *UNUSED(scene)) {} +void sound_seek_scene(struct bContext *UNUSED(C)) {} +float sound_sync_scene(struct Scene *UNUSED(scene)) { return 0.0f; } +int sound_scene_playing(struct Scene *UNUSED(scene)) { return 0; } +int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; } +int sound_get_channels(struct bSound* UNUSED(sound)) { return 1; } + +#endif // WITH_AUDASPACE |