sndplayer: free audio device after playback is over
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 30 Mar 2021 10:19:24 +0000 (12:19 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 30 Mar 2021 10:19:24 +0000 (12:19 +0200)
sndplay/src/main.rs

index 43f8fca879895f016df669541c16c4d15ced5986..e1b8472886a93aab83ed46cecd65846b1d47d67b 100644 (file)
@@ -86,6 +86,12 @@ impl AudioDevice {
     }
 }
 
+impl Drop for AudioDevice {
+    fn drop(&mut self) {
+        unsafe { sdl2_sys::SDL_CloseAudioDevice(self.device_id); }
+    }
+}
+
 struct Decoder<'a> {
     demuxer:    Demuxer<'a>,
     decoder:    Box<dyn NADecoder>,