viewgit/index.php:465 Only variables should be passed by reference [2048]

viewgit/index.php:466 Non-static method GeSHi::get_language_name_from_extension() should not be called statically [2048]

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <pulse/pulseaudio.h>
  5. #include <libnotify/notify.h>
  6.  
  7. /**
  8.  * Global variable to keep track of the main pulse audio loop, that
  9.  * will be terminated on the success or failure of the switch. */
  10. pa_mainloop* mainloop;
  11.  
  12. /**
  13.  * @brief Callback called by toggle_mute when the switch operation
  14.  * is completed (with success or failure). It terminates the mainloop
  15.  * and exit the program.
  16.  *
  17.  * @param c the Pulseaudio context.
  18.  * @param success 0 if the switch has gone well, not zero othewise.
  19.  * @param new_output The description of the new active output.
  20.  */
  21. void
  22. success_callback(pa_context *c, int success, char* new_output)
  23. {
  24. /* Notify to the user that the switch was successful */
  25. GError* error = NULL;
  26. char *title, *body;
  27.  
  28.  
  29.  
  30. /* Set messages of the notification based on the success
  31.   * of the switching operation */
  32. if (!success)
  33. {
  34. title = "Audio switch failure";
  35. body = "Audio switching operation failed.";
  36. }
  37. else
  38. {
  39. title = "Audio switched";
  40. body = (char*) malloc(sizeof(char) * 255);
  41. if (strlen(new_output) < 235)
  42. sprintf(body, "New active output: %s", new_output);
  43. else
  44. strncpy(body, new_output, 255);
  45. }
  46.  
  47. /* Display the notification */
  48. NotifyNotification *notification = notify_notification_new (title,
  49. body,
  50. "gnome-mixer");
  51. notify_notification_show (notification,
  52. &error);
  53.  
  54. /* Free vars */
  55. if (success)
  56. free (body);
  57.  
  58. /* Exit the pulseaudio mainloop */
  59. pa_mainloop_quit(mainloop, success);
  60. }
  61.  
  62. /**
  63.  * @brief Called for every sink output of pulse audio.
  64.  * It toggles mute cycling through the available output
  65.  * ports.
  66.  */
  67. void
  68. toggle_mute(pa_context *c, pa_sink_info *i, void* user_data)
  69. {
  70. int j;
  71. if (i) {
  72. /* Cycle through available active ports. This should
  73.   * rotate between headphones and/or analog output. */
  74. for(j = 0; j < i->n_ports; j++) {
  75. if (i->active_port == i->ports[j]) {
  76. pa_context_set_sink_port_by_index(c,
  77. i->index,
  78. i->ports[(j + 1) % i->n_ports]->name,
  79. (pa_context_success_cb_t) success_callback,
  80. (char*) i->ports[(j+1) % i->n_ports]->description);
  81. }
  82. }
  83. }
  84. }
  85.  
  86.  
  87. /**
  88.  * @brief Callback called on the phasis of the connection
  89.  * to the default Pulseaudio server.
  90.  */
  91. void
  92. context_connected_cb(pa_context *c, void* user_data)
  93. {
  94. if (pa_context_get_state(c) == PA_CONTEXT_READY) {
  95. pa_context_get_sink_info_list(c,
  96. (pa_sink_info_cb_t) toggle_mute,
  97. NULL);
  98. }
  99. }
  100.  
  101. /**
  102.  * @brief main routine
  103.  */
  104. int
  105. main()
  106. {
  107. pa_mainloop_api *api;
  108. pa_context *c;
  109. int retval;
  110. pa_proplist *proplist;
  111.  
  112. /* Create a new pulseaudio mainloop */
  113. mainloop = pa_mainloop_new();
  114. api = pa_mainloop_get_api(mainloop);
  115.  
  116. /* Init notification system */
  117. notify_init ("AudioSwitch");
  118.  
  119. /* Create a new Pualseaudio context with the propery
  120.   * dictionary */
  121. proplist = pa_proplist_new();
  122. pa_proplist_sets(proplist, PA_PROP_DEVICE_API, "alsa");
  123. c = pa_context_new_with_proplist(api, "Audio Switcher",
  124. proplist);
  125.  
  126. /* Connect to the default Pulseaudio server, ask for
  127.   * information about Front so we can check if it is
  128.   * already muted or not. */
  129. pa_context_connect(c, NULL, PA_CONTEXT_NOFLAGS, NULL);
  130. pa_context_set_state_callback(c, (pa_context_notify_cb_t) context_connected_cb, mainloop);
  131.  
  132. /* Loop until quit is explictly require by the success_callback */
  133. pa_mainloop_run(mainloop, &retval);
  134.  
  135. return retval;
  136. }