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. /* Global variable to keep track of the main pulse audio loop */
  8. pa_mainloop* mainloop;
  9.  
  10. void
  11. success_callback(pa_context *c, int success, char* new_output)
  12. {
  13. /* Notify to the user that the switch was successful */
  14. GError* error = NULL;
  15. char body[255];
  16. if (strlen(new_output) < 200)
  17. sprintf(body, "New active output: %s", new_output);
  18. else
  19. strncpy(body, new_output, 255);
  20. NotifyNotification *notification = notify_notification_new ("Audio switched",
  21. body,
  22. "gnome-mixer");
  23. notify_notification_show (notification,
  24. &error);
  25.  
  26. /* Exit the pulseaudio mainloop */
  27. pa_mainloop_quit(mainloop, success);
  28. }
  29.  
  30.  
  31. void
  32. toggle_mute(pa_context *c, pa_sink_info *i, void* user_data)
  33. {
  34. int j;
  35. if (i) {
  36. /* Cycle through available active ports. This should
  37.   * rotate between headphones and/or analog output. */
  38. for(j = 0; j < i->n_ports; j++) {
  39. if (i->active_port == i->ports[j]) {
  40. pa_context_set_sink_port_by_index(c,
  41. i->index,
  42. i->ports[(j + 1) % i->n_ports]->name,
  43. (pa_context_success_cb_t) success_callback,
  44. (char*) i->ports[(j+1) % i->n_ports]->description);
  45. }
  46. }
  47. }
  48. }
  49.  
  50.  
  51. void
  52. context_connected_cb(pa_context *c, void* user_data)
  53. {
  54. if (pa_context_get_state(c) == PA_CONTEXT_READY) {
  55. pa_context_get_sink_info_list(c,
  56. (pa_sink_info_cb_t) toggle_mute,
  57. NULL);
  58. }
  59. }
  60.  
  61. int
  62. main()
  63. {
  64. mainloop = pa_mainloop_new();
  65. pa_mainloop_api *api = pa_mainloop_get_api (mainloop);
  66. pa_context *c;
  67. pa_operation* operation;
  68. pa_operation_state_t state = PA_OPERATION_RUNNING;
  69. int retval;
  70. pa_proplist *proplist;
  71.  
  72. notify_init ("AudioSwitch");
  73.  
  74. proplist = pa_proplist_new();
  75. pa_proplist_sets(proplist, PA_PROP_DEVICE_API, "alsa");
  76. c = pa_context_new_with_proplist(api, "Audio Switcher",
  77. proplist);
  78.  
  79. /* Connect to the default Pulseaudio server, ask for
  80.   * information about Front so we can check if it is
  81.   * already muted or not. */
  82. pa_context_connect(c, NULL, PA_CONTEXT_NOFLAGS, NULL);
  83. pa_context_set_state_callback(c, (pa_context_notify_cb_t) context_connected_cb, mainloop);
  84.  
  85. /* Loop :) */
  86. pa_mainloop_run(mainloop, &retval);
  87. return retval;
  88. }