{"action":"created","comment":{"url":"https://api.github.com/repos/nemomobile/ngfd/pulls/comments/29665270","id":29665270,"diff_hunk":"@@ -0,0 +1,332 @@\n+/*************************************************************************\n+This file is part of tone-generator\n+\n+Copyright (C) 2010 Nokia Corporation.\n+\n+This library is free software; you can redistribute\n+it and/or modify it under the terms of the GNU Lesser General Public\n+License as published by the Free Software Foundation\n+version 2.1 of the License.\n+\n+This library is distributed in the hope that it will be useful,\n+but WITHOUT ANY WARRANTY; without even the implied warranty of\n+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+Lesser General Public License for more details.\n+\n+You should have received a copy of the GNU Lesser General Public\n+License along with this library; if not, write to the Free Software\n+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301\n+USA.\n+*************************************************************************/\n+\n+#define _GNU_SOURCE\n+\n+#include <stdlib.h>\n+#include <string.h>\n+#include <errno.h>\n+\n+#include <ngf/log.h>\n+#include <trace/trace.h>\n+\n+#include \"stream.h\"\n+#include \"ausrv.h\"\n+\n+#if PA_API_VERSION < 9\n+#error Invalid PulseAudio API version\n+#endif\n+\n+#define DISCONNECTED    0\n+#define CONNECTED       1\n+\n+#define DEFAULT_SERVER  \"default Pulse Audio\"\n+#define CONNECT_DELAY   10                              /* in seconds */\n+\n+#define TRACE(f, args...) trace_write(trctx, trflags, trkeys, f, ##args)\n+#define LOG_CAT \"tonegen-ausrv: \"\n+\n+static void set_connection_status(struct ausrv *, int);\n+static void context_callback(pa_context *, void *);\n+static void event_callback(pa_context *, pa_subscription_event_type_t,\n+                           uint32_t, void *);\n+static void connect_server(struct ausrv *);\n+static void restart_timer(struct ausrv *, int);\n+static void cancel_timer(struct ausrv *);\n+\n+static const char *pa_client_name = \"ngf-tonegen-plugin\";\n+\n+\n+int ausrv_init(void)\n+{\n+    return 0;\n+}\n+\n+void ausrv_exit(void)\n+{\n+}\n+\n+struct ausrv *ausrv_create(struct tonegend *tonegend, char *server)\n+{\n+    pa_glib_mainloop   *mainloop = NULL;\n+    struct ausrv       *ausrv;\n+    pa_mainloop_api    *mainloop_api;\n+\n+    if ((ausrv = malloc(sizeof(*ausrv))) == NULL) {\n+        N_ERROR(LOG_CAT \"%s(): Can't allocate memory\", __FUNCTION__);\n+        goto failed;\n+    }\n+\n+    if ((mainloop = pa_glib_mainloop_new(NULL)) == NULL) {\n+        N_ERROR(LOG_CAT \"%s(): pa_glib_mainloop_new() failed\", __FUNCTION__);\n+        goto failed;\n+    }\n+\n+    mainloop_api = pa_glib_mainloop_get_api(mainloop);\n+\n+    if (pa_signal_init(mainloop_api) < 0) {\n+        N_ERROR(LOG_CAT \"%s(): pa_signal_init() failed\", __FUNCTION__);\n+        goto failed;\n+    }\n+    \n+    memset(ausrv, 0, sizeof(*ausrv));\n+    ausrv->tonegend = tonegend;\n+    ausrv->server   = strdup(server ? server : DEFAULT_SERVER);","path":"src/plugins/tonegen/ausrv.c","position":92,"original_position":92,"commit_id":"322bdfa2fe2d5c776883e1d64b935d400e548485","original_commit_id":"322bdfa2fe2d5c776883e1d64b935d400e548485","user":{"login":"thp","id":135241,"avatar_url":"https://avatars.githubusercontent.com/u/135241?v=3","gravatar_id":"","url":"https://api.github.com/users/thp","html_url":"https://github.com/thp","followers_url":"https://api.github.com/users/thp/followers","following_url":"https://api.github.com/users/thp/following{/other_user}","gists_url":"https://api.github.com/users/thp/gists{/gist_id}","starred_url":"https://api.github.com/users/thp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thp/subscriptions","organizations_url":"https://api.github.com/users/thp/orgs","repos_url":"https://api.github.com/users/thp/repos","events_url":"https://api.github.com/users/thp/events{/privacy}","received_events_url":"https://api.github.com/users/thp/received_events","type":"User","site_admin":false},"body":"`server ? server : DEFAULT_SERVER` can be rewritten as `server ?: DEFAULT_SERVER` (GNU extension).","created_at":"2015-05-05T12:59:02Z","updated_at":"2015-05-05T12:59:02Z","html_url":"https://github.com/nemomobile/ngfd/pull/46#discussion_r29665270","pull_request_url":"https://api.github.com/repos/nemomobile/ngfd/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/nemomobile/ngfd/pulls/comments/29665270"},"html":{"href":"https://github.com/nemomobile/ngfd/pull/46#discussion_r29665270"},"pull_request":{"href":"https://api.github.com/repos/nemomobile/ngfd/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/nemomobile/ngfd/pulls/46","id":23981381,"html_url":"https://github.com/nemomobile/ngfd/pull/46","diff_url":"https://github.com/nemomobile/ngfd/pull/46.diff","patch_url":"https://github.com/nemomobile/ngfd/pull/46.patch","issue_url":"https://api.github.com/repos/nemomobile/ngfd/issues/46","number":46,"state":"open","locked":false,"title":"Merge tonegend as NGFD tonegen plugin.","user":{"login":"jusa","id":184568,"avatar_url":"https://avatars.githubusercontent.com/u/184568?v=3","gravatar_id":"","url":"https://api.github.com/users/jusa","html_url":"https://github.com/jusa","followers_url":"https://api.github.com/users/jusa/followers","following_url":"https://api.github.com/users/jusa/following{/other_user}","gists_url":"https://api.github.com/users/jusa/gists{/gist_id}","starred_url":"https://api.github.com/users/jusa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jusa/subscriptions","organizations_url":"https://api.github.com/users/jusa/orgs","repos_url":"https://api.github.com/users/jusa/repos","events_url":"https://api.github.com/users/jusa/events{/privacy}","received_events_url":"https://api.github.com/users/jusa/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-11-06T13:50:56Z","updated_at":"2015-05-05T12:59:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"29bf973998dab4a3422b27cc95b523fa71663d06","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nemomobile/ngfd/pulls/46/commits","review_comments_url":"https://api.github.com/repos/nemomobile/ngfd/pulls/46/comments","review_comment_url":"https://api.github.com/repos/nemomobile/ngfd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nemomobile/ngfd/issues/46/comments","statuses_url":"https://api.github.com/repos/nemomobile/ngfd/statuses/322bdfa2fe2d5c776883e1d64b935d400e548485","head":{"label":"jusa:tone-generator","ref":"tone-generator","sha":"322bdfa2fe2d5c776883e1d64b935d400e548485","user":{"login":"jusa","id":184568,"avatar_url":"https://avatars.githubusercontent.com/u/184568?v=3","gravatar_id":"","url":"https://api.github.com/users/jusa","html_url":"https://github.com/jusa","followers_url":"https://api.github.com/users/jusa/followers","following_url":"https://api.github.com/users/jusa/following{/other_user}","gists_url":"https://api.github.com/users/jusa/gists{/gist_id}","starred_url":"https://api.github.com/users/jusa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jusa/subscriptions","organizations_url":"https://api.github.com/users/jusa/orgs","repos_url":"https://api.github.com/users/jusa/repos","events_url":"https://api.github.com/users/jusa/events{/privacy}","received_events_url":"https://api.github.com/users/jusa/received_events","type":"User","site_admin":false},"repo":{"id":6756978,"name":"ngfd","full_name":"jusa/ngfd","owner":{"login":"jusa","id":184568,"avatar_url":"https://avatars.githubusercontent.com/u/184568?v=3","gravatar_id":"","url":"https://api.github.com/users/jusa","html_url":"https://github.com/jusa","followers_url":"https://api.github.com/users/jusa/followers","following_url":"https://api.github.com/users/jusa/following{/other_user}","gists_url":"https://api.github.com/users/jusa/gists{/gist_id}","starred_url":"https://api.github.com/users/jusa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jusa/subscriptions","organizations_url":"https://api.github.com/users/jusa/orgs","repos_url":"https://api.github.com/users/jusa/repos","events_url":"https://api.github.com/users/jusa/events{/privacy}","received_events_url":"https://api.github.com/users/jusa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jusa/ngfd","description":"Non-graphical feedback daemon.","fork":true,"url":"https://api.github.com/repos/jusa/ngfd","forks_url":"https://api.github.com/repos/jusa/ngfd/forks","keys_url":"https://api.github.com/repos/jusa/ngfd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jusa/ngfd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jusa/ngfd/teams","hooks_url":"https://api.github.com/repos/jusa/ngfd/hooks","issue_events_url":"https://api.github.com/repos/jusa/ngfd/issues/events{/number}","events_url":"https://api.github.com/repos/jusa/ngfd/events","assignees_url":"https://api.github.com/repos/jusa/ngfd/assignees{/user}","branches_url":"https://api.github.com/repos/jusa/ngfd/branches{/branch}","tags_url":"https://api.github.com/repos/jusa/ngfd/tags","blobs_url":"https://api.github.com/repos/jusa/ngfd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jusa/ngfd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jusa/ngfd/git/refs{/sha}","trees_url":"https://api.github.com/repos/jusa/ngfd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jusa/ngfd/statuses/{sha}","languages_url":"https://api.github.com/repos/jusa/ngfd/languages","stargazers_url":"https://api.github.com/repos/jusa/ngfd/stargazers","contributors_url":"https://api.github.com/repos/jusa/ngfd/contributors","subscribers_url":"https://api.github.com/repos/jusa/ngfd/subscribers","subscription_url":"https://api.github.com/repos/jusa/ngfd/subscription","commits_url":"https://api.github.com/repos/jusa/ngfd/commits{/sha}","git_commits_url":"https://api.github.com/repos/jusa/ngfd/git/commits{/sha}","comments_url":"https://api.github.com/repos/jusa/ngfd/comments{/number}","issue_comment_url":"https://api.github.com/repos/jusa/ngfd/issues/comments{/number}","contents_url":"https://api.github.com/repos/jusa/ngfd/contents/{+path}","compare_url":"https://api.github.com/repos/jusa/ngfd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jusa/ngfd/merges","archive_url":"https://api.github.com/repos/jusa/ngfd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jusa/ngfd/downloads","issues_url":"https://api.github.com/repos/jusa/ngfd/issues{/number}","pulls_url":"https://api.github.com/repos/jusa/ngfd/pulls{/number}","milestones_url":"https://api.github.com/repos/jusa/ngfd/milestones{/number}","notifications_url":"https://api.github.com/repos/jusa/ngfd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jusa/ngfd/labels{/name}","releases_url":"https://api.github.com/repos/jusa/ngfd/releases{/id}","created_at":"2012-11-19T08:17:47Z","updated_at":"2014-06-13T10:05:58Z","pushed_at":"2015-05-04T08:41:19Z","git_url":"git://github.com/jusa/ngfd.git","ssh_url":"git@github.com:jusa/ngfd.git","clone_url":"https://github.com/jusa/ngfd.git","svn_url":"https://github.com/jusa/ngfd","homepage":null,"size":1654,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nemomobile:master","ref":"master","sha":"9eb88180f0e3516b9f23e21fe8ef90ca33bdc583","user":{"login":"nemomobile","id":1088947,"avatar_url":"https://avatars.githubusercontent.com/u/1088947?v=3","gravatar_id":"","url":"https://api.github.com/users/nemomobile","html_url":"https://github.com/nemomobile","followers_url":"https://api.github.com/users/nemomobile/followers","following_url":"https://api.github.com/users/nemomobile/following{/other_user}","gists_url":"https://api.github.com/users/nemomobile/gists{/gist_id}","starred_url":"https://api.github.com/users/nemomobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nemomobile/subscriptions","organizations_url":"https://api.github.com/users/nemomobile/orgs","repos_url":"https://api.github.com/users/nemomobile/repos","events_url":"https://api.github.com/users/nemomobile/events{/privacy}","received_events_url":"https://api.github.com/users/nemomobile/received_events","type":"Organization","site_admin":false},"repo":{"id":6747379,"name":"ngfd","full_name":"nemomobile/ngfd","owner":{"login":"nemomobile","id":1088947,"avatar_url":"https://avatars.githubusercontent.com/u/1088947?v=3","gravatar_id":"","url":"https://api.github.com/users/nemomobile","html_url":"https://github.com/nemomobile","followers_url":"https://api.github.com/users/nemomobile/followers","following_url":"https://api.github.com/users/nemomobile/following{/other_user}","gists_url":"https://api.github.com/users/nemomobile/gists{/gist_id}","starred_url":"https://api.github.com/users/nemomobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nemomobile/subscriptions","organizations_url":"https://api.github.com/users/nemomobile/orgs","repos_url":"https://api.github.com/users/nemomobile/repos","events_url":"https://api.github.com/users/nemomobile/events{/privacy}","received_events_url":"https://api.github.com/users/nemomobile/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nemomobile/ngfd","description":"Non-graphical feedback daemon.","fork":false,"url":"https://api.github.com/repos/nemomobile/ngfd","forks_url":"https://api.github.com/repos/nemomobile/ngfd/forks","keys_url":"https://api.github.com/repos/nemomobile/ngfd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nemomobile/ngfd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nemomobile/ngfd/teams","hooks_url":"https://api.github.com/repos/nemomobile/ngfd/hooks","issue_events_url":"https://api.github.com/repos/nemomobile/ngfd/issues/events{/number}","events_url":"https://api.github.com/repos/nemomobile/ngfd/events","assignees_url":"https://api.github.com/repos/nemomobile/ngfd/assignees{/user}","branches_url":"https://api.github.com/repos/nemomobile/ngfd/branches{/branch}","tags_url":"https://api.github.com/repos/nemomobile/ngfd/tags","blobs_url":"https://api.github.com/repos/nemomobile/ngfd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nemomobile/ngfd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nemomobile/ngfd/git/refs{/sha}","trees_url":"https://api.github.com/repos/nemomobile/ngfd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nemomobile/ngfd/statuses/{sha}","languages_url":"https://api.github.com/repos/nemomobile/ngfd/languages","stargazers_url":"https://api.github.com/repos/nemomobile/ngfd/stargazers","contributors_url":"https://api.github.com/repos/nemomobile/ngfd/contributors","subscribers_url":"https://api.github.com/repos/nemomobile/ngfd/subscribers","subscription_url":"https://api.github.com/repos/nemomobile/ngfd/subscription","commits_url":"https://api.github.com/repos/nemomobile/ngfd/commits{/sha}","git_commits_url":"https://api.github.com/repos/nemomobile/ngfd/git/commits{/sha}","comments_url":"https://api.github.com/repos/nemomobile/ngfd/comments{/number}","issue_comment_url":"https://api.github.com/repos/nemomobile/ngfd/issues/comments{/number}","contents_url":"https://api.github.com/repos/nemomobile/ngfd/contents/{+path}","compare_url":"https://api.github.com/repos/nemomobile/ngfd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nemomobile/ngfd/merges","archive_url":"https://api.github.com/repos/nemomobile/ngfd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nemomobile/ngfd/downloads","issues_url":"https://api.github.com/repos/nemomobile/ngfd/issues{/number}","pulls_url":"https://api.github.com/repos/nemomobile/ngfd/pulls{/number}","milestones_url":"https://api.github.com/repos/nemomobile/ngfd/milestones{/number}","notifications_url":"https://api.github.com/repos/nemomobile/ngfd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nemomobile/ngfd/labels{/name}","releases_url":"https://api.github.com/repos/nemomobile/ngfd/releases{/id}","created_at":"2012-11-18T14:19:10Z","updated_at":"2014-07-23T12:35:40Z","pushed_at":"2015-05-04T08:41:20Z","git_url":"git://github.com/nemomobile/ngfd.git","ssh_url":"git@github.com:nemomobile/ngfd.git","clone_url":"https://github.com/nemomobile/ngfd.git","svn_url":"https://github.com/nemomobile/ngfd","homepage":null,"size":1911,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":2,"forks":12,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nemomobile/ngfd/pulls/46"},"html":{"href":"https://github.com/nemomobile/ngfd/pull/46"},"issue":{"href":"https://api.github.com/repos/nemomobile/ngfd/issues/46"},"comments":{"href":"https://api.github.com/repos/nemomobile/ngfd/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/nemomobile/ngfd/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/nemomobile/ngfd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nemomobile/ngfd/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/nemomobile/ngfd/statuses/322bdfa2fe2d5c776883e1d64b935d400e548485"}}}}