re-attempt at workaround for vector<Mix_Chunk*> deletion error
feel free to submit a "real fix"
This commit is contained in:
parent
8211e46f91
commit
a32b17aed1
3 changed files with 7 additions and 36 deletions
26
src/game.cpp
26
src/game.cpp
|
@ -130,7 +130,6 @@ private:
|
|||
|
||||
const font::manager font_manager_;
|
||||
const preferences::manager prefs_manager_;
|
||||
const sound::manager sound_manager_;
|
||||
const image::manager image_manager_;
|
||||
const events::event_context main_event_context_;
|
||||
const hotkey::manager hotkey_manager_;
|
||||
|
@ -1622,26 +1621,13 @@ extern threading::mutex channel_mutex;
|
|||
game_controller::~game_controller()
|
||||
{
|
||||
delete gui::empty_menu;
|
||||
threading::lock l(sound::channel_mutex);
|
||||
sound::close_sound();
|
||||
{
|
||||
int deletion_errs = 0;
|
||||
while (sound::channel_chunks->size() > deletion_errs) {
|
||||
try {
|
||||
sound::channel_chunks->erase(sound::channel_chunks->end() - deletion_errs - 1);
|
||||
} catch(...) {
|
||||
++deletion_errs;
|
||||
}
|
||||
}
|
||||
if(deletion_errs > 0)
|
||||
{
|
||||
std::cerr << "Unable to delete some Mix_Chunk*, count was " << deletion_errs << ".\n";
|
||||
} else {
|
||||
try {
|
||||
delete sound::channel_chunks;
|
||||
} catch(...) {
|
||||
std::cerr << "Unable to delete empty std::vector<Mix_Chunk*> sound::channel_chunks.\n";
|
||||
}
|
||||
}
|
||||
threading::lock l(sound::channel_mutex);
|
||||
sound::channel_chunks->clear();
|
||||
/*
|
||||
delete sound::channel_chunks; //FIXME: sometimes crashes
|
||||
*/
|
||||
sound::channel_chunks = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -250,16 +250,6 @@ void channel_finished_hook(int channel)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
manager::manager()
|
||||
{
|
||||
}
|
||||
|
||||
manager::~manager()
|
||||
{
|
||||
close_sound();
|
||||
}
|
||||
|
||||
bool init_sound() {
|
||||
|
||||
if(SDL_WasInit(SDL_INIT_AUDIO) == 0)
|
||||
|
@ -277,7 +267,7 @@ bool init_sound() {
|
|||
Mix_AllocateChannels(n_of_channels);
|
||||
Mix_ReserveChannels(n_reserved_channels);
|
||||
|
||||
channel_chunks = new std::vector<Mix_Chunk*>(n_of_channels, 0);
|
||||
channel_chunks = new std::vector<Mix_Chunk*>(n_of_channels, NULL);
|
||||
channel_ids.resize(source_channels, -1);
|
||||
|
||||
const size_t source_channel_last = source_channels - source_channel_start + 1;
|
||||
|
|
|
@ -19,11 +19,6 @@
|
|||
|
||||
namespace sound {
|
||||
|
||||
struct manager {
|
||||
manager();
|
||||
~manager();
|
||||
};
|
||||
|
||||
bool init_sound();
|
||||
void close_sound();
|
||||
void reset_sound();
|
||||
|
|
Loading…
Add table
Reference in a new issue