Simplify audio mixer functions
This commit is contained in:
parent
69605b7c9c
commit
f12ad9ed34
|
@ -1508,8 +1508,6 @@ void audio_driver_mixer_set_stream_volume(unsigned i, float vol)
|
||||||
|
|
||||||
void audio_driver_mixer_stop_stream(unsigned i)
|
void audio_driver_mixer_stop_stream(unsigned i)
|
||||||
{
|
{
|
||||||
bool set_state = false;
|
|
||||||
|
|
||||||
if (i >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
if (i >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1518,14 +1516,6 @@ void audio_driver_mixer_stop_stream(unsigned i)
|
||||||
case AUDIO_STREAM_STATE_PLAYING:
|
case AUDIO_STREAM_STATE_PLAYING:
|
||||||
case AUDIO_STREAM_STATE_PLAYING_LOOPED:
|
case AUDIO_STREAM_STATE_PLAYING_LOOPED:
|
||||||
case AUDIO_STREAM_STATE_PLAYING_SEQUENTIAL:
|
case AUDIO_STREAM_STATE_PLAYING_SEQUENTIAL:
|
||||||
set_state = true;
|
|
||||||
break;
|
|
||||||
case AUDIO_STREAM_STATE_STOPPED:
|
|
||||||
case AUDIO_STREAM_STATE_NONE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (set_state)
|
|
||||||
{
|
{
|
||||||
audio_mixer_voice_t *voice = audio_driver_st.mixer_streams[i].voice;
|
audio_mixer_voice_t *voice = audio_driver_st.mixer_streams[i].voice;
|
||||||
|
|
||||||
|
@ -1534,12 +1524,15 @@ void audio_driver_mixer_stop_stream(unsigned i)
|
||||||
audio_driver_st.mixer_streams[i].state = AUDIO_STREAM_STATE_STOPPED;
|
audio_driver_st.mixer_streams[i].state = AUDIO_STREAM_STATE_STOPPED;
|
||||||
audio_driver_st.mixer_streams[i].volume = 1.0f;
|
audio_driver_st.mixer_streams[i].volume = 1.0f;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case AUDIO_STREAM_STATE_STOPPED:
|
||||||
|
case AUDIO_STREAM_STATE_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_driver_mixer_remove_stream(unsigned i)
|
void audio_driver_mixer_remove_stream(unsigned i)
|
||||||
{
|
{
|
||||||
bool destroy = false;
|
|
||||||
|
|
||||||
if (i >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
if (i >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1549,16 +1542,8 @@ void audio_driver_mixer_remove_stream(unsigned i)
|
||||||
case AUDIO_STREAM_STATE_PLAYING_LOOPED:
|
case AUDIO_STREAM_STATE_PLAYING_LOOPED:
|
||||||
case AUDIO_STREAM_STATE_PLAYING_SEQUENTIAL:
|
case AUDIO_STREAM_STATE_PLAYING_SEQUENTIAL:
|
||||||
audio_driver_mixer_stop_stream(i);
|
audio_driver_mixer_stop_stream(i);
|
||||||
destroy = true;
|
/* fall-through */
|
||||||
break;
|
|
||||||
case AUDIO_STREAM_STATE_STOPPED:
|
case AUDIO_STREAM_STATE_STOPPED:
|
||||||
destroy = true;
|
|
||||||
break;
|
|
||||||
case AUDIO_STREAM_STATE_NONE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (destroy)
|
|
||||||
{
|
{
|
||||||
audio_mixer_sound_t *handle = audio_driver_st.mixer_streams[i].handle;
|
audio_mixer_sound_t *handle = audio_driver_st.mixer_streams[i].handle;
|
||||||
if (handle)
|
if (handle)
|
||||||
|
@ -1574,6 +1559,11 @@ void audio_driver_mixer_remove_stream(unsigned i)
|
||||||
audio_driver_st.mixer_streams[i].voice = NULL;
|
audio_driver_st.mixer_streams[i].voice = NULL;
|
||||||
audio_driver_st.mixer_streams[i].name = NULL;
|
audio_driver_st.mixer_streams[i].name = NULL;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case AUDIO_STREAM_STATE_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool audio_driver_mixer_toggle_mute(void)
|
bool audio_driver_mixer_toggle_mute(void)
|
||||||
|
|
Loading…
Reference in New Issue