@@ -32,6 +32,7 @@ struct sfxEffect {
32
32
const char * name ;
33
33
void * buffer ;
34
34
int size ;
35
+ int builtin ;
35
36
};
36
37
37
38
static struct sfxEffect sfx_files [SFX_COUNT ] = {
@@ -85,6 +86,7 @@ static int sfxRead(const char *full_path, struct sfxEffect *sfx)
85
86
86
87
sfx -> buffer = buffer ;
87
88
sfx -> size = size ;
89
+ sfx -> builtin = 0 ;
88
90
89
91
return 0 ;
90
92
}
@@ -93,16 +95,22 @@ static void sfxInitDefaults(void)
93
95
{
94
96
sfx_files [SFX_BOOT ].buffer = boot_adp ;
95
97
sfx_files [SFX_BOOT ].size = size_boot_adp ;
98
+ sfx_files [SFX_BOOT ].builtin = 1 ;
96
99
sfx_files [SFX_CANCEL ].buffer = cancel_adp ;
97
100
sfx_files [SFX_CANCEL ].size = size_cancel_adp ;
101
+ sfx_files [SFX_CANCEL ].builtin = 1 ;
98
102
sfx_files [SFX_CONFIRM ].buffer = confirm_adp ;
99
103
sfx_files [SFX_CONFIRM ].size = size_confirm_adp ;
104
+ sfx_files [SFX_CONFIRM ].builtin = 1 ;
100
105
sfx_files [SFX_CURSOR ].buffer = cursor_adp ;
101
106
sfx_files [SFX_CURSOR ].size = size_cursor_adp ;
107
+ sfx_files [SFX_CURSOR ].builtin = 1 ;
102
108
sfx_files [SFX_MESSAGE ].buffer = message_adp ;
103
109
sfx_files [SFX_MESSAGE ].size = size_message_adp ;
110
+ sfx_files [SFX_MESSAGE ].builtin = 1 ;
104
111
sfx_files [SFX_TRANSITION ].buffer = transition_adp ;
105
112
sfx_files [SFX_TRANSITION ].size = size_transition_adp ;
113
+ sfx_files [SFX_TRANSITION ].builtin = 1 ;
106
114
}
107
115
108
116
//Returns 0 (AUDSRV_ERR_NOERROR) if the sound was loaded successfully.
@@ -111,8 +119,10 @@ static int sfxLoad(struct sfxEffect *sfxData, audsrv_adpcm_t *sfx)
111
119
int ret ;
112
120
113
121
ret = audsrv_load_adpcm (sfx , sfxData -> buffer , sfxData -> size );
114
- free (sfxData -> buffer );
115
- sfxData -> buffer = NULL ; //Mark the buffer as freed.
122
+ if (sfxData -> builtin == 0 ) {
123
+ free (sfxData -> buffer );
124
+ sfxData -> buffer = NULL ; //Mark the buffer as freed.
125
+ }
116
126
117
127
return ret ;
118
128
}
0 commit comments