{"action":"created","comment":{"url":"https://api.github.com/repos/google/oboe/pulls/comments/193874901","pull_request_review_id":126938720,"id":193874901,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Mzg3NDkwMQ==","diff_hunk":"@@ -0,0 +1,277 @@\n+/*\n+ * Copyright 2018 The Android Open Source Project\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+#include \"AudioEffect.h\"\n+#include <logging_macros.h>\n+#include <climits>\n+#include <cstring>\n+#include <audio_common.h>\n+\n+/*\n+ * Mixing Audio in integer domain to avoid FP calculation\n+ *   (FG * ( MixFactor * 16 ) + BG * ( (1.0f-MixFactor) * 16 )) / 16\n+ */\n+static const int32_t kFloatToIntMapFactor = 128;\n+\n+AudioMixer::AudioMixer() :\n+    AudioFormat(48000, 2, oboe::AudioFormat::I16) {\n+\n+  busy_ = false;\n+  bgMixFactorInt_ = (int32_t)\n+                   (bgMixFactor_ * kFloatToIntMapFactor + 0.5f);\n+  fgMixFactorInt_ = kFloatToIntMapFactor - bgMixFactorInt_;\n+}\n+\n+/**\n+ * destructor: release memory for audio samples\n+ */\n+AudioMixer::~AudioMixer() {\n+}\n+/**\n+ * Set mix factor for the 2 streams( background and forground );\n+ * blending:\n+ *    recordedAudio * fgMix +\n+ *    backgroundMusic * ( 1.0f - fgMix )\n+ * @param fgMix is background music mixer\n+ */\n+void  AudioMixer::setBackgroundMixer(float mixer) {\n+  if (mixer >= 0.0f && mixer <= 1.0f) {\n+    bgMixFactor_ = mixer;\n+    bgMixFactorInt_ = (int32_t)\n+      (bgMixFactor_ * kFloatToIntMapFactor + 0.5f);\n+    fgMixFactorInt_ = kFloatToIntMapFactor - bgMixFactorInt_;\n+  }\n+}\n+\n+/**\n+ * Insert a raw PCM audio buffer to blend with live audio\n+ *\n+ * @param samples points to PCM audio buffer\n+ * @param sampleCount is total samples pointed by samples\n+ * @param channelCount channels for PCM audio pointed by samples\n+ * @param freq is PCM audio frequency (48000hz for this sample)\n+ */\n+void  AudioMixer::addStream(std::unique_ptr<int16_t[]>samples, size_t sampleCount,\n+          int32_t sampleRate, int32_t channelCount, oboe::AudioFormat format){\n+  if (busy_) {","path":"samples/echo/src/main/cpp/AudioEffect.cpp","position":68,"original_position":68,"commit_id":"c6d2ac921851247adb7aedca4aafdc1e940e7124","original_commit_id":"c6d2ac921851247adb7aedca4aafdc1e940e7124","user":{"login":"ggfan","id":10564521,"node_id":"MDQ6VXNlcjEwNTY0NTIx","avatar_url":"https://avatars3.githubusercontent.com/u/10564521?v=4","gravatar_id":"","url":"https://api.github.com/users/ggfan","html_url":"https://github.com/ggfan","followers_url":"https://api.github.com/users/ggfan/followers","following_url":"https://api.github.com/users/ggfan/following{/other_user}","gists_url":"https://api.github.com/users/ggfan/gists{/gist_id}","starred_url":"https://api.github.com/users/ggfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggfan/subscriptions","organizations_url":"https://api.github.com/users/ggfan/orgs","repos_url":"https://api.github.com/users/ggfan/repos","events_url":"https://api.github.com/users/ggfan/events{/privacy}","received_events_url":"https://api.github.com/users/ggfan/received_events","type":"User","site_admin":false},"body":"I see what you mean: yeah there is a brief window of contention. I will add lock to it","created_at":"2018-06-07T20:12:06Z","updated_at":"2018-06-07T20:12:07Z","html_url":"https://github.com/google/oboe/pull/103#discussion_r193874901","pull_request_url":"https://api.github.com/repos/google/oboe/pulls/103","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/google/oboe/pulls/comments/193874901"},"html":{"href":"https://github.com/google/oboe/pull/103#discussion_r193874901"},"pull_request":{"href":"https://api.github.com/repos/google/oboe/pulls/103"}},"in_reply_to_id":193866276},"pull_request":{"url":"https://api.github.com/repos/google/oboe/pulls/103","id":193216054,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzMjE2MDU0","html_url":"https://github.com/google/oboe/pull/103","diff_url":"https://github.com/google/oboe/pull/103.diff","patch_url":"https://github.com/google/oboe/pull/103.patch","issue_url":"https://api.github.com/repos/google/oboe/issues/103","number":103,"state":"open","locked":false,"title":"Adding loopback example ( echo ) sample","user":{"login":"ggfan","id":10564521,"node_id":"MDQ6VXNlcjEwNTY0NTIx","avatar_url":"https://avatars3.githubusercontent.com/u/10564521?v=4","gravatar_id":"","url":"https://api.github.com/users/ggfan","html_url":"https://github.com/ggfan","followers_url":"https://api.github.com/users/ggfan/followers","following_url":"https://api.github.com/users/ggfan/following{/other_user}","gists_url":"https://api.github.com/users/ggfan/gists{/gist_id}","starred_url":"https://api.github.com/users/ggfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggfan/subscriptions","organizations_url":"https://api.github.com/users/ggfan/orgs","repos_url":"https://api.github.com/users/ggfan/repos","events_url":"https://api.github.com/users/ggfan/events{/privacy}","received_events_url":"https://api.github.com/users/ggfan/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-07T06:31:56Z","updated_at":"2018-06-07T20:12:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d28937fb7ec957ab93852cb5766db6b3c50c05c","assignee":null,"assignees":[],"requested_reviewers":[{"login":"dturner","id":873212,"node_id":"MDQ6VXNlcjg3MzIxMg==","avatar_url":"https://avatars1.githubusercontent.com/u/873212?v=4","gravatar_id":"","url":"https://api.github.com/users/dturner","html_url":"https://github.com/dturner","followers_url":"https://api.github.com/users/dturner/followers","following_url":"https://api.github.com/users/dturner/following{/other_user}","gists_url":"https://api.github.com/users/dturner/gists{/gist_id}","starred_url":"https://api.github.com/users/dturner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dturner/subscriptions","organizations_url":"https://api.github.com/users/dturner/orgs","repos_url":"https://api.github.com/users/dturner/repos","events_url":"https://api.github.com/users/dturner/events{/privacy}","received_events_url":"https://api.github.com/users/dturner/received_events","type":"User","site_admin":false},{"login":"philburk","id":5175913,"node_id":"MDQ6VXNlcjUxNzU5MTM=","avatar_url":"https://avatars0.githubusercontent.com/u/5175913?v=4","gravatar_id":"","url":"https://api.github.com/users/philburk","html_url":"https://github.com/philburk","followers_url":"https://api.github.com/users/philburk/followers","following_url":"https://api.github.com/users/philburk/following{/other_user}","gists_url":"https://api.github.com/users/philburk/gists{/gist_id}","starred_url":"https://api.github.com/users/philburk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philburk/subscriptions","organizations_url":"https://api.github.com/users/philburk/orgs","repos_url":"https://api.github.com/users/philburk/repos","events_url":"https://api.github.com/users/philburk/events{/privacy}","received_events_url":"https://api.github.com/users/philburk/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/oboe/pulls/103/commits","review_comments_url":"https://api.github.com/repos/google/oboe/pulls/103/comments","review_comment_url":"https://api.github.com/repos/google/oboe/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/oboe/issues/103/comments","statuses_url":"https://api.github.com/repos/google/oboe/statuses/c6d2ac921851247adb7aedca4aafdc1e940e7124","head":{"label":"ggfan:echo","ref":"echo","sha":"c6d2ac921851247adb7aedca4aafdc1e940e7124","user":{"login":"ggfan","id":10564521,"node_id":"MDQ6VXNlcjEwNTY0NTIx","avatar_url":"https://avatars3.githubusercontent.com/u/10564521?v=4","gravatar_id":"","url":"https://api.github.com/users/ggfan","html_url":"https://github.com/ggfan","followers_url":"https://api.github.com/users/ggfan/followers","following_url":"https://api.github.com/users/ggfan/following{/other_user}","gists_url":"https://api.github.com/users/ggfan/gists{/gist_id}","starred_url":"https://api.github.com/users/ggfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggfan/subscriptions","organizations_url":"https://api.github.com/users/ggfan/orgs","repos_url":"https://api.github.com/users/ggfan/repos","events_url":"https://api.github.com/users/ggfan/events{/privacy}","received_events_url":"https://api.github.com/users/ggfan/received_events","type":"User","site_admin":false},"repo":{"id":134623151,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQ2MjMxNTE=","name":"oboe","full_name":"ggfan/oboe","owner":{"login":"ggfan","id":10564521,"node_id":"MDQ6VXNlcjEwNTY0NTIx","avatar_url":"https://avatars3.githubusercontent.com/u/10564521?v=4","gravatar_id":"","url":"https://api.github.com/users/ggfan","html_url":"https://github.com/ggfan","followers_url":"https://api.github.com/users/ggfan/followers","following_url":"https://api.github.com/users/ggfan/following{/other_user}","gists_url":"https://api.github.com/users/ggfan/gists{/gist_id}","starred_url":"https://api.github.com/users/ggfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggfan/subscriptions","organizations_url":"https://api.github.com/users/ggfan/orgs","repos_url":"https://api.github.com/users/ggfan/repos","events_url":"https://api.github.com/users/ggfan/events{/privacy}","received_events_url":"https://api.github.com/users/ggfan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ggfan/oboe","description":"Oboe is a C++ library which makes it easy to build high-performance audio apps on Android.","fork":true,"url":"https://api.github.com/repos/ggfan/oboe","forks_url":"https://api.github.com/repos/ggfan/oboe/forks","keys_url":"https://api.github.com/repos/ggfan/oboe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ggfan/oboe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ggfan/oboe/teams","hooks_url":"https://api.github.com/repos/ggfan/oboe/hooks","issue_events_url":"https://api.github.com/repos/ggfan/oboe/issues/events{/number}","events_url":"https://api.github.com/repos/ggfan/oboe/events","assignees_url":"https://api.github.com/repos/ggfan/oboe/assignees{/user}","branches_url":"https://api.github.com/repos/ggfan/oboe/branches{/branch}","tags_url":"https://api.github.com/repos/ggfan/oboe/tags","blobs_url":"https://api.github.com/repos/ggfan/oboe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ggfan/oboe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ggfan/oboe/git/refs{/sha}","trees_url":"https://api.github.com/repos/ggfan/oboe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ggfan/oboe/statuses/{sha}","languages_url":"https://api.github.com/repos/ggfan/oboe/languages","stargazers_url":"https://api.github.com/repos/ggfan/oboe/stargazers","contributors_url":"https://api.github.com/repos/ggfan/oboe/contributors","subscribers_url":"https://api.github.com/repos/ggfan/oboe/subscribers","subscription_url":"https://api.github.com/repos/ggfan/oboe/subscription","commits_url":"https://api.github.com/repos/ggfan/oboe/commits{/sha}","git_commits_url":"https://api.github.com/repos/ggfan/oboe/git/commits{/sha}","comments_url":"https://api.github.com/repos/ggfan/oboe/comments{/number}","issue_comment_url":"https://api.github.com/repos/ggfan/oboe/issues/comments{/number}","contents_url":"https://api.github.com/repos/ggfan/oboe/contents/{+path}","compare_url":"https://api.github.com/repos/ggfan/oboe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ggfan/oboe/merges","archive_url":"https://api.github.com/repos/ggfan/oboe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ggfan/oboe/downloads","issues_url":"https://api.github.com/repos/ggfan/oboe/issues{/number}","pulls_url":"https://api.github.com/repos/ggfan/oboe/pulls{/number}","milestones_url":"https://api.github.com/repos/ggfan/oboe/milestones{/number}","notifications_url":"https://api.github.com/repos/ggfan/oboe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ggfan/oboe/labels{/name}","releases_url":"https://api.github.com/repos/ggfan/oboe/releases{/id}","deployments_url":"https://api.github.com/repos/ggfan/oboe/deployments","created_at":"2018-05-23T20:40:24Z","updated_at":"2018-05-23T20:40:26Z","pushed_at":"2018-06-07T17:08:36Z","git_url":"git://github.com/ggfan/oboe.git","ssh_url":"git@github.com:ggfan/oboe.git","clone_url":"https://github.com/ggfan/oboe.git","svn_url":"https://github.com/ggfan/oboe","homepage":"","size":75101,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"a5f1e73cf17aff623c10356cdb292313df0aeea9","user":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":105566333,"node_id":"MDEwOlJlcG9zaXRvcnkxMDU1NjYzMzM=","name":"oboe","full_name":"google/oboe","owner":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/oboe","description":"Oboe is a C++ library which makes it easy to build high-performance audio apps on Android.","fork":false,"url":"https://api.github.com/repos/google/oboe","forks_url":"https://api.github.com/repos/google/oboe/forks","keys_url":"https://api.github.com/repos/google/oboe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/oboe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/oboe/teams","hooks_url":"https://api.github.com/repos/google/oboe/hooks","issue_events_url":"https://api.github.com/repos/google/oboe/issues/events{/number}","events_url":"https://api.github.com/repos/google/oboe/events","assignees_url":"https://api.github.com/repos/google/oboe/assignees{/user}","branches_url":"https://api.github.com/repos/google/oboe/branches{/branch}","tags_url":"https://api.github.com/repos/google/oboe/tags","blobs_url":"https://api.github.com/repos/google/oboe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/oboe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/oboe/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/oboe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/oboe/statuses/{sha}","languages_url":"https://api.github.com/repos/google/oboe/languages","stargazers_url":"https://api.github.com/repos/google/oboe/stargazers","contributors_url":"https://api.github.com/repos/google/oboe/contributors","subscribers_url":"https://api.github.com/repos/google/oboe/subscribers","subscription_url":"https://api.github.com/repos/google/oboe/subscription","commits_url":"https://api.github.com/repos/google/oboe/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/oboe/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/oboe/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/oboe/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/oboe/contents/{+path}","compare_url":"https://api.github.com/repos/google/oboe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/oboe/merges","archive_url":"https://api.github.com/repos/google/oboe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/oboe/downloads","issues_url":"https://api.github.com/repos/google/oboe/issues{/number}","pulls_url":"https://api.github.com/repos/google/oboe/pulls{/number}","milestones_url":"https://api.github.com/repos/google/oboe/milestones{/number}","notifications_url":"https://api.github.com/repos/google/oboe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/oboe/labels{/name}","releases_url":"https://api.github.com/repos/google/oboe/releases{/id}","deployments_url":"https://api.github.com/repos/google/oboe/deployments","created_at":"2017-10-02T17:56:48Z","updated_at":"2018-06-07T16:00:00Z","pushed_at":"2018-06-07T17:11:28Z","git_url":"git://github.com/google/oboe.git","ssh_url":"git@github.com:google/oboe.git","clone_url":"https://github.com/google/oboe.git","svn_url":"https://github.com/google/oboe","homepage":"","size":1779,"stargazers_count":375,"watchers_count":375,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":32,"mirror_url":null,"archived":false,"open_issues_count":23,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":32,"open_issues":23,"watchers":375,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/oboe/pulls/103"},"html":{"href":"https://github.com/google/oboe/pull/103"},"issue":{"href":"https://api.github.com/repos/google/oboe/issues/103"},"comments":{"href":"https://api.github.com/repos/google/oboe/issues/103/comments"},"review_comments":{"href":"https://api.github.com/repos/google/oboe/pulls/103/comments"},"review_comment":{"href":"https://api.github.com/repos/google/oboe/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/oboe/pulls/103/commits"},"statuses":{"href":"https://api.github.com/repos/google/oboe/statuses/c6d2ac921851247adb7aedca4aafdc1e940e7124"}},"author_association":"NONE"}}
{"actor":{"display_login":"ggfan"}}