Fix sound issues in multiple apps

This commit is contained in:
MX 2022-12-19 21:55:06 +03:00
parent de2334f314
commit 577334a394
No known key found for this signature in database
GPG key ID: 6C4C311DFD4B4AB5
5 changed files with 88 additions and 63 deletions

View file

@ -1,4 +1,5 @@
### New changes
* **Fixed sound issues with WAV Player, Metronome, Morse code, DTMF Dolphin**
* API: Version was changed due to breaking changes - from 10.x to 11.x - Extra pack was updated, download it by using link below ([- Download latest extra apps pack](https://download-directory.github.io/?url=https://github.com/xMasterX/unleashed-extra-pack/tree/main/apps))
* Plugins: Add (UniTemp) Temp sensor reader (PR #216 | by @quen0n) [(plugin repo)](https://github.com/quen0n/unitemp-flipperzero) and Remove DHT Monitor and AM2320 plugins (unitemp has support for that sensors)
* Plugins -> SubGHz Bruteforcer: Add support for PT2260, SMC5326, UNILARM, Honeywell(file only) protocols

View file

@ -219,11 +219,15 @@ bool dtmf_dolphin_audio_play_tones(
furi_hal_interrupt_set_isr(
FuriHalInterruptIdDma1Ch1, dtmf_dolphin_audio_dma_isr, current_player->queue);
dtmf_dolphin_dma_start();
dtmf_dolphin_speaker_start();
current_player->playing = true;
return true;
if(furi_hal_speaker_acquire(1000)) {
dtmf_dolphin_dma_start();
dtmf_dolphin_speaker_start();
current_player->playing = true;
return true;
} else {
current_player->playing = false;
return false;
}
}
bool dtmf_dolphin_audio_stop_tones() {
@ -238,6 +242,7 @@ bool dtmf_dolphin_audio_stop_tones() {
}
dtmf_dolphin_speaker_stop();
dtmf_dolphin_dma_stop();
furi_hal_speaker_release();
furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, NULL, NULL);

View file

@ -149,7 +149,9 @@ static void timer_callback(void* ctx) {
notification_message(metronome_state->notifications, &sequence_set_only_red_255);
switch(metronome_state->output_mode) {
case Loud:
furi_hal_speaker_start(440.0f, 1.0f);
if(furi_hal_speaker_acquire(1000)) {
furi_hal_speaker_start(440.0f, 1.0f);
}
break;
case Vibro:
notification_message(metronome_state->notifications, &sequence_set_vibro_on);
@ -162,7 +164,9 @@ static void timer_callback(void* ctx) {
notification_message(metronome_state->notifications, &sequence_set_only_green_255);
switch(metronome_state->output_mode) {
case Loud:
furi_hal_speaker_start(220.0f, 1.0f);
if(furi_hal_speaker_acquire(1000)) {
furi_hal_speaker_start(220.0f, 1.0f);
}
break;
case Vibro:
notification_message(metronome_state->notifications, &sequence_set_vibro_on);
@ -176,7 +180,10 @@ static void timer_callback(void* ctx) {
switch(metronome_state->output_mode) {
case Loud:
furi_delay_ms(BEEP_DELAY_MS);
furi_hal_speaker_stop();
if(furi_hal_speaker_is_mine()) {
furi_hal_speaker_stop();
furi_hal_speaker_release();
}
break;
case Vibro:
if(metronome_state->current_beat == 1) {

View file

@ -61,17 +61,23 @@ static int32_t morse_code_worker_thread_callback(void* context) {
bool spaced = true;
while(instance->is_running) {
furi_delay_ms(SLEEP);
if(instance->play) {
if(!was_playing) {
start_tick = furi_get_tick();
furi_hal_speaker_start(FREQUENCY, instance->volume);
if(furi_hal_speaker_acquire(1000)) {
furi_hal_speaker_start(FREQUENCY, instance->volume);
}
was_playing = true;
}
} else {
if(was_playing) {
pushed = false;
spaced = false;
furi_hal_speaker_stop();
if(furi_hal_speaker_is_mine()) {
furi_hal_speaker_stop();
furi_hal_speaker_release();
}
end_tick = furi_get_tick();
was_playing = false;
morse_code_worker_fill_buffer(instance, end_tick - start_tick);

View file

@ -237,65 +237,71 @@ static void app_run(WavPlayerApp* app) {
furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, wav_player_dma_isr, app->queue);
wav_player_dma_start();
wav_player_speaker_start();
if(furi_hal_speaker_acquire(1000)) {
wav_player_dma_start();
wav_player_speaker_start();
WavPlayerEvent event;
WavPlayerEvent event;
while(1) {
if(furi_message_queue_get(app->queue, &event, FuriWaitForever) == FuriStatusOk) {
if(event.type == WavPlayerEventHalfTransfer) {
eof = fill_data(app, 0);
wav_player_view_set_current(app->view, stream_tell(app->stream));
if(eof) {
stream_seek(
app->stream,
wav_parser_get_data_start(app->parser),
StreamOffsetFromStart);
while(1) {
if(furi_message_queue_get(app->queue, &event, FuriWaitForever) == FuriStatusOk) {
if(event.type == WavPlayerEventHalfTransfer) {
eof = fill_data(app, 0);
wav_player_view_set_current(app->view, stream_tell(app->stream));
if(eof) {
stream_seek(
app->stream,
wav_parser_get_data_start(app->parser),
StreamOffsetFromStart);
}
} else if(event.type == WavPlayerEventFullTransfer) {
eof = fill_data(app, app->samples_count_half);
wav_player_view_set_current(app->view, stream_tell(app->stream));
if(eof) {
stream_seek(
app->stream,
wav_parser_get_data_start(app->parser),
StreamOffsetFromStart);
}
} else if(event.type == WavPlayerEventCtrlVolUp) {
if(app->volume < 9.9) app->volume += 0.4;
wav_player_view_set_volume(app->view, app->volume);
} else if(event.type == WavPlayerEventCtrlVolDn) {
if(app->volume > 0.01) app->volume -= 0.4;
wav_player_view_set_volume(app->view, app->volume);
} else if(event.type == WavPlayerEventCtrlMoveL) {
int32_t seek =
stream_tell(app->stream) - wav_parser_get_data_start(app->parser);
seek =
MIN(seek, (int32_t)(wav_parser_get_data_len(app->parser) / (size_t)100));
stream_seek(app->stream, -seek, StreamOffsetFromCurrent);
wav_player_view_set_current(app->view, stream_tell(app->stream));
} else if(event.type == WavPlayerEventCtrlMoveR) {
int32_t seek = wav_parser_get_data_end(app->parser) - stream_tell(app->stream);
seek =
MIN(seek, (int32_t)(wav_parser_get_data_len(app->parser) / (size_t)100));
stream_seek(app->stream, seek, StreamOffsetFromCurrent);
wav_player_view_set_current(app->view, stream_tell(app->stream));
} else if(event.type == WavPlayerEventCtrlOk) {
app->play = !app->play;
wav_player_view_set_play(app->view, app->play);
if(!app->play) {
wav_player_speaker_stop();
} else {
wav_player_speaker_start();
}
} else if(event.type == WavPlayerEventCtrlBack) {
break;
}
} else if(event.type == WavPlayerEventFullTransfer) {
eof = fill_data(app, app->samples_count_half);
wav_player_view_set_current(app->view, stream_tell(app->stream));
if(eof) {
stream_seek(
app->stream,
wav_parser_get_data_start(app->parser),
StreamOffsetFromStart);
}
} else if(event.type == WavPlayerEventCtrlVolUp) {
if(app->volume < 9.9) app->volume += 0.4;
wav_player_view_set_volume(app->view, app->volume);
} else if(event.type == WavPlayerEventCtrlVolDn) {
if(app->volume > 0.01) app->volume -= 0.4;
wav_player_view_set_volume(app->view, app->volume);
} else if(event.type == WavPlayerEventCtrlMoveL) {
int32_t seek = stream_tell(app->stream) - wav_parser_get_data_start(app->parser);
seek = MIN(seek, (int32_t)(wav_parser_get_data_len(app->parser) / (size_t)100));
stream_seek(app->stream, -seek, StreamOffsetFromCurrent);
wav_player_view_set_current(app->view, stream_tell(app->stream));
} else if(event.type == WavPlayerEventCtrlMoveR) {
int32_t seek = wav_parser_get_data_end(app->parser) - stream_tell(app->stream);
seek = MIN(seek, (int32_t)(wav_parser_get_data_len(app->parser) / (size_t)100));
stream_seek(app->stream, seek, StreamOffsetFromCurrent);
wav_player_view_set_current(app->view, stream_tell(app->stream));
} else if(event.type == WavPlayerEventCtrlOk) {
app->play = !app->play;
wav_player_view_set_play(app->view, app->play);
if(!app->play) {
wav_player_speaker_stop();
} else {
wav_player_speaker_start();
}
} else if(event.type == WavPlayerEventCtrlBack) {
break;
}
}
}
wav_player_speaker_stop();
wav_player_dma_stop();
wav_player_speaker_stop();
wav_player_dma_stop();
furi_hal_speaker_release();
}
furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, NULL, NULL);
}