style cleanup

This commit is contained in:
Campbell Barton 2012-05-24 10:16:42 +00:00
parent b5c3ffe9c7
commit 39ff86eb32

@ -80,7 +80,7 @@
static int sound_open_cancel(bContext *UNUSED(C), wmOperator *op) static int sound_open_cancel(bContext *UNUSED(C), wmOperator *op)
{ {
MEM_freeN(op->customdata); MEM_freeN(op->customdata);
op->customdata= NULL; op->customdata = NULL;
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -88,7 +88,7 @@ static void sound_open_init(bContext *C, wmOperator *op)
{ {
PropertyPointerRNA *pprop; PropertyPointerRNA *pprop;
op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
uiIDContextProperty(C, &pprop->ptr, &pprop->prop); uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
} }
@ -108,7 +108,7 @@ static int sound_open_exec(bContext *C, wmOperator *op)
if (!op->customdata) if (!op->customdata)
sound_open_init(C, op); 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); if (op->customdata) MEM_freeN(op->customdata);
BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
@ -133,7 +133,7 @@ static int sound_open_exec(bContext *C, wmOperator *op)
} }
/* hook into UI */ /* hook into UI */
pprop= op->customdata; pprop = op->customdata;
if (pprop->prop) { if (pprop->prop) {
/* when creating new ID blocks, use is already 1, but RNA /* 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; ot->cancel = sound_open_cancel;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */ /* 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, "cache", FALSE, "Cache", "Cache the sound in memory");
RNA_def_boolean(ot->srna, "mono", FALSE, "Mono", "Mixdown the sound to mono"); 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; ot->cancel = sound_open_cancel;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */ /* 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, "cache", FALSE, "Cache", "Cache the sound in memory");
RNA_def_boolean(ot->srna, "mono", TRUE, "Mono", "Mixdown the sound to mono"); 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)) static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op))
{ {
Sequence* seq; Sequence *seq;
Scene* scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
struct FCurve* fcu; struct FCurve *fcu;
char driven; 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); fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, &driven);
if (fcu || 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)) static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
{ {
Main* bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
Scene* scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
int oldfra = scene->r.cfra; int oldfra = scene->r.cfra;
int cfra; int cfra;
@ -325,7 +325,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
AUD_DeviceSpecs specs; AUD_DeviceSpecs specs;
AUD_Container container; AUD_Container container;
AUD_Codec codec; AUD_Codec codec;
const char* result; const char *result;
sound_bake_animation_exec(C, op); 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"); AUD_Container container = RNA_enum_get(op->ptr, "container");
const char* extension = NULL; const char *extension = NULL;
EnumPropertyItem* item = container_items; EnumPropertyItem *item = container_items;
while(item->identifier != NULL) while (item->identifier != NULL) {
{ if (item->value == container) {
if(item->value == container) const char **ext = snd_ext_sound;
{ while (*ext != NULL) {
const char** ext = snd_ext_sound; if (!strcmp(*ext + 1, item->name)) {
while(*ext != NULL)
{
if(!strcmp(*ext + 1, item->name))
{
extension = *ext; extension = *ext;
break; break;
} }
@ -424,12 +420,12 @@ static int sound_mixdown_check(bContext *UNUSED(C), wmOperator *op)
prop = RNA_struct_find_property(op->ptr, "filepath"); prop = RNA_struct_find_property(op->ptr, "filepath");
RNA_property_string_get(op->ptr, prop, 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); check = BLI_replace_extension(filepath, FILE_MAX, extension);
else else
check = BLI_ensure_extension(filepath, FILE_MAX, extension); check = BLI_ensure_extension(filepath, FILE_MAX, extension);
if(!check) if (!check)
return check; return check;
RNA_property_string_set(op->ptr, prop, filepath); 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) static int sound_mixdown_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
{ {
const char *prop_id= RNA_property_identifier(prop); const char *prop_id = RNA_property_identifier(prop);
return !( strcmp(prop_id, "filepath") == 0 || return !(strcmp(prop_id, "filepath") == 0 ||
strcmp(prop_id, "directory") == 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) 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_S32, "S32", 0, "S32", "32 bit signed"},
{AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"}, {AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"},
{AUD_FORMAT_FLOAT64, "F64", 0, "F64", "64 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[] = { static EnumPropertyItem mp3_format_items[] = {
{AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"},
{AUD_FORMAT_S32, "S32", 0, "S32", "32 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[] = { static EnumPropertyItem ac3_format_items[] = {
{AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"},
{AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"}, {AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
#ifdef WITH_SNDFILE #ifdef WITH_SNDFILE
static EnumPropertyItem flac_format_items[] = { static EnumPropertyItem flac_format_items[] = {
{AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"},
{AUD_FORMAT_S24, "S24", 0, "S24", "24 bit signed"}, {AUD_FORMAT_S24, "S24", 0, "S24", "24 bit signed"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
#endif #endif
static EnumPropertyItem all_codec_items[] = { 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_MP3, "MP3", 0, "MP3", "MPEG-2 Audio Layer III"},
{AUD_CODEC_PCM, "PCM", 0, "PCM", "Pulse Code Modulation (RAW)"}, {AUD_CODEC_PCM, "PCM", 0, "PCM", "Pulse Code Modulation (RAW)"},
{AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"}, {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[] = { static EnumPropertyItem ogg_codec_items[] = {
{AUD_CODEC_FLAC, "FLAC", 0, "FLAC", "Free Lossless Audio Codec"}, {AUD_CODEC_FLAC, "FLAC", 0, "FLAC", "Free Lossless Audio Codec"},
{AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis 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; uiLayout *layout = op->layout;
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
PointerRNA ptr; PointerRNA ptr;
PropertyRNA *prop_format; PropertyRNA *prop_format;
PropertyRNA *prop_codec; 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_S32, "S32", 0, "S32", "32 bit signed"},
{AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"}, {AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"},
{AUD_FORMAT_FLOAT64, "F64", 0, "F64", "64 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[] = { static EnumPropertyItem codec_items[] = {
#ifdef WITH_FFMPEG #ifdef WITH_FFMPEG
@ -635,7 +637,8 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
#endif #endif
{AUD_CODEC_PCM, "PCM", 0, "PCM", "Pulse Code Modulation (RAW)"}, {AUD_CODEC_PCM, "PCM", 0, "PCM", "Pulse Code Modulation (RAW)"},
{AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"}, {AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
#endif // WITH_AUDASPACE #endif // WITH_AUDASPACE
@ -671,7 +674,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
static int sound_poll(bContext *C) 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) if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND)
return 0; return 0;
@ -682,9 +685,9 @@ static int sound_poll(bContext *C)
static int sound_pack_exec(bContext *C, wmOperator *op) static int sound_pack_exec(bContext *C, wmOperator *op)
{ {
Main *bmain= CTX_data_main(C); Main *bmain = CTX_data_main(C);
Editing* ed = CTX_data_scene(C)->ed; Editing *ed = CTX_data_scene(C)->ed;
bSound* sound; bSound *sound;
if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND) if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND)
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
@ -694,7 +697,7 @@ static int sound_pack_exec(bContext *C, wmOperator *op)
if (!sound || sound->packedfile) if (!sound || sound->packedfile)
return OPERATOR_CANCELLED; 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); sound_load(CTX_data_main(C), sound);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -712,19 +715,19 @@ static void SOUND_OT_pack(wmOperatorType *ot)
ot->poll = sound_poll; ot->poll = sound_poll;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
} }
/********************* unpack operator *********************/ /********************* unpack operator *********************/
static int sound_unpack_exec(bContext *C, wmOperator *op) static int sound_unpack_exec(bContext *C, wmOperator *op)
{ {
int method= RNA_enum_get(op->ptr, "method"); int method = RNA_enum_get(op->ptr, "method");
bSound* sound= NULL; bSound *sound = NULL;
/* find the suppplied image by name */ /* find the suppplied image by name */
if (RNA_struct_property_is_set(op->ptr, "id")) { 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); RNA_string_get(op->ptr, "id", sndname);
sound = BLI_findstring(&CTX_data_main(C)->sound, sndname, offsetof(ID, name) + 2); 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)) static int sound_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{ {
Editing* ed = CTX_data_scene(C)->ed; Editing *ed = CTX_data_scene(C)->ed;
bSound* sound; bSound *sound;
if (RNA_struct_property_is_set(op->ptr, "id")) if (RNA_struct_property_is_set(op->ptr, "id"))
return sound_unpack_exec(C, op); 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) if (G.fileflags & G_AUTOPACK)
BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save"); 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; return OPERATOR_FINISHED;
} }
@ -777,11 +780,11 @@ static void SOUND_OT_unpack(wmOperatorType *ot)
ot->poll = sound_poll; ot->poll = sound_poll;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */ /* properties */
RNA_def_enum(ot->srna, "method", unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack"); 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 */
} }
/* ******************************************************* */ /* ******************************************************* */