{"action":"created","comment":{"url":"https://api.github.com/repos/mosra/magnum-plugins/pulls/comments/40906701","id":40906701,"diff_hunk":"@@ -0,0 +1,95 @@\n+/*\n+    This file is part of Magnum.\n+\n+    Copyright © 2010, 2011, 2012, 2013, 2014, 2015\n+              Vladimír Vondruš <mosra@centrum.cz>\n+    Copyright © 2015 Jonathan Hale <squareys@googlemail.com>\n+\n+    Permission is hereby granted, free of charge, to any person obtaining a\n+    copy of this software and associated documentation files (the \"Software\"),\n+    to deal in the Software without restriction, including without limitation\n+    the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+    and/or sell copies of the Software, and to permit persons to whom the\n+    Software is furnished to do so, subject to the following conditions:\n+\n+    The above copyright notice and this permission notice shall be included\n+    in all copies or substantial portions of the Software.\n+\n+    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n+    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n+    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n+    DEALINGS IN THE SOFTWARE.\n+*/\n+\n+#include \"StbVorbisImporter.h\"\n+\n+#include <Corrade/Utility/Assert.h>\n+#include <Corrade/Utility/Debug.h>\n+#include <Corrade/Utility/Endianness.h>\n+\n+#include \"stb_vorbis.c\"\n+\n+namespace Magnum { namespace Audio {\n+\n+StbVorbisImporter::StbVorbisImporter() = default;\n+\n+StbVorbisImporter::StbVorbisImporter(PluginManager::AbstractManager& manager, std::string plugin): AbstractImporter(manager, std::move(plugin)) {}\n+\n+StbVorbisImporter::~StbVorbisImporter() { close(); }\n+\n+auto StbVorbisImporter::doFeatures() const -> Features { return Feature::OpenData; }\n+\n+bool StbVorbisImporter::doIsOpened() const { return _data; }\n+\n+void StbVorbisImporter::doOpenData(Containers::ArrayView<const char> data) {\n+\n+    Int numChannels, frequency;\n+    Short* decodedData;\n+\n+    Int samples = stb_vorbis_decode_memory(reinterpret_cast<const UnsignedByte*>(data.data()), data.size(), &numChannels, &frequency, &decodedData);\n+    _data = Containers::Array<char>(reinterpret_cast<char*>(decodedData), samples*numChannels*2);","path":"src/MagnumPlugins/StbVorbisImporter/StbVorbisImporter.cpp","position":53,"original_position":53,"commit_id":"2295501112910b9109ce7437d8af6906833fc6c3","original_commit_id":"2295501112910b9109ce7437d8af6906833fc6c3","user":{"login":"mosra","id":344828,"avatar_url":"https://avatars.githubusercontent.com/u/344828?v=3","gravatar_id":"","url":"https://api.github.com/users/mosra","html_url":"https://github.com/mosra","followers_url":"https://api.github.com/users/mosra/followers","following_url":"https://api.github.com/users/mosra/following{/other_user}","gists_url":"https://api.github.com/users/mosra/gists{/gist_id}","starred_url":"https://api.github.com/users/mosra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosra/subscriptions","organizations_url":"https://api.github.com/users/mosra/orgs","repos_url":"https://api.github.com/users/mosra/repos","events_url":"https://api.github.com/users/mosra/events{/privacy}","received_events_url":"https://api.github.com/users/mosra/received_events","type":"User","site_admin":false},"body":"It will be done implicitly when the local Array instance goes out of scope, no?\r\n\r\nIf I remember correctly, memory in stb_* is allocated using `malloc` so you can't use `delete`. See e.g. fd9726c52aea146fb2ff93978c57678ed5ffb023 for solution. Consult the documentation for details (might be done differently in stb_vorbis, I don't know).","created_at":"2015-10-01T12:23:31Z","updated_at":"2015-10-01T12:23:31Z","html_url":"https://github.com/mosra/magnum-plugins/pull/8#discussion_r40906701","pull_request_url":"https://api.github.com/repos/mosra/magnum-plugins/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/mosra/magnum-plugins/pulls/comments/40906701"},"html":{"href":"https://github.com/mosra/magnum-plugins/pull/8#discussion_r40906701"},"pull_request":{"href":"https://api.github.com/repos/mosra/magnum-plugins/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/mosra/magnum-plugins/pulls/8","id":46514817,"html_url":"https://github.com/mosra/magnum-plugins/pull/8","diff_url":"https://github.com/mosra/magnum-plugins/pull/8.diff","patch_url":"https://github.com/mosra/magnum-plugins/pull/8.patch","issue_url":"https://api.github.com/repos/mosra/magnum-plugins/issues/8","number":8,"state":"open","locked":false,"title":"Add Vorbis/Ogg Importer based on stb_vorbis","user":{"login":"Squareys","id":1889284,"avatar_url":"https://avatars.githubusercontent.com/u/1889284?v=3","gravatar_id":"","url":"https://api.github.com/users/Squareys","html_url":"https://github.com/Squareys","followers_url":"https://api.github.com/users/Squareys/followers","following_url":"https://api.github.com/users/Squareys/following{/other_user}","gists_url":"https://api.github.com/users/Squareys/gists{/gist_id}","starred_url":"https://api.github.com/users/Squareys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Squareys/subscriptions","organizations_url":"https://api.github.com/users/Squareys/orgs","repos_url":"https://api.github.com/users/Squareys/repos","events_url":"https://api.github.com/users/Squareys/events{/privacy}","received_events_url":"https://api.github.com/users/Squareys/received_events","type":"User","site_admin":false},"body":"Hi @mosra !\r\n\r\nStb is really something, this went pretty quick! The importer only supports 16 bit mono/stereo, no streaming, but here is ogg files support for magnum.\r\n\r\nstb_vorbis could also support float data, which will have to wait until `audio-extension-support` is done, though.\r\n\r\nIt would be awesome if you could have a quick look at this (it's basically only 10 lines of code or so, everything else is pretty much identical to the wav importer).\r\n\r\nGreetings,\r\nSquareys","created_at":"2015-10-01T12:01:49Z","updated_at":"2015-10-01T12:23:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"44790ae2dc03e185cf9dc80ca906c68581eb559b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mosra/magnum-plugins/pulls/8/commits","review_comments_url":"https://api.github.com/repos/mosra/magnum-plugins/pulls/8/comments","review_comment_url":"https://api.github.com/repos/mosra/magnum-plugins/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mosra/magnum-plugins/issues/8/comments","statuses_url":"https://api.github.com/repos/mosra/magnum-plugins/statuses/2295501112910b9109ce7437d8af6906833fc6c3","head":{"label":"Squareys:stb-vorbis-importer","ref":"stb-vorbis-importer","sha":"2295501112910b9109ce7437d8af6906833fc6c3","user":{"login":"Squareys","id":1889284,"avatar_url":"https://avatars.githubusercontent.com/u/1889284?v=3","gravatar_id":"","url":"https://api.github.com/users/Squareys","html_url":"https://github.com/Squareys","followers_url":"https://api.github.com/users/Squareys/followers","following_url":"https://api.github.com/users/Squareys/following{/other_user}","gists_url":"https://api.github.com/users/Squareys/gists{/gist_id}","starred_url":"https://api.github.com/users/Squareys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Squareys/subscriptions","organizations_url":"https://api.github.com/users/Squareys/orgs","repos_url":"https://api.github.com/users/Squareys/repos","events_url":"https://api.github.com/users/Squareys/events{/privacy}","received_events_url":"https://api.github.com/users/Squareys/received_events","type":"User","site_admin":false},"repo":{"id":40075154,"name":"magnum-plugins","full_name":"Squareys/magnum-plugins","owner":{"login":"Squareys","id":1889284,"avatar_url":"https://avatars.githubusercontent.com/u/1889284?v=3","gravatar_id":"","url":"https://api.github.com/users/Squareys","html_url":"https://github.com/Squareys","followers_url":"https://api.github.com/users/Squareys/followers","following_url":"https://api.github.com/users/Squareys/following{/other_user}","gists_url":"https://api.github.com/users/Squareys/gists{/gist_id}","starred_url":"https://api.github.com/users/Squareys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Squareys/subscriptions","organizations_url":"https://api.github.com/users/Squareys/orgs","repos_url":"https://api.github.com/users/Squareys/repos","events_url":"https://api.github.com/users/Squareys/events{/privacy}","received_events_url":"https://api.github.com/users/Squareys/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Squareys/magnum-plugins","description":"Plugins for Magnum graphics engine","fork":true,"url":"https://api.github.com/repos/Squareys/magnum-plugins","forks_url":"https://api.github.com/repos/Squareys/magnum-plugins/forks","keys_url":"https://api.github.com/repos/Squareys/magnum-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Squareys/magnum-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Squareys/magnum-plugins/teams","hooks_url":"https://api.github.com/repos/Squareys/magnum-plugins/hooks","issue_events_url":"https://api.github.com/repos/Squareys/magnum-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/Squareys/magnum-plugins/events","assignees_url":"https://api.github.com/repos/Squareys/magnum-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/Squareys/magnum-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/Squareys/magnum-plugins/tags","blobs_url":"https://api.github.com/repos/Squareys/magnum-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Squareys/magnum-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Squareys/magnum-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/Squareys/magnum-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Squareys/magnum-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/Squareys/magnum-plugins/languages","stargazers_url":"https://api.github.com/repos/Squareys/magnum-plugins/stargazers","contributors_url":"https://api.github.com/repos/Squareys/magnum-plugins/contributors","subscribers_url":"https://api.github.com/repos/Squareys/magnum-plugins/subscribers","subscription_url":"https://api.github.com/repos/Squareys/magnum-plugins/subscription","commits_url":"https://api.github.com/repos/Squareys/magnum-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/Squareys/magnum-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/Squareys/magnum-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/Squareys/magnum-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/Squareys/magnum-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/Squareys/magnum-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Squareys/magnum-plugins/merges","archive_url":"https://api.github.com/repos/Squareys/magnum-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Squareys/magnum-plugins/downloads","issues_url":"https://api.github.com/repos/Squareys/magnum-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/Squareys/magnum-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/Squareys/magnum-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/Squareys/magnum-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Squareys/magnum-plugins/labels{/name}","releases_url":"https://api.github.com/repos/Squareys/magnum-plugins/releases{/id}","created_at":"2015-08-02T09:45:26Z","updated_at":"2015-08-02T09:45:27Z","pushed_at":"2015-10-01T11:55:18Z","git_url":"git://github.com/Squareys/magnum-plugins.git","ssh_url":"git@github.com:Squareys/magnum-plugins.git","clone_url":"https://github.com/Squareys/magnum-plugins.git","svn_url":"https://github.com/Squareys/magnum-plugins","homepage":"http://mosra.cz/blog/magnum.php","size":1611,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mosra:master","ref":"master","sha":"b60fafdb0dd75786d4082c6da0e247daa313af00","user":{"login":"mosra","id":344828,"avatar_url":"https://avatars.githubusercontent.com/u/344828?v=3","gravatar_id":"","url":"https://api.github.com/users/mosra","html_url":"https://github.com/mosra","followers_url":"https://api.github.com/users/mosra/followers","following_url":"https://api.github.com/users/mosra/following{/other_user}","gists_url":"https://api.github.com/users/mosra/gists{/gist_id}","starred_url":"https://api.github.com/users/mosra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosra/subscriptions","organizations_url":"https://api.github.com/users/mosra/orgs","repos_url":"https://api.github.com/users/mosra/repos","events_url":"https://api.github.com/users/mosra/events{/privacy}","received_events_url":"https://api.github.com/users/mosra/received_events","type":"User","site_admin":false},"repo":{"id":2982886,"name":"magnum-plugins","full_name":"mosra/magnum-plugins","owner":{"login":"mosra","id":344828,"avatar_url":"https://avatars.githubusercontent.com/u/344828?v=3","gravatar_id":"","url":"https://api.github.com/users/mosra","html_url":"https://github.com/mosra","followers_url":"https://api.github.com/users/mosra/followers","following_url":"https://api.github.com/users/mosra/following{/other_user}","gists_url":"https://api.github.com/users/mosra/gists{/gist_id}","starred_url":"https://api.github.com/users/mosra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosra/subscriptions","organizations_url":"https://api.github.com/users/mosra/orgs","repos_url":"https://api.github.com/users/mosra/repos","events_url":"https://api.github.com/users/mosra/events{/privacy}","received_events_url":"https://api.github.com/users/mosra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mosra/magnum-plugins","description":"Plugins for Magnum graphics engine","fork":false,"url":"https://api.github.com/repos/mosra/magnum-plugins","forks_url":"https://api.github.com/repos/mosra/magnum-plugins/forks","keys_url":"https://api.github.com/repos/mosra/magnum-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mosra/magnum-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mosra/magnum-plugins/teams","hooks_url":"https://api.github.com/repos/mosra/magnum-plugins/hooks","issue_events_url":"https://api.github.com/repos/mosra/magnum-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/mosra/magnum-plugins/events","assignees_url":"https://api.github.com/repos/mosra/magnum-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/mosra/magnum-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/mosra/magnum-plugins/tags","blobs_url":"https://api.github.com/repos/mosra/magnum-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mosra/magnum-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mosra/magnum-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/mosra/magnum-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mosra/magnum-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/mosra/magnum-plugins/languages","stargazers_url":"https://api.github.com/repos/mosra/magnum-plugins/stargazers","contributors_url":"https://api.github.com/repos/mosra/magnum-plugins/contributors","subscribers_url":"https://api.github.com/repos/mosra/magnum-plugins/subscribers","subscription_url":"https://api.github.com/repos/mosra/magnum-plugins/subscription","commits_url":"https://api.github.com/repos/mosra/magnum-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/mosra/magnum-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/mosra/magnum-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/mosra/magnum-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/mosra/magnum-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/mosra/magnum-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mosra/magnum-plugins/merges","archive_url":"https://api.github.com/repos/mosra/magnum-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mosra/magnum-plugins/downloads","issues_url":"https://api.github.com/repos/mosra/magnum-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/mosra/magnum-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/mosra/magnum-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/mosra/magnum-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mosra/magnum-plugins/labels{/name}","releases_url":"https://api.github.com/repos/mosra/magnum-plugins/releases{/id}","created_at":"2011-12-14T20:43:25Z","updated_at":"2015-07-07T17:14:12Z","pushed_at":"2015-10-01T12:01:49Z","git_url":"git://github.com/mosra/magnum-plugins.git","ssh_url":"git@github.com:mosra/magnum-plugins.git","clone_url":"https://github.com/mosra/magnum-plugins.git","svn_url":"https://github.com/mosra/magnum-plugins","homepage":"http://mosra.cz/blog/magnum.php","size":2901,"stargazers_count":8,"watchers_count":8,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":1,"forks":9,"open_issues":1,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mosra/magnum-plugins/pulls/8"},"html":{"href":"https://github.com/mosra/magnum-plugins/pull/8"},"issue":{"href":"https://api.github.com/repos/mosra/magnum-plugins/issues/8"},"comments":{"href":"https://api.github.com/repos/mosra/magnum-plugins/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/mosra/magnum-plugins/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/mosra/magnum-plugins/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mosra/magnum-plugins/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/mosra/magnum-plugins/statuses/2295501112910b9109ce7437d8af6906833fc6c3"}}}}