From: Peter W. <tj...@us...> - 2013-04-28 06:45:22
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Allegro". The branch, 5.1 has been updated via 36054d04c680a9a01a06d8c206dbaff7433978bf (commit) via 44b34a510888f5d99881fbafc07ac78ffea53d37 (commit) via 1f281a0dcc65b29111f5c937a7e0c2d96fe67e4d (commit) via d6008af4a48d4c50458d36d3915580c3e5dc6efb (commit) via 6bff0a674a2de95d0ca654d07d4ac345dd811601 (commit) via 80fd9ae9493b858efc57f4549c293cb038d4c2e5 (commit) via a34b88a7704ae747a005b4238a2c38a6db05a00f (commit) from d55f2ce66997282cc8a4e08f4c7657d9671d6eaa (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 36054d04c680a9a01a06d8c206dbaff7433978bf Author: Peter Wang <tj...@us...> Date: Sun Apr 28 10:54:16 2013 +1000 pulseaudio: Use smaller buffer size by default, and make it configurable. The old default of 4096 was lags badly in ex_audio_timer. I considered generalising it to an audio.buffer_size setting but I'm not sure that it make sense. commit 44b34a510888f5d99881fbafc07ac78ffea53d37 Author: Peter Wang <tj...@us...> Date: Sun Apr 28 10:30:55 2013 +1000 pulseaudio: Clean up state transitions. commit 1f281a0dcc65b29111f5c937a7e0c2d96fe67e4d Author: Peter Wang <tj...@us...> Date: Sun Apr 28 10:10:52 2013 +1000 pulseaudio: Minor cleanups. commit d6008af4a48d4c50458d36d3915580c3e5dc6efb Author: Peter Wang <tj...@us...> Date: Sat Apr 27 11:30:35 2013 +1000 ex_audio_timer: Add new example. commit 6bff0a674a2de95d0ca654d07d4ac345dd811601 Author: Peter Wang <tj...@us...> Date: Sun Apr 28 11:24:24 2013 +1000 speed: Draw circles with 0.5 offset from integer coordinates. Also use thickness 1 instead of 0 for circle outline. commit 80fd9ae9493b858efc57f4549c293cb038d4c2e5 Author: Peter Wang <tj...@us...> Date: Sun Apr 28 11:15:36 2013 +1000 speed: Don't need a4_font.tga any longer. commit a34b88a7704ae747a005b4238a2c38a6db05a00f Author: Peter Wang <tj...@us...> Date: Sun Apr 28 16:34:26 2013 +1000 Make al_destroy_bitmap REALLY maintain the current display when untargeting the bitmap to be destroyed. This was previously incorrect for memory bitmaps. ----------------------------------------------------------------------- Summary of changes: addons/audio/pulseaudio.c | 180 ++++++++++++++++++++++++++++++++------------ allegro5.cfg | 5 + demos/speed/CMakeLists.txt | 14 +--- demos/speed/a4_aux.c | 16 ++++ demos/speed/a4_aux.h | 2 + demos/speed/explode.c | 6 +- examples/CMakeLists.txt | 1 + examples/ex_audio_timer.c | 167 ++++++++++++++++++++++++++++++++++++++++ src/bitmap.c | 2 +- 9 files changed, 328 insertions(+), 65 deletions(-) create mode 100644 examples/ex_audio_timer.c diff --git a/addons/audio/pulseaudio.c b/addons/audio/pulseaudio.c index b90c515..df1bb6f 100644 --- a/addons/audio/pulseaudio.c +++ b/addons/audio/pulseaudio.c @@ -26,28 +26,58 @@ ALLEGRO_DEBUG_CHANNEL("PulseAudio") +enum PULSEAUDIO_VOICE_STATUS { + PV_IDLE, + PV_PLAYING, + PV_STOPPING, + PV_JOIN +}; + typedef struct PULSEAUDIO_VOICE { - pa_simple *s; - ALLEGRO_THREAD *poll_thread; + pa_simple *s; + unsigned int buffer_size_in_frames; + unsigned int frame_size_in_bytes; + + ALLEGRO_THREAD *poll_thread; + ALLEGRO_MUTEX *status_mutex; + ALLEGRO_COND *status_cond; + enum PULSEAUDIO_VOICE_STATUS status; + + // direct buffer (non-streaming): + ALLEGRO_MUTEX *buffer_mutex; + char *buffer; + char *buffer_end; +} PULSEAUDIO_VOICE; - volatile enum { PV_PLAYING, PV_STOPPING, PV_STOPPED } status; +#define DEFAULT_BUFFER_SIZE 1024 +#define MIN_BUFFER_SIZE 128 - int frame_size; // number of bytes per frame +static unsigned int get_buffer_size(const ALLEGRO_CONFIG *config) +{ + if (config) { + const char *val = al_get_config_value(config, + "pulseaudio", "buffer_size"); + if (val && val[0] != '\0') { + int n = atoi(val); + if (n < MIN_BUFFER_SIZE) + n = MIN_BUFFER_SIZE; + return n; + } + } - // direct buffer (non-streaming): - ALLEGRO_MUTEX *buffer_mutex; - char *buffer, *buffer_end; - -} PULSEAUDIO_VOICE; + return DEFAULT_BUFFER_SIZE; +} static void sink_info_cb(pa_context *c, const pa_sink_info *i, int eol, void *userdata) { (void)c; (void)eol; + pa_sink_state_t *ret = userdata; - if (!i) return; + if (!i) + return; *ret = i->state; } @@ -77,7 +107,7 @@ static int pulseaudio_open(void) while (1) { /* Don't block or it will hang if there is no server to connect to. */ - const bool blocking = 0; + const int blocking = 0; if (pa_mainloop_iterate(mainloop, blocking, NULL) < 0) { ALLEGRO_ERROR("pa_mainloop_iterate failed\n"); pa_context_disconnect(c); @@ -98,8 +128,7 @@ static int pulseaudio_open(void) } pa_sink_state_t state = 0; - pa_operation *op = pa_context_get_sink_info_list(c, sink_info_cb, - &state); + pa_operation *op = pa_context_get_sink_info_list(c, sink_info_cb, &state); while (pa_operation_get_state(op) == PA_OPERATION_RUNNING) { pa_mainloop_iterate(mainloop, 1, NULL); } @@ -123,29 +152,46 @@ static void *pulseaudio_update(ALLEGRO_THREAD *self, void *data) { ALLEGRO_VOICE *voice = data; PULSEAUDIO_VOICE *pv = voice->extra; + (void)self; + + for (;;) { + enum PULSEAUDIO_VOICE_STATUS status; + + al_lock_mutex(pv->status_mutex); + while ((status = pv->status) == PV_IDLE) { + al_wait_cond(pv->status_cond, pv->status_mutex); + } + al_unlock_mutex(pv->status_mutex); + + if (status == PV_JOIN) { + break; + } - while (!al_get_thread_should_stop(self)) { - if (pv->status == PV_PLAYING) { - unsigned int frames = 4096; + if (status == PV_PLAYING) { + unsigned int frames = pv->buffer_size_in_frames; if (voice->is_streaming) { // streaming audio const void *data = _al_voice_update(voice, &frames); if (data) { - pa_simple_write(pv->s, data, frames * pv->frame_size, NULL); + pa_simple_write(pv->s, data, + frames * pv->frame_size_in_bytes, NULL); } } else { // direct buffer audio al_lock_mutex(pv->buffer_mutex); const char *data = pv->buffer; - unsigned int len = frames * pv->frame_size; - pv->buffer += frames * pv->frame_size; + unsigned int len = frames * pv->frame_size_in_bytes; + pv->buffer += frames * pv->frame_size_in_bytes; if (pv->buffer > pv->buffer_end) { len = pv->buffer_end - data; pv->buffer = voice->attached_stream->spl_data.buffer.ptr; voice->attached_stream->pos = 0; if (voice->attached_stream->loop == ALLEGRO_PLAYMODE_ONCE) { + al_lock_mutex(pv->status_mutex); pv->status = PV_STOPPING; + al_broadcast_cond(pv->status_cond); + al_unlock_mutex(pv->status_mutex); } } else { @@ -156,12 +202,12 @@ static void *pulseaudio_update(ALLEGRO_THREAD *self, void *data) pa_simple_write(pv->s, data, len, NULL); } } - else if (pv->status == PV_STOPPING) { + else if (status == PV_STOPPING) { pa_simple_flush(pv->s, NULL); - pv->status = PV_STOPPED; - } - else if (pv->status == PV_STOPPED) { - al_rest(0.001); + al_lock_mutex(pv->status_mutex); + pv->status = PV_IDLE; + al_broadcast_cond(pv->status_cond); + al_unlock_mutex(pv->status_mutex); } } @@ -199,15 +245,16 @@ static int pulseaudio_allocate_voice(ALLEGRO_VOICE *voice) ba.minreq = 0; // minimum size of request ba.fragsize = -1; // fragment size (recording) - pv->s = pa_simple_new(NULL, // Use the default server. - al_get_app_name(), - PA_STREAM_PLAYBACK, - NULL, // Use the default device. - "Allegro Voice", - &ss, - NULL, // Use default channel map - &ba, - NULL // Ignore error code. + pv->s = pa_simple_new( + NULL, // Use the default server. + al_get_app_name(), + PA_STREAM_PLAYBACK, + NULL, // Use the default device. + "Allegro Voice", + &ss, + NULL, // Use default channel map + &ba, + NULL // Ignore error code. ); if (!pv->s) { @@ -217,8 +264,12 @@ static int pulseaudio_allocate_voice(ALLEGRO_VOICE *voice) voice->extra = pv; - pv->frame_size = ss.channels * al_get_audio_depth_size(voice->depth); - pv->status = PV_STOPPED; + pv->buffer_size_in_frames = get_buffer_size(al_get_system_config()); + pv->frame_size_in_bytes = ss.channels * al_get_audio_depth_size(voice->depth); + + pv->status = PV_IDLE; + pv->status_mutex = al_create_mutex(); + pv->status_cond = al_create_cond(); pv->buffer_mutex = al_create_mutex(); pv->poll_thread = al_create_thread(pulseaudio_update, (void*)voice); @@ -231,13 +282,19 @@ static void pulseaudio_deallocate_voice(ALLEGRO_VOICE *voice) { PULSEAUDIO_VOICE *pv = voice->extra; + al_lock_mutex(pv->status_mutex); + pv->status = PV_JOIN; + al_broadcast_cond(pv->status_cond); + al_unlock_mutex(pv->status_mutex); + /* We do NOT hold the voice mutex here, so this does NOT result in a * deadlock when the thread calls _al_voice_update. */ - al_set_thread_should_stop(pv->poll_thread); al_join_thread(pv->poll_thread, NULL); al_destroy_thread(pv->poll_thread); + al_destroy_mutex(pv->status_mutex); + al_destroy_cond(pv->status_cond); al_destroy_mutex(pv->buffer_mutex); pa_simple_free(pv->s); @@ -247,6 +304,7 @@ static void pulseaudio_deallocate_voice(ALLEGRO_VOICE *voice) static int pulseaudio_load_voice(ALLEGRO_VOICE *voice, const void *data) { PULSEAUDIO_VOICE *pv = voice->extra; + (void)data; if (voice->attached_stream->loop == ALLEGRO_PLAYMODE_BIDIR) { ALLEGRO_INFO("Backwards playing not supported by the driver.\n"); @@ -256,10 +314,10 @@ static int pulseaudio_load_voice(ALLEGRO_VOICE *voice, const void *data) voice->attached_stream->pos = 0; pv->buffer = voice->attached_stream->spl_data.buffer.ptr; - pv->buffer_end = pv->buffer + (voice->attached_stream->spl_data.len) * pv->frame_size; + pv->buffer_end = pv->buffer + + (voice->attached_stream->spl_data.len) * pv->frame_size_in_bytes; return 0; - (void)data; } static void pulseaudio_unload_voice(ALLEGRO_VOICE *voice) @@ -270,27 +328,52 @@ static void pulseaudio_unload_voice(ALLEGRO_VOICE *voice) static int pulseaudio_start_voice(ALLEGRO_VOICE *voice) { PULSEAUDIO_VOICE *pv = voice->extra; - pv->status = PV_PLAYING; - - return 0; + int ret; + + al_lock_mutex(pv->status_mutex); + if (pv->status == PV_IDLE) { + pv->status = PV_PLAYING; + al_broadcast_cond(pv->status_cond); + ret = 0; + } + else { + ret = 1; + } + al_unlock_mutex(pv->status_mutex); + + return ret; } static int pulseaudio_stop_voice(ALLEGRO_VOICE *voice) { PULSEAUDIO_VOICE *pv = voice->extra; - pv->status = PV_STOPPING; - while (pv->status == PV_STOPPING) { - al_rest(0.001); + al_lock_mutex(pv->status_mutex); + + if (pv->status == PV_PLAYING) { + pv->status = PV_STOPPING; + al_broadcast_cond(pv->status_cond); } - + + while (pv->status != PV_IDLE) { + al_wait_cond(pv->status_cond, pv->status_mutex); + } + + al_unlock_mutex(pv->status_mutex); + return 0; } static bool pulseaudio_voice_is_playing(const ALLEGRO_VOICE *voice) { PULSEAUDIO_VOICE *pv = voice->extra; - return pv->status == PV_PLAYING; + enum PULSEAUDIO_VOICE_STATUS status; + + al_lock_mutex(pv->status_mutex); + status = pv->status; + al_unlock_mutex(pv->status_mutex); + + return (status == PV_PLAYING); } static unsigned int pulseaudio_get_voice_position(const ALLEGRO_VOICE *voice) @@ -303,10 +386,11 @@ static int pulseaudio_set_voice_position(ALLEGRO_VOICE *voice, unsigned int pos) PULSEAUDIO_VOICE *pv = voice->extra; pa_simple_drain(pv->s, NULL); - + al_lock_mutex(pv->buffer_mutex); voice->attached_stream->pos = pos; - pv->buffer = (char*)voice->attached_stream->spl_data.buffer.ptr + pos * pv->frame_size; + pv->buffer = (char *)voice->attached_stream->spl_data.buffer.ptr + + pos * pv->frame_size_in_bytes; al_unlock_mutex(pv->buffer_mutex); return 0; diff --git a/allegro5.cfg b/allegro5.cfg index ea241c8..04eeab4 100644 --- a/allegro5.cfg +++ b/allegro5.cfg @@ -62,6 +62,11 @@ device=default # Default is 'default'. capture_device=default +[pulseaudio] + +# Set the buffer size (in samples) +buffer_size=1024 + [directsound] # Set the DirectSound buffer size (in samples) diff --git a/demos/speed/CMakeLists.txt b/demos/speed/CMakeLists.txt index b5e7f4c..2e971da 100644 --- a/demos/speed/CMakeLists.txt +++ b/demos/speed/CMakeLists.txt @@ -20,8 +20,6 @@ set(SPEED_SRCS view.c ) -set(A4_FONT ${CMAKE_CURRENT_BINARY_DIR}/a4_font.tga) - if(NOT SUPPORT_AUDIO OR NOT SUPPORT_PRIMITIVES OR NOT SUPPORT_FONT) message(STATUS "Not building SPEED") return() @@ -38,7 +36,7 @@ else(APPLE) set(DEMO_EXECUTABLE_TYPE "${EXECUTABLE_TYPE}") endif(APPLE) -add_executable(speed ${DEMO_EXECUTABLE_TYPE} ${SPEED_SRCS} ${A4_FONT}) +add_executable(speed ${DEMO_EXECUTABLE_TYPE} ${SPEED_SRCS}) fix_executable(speed) @@ -59,15 +57,5 @@ if(NOT BUILD_SHARED_LIBS) set_target_properties(speed PROPERTIES COMPILE_FLAGS "-DALLEGRO_STATICLINK") endif(NOT BUILD_SHARED_LIBS) -set_source_files_properties(${A4_FONT} PROPERTIES - MACOSX_PACKAGE_LOCATION "Resources" -) - -add_custom_command( - OUTPUT ${A4_FONT} - COMMAND "${CMAKE_COMMAND}" -E copy - "${CMAKE_SOURCE_DIR}/examples/data/a4_font.tga" ${A4_FONT} - ) - #-----------------------------------------------------------------------------# # vim: set ts=8 sts=4 sw=4 et: diff --git a/demos/speed/a4_aux.c b/demos/speed/a4_aux.c index 4a82f80..e218043 100644 --- a/demos/speed/a4_aux.c +++ b/demos/speed/a4_aux.c @@ -326,6 +326,22 @@ void rectfill(int x1, int y1, int x2, int y2, ALLEGRO_COLOR color) +/* emulate circle() */ +void circle(int x, int y, int radius, ALLEGRO_COLOR color) +{ + al_draw_circle(x+0.5, y+0.5, radius, color, 1); +} + + + +/* emulate circlefill() */ +void circlefill(int x, int y, int radius, ALLEGRO_COLOR color) +{ + al_draw_filled_circle(x+0.5, y+0.5, radius, color); +} + + + /* emulate stretch_sprite() */ void stretch_sprite(ALLEGRO_BITMAP *bmp, ALLEGRO_BITMAP *sprite, int x, int y, int w, int h) diff --git a/demos/speed/a4_aux.h b/demos/speed/a4_aux.h index 664d2d1..350de94 100644 --- a/demos/speed/a4_aux.h +++ b/demos/speed/a4_aux.h @@ -58,6 +58,8 @@ void hline(int x1, int y, int x2, ALLEGRO_COLOR c); void vline(int x, int y1, int y2, ALLEGRO_COLOR c); void line(int x1, int y1, int x2, int y2, ALLEGRO_COLOR color); void rectfill(int x1, int y1, int x2, int y2, ALLEGRO_COLOR color); +void circle(int x, int y, int radius, ALLEGRO_COLOR color); +void circlefill(int x, int y, int radius, ALLEGRO_COLOR color); void stretch_sprite(ALLEGRO_BITMAP *bmp, ALLEGRO_BITMAP *sprite, int x, int y, int w, int h); void polygon(int vertices, const int *points, ALLEGRO_COLOR color); void textout(struct ALLEGRO_FONT const *font, const char *s, int x, int y, ALLEGRO_COLOR c); diff --git a/demos/speed/explode.c b/demos/speed/explode.c index ebddf3d..dadcd04 100644 --- a/demos/speed/explode.c +++ b/demos/speed/explode.c @@ -112,8 +112,8 @@ void draw_explode(int r, int g, int b, int (*project)(float *f, int *i, int c)) c = (24 - e->time) * 255 / 24; col = makecol(c, c, c); - al_draw_circle(ipos[0], ipos[1], s*2, col, 0); - al_draw_circle(ipos[0], ipos[1], s*s/8, col, 0); + circle(ipos[0], ipos[1], s*2, col); + circle(ipos[0], ipos[1], s*s/8, col); } if (e->time < 32) { @@ -129,7 +129,7 @@ void draw_explode(int r, int g, int b, int (*project)(float *f, int *i, int c)) col = makecol(rr, gg, bb); - al_draw_filled_circle(ipos[0], ipos[1], s, col); + circlefill(ipos[0], ipos[1], s, col); } } diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 04ee29e..babde1a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -201,6 +201,7 @@ example(ex_acodec_multi CONSOLE ${AUDIO} ${ACODEC}) example(ex_audio_chain ex_audio_chain.cpp ${AUDIO} ${ACODEC} ${PRIM} ${FONT} ${TTF}) example(ex_audio_props CONSOLE ex_audio_props.cpp ${NIHGUI} ${IMAGE} ${AUDIO} ${ACODEC}) example(ex_audio_simple CONSOLE ${AUDIO} ${ACODEC}) +example(ex_audio_timer ${AUDIO} ${FONT}) example(ex_haiku ${AUDIO} ${ACODEC} ${IMAGE}) example(ex_kcm_direct CONSOLE ${AUDIO} ${ACODEC}) example(ex_mixer_chain CONSOLE ${AUDIO} ${ACODEC}) diff --git a/examples/ex_audio_timer.c b/examples/ex_audio_timer.c new file mode 100644 index 0000000..9bddb5c --- /dev/null +++ b/examples/ex_audio_timer.c @@ -0,0 +1,167 @@ +/* + * Example program for the Allegro library. + */ + +#include <math.h> + +#include "allegro5/allegro.h" +#include "allegro5/allegro_audio.h" +#include "allegro5/allegro_font.h" + +#include "common.c" + + +#define RESERVED_SAMPLES 16 +#define PERIOD 5 + + +static ALLEGRO_DISPLAY *display; +static ALLEGRO_FONT *font; +static ALLEGRO_SAMPLE *ping; +static ALLEGRO_TIMER *timer; +static ALLEGRO_EVENT_QUEUE *event_queue; + + +static ALLEGRO_SAMPLE *create_sample_s16(int freq, int len) +{ + char *buf = al_malloc(freq * len * sizeof(int16_t)); + + return al_create_sample(buf, len, freq, ALLEGRO_AUDIO_DEPTH_INT16, + ALLEGRO_CHANNEL_CONF_1, true); +} + + +/* Adapted from SPEED. */ +static ALLEGRO_SAMPLE *generate_ping(void) +{ + float osc1, osc2, vol, ramp; + int16_t *p; + int len; + int i; + + /* ping consists of two sine waves */ + len = 8192; + ping = create_sample_s16(22050, len); + if (!ping) + return NULL; + + p = (int16_t *)al_get_sample_data(ping); + + osc1 = 0; + osc2 = 0; + + for (i=0; i<len; i++) { + vol = (float)(len - i) / (float)len * 4000; + + ramp = (float)i / (float)len * 8; + if (ramp < 1.0f) + vol *= ramp; + + *p = (sin(osc1) + sin(osc2) - 1) * vol; + + osc1 += 0.1; + osc2 += 0.15; + + p++; + } + + return ping; +} + + +int main(void) +{ + ALLEGRO_TRANSFORM trans; + ALLEGRO_EVENT event; + int bps = 4; + bool redraw = false; + unsigned int last_timer = 0; + + if (!al_init()) { + abort_example("Could not init Allegro.\n"); + } + + al_install_keyboard(); + + display = al_create_display(640, 480); + if (!display) { + abort_example("Could not create display\n"); + } + + font = al_create_builtin_font(); + if (!font) { + abort_example("Could not create font\n"); + } + + if (!al_install_audio()) { + abort_example("Could not init sound\n"); + } + + if (!al_reserve_samples(RESERVED_SAMPLES)) { + abort_example("Could not set up voice and mixer\n"); + } + + ping = generate_ping(); + if (!ping) { + abort_example("Could not generate sample\n"); + } + + timer = al_create_timer(1.0 / bps); + al_set_timer_count(timer, -1); + + event_queue = al_create_event_queue(); + al_register_event_source(event_queue, al_get_keyboard_event_source()); + al_register_event_source(event_queue, al_get_timer_event_source(timer)); + + al_identity_transform(&trans); + al_scale_transform(&trans, 16.0, 16.0); + al_use_transform(&trans); + + al_start_timer(timer); + + while (true) { + al_wait_for_event(event_queue, &event); + if (event.type == ALLEGRO_EVENT_TIMER) { + const float speed = pow(21.0/20.0, (event.timer.count % PERIOD)); + if (!al_play_sample(ping, 1.0, 0.0, speed, ALLEGRO_PLAYMODE_ONCE, NULL)) { + fprintf(stderr, "Not enough reserved samples.\n"); + } + redraw = true; + last_timer = event.timer.count; + } + else if (event.type == ALLEGRO_EVENT_KEY_CHAR) { + if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) { + break; + } + if (event.keyboard.unichar == '+' || event.keyboard.unichar == '=') { + if (bps < 32) { + bps++; + al_set_timer_speed(timer, 1.0 / bps); + } + } + else if (event.keyboard.unichar == '-') { + if (bps > 1) { + bps--; + al_set_timer_speed(timer, 1.0 / bps); + } + } + } + + if (redraw && al_is_event_queue_empty(event_queue)) { + ALLEGRO_COLOR c; + if (last_timer % PERIOD == 0) + c = al_map_rgb_f(1, 1, 1); + else + c = al_map_rgb_f(0.5, 0.5, 1.0); + + al_clear_to_color(al_map_rgb(0, 0, 0)); + al_draw_textf(font, c, 640/32, 480/32 - 4, ALLEGRO_ALIGN_CENTRE, + "%u", last_timer); + al_flip_display(); + } + } + + return 0; +} + +/* vim: set sts=3 sw=3 et: */ diff --git a/src/bitmap.c b/src/bitmap.c index 25389c0..438853d 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -198,7 +198,7 @@ void al_destroy_bitmap(ALLEGRO_BITMAP *bitmap) * before it is destroyed, but maintain the current display. */ if (bitmap == al_get_target_bitmap()) { - ALLEGRO_DISPLAY *display = bitmap->display; + ALLEGRO_DISPLAY *display = al_get_current_display(); if (display) al_set_target_bitmap(al_get_backbuffer(display)); else hooks/post-receive -- Allegro |