diff options
author | Gregory Mullen (grayhatter) <greg@grayhatter.com> | 2016-09-11 16:27:03 -0700 |
---|---|---|
committer | Gregory Mullen (grayhatter) <greg@grayhatter.com> | 2016-09-17 14:05:51 -0700 |
commit | 21f8db12c45bd56293262cd4abfb73cd9abec821 (patch) | |
tree | 580729367d00e1eb7e0c4d533777d22af7d7ffc5 /toxav/audio.c | |
parent | 5da85c582d97d746887da407153afc0acf0a4215 (diff) |
Make ToxAV stateless
Diffstat (limited to 'toxav/audio.c')
-rw-r--r-- | toxav/audio.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/toxav/audio.c b/toxav/audio.c index 59d1554e..3fb0985e 100644 --- a/toxav/audio.c +++ b/toxav/audio.c | |||
@@ -43,7 +43,7 @@ bool reconfigure_audio_decoder(ACSession *ac, int32_t sampling_rate, int8_t chan | |||
43 | 43 | ||
44 | 44 | ||
45 | 45 | ||
46 | ACSession *ac_new(Logger *log, ToxAV *av, uint32_t friend_number, toxav_audio_receive_frame_cb *cb, void *cb_data) | 46 | ACSession *ac_new(Logger *log, ToxAV *av, uint32_t friend_number, toxav_audio_receive_frame_cb *cb) |
47 | { | 47 | { |
48 | ACSession *ac = calloc(sizeof(ACSession), 1); | 48 | ACSession *ac = calloc(sizeof(ACSession), 1); |
49 | 49 | ||
@@ -97,8 +97,7 @@ ACSession *ac_new(Logger *log, ToxAV *av, uint32_t friend_number, toxav_audio_re | |||
97 | 97 | ||
98 | ac->av = av; | 98 | ac->av = av; |
99 | ac->friend_number = friend_number; | 99 | ac->friend_number = friend_number; |
100 | ac->acb.first = cb; | 100 | ac->on_audio_frame = cb; |
101 | ac->acb.second = cb_data; | ||
102 | 101 | ||
103 | return ac; | 102 | return ac; |
104 | 103 | ||
@@ -125,7 +124,7 @@ void ac_kill(ACSession *ac) | |||
125 | LOGGER_DEBUG(ac->log, "Terminated audio handler: %p", ac); | 124 | LOGGER_DEBUG(ac->log, "Terminated audio handler: %p", ac); |
126 | free(ac); | 125 | free(ac); |
127 | } | 126 | } |
128 | void ac_iterate(ACSession *ac) | 127 | void ac_iterate(ACSession *ac, void *userdata) |
129 | { | 128 | { |
130 | if (!ac) { | 129 | if (!ac) { |
131 | return; | 130 | return; |
@@ -186,11 +185,11 @@ void ac_iterate(ACSession *ac) | |||
186 | 185 | ||
187 | if (rc < 0) { | 186 | if (rc < 0) { |
188 | LOGGER_WARNING(ac->log, "Decoding error: %s", opus_strerror(rc)); | 187 | LOGGER_WARNING(ac->log, "Decoding error: %s", opus_strerror(rc)); |
189 | } else if (ac->acb.first) { | 188 | } else if (ac->on_audio_frame) { |
190 | ac->lp_frame_duration = (rc * 1000) / ac->lp_sampling_rate; | 189 | ac->lp_frame_duration = (rc * 1000) / ac->lp_sampling_rate; |
191 | 190 | ||
192 | ac->acb.first(ac->av, ac->friend_number, tmp, rc, ac->lp_channel_count, | 191 | ac->on_audio_frame(ac->av, ac->friend_number, tmp, rc, ac->lp_channel_count, |
193 | ac->lp_sampling_rate, ac->acb.second); | 192 | ac->lp_sampling_rate, userdata); |
194 | } | 193 | } |
195 | 194 | ||
196 | return; | 195 | return; |