mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2026-04-24 23:17:43 -05:00
Add key to manually restart audio
This commit is contained in:
parent
b48ec6cf17
commit
8c526e3747
|
|
@ -88,6 +88,7 @@ On MacOS, you may also be prompted to install the Apple Command Line Developer T
|
|||
- __M key__: Toggles mute on/off.
|
||||
- __, key__: Decrements the volume by 5 units. 0 is the minimum.
|
||||
- __. key__: Increments the volume by 5 units. 100 is the maximum.
|
||||
- __N key__: Restarts the audio output. Useful if the audio stops working after changing system settings.
|
||||
- __O key__: Open/Close connection to the 3DS.
|
||||
- __F1 - F4 keys__: Loads from layouts 1 through 4 respectively.
|
||||
- __F5 - F8 keys__: Saves to layouts 1 through 4 respectively.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ public:
|
|||
void reset();
|
||||
void change_audio_volume(bool is_change_positive);
|
||||
void change_audio_mute();
|
||||
void request_audio_restart();
|
||||
bool check_audio_restart_request();
|
||||
int get_final_volume();
|
||||
bool has_text_to_print();
|
||||
std::string text_to_print();
|
||||
|
|
@ -18,6 +20,7 @@ public:
|
|||
private:
|
||||
int volume;
|
||||
bool mute;
|
||||
bool restart_request = false;
|
||||
bool text_updated;
|
||||
void set_audio_volume(int new_volume);
|
||||
void set_audio_mute(bool new_mute);
|
||||
|
|
|
|||
|
|
@ -441,6 +441,11 @@ bool WindowScreen::main_poll(SFEvent &event_data) {
|
|||
audio_data->change_audio_volume(true);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
audio_data->request_audio_restart();
|
||||
this->print_notification("Restarting audio...");
|
||||
break;
|
||||
|
||||
default:
|
||||
consumed = false;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ Sample::Sample(sf::Int16 *bytes, std::size_t size, float time) : bytes(bytes), s
|
|||
|
||||
Audio::Audio(AudioData *audio_data) {
|
||||
this->audio_data = audio_data;
|
||||
// Consume old events
|
||||
this->audio_data->check_audio_restart_request();
|
||||
sf::SoundStream::initialize(AUDIO_CHANNELS, SAMPLE_RATE);
|
||||
#if (SFML_VERSION_MAJOR > 2) || ((SFML_VERSION_MAJOR == 2) && (SFML_VERSION_MINOR >= 6))
|
||||
// Since we receive data every 16.6 ms, this is useless,
|
||||
|
|
@ -60,6 +62,8 @@ bool Audio::onGetData(sf::SoundStream::Chunk &data) {
|
|||
num_consecutive_fast_seek = 0;
|
||||
if(num_consecutive_fast_seek > AUDIO_FAILURE_THRESHOLD)
|
||||
restart = true;
|
||||
if(this->audio_data->check_audio_restart_request())
|
||||
restart = true;
|
||||
|
||||
if(restart) {
|
||||
terminate = true;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
void AudioData::reset() {
|
||||
this->volume = 50;
|
||||
this->mute = false;
|
||||
this->restart_request = false;
|
||||
this->text_updated = false;
|
||||
}
|
||||
|
||||
|
|
@ -23,9 +24,21 @@ void AudioData::change_audio_mute() {
|
|||
this->text_updated = true;
|
||||
}
|
||||
|
||||
void AudioData::request_audio_restart() {
|
||||
this->restart_request = true;
|
||||
}
|
||||
|
||||
bool AudioData::check_audio_restart_request() {
|
||||
bool retval = this->restart_request;
|
||||
if(retval)
|
||||
this->restart_request = false;
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool AudioData::has_text_to_print() {
|
||||
bool retval = this->text_updated;
|
||||
this->text_updated = false;
|
||||
if(retval)
|
||||
this->text_updated = false;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user