{"action":"created","comment":{"url":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/comments/26803694","id":26803694,"diff_hunk":"@@ -0,0 +1,216 @@\n+/*\n+ * Copyright (C) 2015 Endless Mobile\n+ *\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU General Public License as\n+ * published by the Free Software Foundation; either version 2 of the\n+ * License, or (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful, but\n+ * WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+ * General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\n+ * 02111-1307, USA.\n+ *\n+ * Written by:\n+ *     Jasper St. Pierre <jstpierre@mecheye.net>\n+ */\n+\n+#include \"gis-music-player.h\"\n+\n+#include <gst/gst.h>\n+#include <stdio.h>\n+#include <string.h>\n+#include <stdint.h>\n+\n+struct _GisMusicPlayerPrivate\n+{\n+  GstElement *playbin;\n+  GstBus *bus;\n+\n+  gboolean playing;\n+  int64_t loop_point;\n+\n+  /* fade */\n+  GstClockTime fade_start_time;\n+  int fade_timeout_id;\n+  double fade_start_volume;\n+};\n+typedef struct _GisMusicPlayerPrivate GisMusicPlayerPrivate;\n+\n+G_DEFINE_TYPE_WITH_PRIVATE (GisMusicPlayer, gis_music_player, G_TYPE_OBJECT);\n+\n+static void\n+gis_music_player_dispose (GObject *object)\n+{\n+  GisMusicPlayer *player = GIS_MUSIC_PLAYER (object);\n+  GisMusicPlayerPrivate *priv = gis_music_player_get_instance_private (player);\n+\n+  g_clear_object (&priv->bus);\n+  g_clear_object (&priv->playbin);\n+}\n+\n+static void\n+gis_music_player_class_init (GisMusicPlayerClass *klass)\n+{\n+  GObjectClass *object_class = G_OBJECT_CLASS (klass);\n+\n+  object_class->dispose = gis_music_player_dispose;\n+}\n+\n+static void\n+gis_music_player_init (GisMusicPlayer *player)\n+{\n+}\n+\n+static void\n+on_state_changed (GstBus     *bus,\n+                  GstMessage *message,\n+                  gpointer    user_data)\n+{\n+  GisMusicPlayer *player = user_data;\n+  GisMusicPlayerPrivate *priv = gis_music_player_get_instance_private (player);\n+\n+  GstState old, new;\n+  gst_message_parse_state_changed (message, &old, &new, NULL);\n+  GstStateChange trans = GST_STATE_TRANSITION (old, new);\n+\n+  if (priv->playing &&\n+      message->src == GST_OBJECT (priv->playbin) &&\n+      trans == GST_STATE_CHANGE_READY_TO_PAUSED)\n+    {\n+      gst_element_seek_simple (priv->playbin, GST_FORMAT_TIME,\n+                               (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT),\n+                               0);\n+      gst_element_set_state (priv->playbin, GST_STATE_PLAYING);\n+    }\n+}\n+\n+static void\n+process_tag (const GstTagList *tag_list,\n+             const char       *tag,\n+             gpointer          user_data)\n+{\n+  GisMusicPlayer *player = user_data;\n+  GisMusicPlayerPrivate *priv = gis_music_player_get_instance_private (player);\n+\n+  /* loop points are non-standard, so they go in the extended\n+   * comments, which is gstreamer's \"catch-all\" */\n+  if (strcmp (tag, GST_TAG_EXTENDED_COMMENT) == 0)\n+    {\n+      int n = gst_tag_list_get_tag_size (tag_list, tag);\n+      while (n--)\n+        {\n+          char *str;\n+          int64_t loop_point;\n+\n+          if (!gst_tag_list_get_string_index (tag_list, tag, n, &str))\n+            continue;\n+          if (sscanf (str, \"LOOP_POINT=%\" G_GINT64_FORMAT, &loop_point) != 0)\n+            priv->loop_point = loop_point;\n+\n+          g_free (str);\n+        }\n+    }\n+}\n+\n+static void\n+on_tag (GstBus     *bus,\n+        GstMessage *message,\n+        gpointer    user_data)\n+{\n+  GstTagList *tag_list;\n+  gst_message_parse_tag (message, &tag_list);\n+  gst_tag_list_foreach (tag_list, process_tag, user_data);\n+  gst_tag_list_unref (tag_list);\n+}\n+\n+static void\n+on_segment_done (GstBus     *bus,\n+                 GstMessage *message,\n+                 gpointer    user_data)\n+{\n+  GisMusicPlayer *player = user_data;\n+  GisMusicPlayerPrivate *priv = gis_music_player_get_instance_private (player);\n+\n+  if (priv->playing &&\n+      message->src == GST_OBJECT (priv->playbin))\n+    {\n+      gst_element_seek_simple (priv->playbin, GST_FORMAT_TIME,\n+                               GST_SEEK_FLAG_SEGMENT,\n+                               priv->loop_point);\n+    }\n+}\n+\n+GisMusicPlayer *\n+gis_music_player_new (const char *uri)\n+{\n+  GisMusicPlayer *player = g_object_new (GIS_TYPE_MUSIC_PLAYER, NULL);\n+  GisMusicPlayerPrivate *priv = gis_music_player_get_instance_private (player);\n+\n+  priv->playbin = gst_element_factory_make (\"playbin\", \"player\");\n+  g_object_set (priv->playbin, \"uri\", uri, NULL);\n+\n+  priv->bus = gst_element_get_bus (priv->playbin);\n+  gst_bus_add_signal_watch (priv->bus);\n+  g_signal_connect (priv->bus, \"message::state-changed\",\n+                    G_CALLBACK (on_state_changed), player);\n+  g_signal_connect (priv->bus, \"message::segment-done\",\n+                    G_CALLBACK (on_segment_done), player);\n+  g_signal_connect (priv->bus, \"message::tag\",\n+                    G_CALLBACK (on_tag), player);\n+\n+  return player;\n+}\n+\n+void\n+gis_music_player_play (GisMusicPlayer *player)\n+{\n+  GisMusicPlayerPrivate *priv = gis_music_player_get_instance_private (player);\n+  priv->playing = TRUE;\n+  gst_element_set_state (priv->playbin, GST_STATE_PAUSED);","path":"gnome-initial-setup/gis-music-player.c","position":175,"original_position":175,"commit_id":"dfef0d981720ce071ca70c5688afb114ccb2a800","original_commit_id":"dfef0d981720ce071ca70c5688afb114ccb2a800","user":{"login":"magcius","id":40890,"avatar_url":"https://avatars.githubusercontent.com/u/40890?v=3","gravatar_id":"","url":"https://api.github.com/users/magcius","html_url":"https://github.com/magcius","followers_url":"https://api.github.com/users/magcius/followers","following_url":"https://api.github.com/users/magcius/following{/other_user}","gists_url":"https://api.github.com/users/magcius/gists{/gist_id}","starred_url":"https://api.github.com/users/magcius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magcius/subscriptions","organizations_url":"https://api.github.com/users/magcius/orgs","repos_url":"https://api.github.com/users/magcius/repos","events_url":"https://api.github.com/users/magcius/events{/privacy}","received_events_url":"https://api.github.com/users/magcius/received_events","type":"User","site_admin":false},"body":"No, it should be `PAUSED`. See the `on_state_changed` which sets it to PLAYING after the preroll is done. We need to hold off in order to do a proper segment seek.","created_at":"2015-03-19T22:19:31Z","updated_at":"2015-03-19T22:19:31Z","html_url":"https://github.com/endlessm/gnome-initial-setup/pull/87#discussion_r26803694","pull_request_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/87","_links":{"self":{"href":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/comments/26803694"},"html":{"href":"https://github.com/endlessm/gnome-initial-setup/pull/87#discussion_r26803694"},"pull_request":{"href":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/87"}}},"pull_request":{"url":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/87","id":31488173,"html_url":"https://github.com/endlessm/gnome-initial-setup/pull/87","diff_url":"https://github.com/endlessm/gnome-initial-setup/pull/87.diff","patch_url":"https://github.com/endlessm/gnome-initial-setup/pull/87.patch","issue_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/issues/87","number":87,"state":"open","locked":false,"title":"Add a music player","user":{"login":"magcius","id":40890,"avatar_url":"https://avatars.githubusercontent.com/u/40890?v=3","gravatar_id":"","url":"https://api.github.com/users/magcius","html_url":"https://github.com/magcius","followers_url":"https://api.github.com/users/magcius/followers","following_url":"https://api.github.com/users/magcius/following{/other_user}","gists_url":"https://api.github.com/users/magcius/gists{/gist_id}","starred_url":"https://api.github.com/users/magcius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magcius/subscriptions","organizations_url":"https://api.github.com/users/magcius/orgs","repos_url":"https://api.github.com/users/magcius/repos","events_url":"https://api.github.com/users/magcius/events{/privacy}","received_events_url":"https://api.github.com/users/magcius/received_events","type":"User","site_admin":false},"body":"Add the ability to play some chill tunes in a loop while going through\r\nthe FBE. There's a minimal rampout fade, but it's not hooked up yet.\r\n\r\nWe aren't going to install the actual music asset yet, pending approval\r\nour creative team. Thankfully, it's super simple to drop in once we do\r\napprove it.\r\n\r\n[endlessm/eos-shell#4765]","created_at":"2015-03-19T01:21:45Z","updated_at":"2015-03-19T22:19:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c53170a7851cad95b04346290be6f3c82d71759e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/87/commits","review_comments_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/87/comments","review_comment_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/comments{/number}","comments_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/issues/87/comments","statuses_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/statuses/dfef0d981720ce071ca70c5688afb114ccb2a800","head":{"label":"endlessm:shell/4765","ref":"shell/4765","sha":"dfef0d981720ce071ca70c5688afb114ccb2a800","user":{"login":"endlessm","id":1930958,"avatar_url":"https://avatars.githubusercontent.com/u/1930958?v=3","gravatar_id":"","url":"https://api.github.com/users/endlessm","html_url":"https://github.com/endlessm","followers_url":"https://api.github.com/users/endlessm/followers","following_url":"https://api.github.com/users/endlessm/following{/other_user}","gists_url":"https://api.github.com/users/endlessm/gists{/gist_id}","starred_url":"https://api.github.com/users/endlessm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endlessm/subscriptions","organizations_url":"https://api.github.com/users/endlessm/orgs","repos_url":"https://api.github.com/users/endlessm/repos","events_url":"https://api.github.com/users/endlessm/events{/privacy}","received_events_url":"https://api.github.com/users/endlessm/received_events","type":"Organization","site_admin":false},"repo":{"id":17677386,"name":"gnome-initial-setup","full_name":"endlessm/gnome-initial-setup","owner":{"login":"endlessm","id":1930958,"avatar_url":"https://avatars.githubusercontent.com/u/1930958?v=3","gravatar_id":"","url":"https://api.github.com/users/endlessm","html_url":"https://github.com/endlessm","followers_url":"https://api.github.com/users/endlessm/followers","following_url":"https://api.github.com/users/endlessm/following{/other_user}","gists_url":"https://api.github.com/users/endlessm/gists{/gist_id}","starred_url":"https://api.github.com/users/endlessm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endlessm/subscriptions","organizations_url":"https://api.github.com/users/endlessm/orgs","repos_url":"https://api.github.com/users/endlessm/repos","events_url":"https://api.github.com/users/endlessm/events{/privacy}","received_events_url":"https://api.github.com/users/endlessm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/endlessm/gnome-initial-setup","description":"Fork of gnome-initial-setup with endless customizations and translations","fork":false,"url":"https://api.github.com/repos/endlessm/gnome-initial-setup","forks_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/forks","keys_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/teams","hooks_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/hooks","issue_events_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/issues/events{/number}","events_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/events","assignees_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/assignees{/user}","branches_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/branches{/branch}","tags_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/tags","blobs_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/git/refs{/sha}","trees_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/statuses/{sha}","languages_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/languages","stargazers_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/stargazers","contributors_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/contributors","subscribers_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/subscribers","subscription_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/subscription","commits_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/commits{/sha}","git_commits_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/git/commits{/sha}","comments_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/comments{/number}","issue_comment_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/issues/comments{/number}","contents_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/contents/{+path}","compare_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/merges","archive_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/downloads","issues_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/issues{/number}","pulls_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls{/number}","milestones_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/milestones{/number}","notifications_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/labels{/name}","releases_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/releases{/id}","created_at":"2014-03-12T18:10:28Z","updated_at":"2015-03-19T07:07:36Z","pushed_at":"2015-03-19T07:07:35Z","git_url":"git://github.com/endlessm/gnome-initial-setup.git","ssh_url":"git@github.com:endlessm/gnome-initial-setup.git","clone_url":"https://github.com/endlessm/gnome-initial-setup.git","svn_url":"https://github.com/endlessm/gnome-initial-setup","homepage":null,"size":5481,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"endlessm:master","ref":"master","sha":"159334c87e54989e4097aac272f539dc1b141763","user":{"login":"endlessm","id":1930958,"avatar_url":"https://avatars.githubusercontent.com/u/1930958?v=3","gravatar_id":"","url":"https://api.github.com/users/endlessm","html_url":"https://github.com/endlessm","followers_url":"https://api.github.com/users/endlessm/followers","following_url":"https://api.github.com/users/endlessm/following{/other_user}","gists_url":"https://api.github.com/users/endlessm/gists{/gist_id}","starred_url":"https://api.github.com/users/endlessm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endlessm/subscriptions","organizations_url":"https://api.github.com/users/endlessm/orgs","repos_url":"https://api.github.com/users/endlessm/repos","events_url":"https://api.github.com/users/endlessm/events{/privacy}","received_events_url":"https://api.github.com/users/endlessm/received_events","type":"Organization","site_admin":false},"repo":{"id":17677386,"name":"gnome-initial-setup","full_name":"endlessm/gnome-initial-setup","owner":{"login":"endlessm","id":1930958,"avatar_url":"https://avatars.githubusercontent.com/u/1930958?v=3","gravatar_id":"","url":"https://api.github.com/users/endlessm","html_url":"https://github.com/endlessm","followers_url":"https://api.github.com/users/endlessm/followers","following_url":"https://api.github.com/users/endlessm/following{/other_user}","gists_url":"https://api.github.com/users/endlessm/gists{/gist_id}","starred_url":"https://api.github.com/users/endlessm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endlessm/subscriptions","organizations_url":"https://api.github.com/users/endlessm/orgs","repos_url":"https://api.github.com/users/endlessm/repos","events_url":"https://api.github.com/users/endlessm/events{/privacy}","received_events_url":"https://api.github.com/users/endlessm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/endlessm/gnome-initial-setup","description":"Fork of gnome-initial-setup with endless customizations and translations","fork":false,"url":"https://api.github.com/repos/endlessm/gnome-initial-setup","forks_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/forks","keys_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/teams","hooks_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/hooks","issue_events_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/issues/events{/number}","events_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/events","assignees_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/assignees{/user}","branches_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/branches{/branch}","tags_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/tags","blobs_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/git/refs{/sha}","trees_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/statuses/{sha}","languages_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/languages","stargazers_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/stargazers","contributors_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/contributors","subscribers_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/subscribers","subscription_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/subscription","commits_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/commits{/sha}","git_commits_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/git/commits{/sha}","comments_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/comments{/number}","issue_comment_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/issues/comments{/number}","contents_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/contents/{+path}","compare_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/merges","archive_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/downloads","issues_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/issues{/number}","pulls_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls{/number}","milestones_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/milestones{/number}","notifications_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/labels{/name}","releases_url":"https://api.github.com/repos/endlessm/gnome-initial-setup/releases{/id}","created_at":"2014-03-12T18:10:28Z","updated_at":"2015-03-19T07:07:36Z","pushed_at":"2015-03-19T07:07:35Z","git_url":"git://github.com/endlessm/gnome-initial-setup.git","ssh_url":"git@github.com:endlessm/gnome-initial-setup.git","clone_url":"https://github.com/endlessm/gnome-initial-setup.git","svn_url":"https://github.com/endlessm/gnome-initial-setup","homepage":null,"size":5481,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/87"},"html":{"href":"https://github.com/endlessm/gnome-initial-setup/pull/87"},"issue":{"href":"https://api.github.com/repos/endlessm/gnome-initial-setup/issues/87"},"comments":{"href":"https://api.github.com/repos/endlessm/gnome-initial-setup/issues/87/comments"},"review_comments":{"href":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/87/comments"},"review_comment":{"href":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/endlessm/gnome-initial-setup/pulls/87/commits"},"statuses":{"href":"https://api.github.com/repos/endlessm/gnome-initial-setup/statuses/dfef0d981720ce071ca70c5688afb114ccb2a800"}}}}