- char* samples = new char[file->size];
- try {
- file->read(samples, file->size);
- alBufferData(buffer, format, samples,
- static_cast<ALsizei> (file->size),
- static_cast<ALsizei> (file->rate));
- check_al_error("Couldn't fill audio buffer: ");
- } catch(...) {
- delete[] samples;
- throw;
- }
- delete[] samples;
+ std::unique_ptr<char[]> samples(new char[file.size]);
+ file.read(samples.get(), file.size);
+ alBufferData(buffer, format, samples.get(),
+ static_cast<ALsizei>(file.size),
+ static_cast<ALsizei>(file.rate));
+ check_al_error("Couldn't fill audio buffer: ");