Skip to content

Commit

Permalink
Fix error reporting for conference audio enabling and disabling
Browse files Browse the repository at this point in the history
We no longer report an error if we try to enable audio
when audio is already enabled, or vice versa.
  • Loading branch information
JFreegman committed Dec 30, 2023
1 parent 862dc64 commit 9a1d7c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/conference.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,13 @@ bool enable_conference_audio(ToxWindow *self, Tox *tox, uint32_t conferencenum)
}
}

bool success = init_conference_audio_input(tox, conferencenum);
const ConferenceChat *chat = &conferences[conferencenum];

if (chat->audio_enabled) {
return true;
}

const bool success = init_conference_audio_input(tox, conferencenum);

if (success) {
self->is_call = true;
Expand All @@ -1368,9 +1374,11 @@ bool disable_conference_audio(ToxWindow *self, Tox *tox, uint32_t conferencenum)
if (chat->audio_enabled) {
close_device(input, chat->audio_in_idx);
chat->audio_enabled = false;
} else {
return true;
}

bool success = toxav_groupchat_disable_av(tox, conferencenum) == 0;
const bool success = toxav_groupchat_disable_av(tox, conferencenum) == 0;

if (success) {
self->is_call = false;
Expand Down
12 changes: 11 additions & 1 deletion src/conference.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,19 @@ int conference_enable_logging(ToxWindow *self, Tox *m, uint32_t conferencenum, s
uint32_t get_name_list_entries_by_prefix(uint32_t conferencenum, const char *prefix, NameListEntry **entries,
uint32_t maxpeers);

bool init_conference_audio_input(Tox *tox, uint32_t conferencenum);
/* Enable audio in a conference.
*
* Return true on success or if audio is already enabled.
*/
bool enable_conference_audio(ToxWindow *self, Tox *tox, uint32_t conferencenum);

/* Disable audio in a conference.
*
* Return true on success or if audio is already disabled.
*/
bool disable_conference_audio(ToxWindow *self, Tox *tox, uint32_t conferencenum);

bool init_conference_audio_input(Tox *tox, uint32_t conferencenum);
bool toggle_conference_push_to_talk(uint32_t conferencenum, bool enabled);
void audio_conference_callback(void *tox, uint32_t conferencenum, uint32_t peernum,
const int16_t *pcm, unsigned int samples, uint8_t channels, uint32_t
Expand Down

0 comments on commit 9a1d7c0

Please sign in to comment.