{"action":"created","comment":{"url":"https://api.github.com/repos/ferjm/media/pulls/comments/187444881","pull_request_review_id":119228737,"id":187444881,"diff_hunk":"@@ -368,3 +369,56 @@ pub fn register() {\n     let type_ = register_type(AudioSrcStatic);\n     gst::Element::register(None, \"servoaudiosrc\", 0, type_);\n }\n+\n+pub fn app_src_oscillator() -> Result<gst::Element, ()> {\n+    let src = gst::ElementFactory::make(\"appsrc\", None).ok_or(())?;\n+    let src = src.downcast::<AppSrc>().map_err(|_| ())?;\n+    let info = gst_audio::AudioInfo::new(gst_audio::AUDIO_FORMAT_F32, 48000 , 1)\n+        .build().ok_or(())?;\n+    src.set_caps(&info.to_caps().unwrap());\n+    src.set_property_format(gst::Format::Time);\n+    src.set_max_bytes(1);\n+    src.set_property_block(true);\n+    let settings = Settings::default();\n+    let mut sample_offset = 0;\n+    let mut accumulator = 0.;\n+    let n_samples = settings.samples_per_buffer as u64;\n+    let buf_size = (n_samples as usize) * (info.bpf() as usize);\n+    let rate = info.rate();\n+\n+\n+    // AudioSrc::process::<f64>(&mut vec, &mut 0., DEFAULT_FREQ, 1 / samples as u32, 1, DEFAULT_VOLUME);\n+    let need_data = move |app: &AppSrc, _bytes| {\n+        let mut buffer =\n+            gst::Buffer::with_size(buf_size).unwrap();\n+        {\n+            let buffer = buffer.get_mut().unwrap();\n+            // Calculate the current timestamp (PTS) and the next one,\n+            // and calculate the duration from the difference instead of\n+            // simply the number of samples to prevent rounding errors\n+            let pts = sample_offset\n+                .mul_div_floor(gst::SECOND_VAL, rate as u64)\n+                .unwrap()\n+                .into();\n+            let next_pts: gst::ClockTime = (sample_offset + n_samples)\n+                .mul_div_floor(gst::SECOND_VAL, rate as u64)\n+                .unwrap()\n+                .into();\n+            buffer.set_pts(pts);\n+            buffer.set_duration(next_pts - pts);\n+            let mut map = buffer.map_writable().unwrap();\n+            let data = map.as_mut_slice();\n+             AudioSrc::process::<f32>(data, &mut accumulator, settings.freq,\n+                                      rate, 1, settings.volume);\n+            sample_offset += n_samples;\n+\n+        }\n+        let _ = app.push_buffer(buffer);","path":"src/backends/gstreamer/src_element.rs","position":54,"original_position":56,"commit_id":"04e6403243d28391bf14edb0be9e17b80483f28d","original_commit_id":"b9785b1162428fa9b667ec79fa77f3caad36c563","user":{"login":"sdroege","id":301846,"avatar_url":"https://avatars3.githubusercontent.com/u/301846?v=4","gravatar_id":"","url":"https://api.github.com/users/sdroege","html_url":"https://github.com/sdroege","followers_url":"https://api.github.com/users/sdroege/followers","following_url":"https://api.github.com/users/sdroege/following{/other_user}","gists_url":"https://api.github.com/users/sdroege/gists{/gist_id}","starred_url":"https://api.github.com/users/sdroege/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdroege/subscriptions","organizations_url":"https://api.github.com/users/sdroege/orgs","repos_url":"https://api.github.com/users/sdroege/repos","events_url":"https://api.github.com/users/sdroege/events{/privacy}","received_events_url":"https://api.github.com/users/sdroege/received_events","type":"User","site_admin":false},"body":"Right, but a future version of this code might do more things :) Anyway, ignore this comment for the time being then","created_at":"2018-05-10T20:09:43Z","updated_at":"2018-05-10T20:09:43Z","html_url":"https://github.com/ferjm/media/pull/4#discussion_r187444881","pull_request_url":"https://api.github.com/repos/ferjm/media/pulls/4","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/ferjm/media/pulls/comments/187444881"},"html":{"href":"https://github.com/ferjm/media/pull/4#discussion_r187444881"},"pull_request":{"href":"https://api.github.com/repos/ferjm/media/pulls/4"}},"in_reply_to_id":187258459},"pull_request":{"url":"https://api.github.com/repos/ferjm/media/pulls/4","id":187062105,"html_url":"https://github.com/ferjm/media/pull/4","diff_url":"https://github.com/ferjm/media/pull/4.diff","patch_url":"https://github.com/ferjm/media/pull/4.patch","issue_url":"https://api.github.com/repos/ferjm/media/issues/4","number":4,"state":"open","locked":false,"title":"Switch BaseSrc to AppSrc","user":{"login":"Manishearth","id":1617736,"avatar_url":"https://avatars2.githubusercontent.com/u/1617736?v=4","gravatar_id":"","url":"https://api.github.com/users/Manishearth","html_url":"https://github.com/Manishearth","followers_url":"https://api.github.com/users/Manishearth/followers","following_url":"https://api.github.com/users/Manishearth/following{/other_user}","gists_url":"https://api.github.com/users/Manishearth/gists{/gist_id}","starred_url":"https://api.github.com/users/Manishearth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Manishearth/subscriptions","organizations_url":"https://api.github.com/users/Manishearth/orgs","repos_url":"https://api.github.com/users/Manishearth/repos","events_url":"https://api.github.com/users/Manishearth/events{/privacy}","received_events_url":"https://api.github.com/users/Manishearth/received_events","type":"User","site_admin":false},"body":"I'm not sure which one we plan to choose so both are still implemented here and not cleaned up too much.\n\nr? @ferjm\n\ncc @sdroege","created_at":"2018-05-09T23:01:27Z","updated_at":"2018-05-10T20:09:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ferjm/media/pulls/4/commits","review_comments_url":"https://api.github.com/repos/ferjm/media/pulls/4/comments","review_comment_url":"https://api.github.com/repos/ferjm/media/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ferjm/media/issues/4/comments","statuses_url":"https://api.github.com/repos/ferjm/media/statuses/04e6403243d28391bf14edb0be9e17b80483f28d","head":{"label":"Manishearth:appsrc","ref":"appsrc","sha":"04e6403243d28391bf14edb0be9e17b80483f28d","user":{"login":"Manishearth","id":1617736,"avatar_url":"https://avatars2.githubusercontent.com/u/1617736?v=4","gravatar_id":"","url":"https://api.github.com/users/Manishearth","html_url":"https://github.com/Manishearth","followers_url":"https://api.github.com/users/Manishearth/followers","following_url":"https://api.github.com/users/Manishearth/following{/other_user}","gists_url":"https://api.github.com/users/Manishearth/gists{/gist_id}","starred_url":"https://api.github.com/users/Manishearth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Manishearth/subscriptions","organizations_url":"https://api.github.com/users/Manishearth/orgs","repos_url":"https://api.github.com/users/Manishearth/repos","events_url":"https://api.github.com/users/Manishearth/events{/privacy}","received_events_url":"https://api.github.com/users/Manishearth/received_events","type":"User","site_admin":false},"repo":{"id":130885645,"name":"media","full_name":"Manishearth/media","owner":{"login":"Manishearth","id":1617736,"avatar_url":"https://avatars2.githubusercontent.com/u/1617736?v=4","gravatar_id":"","url":"https://api.github.com/users/Manishearth","html_url":"https://github.com/Manishearth","followers_url":"https://api.github.com/users/Manishearth/followers","following_url":"https://api.github.com/users/Manishearth/following{/other_user}","gists_url":"https://api.github.com/users/Manishearth/gists{/gist_id}","starred_url":"https://api.github.com/users/Manishearth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Manishearth/subscriptions","organizations_url":"https://api.github.com/users/Manishearth/orgs","repos_url":"https://api.github.com/users/Manishearth/repos","events_url":"https://api.github.com/users/Manishearth/events{/privacy}","received_events_url":"https://api.github.com/users/Manishearth/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Manishearth/media","description":null,"fork":true,"url":"https://api.github.com/repos/Manishearth/media","forks_url":"https://api.github.com/repos/Manishearth/media/forks","keys_url":"https://api.github.com/repos/Manishearth/media/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Manishearth/media/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Manishearth/media/teams","hooks_url":"https://api.github.com/repos/Manishearth/media/hooks","issue_events_url":"https://api.github.com/repos/Manishearth/media/issues/events{/number}","events_url":"https://api.github.com/repos/Manishearth/media/events","assignees_url":"https://api.github.com/repos/Manishearth/media/assignees{/user}","branches_url":"https://api.github.com/repos/Manishearth/media/branches{/branch}","tags_url":"https://api.github.com/repos/Manishearth/media/tags","blobs_url":"https://api.github.com/repos/Manishearth/media/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Manishearth/media/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Manishearth/media/git/refs{/sha}","trees_url":"https://api.github.com/repos/Manishearth/media/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Manishearth/media/statuses/{sha}","languages_url":"https://api.github.com/repos/Manishearth/media/languages","stargazers_url":"https://api.github.com/repos/Manishearth/media/stargazers","contributors_url":"https://api.github.com/repos/Manishearth/media/contributors","subscribers_url":"https://api.github.com/repos/Manishearth/media/subscribers","subscription_url":"https://api.github.com/repos/Manishearth/media/subscription","commits_url":"https://api.github.com/repos/Manishearth/media/commits{/sha}","git_commits_url":"https://api.github.com/repos/Manishearth/media/git/commits{/sha}","comments_url":"https://api.github.com/repos/Manishearth/media/comments{/number}","issue_comment_url":"https://api.github.com/repos/Manishearth/media/issues/comments{/number}","contents_url":"https://api.github.com/repos/Manishearth/media/contents/{+path}","compare_url":"https://api.github.com/repos/Manishearth/media/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Manishearth/media/merges","archive_url":"https://api.github.com/repos/Manishearth/media/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Manishearth/media/downloads","issues_url":"https://api.github.com/repos/Manishearth/media/issues{/number}","pulls_url":"https://api.github.com/repos/Manishearth/media/pulls{/number}","milestones_url":"https://api.github.com/repos/Manishearth/media/milestones{/number}","notifications_url":"https://api.github.com/repos/Manishearth/media/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Manishearth/media/labels{/name}","releases_url":"https://api.github.com/repos/Manishearth/media/releases{/id}","deployments_url":"https://api.github.com/repos/Manishearth/media/deployments","created_at":"2018-04-24T16:47:02Z","updated_at":"2018-04-24T16:47:04Z","pushed_at":"2018-05-10T17:16:32Z","git_url":"git://github.com/Manishearth/media.git","ssh_url":"git@github.com:Manishearth/media.git","clone_url":"https://github.com/Manishearth/media.git","svn_url":"https://github.com/Manishearth/media","homepage":null,"size":208,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ferjm:master","ref":"master","sha":"95c6dac16485422dcc14970068b094db5e6ff3a8","user":{"login":"ferjm","id":480202,"avatar_url":"https://avatars0.githubusercontent.com/u/480202?v=4","gravatar_id":"","url":"https://api.github.com/users/ferjm","html_url":"https://github.com/ferjm","followers_url":"https://api.github.com/users/ferjm/followers","following_url":"https://api.github.com/users/ferjm/following{/other_user}","gists_url":"https://api.github.com/users/ferjm/gists{/gist_id}","starred_url":"https://api.github.com/users/ferjm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferjm/subscriptions","organizations_url":"https://api.github.com/users/ferjm/orgs","repos_url":"https://api.github.com/users/ferjm/repos","events_url":"https://api.github.com/users/ferjm/events{/privacy}","received_events_url":"https://api.github.com/users/ferjm/received_events","type":"User","site_admin":false},"repo":{"id":125494444,"name":"media","full_name":"ferjm/media","owner":{"login":"ferjm","id":480202,"avatar_url":"https://avatars0.githubusercontent.com/u/480202?v=4","gravatar_id":"","url":"https://api.github.com/users/ferjm","html_url":"https://github.com/ferjm","followers_url":"https://api.github.com/users/ferjm/followers","following_url":"https://api.github.com/users/ferjm/following{/other_user}","gists_url":"https://api.github.com/users/ferjm/gists{/gist_id}","starred_url":"https://api.github.com/users/ferjm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferjm/subscriptions","organizations_url":"https://api.github.com/users/ferjm/orgs","repos_url":"https://api.github.com/users/ferjm/repos","events_url":"https://api.github.com/users/ferjm/events{/privacy}","received_events_url":"https://api.github.com/users/ferjm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ferjm/media","description":null,"fork":false,"url":"https://api.github.com/repos/ferjm/media","forks_url":"https://api.github.com/repos/ferjm/media/forks","keys_url":"https://api.github.com/repos/ferjm/media/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ferjm/media/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ferjm/media/teams","hooks_url":"https://api.github.com/repos/ferjm/media/hooks","issue_events_url":"https://api.github.com/repos/ferjm/media/issues/events{/number}","events_url":"https://api.github.com/repos/ferjm/media/events","assignees_url":"https://api.github.com/repos/ferjm/media/assignees{/user}","branches_url":"https://api.github.com/repos/ferjm/media/branches{/branch}","tags_url":"https://api.github.com/repos/ferjm/media/tags","blobs_url":"https://api.github.com/repos/ferjm/media/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ferjm/media/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ferjm/media/git/refs{/sha}","trees_url":"https://api.github.com/repos/ferjm/media/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ferjm/media/statuses/{sha}","languages_url":"https://api.github.com/repos/ferjm/media/languages","stargazers_url":"https://api.github.com/repos/ferjm/media/stargazers","contributors_url":"https://api.github.com/repos/ferjm/media/contributors","subscribers_url":"https://api.github.com/repos/ferjm/media/subscribers","subscription_url":"https://api.github.com/repos/ferjm/media/subscription","commits_url":"https://api.github.com/repos/ferjm/media/commits{/sha}","git_commits_url":"https://api.github.com/repos/ferjm/media/git/commits{/sha}","comments_url":"https://api.github.com/repos/ferjm/media/comments{/number}","issue_comment_url":"https://api.github.com/repos/ferjm/media/issues/comments{/number}","contents_url":"https://api.github.com/repos/ferjm/media/contents/{+path}","compare_url":"https://api.github.com/repos/ferjm/media/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ferjm/media/merges","archive_url":"https://api.github.com/repos/ferjm/media/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ferjm/media/downloads","issues_url":"https://api.github.com/repos/ferjm/media/issues{/number}","pulls_url":"https://api.github.com/repos/ferjm/media/pulls{/number}","milestones_url":"https://api.github.com/repos/ferjm/media/milestones{/number}","notifications_url":"https://api.github.com/repos/ferjm/media/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ferjm/media/labels{/name}","releases_url":"https://api.github.com/repos/ferjm/media/releases{/id}","deployments_url":"https://api.github.com/repos/ferjm/media/deployments","created_at":"2018-03-16T09:29:29Z","updated_at":"2018-05-04T09:13:17Z","pushed_at":"2018-05-10T17:16:35Z","git_url":"git://github.com/ferjm/media.git","ssh_url":"git@github.com:ferjm/media.git","clone_url":"https://github.com/ferjm/media.git","svn_url":"https://github.com/ferjm/media","homepage":null,"size":229,"stargazers_count":1,"watchers_count":1,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":2,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ferjm/media/pulls/4"},"html":{"href":"https://github.com/ferjm/media/pull/4"},"issue":{"href":"https://api.github.com/repos/ferjm/media/issues/4"},"comments":{"href":"https://api.github.com/repos/ferjm/media/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/ferjm/media/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/ferjm/media/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ferjm/media/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/ferjm/media/statuses/04e6403243d28391bf14edb0be9e17b80483f28d"}},"author_association":"NONE"}}
{"actor":{"display_login":"sdroege"}}