TraceLinJam.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. #if DEBUG
  2. #include "Trace.h"
  3. // enable debug features
  4. // #define DEBUG_EXIT_IMMEDIAYELY
  5. // #define DEBUG_AUTOLOGIN_CHANNEL "localhost:2049"
  6. #define DEBUG_AUTOLOGIN_CHANNEL "ninbot.com:2052"
  7. // #define DEBUG_AUTOLOGIN_CHANNEL "ninjamer.com:2051"
  8. /* state */
  9. #define DEBUG_TRACE_LINJAM_INIT Trace::TraceState("initializing") ;
  10. #define DEBUG_TRACE_CONNECT \
  11. Trace::TraceState((!IsAgreed())? "connecting to " + host : \
  12. "joining " + host + " as " + login) ;
  13. #define DEBUG_TRACE_LICENSE \
  14. Trace::TraceState((IsAgreed())? "agreeing to license" : \
  15. "prompting for license agreement") ;
  16. #ifdef CLEAN_SESSION
  17. # define DEBUG_TRACE_CLEAN_SESSION \
  18. File thisfile = File::getSpecialLocation(File::currentExecutableFile) ; \
  19. File thisdir = thisfile.getParentDirectory() ; \
  20. String sessiondir = SessionDir.getFullPathName() ; \
  21. if (!SessionDir.isDirectory() || !SessionDir.isAChildOf(thisdir)) \
  22. Trace::TraceError("session directory '" + sessiondir + "' is invalid") ; \
  23. else Trace::TraceState("cleaning session directory '" + sessiondir + "'") ;
  24. #else // CLEAN_SESSION
  25. # define DEBUG_TRACE_CLEAN_SESSION \
  26. String sessiondir = SessionDir.getFullPathName() ; \
  27. Trace::TraceState("cleaning session directory '" + sessiondir + "' (disabled)") ;
  28. #endif // CLEAN_SESSION
  29. /* audio */
  30. #define DEBUG_TRACE_AUDIO_INIT_WIN \
  31. audioStreamer::Interface if_n = (audioStreamer::Interface)win_interface_n ; \
  32. String type = (if_n == audioStreamer::WIN_AUDIO_ASIO)? CLIENT::ASIO_DEVICE_TYPE : \
  33. (if_n == audioStreamer::WIN_AUDIO_KS) ? CLIENT::KS_DEVICE_TYPE : \
  34. (if_n == audioStreamer::WIN_AUDIO_DS) ? CLIENT::DS_DEVICE_TYPE : \
  35. (if_n == audioStreamer::WIN_AUDIO_WAVE)? CLIENT::WAVE_DEVICE_TYPE : \
  36. CLIENT::NFG_DEVICE_TYPE ; \
  37. String dbg = "initializing " + type + " audiostreamer =>" ; \
  38. switch ((int)if_n) \
  39. { \
  40. case audioStreamer::WIN_AUDIO_ASIO: dbg = dbg + \
  41. "\n\t" + CONFIG::ASIO_DRIVER_KEY + " => " + String(asio_driver) + \
  42. "\n\t" + CONFIG::ASIO_INPUT0_KEY + " => " + String(asio_input0) + \
  43. "\n\t" + CONFIG::ASIO_INPUT1_KEY + " => " + String(asio_input1) + \
  44. "\n\t" + CONFIG::ASIO_OUTPUT0_KEY + " => " + String(asio_output0) + \
  45. "\n\t" + CONFIG::ASIO_OUTPUT1_KEY + " => " + String(asio_output1) ; \
  46. break ; \
  47. case audioStreamer::WIN_AUDIO_KS: dbg = dbg + \
  48. "\n\t" + CONFIG::KS_SAMPLERATE_KEY + " => " + String(ks_sample_rate) + \
  49. "\n\t" + CONFIG::KS_BITDEPTH_KEY + " => " + String(ks_bit_depth) + \
  50. "\n\t" + CONFIG::KS_NBLOCKS_KEY + " => " + String(ks_n_buffers) + \
  51. "\n\t" + CONFIG::KS_BLOCKSIZE_KEY + " => " + String(ks_buffer_size) ; \
  52. break ; \
  53. case audioStreamer::WIN_AUDIO_DS: dbg = dbg + \
  54. "\n\t" + CONFIG::DS_INPUT0_KEY + " => " + String(ds_device[0][0]) + \
  55. "\n\t" + CONFIG::DS_INPUT1_KEY + " => " + String(ds_device[0][1]) + \
  56. "\n\t" + CONFIG::DS_INPUT2_KEY + " => " + String(ds_device[0][2]) + \
  57. "\n\t" + CONFIG::DS_INPUT3_KEY + " => " + String(ds_device[0][3]) + \
  58. "\n\t" + CONFIG::DS_OUTPUT0_KEY + " => " + String(ds_device[1][0]) + \
  59. "\n\t" + CONFIG::DS_OUTPUT1_KEY + " => " + String(ds_device[1][1]) + \
  60. "\n\t" + CONFIG::DS_OUTPUT2_KEY + " => " + String(ds_device[1][2]) + \
  61. "\n\t" + CONFIG::DS_OUTPUT3_KEY + " => " + String(ds_device[1][3]) + \
  62. "\n\t" + CONFIG::DS_SAMPLERATE_KEY + " => " + String(ds_sample_rate) + \
  63. "\n\t" + CONFIG::DS_BITDEPTH_KEY + " => " + String(ds_bit_depth) + \
  64. "\n\t" + CONFIG::DS_NBLOCKS_KEY + " => " + String(ds_n_buffers) + \
  65. "\n\t" + CONFIG::DS_BLOCKSIZE_KEY + " => " + String(ds_buffer_size) ; \
  66. break ; \
  67. case audioStreamer::WIN_AUDIO_WAVE: dbg = dbg + \
  68. "\n\t" + CONFIG::WAVE_INPUT_KEY + " => " + String(wave_device[0]) + \
  69. "\n\t" + CONFIG::WAVE_OUTPUT_KEY + " => " + String(wave_device[1]) + \
  70. "\n\t" + CONFIG::WAVE_SAMPLERATE_KEY + " => " + String(wave_sample_rate) + \
  71. "\n\t" + CONFIG::WAVE_BITDEPTH_KEY + " => " + String(wave_bit_depth) + \
  72. "\n\t" + CONFIG::WAVE_NBLOCKS_KEY + " => " + String(wave_n_buffers) + \
  73. "\n\t" + CONFIG::WAVE_BLOCKSIZE_KEY + " => " + String(wave_buffer_size) ; \
  74. break ; \
  75. } \
  76. Trace::TraceClient("detected platform is _WIN32") ; \
  77. if (TRACE_AUDIO_INIT_VB) Trace::TraceClient(dbg) ;
  78. #define DEBUG_TRACE_AUDIO_INIT_MAC \
  79. String type = CLIENT::CA_DEVICE_TYPE ; \
  80. Trace::TraceClient("detected platform is _MAC") ; \
  81. if (TRACE_AUDIO_INIT_VB) \
  82. Trace::TraceClient("initializing " + type + " audiostreamer =>" + \
  83. "\n\t" + CONFIG::MAC_DEVICE_KEY + " => " + mac_device_name + \
  84. "\n\t" + CONFIG::MAC_NINPUTS_KEY + " => " + String(mac_n_inputs) + \
  85. "\n\t" + CONFIG::MAC_SAMPLERATE_KEY + " => " + String(mac_sample_rate) + \
  86. "\n\t" + CONFIG::MAC_BITDEPTH_KEY + " => " + String(mac_bit_depth) ) ;
  87. #define DEBUG_TRACE_AUDIO_INIT_NIX \
  88. audioStreamer::Interface if_n = (audioStreamer::Interface)nix_interface_n ; \
  89. String type = (if_n == audioStreamer::NIX_AUDIO_JACK) ? CLIENT::JACK_DEVICE_TYPE : \
  90. (if_n == audioStreamer::NIX_AUDIO_ALSA) ? CLIENT::ALSA_DEVICE_TYPE : \
  91. CLIENT::NFG_DEVICE_TYPE ; \
  92. Trace::TraceClient("detected platform is *NIX") ;
  93. #define DEBUG_TRACE_AUDIO_INIT_JACK \
  94. if (TRACE_AUDIO_INIT_VB) \
  95. Trace::TraceClient("initializing " + type + " audiostreamer =>" + \
  96. "\n\t" + CONFIG::JACK_NAME_KEY + " => " + jack_name + \
  97. "\n\t" + CONFIG::JACK_NINPUTS_KEY + " => " + String(jack_n_inputs) + \
  98. "\n\t" + CONFIG::JACK_NOUTPUTS_KEY + " => " + String(jack_n_outputs)) ; \
  99. if (!Audio) Trace::TraceState("could not connect to JACK - falling back to ALSA") ;
  100. #define DEBUG_TRACE_AUDIO_INIT_ALSA \
  101. if (TRACE_AUDIO_INIT_VB) \
  102. Trace::TraceClient("initializing " + type + " audiostreamer =>" + \
  103. "\n" + CONFIG::ALSA_CONFIG_KEY + " => " + alsa_config ) ;
  104. #define DEBUG_TRACE_AUDIO_INIT \
  105. if (!Audio) Trace::TraceError("error opening audio device using " + type) ; \
  106. else Trace::TraceState("opened audio device using " + type + " audiostreamer - " + \
  107. String(Audio->m_srate) + "Hz " + \
  108. String(Audio->m_bps) + "bps " + \
  109. String(Audio->m_innch) + "in -> " + \
  110. String(Audio->m_outnch) + "out " ) ;
  111. /* network */
  112. static int PrevStatus = -9 ;
  113. #define DEBUG_TRACE_STATUS_CHANGED \
  114. int prev_status = PrevStatus ; \
  115. int curr_status = (PrevStatus = int(Status.getValue())) ; \
  116. String prev_msg = Trace::Status2String(prev_status) ; \
  117. String curr_msg = Trace::Status2String(curr_status) ; \
  118. String host_name = Client->GetHostName() ; \
  119. char* client_error = Client->GetErrorStr() ; \
  120. String changed_msg = prev_msg + " -> " + curr_msg ; \
  121. String connected_msg = "connected to host: " + host_name ; \
  122. String error_msg = "Error: " + CharPointer_UTF8(client_error) ; \
  123. if (curr_status == LINJAM_STATUS_AUDIOERROR) Trace::TraceClient(curr_msg) ; \
  124. else if (prev_status == LINJAM_STATUS_AUDIOERROR) Trace::TraceState(curr_msg) ; \
  125. else Trace::TraceState(changed_msg) ; \
  126. if (curr_status == NJClient::NJC_STATUS_OK) Trace::TraceServer(connected_msg) ; \
  127. if (client_error[0]) Trace::TraceServer(error_msg) ;
  128. /* channels */
  129. #define DEBUG_TRACE_INITIAL_CHANNELS \
  130. int n_chs = Config->localChannels.getNumChildren() ; \
  131. if (!n_chs) Trace::TraceConfig("no stored channels found") ; \
  132. else Trace::TraceConfig("restoring " + String(n_chs) + " stored local channels") ;
  133. #define DEBUG_TRACE_ADD_LOCAL_CHANNEL \
  134. String channel_name = channel_store[CONFIG::CHANNEL_NAME_ID].toString() ; \
  135. int ch_idx = int(channel_store[CONFIG::CHANNEL_IDX_ID]) ; \
  136. int source = int(channel_store[CONFIG::SOURCE_N_ID]) ; \
  137. bool stereo = int(channel_store[CONFIG::STEREO_ID]) != CONFIG::MONO ; \
  138. String type = (!stereo)? "mono" : "stereo" ; \
  139. bool is_new = ch_idx == CONFIG::DEFAULT_CHANNEL_IDX ; \
  140. bool exists = IsConfiguredChannel(ch_idx) ; \
  141. bool valid_source = source >= 0 && source < GetNumAudioSources() ; \
  142. int n_vacant = GetNumVacantChannels() ; \
  143. bool no_free_chs = (!stereo && n_vacant < 1 || stereo && n_vacant < 2) ; \
  144. String dbg = "adding " + String((is_new)? "new" : "stored") + " local " + \
  145. type + " input[" + String(source) + "] '" + channel_name + "'" ; \
  146. if (exists) \
  147. Trace::TraceError("channel already exists " + dbg) ; \
  148. else if (!valid_source) \
  149. Trace::TraceError("non-existent source " + dbg) ; \
  150. else if (no_free_chs) \
  151. { \
  152. Trace::TraceError("insufficient free channels " + dbg) ; \
  153. if (TRACE_LOCAL_CHANNELS_VB) \
  154. DBG(Trace::DumpStoredChannels() + Trace::DumpClientChannels()) ; \
  155. } \
  156. else Trace::TraceEvent(dbg) ;
  157. #define DEBUG_TRACE_INSTANTIATE_LOCAL_CHANNEL \
  158. Trace::TraceState("instantiating local " + type + " " + \
  159. String(channel_store.getType()) + " '" + channel_name + "'") ;
  160. #define DEBUG_TRACE_CONFIGURE_LOCAL_CHANNEL \
  161. String ch_name = channel_store[CONFIG::CHANNEL_NAME_ID].toString() ; \
  162. ch_name = Config->makeStereoName(ch_name , stereo_status) ; \
  163. String ch_id = String(channel_store.getType()) ; \
  164. bool is_new = !IsConfiguredChannel(channel_idx) ; \
  165. bool is_stereo = stereo_status != CONFIG::MONO ; \
  166. String pairidx = (stereo_status == CONFIG::MONO) ? \
  167. String(pair_idx) + ((!is_new)? " (deleting)" : "") : \
  168. (stereo_status == CONFIG::STEREO_L) ? \
  169. String(pair_idx) + " (pending)" : \
  170. String(pair_idx) ; \
  171. String type = (!is_stereo) ? "mono" : "stereo" ; \
  172. String prev_type = (is_stereo) ? "mono" : "stereo" ; \
  173. String dbg = String((is_new)? "new" : "existing") + " local " + \
  174. type + " " + ch_id + " '" + ch_name + "'" ; \
  175. String pann = String(pan) + ((stereo_status == CONFIG::MONO) ? "" : \
  176. " (" + String(ComputeStereoPan(pan , stereo_status)) + \
  177. " faux-stereo)") ; \
  178. String stereo = String(is_stereo) + \
  179. ((stereo_status == CONFIG::MONO) ? " (MONO)" : \
  180. (stereo_status == CONFIG::STEREO_L)? " (STEREO_L)" : \
  181. (stereo_status == CONFIG::STEREO_R)? " (STEREO_R)" : "") ; \
  182. if (stereo_status == CONFIG::STEREO_L) dbg += " and its stereo pair" ; \
  183. if (TRACE_LOCAL_CHANNELS_VB) dbg += \
  184. ((should_set_name)? "\n name => " + ch_name : "") + \
  185. ((should_init_all)? "\n channel_idx => " + String(channel_idx) : "") + \
  186. ((should_set_stereo)? "\n pair_idx => " + pairidx : "") + \
  187. ((should_set_volume)? "\n volume => " + String(volume) : "") + \
  188. ((should_set_pan)? "\n pan => " + pann : "") + \
  189. ((should_set_is_xmit)? "\n is_xmit => " + String(is_xmit) : "") + \
  190. ((should_set_is_muted)? "\n is_muted => " + String(is_muted) : "") + \
  191. ((should_set_is_solo)? "\n is_solo => " + String(is_solo) : "") + \
  192. ((should_set_source_n)? "\n source_n => " + String(source_n) : "") + \
  193. ((should_set_bit_depth)? "\n bit_depth => " + String(bit_depth) : "") + \
  194. ((should_set_stereo)? "\n is_stereo => " + stereo : "") ; \
  195. if (should_set_stereo && !should_init_all) \
  196. Trace::TraceClient("converting existing local " + prev_type + " " + \
  197. ch_id + " '" + ch_name + "' to " + type) ; \
  198. Trace::TraceClient("configuring " + dbg) ;
  199. #define DEBUG_TRACE_REMOVE_LOCAL_CHANNEL \
  200. String type = (int(channel_store[CONFIG::STEREO_ID]) == CONFIG::MONO)? \
  201. "mono" : "stereo" ; \
  202. Trace::TraceEvent("destroying local " + type + " channel[" + \
  203. channel_store[CONFIG::CHANNEL_IDX_ID].toString() + "] '" + \
  204. String(channel_store.getType()) + "'" ) ;
  205. #if TRACE_DUMP_FREE_INPUTS
  206. # define DEBUG_TRACE_DUMP_FREE_INPUTS_VB \
  207. SortedSet<int> monos = FreeAudioSources ; int n_monos = monos.size() ; \
  208. SortedSet<int> stereos = FreeAudioSourcePairs ; int n_stereos = stereos.size() ; \
  209. String dump = String(n_monos) + " FreeAudioSources = [" ; \
  210. for (int i = 0 ; i < n_monos ; ++i) dump += String(monos[i]) + " " ; \
  211. Trace::TraceVerbose(dump.trim() + "]") ; \
  212. dump = String(n_stereos) + " FreeAudioSourcePairs = [" ; \
  213. for (int i = 0 ; i < n_stereos ; ++i) dump += String(stereos[i]) + " " ; \
  214. Trace::TraceVerbose(dump.trim() + "]") ;
  215. #else // TRACE_DUMP_FREE_INPUTS
  216. # define DEBUG_TRACE_DUMP_FREE_INPUTS_VB ;
  217. #endif // TRACE_DUMP_FREE_INPUTS
  218. #define DEBUG_TRACE_REMOTE_CHANNELS \
  219. String hidden = (hide_bots && NETWORK::KNOWN_BOTS.contains(u_id))? \
  220. " (bot hidden)" : "" ; \
  221. String dbg = "NJClient remote user[" + String(u_idx) + "] =>" + hidden + \
  222. "\n user_name => " + String(u_name) + \
  223. "\n user_volume => " + String(u_vol) + \
  224. "\n user_pan => " + String(u_pan) + \
  225. "\n user_mute => " + String(u_mute) ; \
  226. int ch_n = -1 ; int ch_idx ; \
  227. while (~(ch_idx = LinJam::Client->EnumUserChannels(u_idx , ++ch_n))) \
  228. { \
  229. bool ch_rcv ; float ch_vol ; float ch_pan ; bool ch_mute ; \
  230. bool ch_solo ; int ch_sink ; bool ch_stereo ; \
  231. String ch_name = LinJam::GetRemoteChannelClientName(u_idx , ch_idx) ; \
  232. LinJam::Client->GetUserChannelState(u_idx , ch_idx , &ch_rcv , \
  233. &ch_vol , &ch_pan , &ch_mute , \
  234. &ch_solo , &ch_sink , &ch_stereo) ; \
  235. dbg += "\n found remote channel[" + String(ch_n) + "] =>" + \
  236. "\n channel_idx => " + String(ch_idx) + \
  237. "\n channel_name => " + String(ch_name) + \
  238. "\n channel_volume => " + String(ch_vol) + \
  239. "\n channel_pan => " + String(ch_pan) + \
  240. "\n is_rcv => " + String(ch_rcv) + \
  241. "\n channel_mute => " + String(ch_mute) + \
  242. "\n is_solo => " + String(ch_solo) + \
  243. "\n sink_n => " + String(ch_sink) + \
  244. "\n is_stereo => " + String(ch_stereo) ; \
  245. } \
  246. Trace::TraceState(dbg) ;
  247. #if TRACE_REMOTE_CHANNELS_VB
  248. # define DEBUG_TRACE_REMOTE_CHANNELS_VB \
  249. bool has_bot = NETWORK::KNOWN_HOSTS.contains(String(Client->GetHostName())) ; \
  250. bool hide_bots = has_bot && bool(Config->shouldHideBots.getValue()) ; \
  251. Trace::TraceServer("user info changed - " + \
  252. String(Client->GetNumUsers()) + " users") ; \
  253. int u_idx = -1 ; String u_name ; float u_vol ; float u_pan ; bool u_mute ; \
  254. while ((u_name = GetRemoteUserName(++u_idx)).isNotEmpty()) \
  255. { \
  256. Client->GetUserState(u_idx , &u_vol , &u_pan , &u_mute) ; \
  257. Identifier u_id = Config->encodeUserId(String(u_name) , u_idx) ; \
  258. DEBUG_TRACE_REMOTE_CHANNELS \
  259. }
  260. #else // TRACE_REMOTE_CHANNELS_VB
  261. # define DEBUG_TRACE_REMOTE_CHANNELS_VB ;
  262. #endif // TRACE_REMOTE_CHANNELS_VB
  263. #define DEBUG_TRACE_CONFIGURE_REMOTE_CHANNEL \
  264. String user_name = String(user_store.getType()) ; \
  265. String dbg = "configuring remote " + String(channel_store.getType()) + \
  266. " '" + channel_store[CONFIG::CHANNEL_NAME_ID].toString() + \
  267. "' for user[" + String(user_idx) + "] '" + user_name + "'" ; \
  268. String pann = String(pan) + ((stereo_status == CONFIG::MONO)? "" : \
  269. " (" + String(ComputeStereoPan(pan , stereo_status)) + \
  270. " faux-stereo)") ; \
  271. String stereo = String(is_stereo) + \
  272. ((stereo_status == CONFIG::MONO) ? " (MONO)" : \
  273. (stereo_status == CONFIG::STEREO_L)? " (STEREO_L)" : \
  274. (stereo_status == CONFIG::STEREO_R)? " (STEREO_R)" : "") ; \
  275. String pseudo_control = (should_set_is_rcv) ? "RCV" : \
  276. (should_set_is_solo)? "SOLO" : "" ; \
  277. bool is_master = (channel_idx == CONFIG::MASTER_CHANNEL_IDX) ; \
  278. if (!is_master) \
  279. { \
  280. if (stereo_status == CONFIG::STEREO_L) dbg += " and its stereo pair" ; \
  281. ValueTree store = Config->getUserMasterChannel(user_store) ; \
  282. bool master_rcv_or = !bool(store[CONFIG::IS_XMIT_RCV_ID]) ; \
  283. bool master_solo_or = bool(store[CONFIG::IS_SOLO_ID]) ; \
  284. is_rcv = is_rcv && !master_rcv_or ; \
  285. is_solo = is_solo || master_solo_or ; \
  286. if (master_rcv_or) dbg += " (master rcv override)" ; \
  287. if (master_solo_or) dbg += " (master solo override)" ; \
  288. } \
  289. if (a_key == CONFIG::STEREO_ID && stereo_status == CONFIG::STEREO_R) ; \
  290. else if (!(~user_idx)) Trace::TraceError("user index out of range " + dbg) ; \
  291. else if (!(~channel_idx)) Trace::TraceError("channel index out of range " + dbg) ; \
  292. else if (TRACE_REMOTE_CHANNELS_VB) Trace::TraceClient(dbg + \
  293. ((should_set_volume)? "\n volume => " + String(volume) : "") + \
  294. ((should_set_pan)? "\n pan => " + pann : "") + \
  295. ((should_set_is_rcv)? "\n is_rcv => " + String(is_rcv) : "") + \
  296. ((should_set_is_muted)? "\n is_muted => " + String(is_muted) : "") + \
  297. ((should_set_is_solo)? "\n is_solo => " + String(is_solo) : "") + \
  298. ((should_init_all)? "\n sink_n => " + String(sink_n) : "") + \
  299. ((should_init_all)? "\n is_stereo => " + stereo : "") ) ; \
  300. if (is_master && !should_set_volume && !should_set_pan && !should_set_is_muted && \
  301. (should_set_is_rcv || should_set_is_solo)) \
  302. Trace::TraceClient("applying user master " + pseudo_control + \
  303. " pseudo control over all " + user_name + " channels") ;
  304. /* subscriptions */
  305. #define DEBUG_TRACE_SUBSCRIPTIONS \
  306. ValueTree subs = Config->subscriptions.createCopy() ; \
  307. std::set<std::string> users = Client->config_autosubscribe_userlist ; \
  308. for (int user_n = 0 ; user_n < subs.getNumChildren() ; ++user_n) \
  309. { \
  310. String user_name = String(subs.getChild(user_n).getType()) ; \
  311. if (!users.count(user_name.toStdString())) \
  312. Trace::TraceClient("ignoring remote user '" + user_name + "'") ; \
  313. } \
  314. for (std::set<std::string>::iterator it = users.begin() ; it != users.end() ; ++it) \
  315. { \
  316. String user_name = String(*it) ; \
  317. if (subs.getChildWithName(Identifier(user_name)).isValid()) \
  318. Trace::TraceClient("subscribing to remote user '" + user_name + "'") ; \
  319. } \
  320. if (TRACE_DUMP_SUBSCRIPTIONS) \
  321. { \
  322. String dbg = "ignore_list =>" ; int n_users = subs.getNumChildren() ; \
  323. for (int user_n = 0 ; user_n < n_users ; ++user_n) \
  324. dbg += "\n " + String(subs.getChild(user_n).getType()) ; \
  325. Trace::TraceClient(dbg + ((!n_users)? " (none)" : "")) ; \
  326. }
  327. /* chat */
  328. #define DEBUG_TRACE_CHAT_IN \
  329. if (chat_user.compare(Config->server[CONFIG::LOGIN_ID].toString())) \
  330. Trace::TraceEvent("incoming chat: " + String(parms[CLIENT::CHATMSG_TYPE_IDX])) ;
  331. #define DEBUG_TRACE_CHAT_OUT \
  332. if ((chat_text = chat_text.trim()).isNotEmpty()) \
  333. Trace::TraceEvent("outgoing chat: " + ((chat_text[0] == '/')? \
  334. chat_text.upToFirstOccurrenceOf(" " , false , false) : \
  335. CLIENT::CHATMSG_TYPE_MSG)) ;
  336. #else // DEBUG
  337. // state
  338. #define DEBUG_TRACE_LINJAM_INIT ;
  339. #define DEBUG_TRACE_CONNECT ;
  340. #define DEBUG_TRACE_LICENSE ;
  341. #define DEBUG_TRACE_CLEAN_SESSION ;
  342. // audio
  343. #define DEBUG_TRACE_AUDIO_INIT_WIN ;
  344. #define DEBUG_TRACE_AUDIO_INIT_MAC ;
  345. #define DEBUG_TRACE_AUDIO_INIT_JACK ;
  346. #define DEBUG_TRACE_AUDIO_INIT_ALSA ;
  347. #define DEBUG_TRACE_AUDIO_INIT ;
  348. // network
  349. #define DEBUG_TRACE_CONNECT_STATUS ;
  350. // channels
  351. #define DEBUG_TRACE_INITIAL_CHANNELS ;
  352. #define DEBUG_TRACE_ADD_LOCAL_CHANNEL ;
  353. #define DEBUG_TRACE_INSTANTIATE_LOCAL_CHANNEL ;
  354. #define DEBUG_TRACE_CONFIGURE_LOCAL_CHANNEL ;
  355. #define DEBUG_TRACE_REMOVE_LOCAL_CHANNEL ;
  356. #define DEBUG_TRACE_DUMP_FREE_INPUTS_VB ;
  357. #define DEBUG_TRACE_REMOTE_CHANNELS ;
  358. #define DEBUG_TRACE_REMOTE_CHANNELS_VB ;
  359. #define DEBUG_TRACE_CONFIGURE_REMOTE_CHANNEL ;
  360. // subscriptions
  361. #define DEBUG_TRACE_SUBSCRIPTIONS ;
  362. // chat
  363. #define DEBUG_TRACE_CHAT_IN ;
  364. #define DEBUG_TRACE_CHAT_OUT ;
  365. #endif // DEBUG