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. body = (char*) malloc(sizeof(char) * 255);
  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. if (strlen(new_output) < 235)
  41. sprintf(body, "New active output: %s", new_output);
  42. else
  43. strncpy(body, new_output, 255);
  44. }
  45.  
  46. /* Display the notification */
  47. NotifyNotification *notification = notify_notification_new (title,
  48. body,
  49. "gnome-mixer");
  50. notify_notification_show (notification,
  51. &error);
  52.  
  53. /* Free vars */
  54. free (body);
  55.  
  56. /* Exit the pulseaudio mainloop */
  57. pa_mainloop_quit(mainloop, success);
  58. }
  59.  
  60. /**
  61.  * @brief Called for every sink output of pulse audio.
  62.  * It toggles mute cycling through the available output
  63.  * ports.
  64.  */
  65. void
  66. toggle_mute(pa_context *c, pa_sink_info *i, void* user_data)
  67. {
  68. int j;
  69. if (i) {
  70. /* Cycle through available active ports. This should
  71.   * rotate between headphones and/or analog output. */
  72. for(j = 0; j < i->n_ports; j++) {
  73. if (i->active_port == i->ports[j]) {
  74. pa_context_set_sink_port_by_index(c,
  75. i->index,
  76. i->ports[(j + 1) % i->n_ports]->name,
  77. (pa_context_success_cb_t) success_callback,
  78. (char*) i->ports[(j+1) % i->n_ports]->description);
  79. }
  80. }
  81. }
  82. }
  83.  
  84.  
  85. /**
  86.  * @brief Callback called on the phasis of the connection
  87.  * to the default Pulseaudio server.
  88.  */
  89. void
  90. context_connected_cb(pa_context *c, void* user_data)
  91. {
  92. if (pa_context_get_state(c) == PA_CONTEXT_READY) {
  93. pa_context_get_sink_info_list(c,
  94. (pa_sink_info_cb_t) toggle_mute,
  95. NULL);
  96. }
  97. }
  98.  
  99. /**
  100.  * @brief main routine
  101.  */
  102. int
  103. main()
  104. {
  105. pa_mainloop_api *api;
  106. pa_context *c;
  107. int retval;
  108. pa_proplist *proplist;
  109.  
  110. /* Create a new pulseaudio mainloop */
  111. mainloop = pa_mainloop_new();
  112. api = pa_mainloop_get_api(mainloop);
  113.  
  114. /* Init notification system */
  115. notify_init ("AudioSwitch");
  116.  
  117. /* Create a new Pualseaudio context with the propery
  118.   * dictionary */
  119. proplist = pa_proplist_new();
  120. pa_proplist_sets(proplist, PA_PROP_DEVICE_API, "alsa");
  121. c = pa_context_new_with_proplist(api, "Audio Switcher",
  122. proplist);
  123.  
  124. /* Connect to the default Pulseaudio server, ask for
  125.   * information about Front so we can check if it is
  126.   * already muted or not. */
  127. pa_context_connect(c, NULL, PA_CONTEXT_NOFLAGS, NULL);
  128. pa_context_set_state_callback(c, (pa_context_notify_cb_t) context_connected_cb, mainloop);
  129.  
  130. /* Loop until quit is explictly require by the success_callback */
  131. pa_mainloop_run(mainloop, &retval);
  132.  
  133. return retval;
  134. }