X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flibgame%2Fsdl.c;h=4108b2b531c533825c092df0ceab9fb1fd596d90;hb=refs%2Fheads%2Fmaster-next-major-release;hp=76c70cc4a66e6b2d3d8ee27c9b1261b5330197da;hpb=0196637b0c226707f177cf52c7c1182bf08e7956;p=rocksndiamonds.git diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 76c70cc4..d664eecc 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -502,7 +502,7 @@ SDL_Surface *SDLCreateNativeSurface(int width, int height, int depth) return surface; } -Bitmap *SDLGetBitmapFromSurface(SDL_Surface *surface) +Bitmap *SDLGetBitmapFromSurface_WithMaskedColor(SDL_Surface *surface, int r, int g, int b) { int width = surface->w; int height = surface->h; @@ -522,11 +522,16 @@ Bitmap *SDLGetBitmapFromSurface(SDL_Surface *surface) if (!SDLHasAlpha(bitmap->surface_masked) && !SDLHasColorKey(bitmap->surface_masked)) SDL_SetColorKey(bitmap->surface_masked, SET_TRANSPARENT_PIXEL, - SDL_MapRGB(bitmap->surface_masked->format, 0x00, 0x00, 0x00)); + SDL_MapRGB(bitmap->surface_masked->format, r, g, b)); return bitmap; } +Bitmap *SDLGetBitmapFromSurface(SDL_Surface *surface) +{ + return SDLGetBitmapFromSurface_WithMaskedColor(surface, 0x00, 0x00, 0x00); +} + static SDL_Texture *SDLCreateTextureFromSurface(SDL_Surface *surface) { if (program.headless) @@ -2512,8 +2517,10 @@ void SDLOpenAudio(void) return; } - if (Mix_OpenAudio(DEFAULT_AUDIO_SAMPLE_RATE, MIX_DEFAULT_FORMAT, - AUDIO_NUM_CHANNELS_STEREO, + // set audio sample rate for mixer + audio.sample_rate = (setup.audio_sample_rate_44100 ? 44100 : 22050); + + if (Mix_OpenAudio(audio.sample_rate, MIX_DEFAULT_FORMAT, AUDIO_NUM_CHANNELS_STEREO, setup.system.audio_fragment_size) < 0) { Warn("Mix_OpenAudio() failed: %s", SDL_GetError()); @@ -2543,6 +2550,12 @@ void SDLCloseAudio(void) SDL_QuitSubSystem(SDL_INIT_AUDIO); } +void SDLReopenAudio(void) +{ + SDLCloseAudio(); + SDLOpenAudio(); +} + // ============================================================================ // event functions