forked from bartvdbraak/blender
style cleanup
This commit is contained in:
parent
b5c3ffe9c7
commit
39ff86eb32
@ -80,7 +80,7 @@
|
||||
static int sound_open_cancel(bContext *UNUSED(C), wmOperator *op)
|
||||
{
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata= NULL;
|
||||
op->customdata = NULL;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ static void sound_open_init(bContext *C, wmOperator *op)
|
||||
{
|
||||
PropertyPointerRNA *pprop;
|
||||
|
||||
op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
|
||||
op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
|
||||
uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ static int sound_open_exec(bContext *C, wmOperator *op)
|
||||
if (!op->customdata)
|
||||
sound_open_init(C, op);
|
||||
|
||||
if (sound==NULL || sound->playback_handle == NULL) {
|
||||
if (sound == NULL || sound->playback_handle == NULL) {
|
||||
if (op->customdata) MEM_freeN(op->customdata);
|
||||
BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
|
||||
return OPERATOR_CANCELLED;
|
||||
@ -133,7 +133,7 @@ static int sound_open_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* hook into UI */
|
||||
pprop= op->customdata;
|
||||
pprop = op->customdata;
|
||||
|
||||
if (pprop->prop) {
|
||||
/* when creating new ID blocks, use is already 1, but RNA
|
||||
@ -183,10 +183,10 @@ static void SOUND_OT_open(wmOperatorType *ot)
|
||||
ot->cancel = sound_open_cancel;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE | SOUNDFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
|
||||
RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory");
|
||||
RNA_def_boolean(ot->srna, "mono", FALSE, "Mono", "Mixdown the sound to mono");
|
||||
}
|
||||
@ -204,10 +204,10 @@ static void SOUND_OT_open_mono(wmOperatorType *ot)
|
||||
ot->cancel = sound_open_cancel;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE | SOUNDFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
|
||||
RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory");
|
||||
RNA_def_boolean(ot->srna, "mono", TRUE, "Mono", "Mixdown the sound to mono");
|
||||
}
|
||||
@ -216,12 +216,12 @@ static void SOUND_OT_open_mono(wmOperatorType *ot)
|
||||
|
||||
static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Sequence* seq;
|
||||
Scene* scene = CTX_data_scene(C);
|
||||
struct FCurve* fcu;
|
||||
Sequence *seq;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
struct FCurve *fcu;
|
||||
char driven;
|
||||
|
||||
SEQ_BEGIN (scene->ed, seq)
|
||||
SEQ_BEGIN(scene->ed, seq)
|
||||
{
|
||||
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, &driven);
|
||||
if (fcu || driven)
|
||||
@ -277,8 +277,8 @@ static void SOUND_OT_update_animation_flags(wmOperatorType *ot)
|
||||
|
||||
static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Main* bmain = CTX_data_main(C);
|
||||
Scene* scene = CTX_data_scene(C);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int oldfra = scene->r.cfra;
|
||||
int cfra;
|
||||
|
||||
@ -325,7 +325,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
|
||||
AUD_DeviceSpecs specs;
|
||||
AUD_Container container;
|
||||
AUD_Codec codec;
|
||||
const char* result;
|
||||
const char *result;
|
||||
|
||||
sound_bake_animation_exec(C, op);
|
||||
|
||||
@ -393,18 +393,14 @@ static int sound_mixdown_check(bContext *UNUSED(C), wmOperator *op)
|
||||
{
|
||||
AUD_Container container = RNA_enum_get(op->ptr, "container");
|
||||
|
||||
const char* extension = NULL;
|
||||
const char *extension = NULL;
|
||||
|
||||
EnumPropertyItem* item = container_items;
|
||||
while(item->identifier != NULL)
|
||||
{
|
||||
if(item->value == container)
|
||||
{
|
||||
const char** ext = snd_ext_sound;
|
||||
while(*ext != NULL)
|
||||
{
|
||||
if(!strcmp(*ext + 1, item->name))
|
||||
{
|
||||
EnumPropertyItem *item = container_items;
|
||||
while (item->identifier != NULL) {
|
||||
if (item->value == container) {
|
||||
const char **ext = snd_ext_sound;
|
||||
while (*ext != NULL) {
|
||||
if (!strcmp(*ext + 1, item->name)) {
|
||||
extension = *ext;
|
||||
break;
|
||||
}
|
||||
@ -424,12 +420,12 @@ static int sound_mixdown_check(bContext *UNUSED(C), wmOperator *op)
|
||||
prop = RNA_struct_find_property(op->ptr, "filepath");
|
||||
RNA_property_string_get(op->ptr, prop, filepath);
|
||||
|
||||
if(BLI_testextensie_array(filepath, snd_ext_sound))
|
||||
if (BLI_testextensie_array(filepath, snd_ext_sound))
|
||||
check = BLI_replace_extension(filepath, FILE_MAX, extension);
|
||||
else
|
||||
check = BLI_ensure_extension(filepath, FILE_MAX, extension);
|
||||
|
||||
if(!check)
|
||||
if (!check)
|
||||
return check;
|
||||
|
||||
RNA_property_string_set(op->ptr, prop, filepath);
|
||||
@ -453,11 +449,10 @@ static int sound_mixdown_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
static int sound_mixdown_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
|
||||
{
|
||||
const char *prop_id= RNA_property_identifier(prop);
|
||||
return !( strcmp(prop_id, "filepath") == 0 ||
|
||||
const char *prop_id = RNA_property_identifier(prop);
|
||||
return !(strcmp(prop_id, "filepath") == 0 ||
|
||||
strcmp(prop_id, "directory") == 0 ||
|
||||
strcmp(prop_id, "filename") == 0
|
||||
);
|
||||
strcmp(prop_id, "filename") == 0);
|
||||
}
|
||||
|
||||
static void sound_mixdown_draw(bContext *C, wmOperator *op)
|
||||
@ -471,23 +466,27 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
|
||||
{AUD_FORMAT_S32, "S32", 0, "S32", "32 bit signed"},
|
||||
{AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"},
|
||||
{AUD_FORMAT_FLOAT64, "F64", 0, "F64", "64 bit floating point"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem mp3_format_items[] = {
|
||||
{AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"},
|
||||
{AUD_FORMAT_S32, "S32", 0, "S32", "32 bit signed"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem ac3_format_items[] = {
|
||||
{AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"},
|
||||
{AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
#ifdef WITH_SNDFILE
|
||||
static EnumPropertyItem flac_format_items[] = {
|
||||
{AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"},
|
||||
{AUD_FORMAT_S24, "S24", 0, "S24", "24 bit signed"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
#endif
|
||||
|
||||
static EnumPropertyItem all_codec_items[] = {
|
||||
@ -498,15 +497,17 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
|
||||
{AUD_CODEC_MP3, "MP3", 0, "MP3", "MPEG-2 Audio Layer III"},
|
||||
{AUD_CODEC_PCM, "PCM", 0, "PCM", "Pulse Code Modulation (RAW)"},
|
||||
{AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem ogg_codec_items[] = {
|
||||
{AUD_CODEC_FLAC, "FLAC", 0, "FLAC", "Free Lossless Audio Codec"},
|
||||
{AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
uiLayout *layout = op->layout;
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop_format;
|
||||
PropertyRNA *prop_codec;
|
||||
@ -621,7 +622,8 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
|
||||
{AUD_FORMAT_S32, "S32", 0, "S32", "32 bit signed"},
|
||||
{AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"},
|
||||
{AUD_FORMAT_FLOAT64, "F64", 0, "F64", "64 bit floating point"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem codec_items[] = {
|
||||
#ifdef WITH_FFMPEG
|
||||
@ -635,7 +637,8 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
|
||||
#endif
|
||||
{AUD_CODEC_PCM, "PCM", 0, "PCM", "Pulse Code Modulation (RAW)"},
|
||||
{AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
#endif // WITH_AUDASPACE
|
||||
|
||||
@ -671,7 +674,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
|
||||
|
||||
static int sound_poll(bContext *C)
|
||||
{
|
||||
Editing* ed = CTX_data_scene(C)->ed;
|
||||
Editing *ed = CTX_data_scene(C)->ed;
|
||||
|
||||
if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND)
|
||||
return 0;
|
||||
@ -682,9 +685,9 @@ static int sound_poll(bContext *C)
|
||||
|
||||
static int sound_pack_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
Editing* ed = CTX_data_scene(C)->ed;
|
||||
bSound* sound;
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Editing *ed = CTX_data_scene(C)->ed;
|
||||
bSound *sound;
|
||||
|
||||
if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND)
|
||||
return OPERATOR_CANCELLED;
|
||||
@ -694,7 +697,7 @@ static int sound_pack_exec(bContext *C, wmOperator *op)
|
||||
if (!sound || sound->packedfile)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
sound->packedfile= newPackedFile(op->reports, sound->name, ID_BLEND_PATH(bmain, &sound->id));
|
||||
sound->packedfile = newPackedFile(op->reports, sound->name, ID_BLEND_PATH(bmain, &sound->id));
|
||||
sound_load(CTX_data_main(C), sound);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@ -712,19 +715,19 @@ static void SOUND_OT_pack(wmOperatorType *ot)
|
||||
ot->poll = sound_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/********************* unpack operator *********************/
|
||||
|
||||
static int sound_unpack_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
int method= RNA_enum_get(op->ptr, "method");
|
||||
bSound* sound= NULL;
|
||||
int method = RNA_enum_get(op->ptr, "method");
|
||||
bSound *sound = NULL;
|
||||
|
||||
/* find the suppplied image by name */
|
||||
if (RNA_struct_property_is_set(op->ptr, "id")) {
|
||||
char sndname[MAX_ID_NAME-2];
|
||||
char sndname[MAX_ID_NAME - 2];
|
||||
RNA_string_get(op->ptr, "id", sndname);
|
||||
sound = BLI_findstring(&CTX_data_main(C)->sound, sndname, offsetof(ID, name) + 2);
|
||||
}
|
||||
@ -742,8 +745,8 @@ static int sound_unpack_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int sound_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
{
|
||||
Editing* ed = CTX_data_scene(C)->ed;
|
||||
bSound* sound;
|
||||
Editing *ed = CTX_data_scene(C)->ed;
|
||||
bSound *sound;
|
||||
|
||||
if (RNA_struct_property_is_set(op->ptr, "id"))
|
||||
return sound_unpack_exec(C, op);
|
||||
@ -759,7 +762,7 @@ static int sound_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
|
||||
if (G.fileflags & G_AUTOPACK)
|
||||
BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save");
|
||||
|
||||
unpack_menu(C, "SOUND_OT_unpack", sound->id.name+2, sound->name, "sounds", sound->packedfile);
|
||||
unpack_menu(C, "SOUND_OT_unpack", sound->id.name + 2, sound->name, "sounds", sound->packedfile);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -777,11 +780,11 @@ static void SOUND_OT_unpack(wmOperatorType *ot)
|
||||
ot->poll = sound_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_enum(ot->srna, "method", unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack");
|
||||
RNA_def_string(ot->srna, "id", "", MAX_ID_NAME-2, "Sound Name", "Sound datablock name to unpack"); /* XXX, weark!, will fail with library, name collisions */
|
||||
RNA_def_string(ot->srna, "id", "", MAX_ID_NAME - 2, "Sound Name", "Sound datablock name to unpack"); /* XXX, weark!, will fail with library, name collisions */
|
||||
}
|
||||
|
||||
/* ******************************************************* */
|
||||
|
Loading…
Reference in New Issue
Block a user