1 #ifndef AUDIO_H 2 #define AUDIO_H 3 4 #include <stdbool.h> 5 #include <stdint.h> 6 #include <stdbool.h> 7 8 #ifdef __APPLE__ 9 #include <OpenAL/alc.h> 10 #else 11 #include <AL/alc.h> 12 #endif 13 14 extern bool utox_audio_thread_init; 15 16 enum { 17 // kill the audio thread 18 UTOXAUDIO_KILL, 19 20 UTOXAUDIO_CHANGE_MIC, 21 UTOXAUDIO_CHANGE_SPEAKER, 22 23 UTOXAUDIO_START_FRIEND, 24 UTOXAUDIO_STOP_FRIEND, 25 26 UTOXAUDIO_GROUPCHAT_START, 27 UTOXAUDIO_GROUPCHAT_STOP, 28 29 UTOXAUDIO_START_PREVIEW, 30 UTOXAUDIO_STOP_PREVIEW, 31 32 UTOXAUDIO_PLAY_RINGTONE, 33 UTOXAUDIO_STOP_RINGTONE, 34 35 UTOXAUDIO_PLAY_NOTIFICATION, 36 UTOXAUDIO_STOP_NOTIFICATION, 37 38 UTOXAUDIO_NEW_AV_INSTANCE, 39 }; 40 41 enum { 42 NOTIFY_TONE_NONE, 43 NOTIFY_TONE_FRIEND_ONLINE, 44 NOTIFY_TONE_FRIEND_OFFLINE, 45 NOTIFY_TONE_FRIEND_NEW_MSG, 46 NOTIFY_TONE_FRIEND_REQUEST, 47 }; 48 49 #define UTOX_DEFAULT_BITRATE_A 32 50 #define UTOX_MIN_BITRATE_AUDIO UTOX_DEFAULT_BITRATE_A //TODO: Find out what the minimum bit rate should be 51 #define UTOX_DEFAULT_FRAME_A 20 52 #define UTOX_DEFAULT_SAMPLE_RATE_A 48000 53 #define UTOX_DEFAULT_AUDIO_CHANNELS 1 54 55 /* Check self */ 56 #define UTOX_SENDING_AUDIO(f_number) (!!(get_friend(f_number)->call_state_self & TOXAV_FRIEND_CALL_STATE_SENDING_A)) 57 // UTOX_ACCEPTING_AUDIO is unused. Delete? 58 #define UTOX_ACCEPTING_AUDIO(f_number) (!!(get_friend(f_number)->call_state_self & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A)) 59 60 /* Check friend */ 61 #define UTOX_AVAILABLE_AUDIO(f_number) (!!(get_friend(f_number)->call_state_friend & TOXAV_FRIEND_CALL_STATE_SENDING_A)) 62 63 /* Check both */ 64 #define UTOX_SEND_AUDIO(f_number) \ 65 (!!(get_friend(f_number)->call_state_self & TOXAV_FRIEND_CALL_STATE_SENDING_A) \ 66 && !!(get_friend(f_number)->call_state_friend & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A)) 67 // UTOX_ACCEPT_AUDIO is unused. Delete? 68 #define UTOX_ACCEPT_AUDIO(f_number) \ 69 (!!(get_friend(f_number)->call_state_self & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A) \ 70 && !!(get_friend(f_number)->call_state_friend & TOXAV_FRIEND_CALL_STATE_SENDING_A)) 71 72 bool utox_audio_in_device_set(ALCdevice *new_device); 73 bool utox_audio_out_device_set(ALCdevice *new_device); 74 ALCdevice *utox_audio_in_device_get(void); 75 // utox_audio_out_device_get is unused. Delete? 76 ALCdevice *utox_audio_out_device_get(void); 77 78 void utox_audio_in_device_open(void); 79 void utox_audio_in_device_close(void); 80 81 void utox_audio_in_listen(void); 82 void utox_audio_in_ignore(void); 83 84 void sourceplaybuffer(unsigned int i, const int16_t *data, int samples, uint8_t channels, unsigned int sample_rate); 85 86 /* send a message to the audio thread */ 87 void postmessage_audio(uint8_t msg, uint32_t param1, uint32_t param2, void *data); 88 89 void utox_audio_thread(void *args); 90 91 #endif 92