1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! A status of an audio device.

use crate::bind;

/// A playing status of an audio device.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AudioStatus {
    /// An audio device is closed or on error.
    Stopped,
    /// An audio device is open and playing the sound.
    Playing,
    /// An audio device is open but not playing the sound.
    Paused,
}

impl From<bind::SDL_AudioStatus> for AudioStatus {
    fn from(raw: bind::SDL_AudioStatus) -> Self {
        match raw {
            bind::SDL_AUDIO_STOPPED => Self::Stopped,
            bind::SDL_AUDIO_PLAYING => Self::Playing,
            bind::SDL_AUDIO_PAUSED => Self::Paused,
            _ => unreachable!(),
        }
    }
}