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]
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <pulse/pulseaudio.h> #include <libnotify/notify.h> /** * Global variable to keep track of the main pulse audio loop, that * will be terminated on the success or failure of the switch. */ pa_mainloop* mainloop; /** * @brief Callback called by toggle_mute when the switch operation * is completed (with success or failure). It terminates the mainloop * and exit the program. * * @param c the Pulseaudio context. * @param success 0 if the switch has gone well, not zero othewise. * @param new_output The description of the new active output. */ void success_callback(pa_context *c, int success, char* new_output) { /* Notify to the user that the switch was successful */ GError* error = NULL; char *title, *body; /* Set messages of the notification based on the success * of the switching operation */ if (!success) { title = "Audio switch failure"; body = "Audio switching operation failed."; } else { title = "Audio switched"; body = (char*) malloc(sizeof(char) * 255); if (strlen(new_output) < 235) sprintf(body, "New active output: %s", new_output); else strncpy(body, new_output, 255); } /* Display the notification */ NotifyNotification *notification = notify_notification_new (title, body, "gnome-mixer"); notify_notification_show (notification, &error); /* Free vars */ if (success) free (body); /* Exit the pulseaudio mainloop */ pa_mainloop_quit(mainloop, success); } /** * @brief Called for every sink output of pulse audio. * It toggles mute cycling through the available output * ports. */ void toggle_mute(pa_context *c, pa_sink_info *i, void* user_data) { int j; if (i) { /* Cycle through available active ports. This should * rotate between headphones and/or analog output. */ for(j = 0; j < i->n_ports; j++) { if (i->active_port == i->ports[j]) { pa_context_set_sink_port_by_index(c, i->index, i->ports[(j + 1) % i->n_ports]->name, (pa_context_success_cb_t) success_callback, (char*) i->ports[(j+1) % i->n_ports]->description); } } } } /** * @brief Callback called on the phasis of the connection * to the default Pulseaudio server. */ void context_connected_cb(pa_context *c, void* user_data) { if (pa_context_get_state(c) == PA_CONTEXT_READY) { pa_context_get_sink_info_list(c, (pa_sink_info_cb_t) toggle_mute, NULL); } } /** * @brief main routine */ int main() { pa_mainloop_api *api; pa_context *c; int retval; pa_proplist *proplist; /* Create a new pulseaudio mainloop */ mainloop = pa_mainloop_new(); api = pa_mainloop_get_api(mainloop); /* Init notification system */ notify_init ("AudioSwitch"); /* Create a new Pualseaudio context with the propery * dictionary */ proplist = pa_proplist_new(); pa_proplist_sets(proplist, PA_PROP_DEVICE_API, "alsa"); c = pa_context_new_with_proplist(api, "Audio Switcher", proplist); /* Connect to the default Pulseaudio server, ask for * information about Front so we can check if it is * already muted or not. */ pa_context_connect(c, NULL, PA_CONTEXT_NOFLAGS, NULL); pa_context_set_state_callback(c, (pa_context_notify_cb_t) context_connected_cb, mainloop); /* Loop until quit is explictly require by the success_callback */ pa_mainloop_run(mainloop, &retval); return retval; }