aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llaudio/vorbisencode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llaudio/vorbisencode.cpp')
-rw-r--r--linden/indra/llaudio/vorbisencode.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/linden/indra/llaudio/vorbisencode.cpp b/linden/indra/llaudio/vorbisencode.cpp
index 805e666..3a107b9 100644
--- a/linden/indra/llaudio/vorbisencode.cpp
+++ b/linden/indra/llaudio/vorbisencode.cpp
@@ -70,7 +70,7 @@
70 70
71#endif 71#endif
72 72
73S32 check_for_invalid_wav_formats(const char *in_fname, char *error_msg) 73S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& error_msg)
74{ 74{
75 U16 num_channels = 0; 75 U16 num_channels = 0;
76 U32 sample_rate = 0; 76 U32 sample_rate = 0;
@@ -83,12 +83,12 @@ S32 check_for_invalid_wav_formats(const char *in_fname, char *error_msg)
83 83
84 unsigned char wav_header[44]; /*Flawfinder: ignore*/ 84 unsigned char wav_header[44]; /*Flawfinder: ignore*/
85 85
86 error_msg[0] = '\0'; 86 error_msg.clear();
87 87
88 apr_file_t* infp = ll_apr_file_open(in_fname,LL_APR_RB); 88 apr_file_t* infp = ll_apr_file_open(in_fname,LL_APR_RB);
89 if (!infp) 89 if (!infp)
90 { 90 {
91 strcpy(error_msg, "CannotUploadSoundFile"); /*Flawfinder: ignore*/ 91 error_msg = "CannotUploadSoundFile";
92 return(LLVORBISENC_SOURCE_OPEN_ERR); 92 return(LLVORBISENC_SOURCE_OPEN_ERR);
93 } 93 }
94 94
@@ -97,14 +97,14 @@ S32 check_for_invalid_wav_formats(const char *in_fname, char *error_msg)
97 97
98 if (strncmp((char *)&(wav_header[0]),"RIFF",4)) 98 if (strncmp((char *)&(wav_header[0]),"RIFF",4))
99 { 99 {
100 strcpy(error_msg, "SoundFileNotRIFF"); /*Flawfinder: ignore*/ 100 error_msg = "SoundFileNotRIFF";
101 apr_file_close(infp); 101 apr_file_close(infp);
102 return(LLVORBISENC_WAV_FORMAT_ERR); 102 return(LLVORBISENC_WAV_FORMAT_ERR);
103 } 103 }
104 104
105 if (strncmp((char *)&(wav_header[8]),"WAVE",4)) 105 if (strncmp((char *)&(wav_header[8]),"WAVE",4))
106 { 106 {
107 strcpy(error_msg, "SoundFileNotRIFF"); /*Flawfinder: ignore*/ 107 error_msg = "SoundFileNotRIFF";
108 apr_file_close(infp); 108 apr_file_close(infp);
109 return(LLVORBISENC_WAV_FORMAT_ERR); 109 return(LLVORBISENC_WAV_FORMAT_ERR);
110 } 110 }
@@ -154,31 +154,31 @@ S32 check_for_invalid_wav_formats(const char *in_fname, char *error_msg)
154 154
155 if (!uncompressed_pcm) 155 if (!uncompressed_pcm)
156 { 156 {
157 strcpy(error_msg, "SoundFileNotPCM"); /*Flawfinder: ignore*/ 157 error_msg = "SoundFileNotPCM";
158 return(LLVORBISENC_PCM_FORMAT_ERR); 158 return(LLVORBISENC_PCM_FORMAT_ERR);
159 } 159 }
160 160
161 if ((num_channels < 1) || (num_channels > 2)) 161 if ((num_channels < 1) || (num_channels > 2))
162 { 162 {
163 strcpy(error_msg, "SoundFileInvalidChannelCount"); /*Flawfinder: ignore*/ 163 error_msg = "SoundFileInvalidChannelCount";
164 return(LLVORBISENC_MULTICHANNEL_ERR); 164 return(LLVORBISENC_MULTICHANNEL_ERR);
165 } 165 }
166 166
167 if (sample_rate != 44100) 167 if (sample_rate != 44100)
168 { 168 {
169 strcpy(error_msg, "SoundFileInvalidSampleRate"); /*Flawfinder: ignore*/ 169 error_msg = "SoundFileInvalidSampleRate";
170 return(LLVORBISENC_UNSUPPORTED_SAMPLE_RATE); 170 return(LLVORBISENC_UNSUPPORTED_SAMPLE_RATE);
171 } 171 }
172 172
173 if ((bits_per_sample != 16) && (bits_per_sample != 8)) 173 if ((bits_per_sample != 16) && (bits_per_sample != 8))
174 { 174 {
175 strcpy(error_msg, "SoundFileInvalidWordSize"); /*Flawfinder: ignore*/ 175 error_msg = "SoundFileInvalidWordSize";
176 return(LLVORBISENC_UNSUPPORTED_WORD_SIZE); 176 return(LLVORBISENC_UNSUPPORTED_WORD_SIZE);
177 } 177 }
178 178
179 if (!raw_data_length) 179 if (!raw_data_length)
180 { 180 {
181 strcpy(error_msg, "SoundFileInvalidHeader"); /*Flawfinder: ignore*/ 181 error_msg = "SoundFileInvalidHeader";
182 return(LLVORBISENC_CLIP_TOO_LONG); 182 return(LLVORBISENC_CLIP_TOO_LONG);
183 } 183 }
184 184
@@ -186,14 +186,14 @@ S32 check_for_invalid_wav_formats(const char *in_fname, char *error_msg)
186 186
187 if (clip_length > 10.0f) 187 if (clip_length > 10.0f)
188 { 188 {
189 strcpy(error_msg, "SoundFileInvalidTooLong"); /*Flawfinder: ignore*/ 189 error_msg = "SoundFileInvalidTooLong";
190 return(LLVORBISENC_CLIP_TOO_LONG); 190 return(LLVORBISENC_CLIP_TOO_LONG);
191 } 191 }
192 192
193 return(LLVORBISENC_NOERR); 193 return(LLVORBISENC_NOERR);
194} 194}
195 195
196S32 encode_vorbis_file(const char *in_fname, const char *out_fname) 196S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname)
197{ 197{
198#define READ_BUFFER 1024 198#define READ_BUFFER 1024
199 unsigned char readbuffer[READ_BUFFER*4+44]; /* out of the data segment, not the stack */ /*Flawfinder: ignore*/ 199 unsigned char readbuffer[READ_BUFFER*4+44]; /* out of the data segment, not the stack */ /*Flawfinder: ignore*/
@@ -216,7 +216,7 @@ S32 encode_vorbis_file(const char *in_fname, const char *out_fname)
216 U32 bits_per_sample = 0; 216 U32 bits_per_sample = 0;
217 217
218 S32 format_error = 0; 218 S32 format_error = 0;
219 char error_msg[MAX_STRING]; /*Flawfinder: ignore*/ 219 std::string error_msg;
220 if ((format_error = check_for_invalid_wav_formats(in_fname, error_msg))) 220 if ((format_error = check_for_invalid_wav_formats(in_fname, error_msg)))
221 { 221 {
222 llwarns << error_msg << ": " << in_fname << llendl; 222 llwarns << error_msg << ": " << in_fname << llendl;