{"action":"created","comment":{"url":"https://api.github.com/repos/rwengine/openrw/pulls/comments/200481749","pull_request_review_id":134808298,"id":200481749,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDQ4MTc0OQ==","diff_hunk":"@@ -173,6 +178,226 @@ void SoundManager::SoundSource::loadFromFile(const std::string& filename) {\n     avformat_close_input(&formatContext);\n }\n \n+/// Structure for input data\n+struct InputData {\n+    uint8_t *ptr = nullptr;\n+    size_t size{}; ///< size left in the buffer\n+};\n+\n+/// Low level function for copying data from handler (opaque)\n+/// to buffer.\n+static int read_packet(void *opaque, uint8_t *buf, int buf_size) {\n+    auto* input = reinterpret_cast<InputData*>(opaque);\n+    buf_size = FFMIN(buf_size, input->size);\n+    /* copy internal data to buf */\n+    memcpy(buf, input->ptr, buf_size);\n+    input->ptr  += buf_size;\n+    input->size -= buf_size;\n+    return buf_size;\n+}\n+\n+void SoundManager::SoundSource::loadSfx(const rwfs::path& path, const size_t& index, const bool asWave) {\n+    // Allocate audio frame\n+    AVFrame* frame = av_frame_alloc();\n+    if (!frame) {\n+        RW_ERROR(\"Error allocating the audio frame\");\n+        return;\n+    }\n+\n+    /// Now we need to prepare \"custom\" format context\n+    /// We need sdt loader for that purpose\n+    LoaderSDT sdt{};\n+    sdt.load(path / \"audio/sfx\");\n+\n+    std::unique_ptr<char[]> raw_sound = sdt.loadToMemory(index, asWave);\n+    if (!raw_sound) {\n+        av_frame_free(&frame);\n+        RW_ERROR(\"Error loading sound\");\n+        return;\n+    }\n+\n+    /// Prepare input\n+    InputData input{};\n+    input.size = sizeof(WaveHeader) + sdt.assetInfo.size;\n+    auto inputDataStart = std::make_unique<uint8_t[]>(input.size); /// Store start ptr of data to be able freed memory later\n+    input.ptr = inputDataStart.get();\n+\n+    /// Alocate memory for buffer\n+    /// Memory freeded at the end\n+    static constexpr size_t ioBufferSize = 4096;\n+    auto  ioBuffer = static_cast<uint8_t*>(av_malloc(ioBufferSize));\n+\n+    /// Convert memory, in order to match required layout for ffmpeg\n+    memcpy(input.ptr, raw_sound.get(), input.size);","path":"rwengine/src/audio/SoundManager.cpp","position":79,"original_position":79,"commit_id":"811d49c080680d286f105ce131a09f4e481c9981","original_commit_id":"811d49c080680d286f105ce131a09f4e481c9981","user":{"login":"danhedron","id":418211,"node_id":"MDQ6VXNlcjQxODIxMQ==","avatar_url":"https://avatars3.githubusercontent.com/u/418211?v=4","gravatar_id":"","url":"https://api.github.com/users/danhedron","html_url":"https://github.com/danhedron","followers_url":"https://api.github.com/users/danhedron/followers","following_url":"https://api.github.com/users/danhedron/following{/other_user}","gists_url":"https://api.github.com/users/danhedron/gists{/gist_id}","starred_url":"https://api.github.com/users/danhedron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danhedron/subscriptions","organizations_url":"https://api.github.com/users/danhedron/orgs","repos_url":"https://api.github.com/users/danhedron/repos","events_url":"https://api.github.com/users/danhedron/events{/privacy}","received_events_url":"https://api.github.com/users/danhedron/received_events","type":"User","site_admin":false},"body":"Why does this need to be copied? Can't the memory for raw_sound be given to the input?","created_at":"2018-07-05T20:33:30Z","updated_at":"2018-07-05T20:33:30Z","html_url":"https://github.com/rwengine/openrw/pull/522#discussion_r200481749","pull_request_url":"https://api.github.com/repos/rwengine/openrw/pulls/522","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/comments/200481749"},"html":{"href":"https://github.com/rwengine/openrw/pull/522#discussion_r200481749"},"pull_request":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/522"}}},"pull_request":{"url":"https://api.github.com/repos/rwengine/openrw/pulls/522","id":196464736,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2NDY0NzM2","html_url":"https://github.com/rwengine/openrw/pull/522","diff_url":"https://github.com/rwengine/openrw/pull/522.diff","patch_url":"https://github.com/rwengine/openrw/pull/522.patch","issue_url":"https://api.github.com/repos/rwengine/openrw/issues/522","number":522,"state":"open","locked":false,"title":"Prepare sdt loader for ffmpeg","user":{"login":"ShFil119","id":7227492,"node_id":"MDQ6VXNlcjcyMjc0OTI=","avatar_url":"https://avatars1.githubusercontent.com/u/7227492?v=4","gravatar_id":"","url":"https://api.github.com/users/ShFil119","html_url":"https://github.com/ShFil119","followers_url":"https://api.github.com/users/ShFil119/followers","following_url":"https://api.github.com/users/ShFil119/following{/other_user}","gists_url":"https://api.github.com/users/ShFil119/gists{/gist_id}","starred_url":"https://api.github.com/users/ShFil119/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShFil119/subscriptions","organizations_url":"https://api.github.com/users/ShFil119/orgs","repos_url":"https://api.github.com/users/ShFil119/repos","events_url":"https://api.github.com/users/ShFil119/events{/privacy}","received_events_url":"https://api.github.com/users/ShFil119/received_events","type":"User","site_admin":false},"body":"Extracted from #420.","created_at":"2018-06-21T14:07:19Z","updated_at":"2018-07-05T20:33:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7cf59e9bc5390ff53dee51ccfa5f6abf55c707da","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rwengine/openrw/pulls/522/commits","review_comments_url":"https://api.github.com/repos/rwengine/openrw/pulls/522/comments","review_comment_url":"https://api.github.com/repos/rwengine/openrw/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rwengine/openrw/issues/522/comments","statuses_url":"https://api.github.com/repos/rwengine/openrw/statuses/811d49c080680d286f105ce131a09f4e481c9981","head":{"label":"ShFil119:prepare_sdt_loader_for_ffmpeg","ref":"prepare_sdt_loader_for_ffmpeg","sha":"811d49c080680d286f105ce131a09f4e481c9981","user":{"login":"ShFil119","id":7227492,"node_id":"MDQ6VXNlcjcyMjc0OTI=","avatar_url":"https://avatars1.githubusercontent.com/u/7227492?v=4","gravatar_id":"","url":"https://api.github.com/users/ShFil119","html_url":"https://github.com/ShFil119","followers_url":"https://api.github.com/users/ShFil119/followers","following_url":"https://api.github.com/users/ShFil119/following{/other_user}","gists_url":"https://api.github.com/users/ShFil119/gists{/gist_id}","starred_url":"https://api.github.com/users/ShFil119/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShFil119/subscriptions","organizations_url":"https://api.github.com/users/ShFil119/orgs","repos_url":"https://api.github.com/users/ShFil119/repos","events_url":"https://api.github.com/users/ShFil119/events{/privacy}","received_events_url":"https://api.github.com/users/ShFil119/received_events","type":"User","site_admin":false},"repo":{"id":94653844,"node_id":"MDEwOlJlcG9zaXRvcnk5NDY1Mzg0NA==","name":"openrw","full_name":"ShFil119/openrw","owner":{"login":"ShFil119","id":7227492,"node_id":"MDQ6VXNlcjcyMjc0OTI=","avatar_url":"https://avatars1.githubusercontent.com/u/7227492?v=4","gravatar_id":"","url":"https://api.github.com/users/ShFil119","html_url":"https://github.com/ShFil119","followers_url":"https://api.github.com/users/ShFil119/followers","following_url":"https://api.github.com/users/ShFil119/following{/other_user}","gists_url":"https://api.github.com/users/ShFil119/gists{/gist_id}","starred_url":"https://api.github.com/users/ShFil119/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShFil119/subscriptions","organizations_url":"https://api.github.com/users/ShFil119/orgs","repos_url":"https://api.github.com/users/ShFil119/repos","events_url":"https://api.github.com/users/ShFil119/events{/privacy}","received_events_url":"https://api.github.com/users/ShFil119/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ShFil119/openrw","description":"OpenRW \"Open ReWrite\" is an un-official open source recreation of the classic Grand Theft Auto III game executable","fork":true,"url":"https://api.github.com/repos/ShFil119/openrw","forks_url":"https://api.github.com/repos/ShFil119/openrw/forks","keys_url":"https://api.github.com/repos/ShFil119/openrw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ShFil119/openrw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ShFil119/openrw/teams","hooks_url":"https://api.github.com/repos/ShFil119/openrw/hooks","issue_events_url":"https://api.github.com/repos/ShFil119/openrw/issues/events{/number}","events_url":"https://api.github.com/repos/ShFil119/openrw/events","assignees_url":"https://api.github.com/repos/ShFil119/openrw/assignees{/user}","branches_url":"https://api.github.com/repos/ShFil119/openrw/branches{/branch}","tags_url":"https://api.github.com/repos/ShFil119/openrw/tags","blobs_url":"https://api.github.com/repos/ShFil119/openrw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ShFil119/openrw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ShFil119/openrw/git/refs{/sha}","trees_url":"https://api.github.com/repos/ShFil119/openrw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ShFil119/openrw/statuses/{sha}","languages_url":"https://api.github.com/repos/ShFil119/openrw/languages","stargazers_url":"https://api.github.com/repos/ShFil119/openrw/stargazers","contributors_url":"https://api.github.com/repos/ShFil119/openrw/contributors","subscribers_url":"https://api.github.com/repos/ShFil119/openrw/subscribers","subscription_url":"https://api.github.com/repos/ShFil119/openrw/subscription","commits_url":"https://api.github.com/repos/ShFil119/openrw/commits{/sha}","git_commits_url":"https://api.github.com/repos/ShFil119/openrw/git/commits{/sha}","comments_url":"https://api.github.com/repos/ShFil119/openrw/comments{/number}","issue_comment_url":"https://api.github.com/repos/ShFil119/openrw/issues/comments{/number}","contents_url":"https://api.github.com/repos/ShFil119/openrw/contents/{+path}","compare_url":"https://api.github.com/repos/ShFil119/openrw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ShFil119/openrw/merges","archive_url":"https://api.github.com/repos/ShFil119/openrw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ShFil119/openrw/downloads","issues_url":"https://api.github.com/repos/ShFil119/openrw/issues{/number}","pulls_url":"https://api.github.com/repos/ShFil119/openrw/pulls{/number}","milestones_url":"https://api.github.com/repos/ShFil119/openrw/milestones{/number}","notifications_url":"https://api.github.com/repos/ShFil119/openrw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ShFil119/openrw/labels{/name}","releases_url":"https://api.github.com/repos/ShFil119/openrw/releases{/id}","deployments_url":"https://api.github.com/repos/ShFil119/openrw/deployments","created_at":"2017-06-17T23:07:19Z","updated_at":"2018-07-05T18:19:56Z","pushed_at":"2018-07-05T20:09:58Z","git_url":"git://github.com/ShFil119/openrw.git","ssh_url":"git@github.com:ShFil119/openrw.git","clone_url":"https://github.com/ShFil119/openrw.git","svn_url":"https://github.com/ShFil119/openrw","homepage":"http://openrw.org","size":3760,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"rwengine:master","ref":"master","sha":"caa1e1eee081323b95436ff521858eb03ccc1ee6","user":{"login":"rwengine","id":19520421,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5NTIwNDIx","avatar_url":"https://avatars0.githubusercontent.com/u/19520421?v=4","gravatar_id":"","url":"https://api.github.com/users/rwengine","html_url":"https://github.com/rwengine","followers_url":"https://api.github.com/users/rwengine/followers","following_url":"https://api.github.com/users/rwengine/following{/other_user}","gists_url":"https://api.github.com/users/rwengine/gists{/gist_id}","starred_url":"https://api.github.com/users/rwengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwengine/subscriptions","organizations_url":"https://api.github.com/users/rwengine/orgs","repos_url":"https://api.github.com/users/rwengine/repos","events_url":"https://api.github.com/users/rwengine/events{/privacy}","received_events_url":"https://api.github.com/users/rwengine/received_events","type":"Organization","site_admin":false},"repo":{"id":34529275,"node_id":"MDEwOlJlcG9zaXRvcnkzNDUyOTI3NQ==","name":"openrw","full_name":"rwengine/openrw","owner":{"login":"rwengine","id":19520421,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5NTIwNDIx","avatar_url":"https://avatars0.githubusercontent.com/u/19520421?v=4","gravatar_id":"","url":"https://api.github.com/users/rwengine","html_url":"https://github.com/rwengine","followers_url":"https://api.github.com/users/rwengine/followers","following_url":"https://api.github.com/users/rwengine/following{/other_user}","gists_url":"https://api.github.com/users/rwengine/gists{/gist_id}","starred_url":"https://api.github.com/users/rwengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwengine/subscriptions","organizations_url":"https://api.github.com/users/rwengine/orgs","repos_url":"https://api.github.com/users/rwengine/repos","events_url":"https://api.github.com/users/rwengine/events{/privacy}","received_events_url":"https://api.github.com/users/rwengine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rwengine/openrw","description":"OpenRW \"Open ReWrite\" is an un-official open source recreation of the classic Grand Theft Auto III game executable","fork":false,"url":"https://api.github.com/repos/rwengine/openrw","forks_url":"https://api.github.com/repos/rwengine/openrw/forks","keys_url":"https://api.github.com/repos/rwengine/openrw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rwengine/openrw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rwengine/openrw/teams","hooks_url":"https://api.github.com/repos/rwengine/openrw/hooks","issue_events_url":"https://api.github.com/repos/rwengine/openrw/issues/events{/number}","events_url":"https://api.github.com/repos/rwengine/openrw/events","assignees_url":"https://api.github.com/repos/rwengine/openrw/assignees{/user}","branches_url":"https://api.github.com/repos/rwengine/openrw/branches{/branch}","tags_url":"https://api.github.com/repos/rwengine/openrw/tags","blobs_url":"https://api.github.com/repos/rwengine/openrw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rwengine/openrw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rwengine/openrw/git/refs{/sha}","trees_url":"https://api.github.com/repos/rwengine/openrw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rwengine/openrw/statuses/{sha}","languages_url":"https://api.github.com/repos/rwengine/openrw/languages","stargazers_url":"https://api.github.com/repos/rwengine/openrw/stargazers","contributors_url":"https://api.github.com/repos/rwengine/openrw/contributors","subscribers_url":"https://api.github.com/repos/rwengine/openrw/subscribers","subscription_url":"https://api.github.com/repos/rwengine/openrw/subscription","commits_url":"https://api.github.com/repos/rwengine/openrw/commits{/sha}","git_commits_url":"https://api.github.com/repos/rwengine/openrw/git/commits{/sha}","comments_url":"https://api.github.com/repos/rwengine/openrw/comments{/number}","issue_comment_url":"https://api.github.com/repos/rwengine/openrw/issues/comments{/number}","contents_url":"https://api.github.com/repos/rwengine/openrw/contents/{+path}","compare_url":"https://api.github.com/repos/rwengine/openrw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rwengine/openrw/merges","archive_url":"https://api.github.com/repos/rwengine/openrw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rwengine/openrw/downloads","issues_url":"https://api.github.com/repos/rwengine/openrw/issues{/number}","pulls_url":"https://api.github.com/repos/rwengine/openrw/pulls{/number}","milestones_url":"https://api.github.com/repos/rwengine/openrw/milestones{/number}","notifications_url":"https://api.github.com/repos/rwengine/openrw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rwengine/openrw/labels{/name}","releases_url":"https://api.github.com/repos/rwengine/openrw/releases{/id}","deployments_url":"https://api.github.com/repos/rwengine/openrw/deployments","created_at":"2015-04-24T16:26:12Z","updated_at":"2018-07-05T19:38:59Z","pushed_at":"2018-07-05T19:38:56Z","git_url":"git://github.com/rwengine/openrw.git","ssh_url":"git@github.com:rwengine/openrw.git","clone_url":"https://github.com/rwengine/openrw.git","svn_url":"https://github.com/rwengine/openrw","homepage":"http://openrw.org","size":3662,"stargazers_count":678,"watchers_count":678,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":82,"mirror_url":null,"archived":false,"open_issues_count":79,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":82,"open_issues":79,"watchers":678,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/522"},"html":{"href":"https://github.com/rwengine/openrw/pull/522"},"issue":{"href":"https://api.github.com/repos/rwengine/openrw/issues/522"},"comments":{"href":"https://api.github.com/repos/rwengine/openrw/issues/522/comments"},"review_comments":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/522/comments"},"review_comment":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/522/commits"},"statuses":{"href":"https://api.github.com/repos/rwengine/openrw/statuses/811d49c080680d286f105ce131a09f4e481c9981"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"danhedron"}}