# SDL\_PauseAudioDevice - bug or intended behavior?

**URL:** <https://discourse.libsdl.org/t/sdl-pauseaudiodevice-bug-or-intended-behavior/19751>\
**Category:** SDL Development\
**Created:** [July 14, 2013, 7:35am UTC](https://discourse.libsdl.org/t/sdl-pauseaudiodevice-bug-or-intended-behavior/19751 "2013-07-14T07:35:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rainer\_Deyke](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/r/a9a28c/32.png) [@Rainer\_Deyke](https://discourse.libsdl.org/u/Rainer_Deyke)\
**Post date:** [July 14, 2013, 7:35am UTC](https://discourse.libsdl.org/t/sdl-pauseaudiodevice-bug-or-intended-behavior/19751/1 "2013-07-14T07:35:19Z")

</div>

I’ve noticed that SDL\_PauseAudioDevice does not lock the audio device.  
This means that although it is safe to allocate a mixing buffer after  
opening an audio device but before unpausing the device, it is not safe  
to deallocate the mixing buffer after pausing the device but before  
closing it. This seems weirdly asymmetrical. Is this intended behavior  
(and therefore deserving of a warning in the wiki) or is it a bug?

device = SDL\_OpenAudioDevice(…);  
allocate\_mixing\_buffer(); // Safe.  
SDL\_PauseAudioDevice(device, 0);  
// …  
SDL\_PauseAudioDevice(device, 1);  
// At this point the audio callback may still be running.  
deallocate\_mixing\_buffer(); // Not safe.  
SDL\_CloseAudioDevice(device);–  
Rainer Deyke (rainerd at [eldwood.com](http://eldwood.com))

---

<div class="post-metadata">

**Author:** ![icculus](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/icculus/32/81_2.png) [@icculus](https://discourse.libsdl.org/u/icculus)\
**Post date:** [July 14, 2013, 4:42pm UTC](https://discourse.libsdl.org/t/sdl-pauseaudiodevice-bug-or-intended-behavior/19751/2 "2013-07-14T16:42:48Z")

</div>

> ```
> SDL_PauseAudioDevice(device, 1);
> // At this point the audio callback may still be running.
> deallocate_mixing_buffer(); // Not safe.
> SDL_CloseAudioDevice(device);
> 
> ```

This is fixed now, hg changeset 6860de5bcb8c.

Thanks!

–ryan.
