{"action":"created","comment":{"url":"https://api.github.com/repos/SFTtech/openage/pulls/comments/23421863","id":23421863,"diff_hunk":"@@ -0,0 +1,156 @@\n+// Copyright 2015-2015 the openage authors. See copying.md for legal info.\n+\n+#include \"dynamic_resource.h\"\n+\n+#include \"../engine.h\"\n+#include \"../log.h\"\n+\n+namespace openage {\n+namespace audio {\n+\n+chunk_info_t::chunk_info_t(int state, size_t buffer_size)\n+\t\t:\n+\t\tstate{state},\n+\t\tactual_size{0},\n+\t\tbuffer{new int16_t[buffer_size]} {\n+}\n+\n+DynamicResource::DynamicResource(category_t category, int id,\n+\t\tconst std::string &path, format_t format, int preload_threshold,\n+\t\tsize_t chunk_size, size_t max_chunks)\n+\t\t:\n+\t\tResource{category, id},\n+\t\tpath{path},\n+\t\tformat{format},\n+\t\tpreload_threshold{preload_threshold},\n+\t\tchunk_size{chunk_size},\n+\t\tmax_chunks{max_chunks},\n+\t\tuse_count{0} {\n+}\n+\n+void DynamicResource::use() {\n+\tlog::msg(\"DYNRES: now in use\");\n+\tlog::msg(\"CS=%lu, MX=%lu\", chunk_size, max_chunks);\n+\t// if the resource is new in use\n+\tif ((this->use_count++) == 0) {\n+\t\t// create loader\n+\t\tthis->loader = DynamicLoader::create(this->path, this->format);\n+\t\t// create chunk information\n+\t\tfor (size_t i = 0; i < this->max_chunks; i++) {\n+\t\t\tthis->chunk_infos.push(std::make_shared<chunk_info_t>(\n+\t\t\t\t\tchunk_info_t::UNUSED, this->chunk_size));\n+\t\t}\n+\t\t// get loading job group\n+\t\tEngine &e = Engine::get();\n+\t\tthis->loading_job_group = e.get_job_manager()->get_job_group();\n+\t}\n+}\n+\n+void DynamicResource::stop_using() {\n+\tlog::msg(\"DYNRES: no longer in use\");\n+\t// if the resource is not used anymore\n+\tif ((--this->use_count) == 0) {\n+\t\t// clear the chunk_mapping\n+\t\tthis->chunk_mapping.clear();\n+\t\t// clear chunk information\n+\t\tthis->chunk_infos.clear();\n+\t}\n+}\n+\n+std::tuple<const int16_t*,size_t> DynamicResource::get_data(\n+\t\tsize_t position, size_t data_length) {","path":"cpp/audio/dynamic_resource.cpp","position":61,"original_position":61,"commit_id":"3fda9b66f9a6126349a985357f6cd42c513157bb","original_commit_id":"3fda9b66f9a6126349a985357f6cd42c513157bb","user":{"login":"TheJJ","id":673543,"avatar_url":"https://avatars.githubusercontent.com/u/673543?v=3","gravatar_id":"","url":"https://api.github.com/users/TheJJ","html_url":"https://github.com/TheJJ","followers_url":"https://api.github.com/users/TheJJ/followers","following_url":"https://api.github.com/users/TheJJ/following{/other_user}","gists_url":"https://api.github.com/users/TheJJ/gists{/gist_id}","starred_url":"https://api.github.com/users/TheJJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheJJ/subscriptions","organizations_url":"https://api.github.com/users/TheJJ/orgs","repos_url":"https://api.github.com/users/TheJJ/repos","events_url":"https://api.github.com/users/TheJJ/events{/privacy}","received_events_url":"https://api.github.com/users/TheJJ/received_events","type":"User","site_admin":false},"body":"using a `struct audio_chunk` instead of the tuple might be more intuitive","created_at":"2015-01-22T23:56:55Z","updated_at":"2015-01-22T23:56:55Z","html_url":"https://github.com/SFTtech/openage/pull/192#discussion_r23421863","pull_request_url":"https://api.github.com/repos/SFTtech/openage/pulls/192","_links":{"self":{"href":"https://api.github.com/repos/SFTtech/openage/pulls/comments/23421863"},"html":{"href":"https://github.com/SFTtech/openage/pull/192#discussion_r23421863"},"pull_request":{"href":"https://api.github.com/repos/SFTtech/openage/pulls/192"}}},"pull_request":{"url":"https://api.github.com/repos/SFTtech/openage/pulls/192","id":27581086,"html_url":"https://github.com/SFTtech/openage/pull/192","diff_url":"https://github.com/SFTtech/openage/pull/192.diff","patch_url":"https://github.com/SFTtech/openage/pull/192.patch","issue_url":"https://api.github.com/repos/SFTtech/openage/issues/192","number":192,"state":"open","locked":false,"title":"New features for job manager and integration into dynamic audio loading.","user":{"login":"fr3akout","id":556394,"avatar_url":"https://avatars.githubusercontent.com/u/556394?v=3","gravatar_id":"","url":"https://api.github.com/users/fr3akout","html_url":"https://github.com/fr3akout","followers_url":"https://api.github.com/users/fr3akout/followers","following_url":"https://api.github.com/users/fr3akout/following{/other_user}","gists_url":"https://api.github.com/users/fr3akout/gists{/gist_id}","starred_url":"https://api.github.com/users/fr3akout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fr3akout/subscriptions","organizations_url":"https://api.github.com/users/fr3akout/orgs","repos_url":"https://api.github.com/users/fr3akout/repos","events_url":"https://api.github.com/users/fr3akout/events{/privacy}","received_events_url":"https://api.github.com/users/fr3akout/received_events","type":"User","site_admin":false},"body":"I have added some features to the job manager.\r\n\r\n1. job groups that assure, that multiple jobs are executed on the same background thread\r\n2. jobs can check whether they should be aborted and abort themselves\r\n\r\nFurther I have integrated the new job groups into the dynamic audio loading implementation.","created_at":"2015-01-19T01:42:42Z","updated_at":"2015-01-22T23:56:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"55d3f357274c1052ae01b8dbbd8de9c0900cdf18","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SFTtech/openage/pulls/192/commits","review_comments_url":"https://api.github.com/repos/SFTtech/openage/pulls/192/comments","review_comment_url":"https://api.github.com/repos/SFTtech/openage/pulls/comments/{number}","comments_url":"https://api.github.com/repos/SFTtech/openage/issues/192/comments","statuses_url":"https://api.github.com/repos/SFTtech/openage/statuses/3fda9b66f9a6126349a985357f6cd42c513157bb","head":{"label":"fr3akout:job","ref":"job","sha":"3fda9b66f9a6126349a985357f6cd42c513157bb","user":{"login":"fr3akout","id":556394,"avatar_url":"https://avatars.githubusercontent.com/u/556394?v=3","gravatar_id":"","url":"https://api.github.com/users/fr3akout","html_url":"https://github.com/fr3akout","followers_url":"https://api.github.com/users/fr3akout/followers","following_url":"https://api.github.com/users/fr3akout/following{/other_user}","gists_url":"https://api.github.com/users/fr3akout/gists{/gist_id}","starred_url":"https://api.github.com/users/fr3akout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fr3akout/subscriptions","organizations_url":"https://api.github.com/users/fr3akout/orgs","repos_url":"https://api.github.com/users/fr3akout/repos","events_url":"https://api.github.com/users/fr3akout/events{/privacy}","received_events_url":"https://api.github.com/users/fr3akout/received_events","type":"User","site_admin":false},"repo":{"id":28625996,"name":"openage","full_name":"fr3akout/openage","owner":{"login":"fr3akout","id":556394,"avatar_url":"https://avatars.githubusercontent.com/u/556394?v=3","gravatar_id":"","url":"https://api.github.com/users/fr3akout","html_url":"https://github.com/fr3akout","followers_url":"https://api.github.com/users/fr3akout/followers","following_url":"https://api.github.com/users/fr3akout/following{/other_user}","gists_url":"https://api.github.com/users/fr3akout/gists{/gist_id}","starred_url":"https://api.github.com/users/fr3akout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fr3akout/subscriptions","organizations_url":"https://api.github.com/users/fr3akout/orgs","repos_url":"https://api.github.com/users/fr3akout/repos","events_url":"https://api.github.com/users/fr3akout/events{/privacy}","received_events_url":"https://api.github.com/users/fr3akout/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fr3akout/openage","description":"Free (as in freedom) open source clone of the Age of Empires II engine.","fork":true,"url":"https://api.github.com/repos/fr3akout/openage","forks_url":"https://api.github.com/repos/fr3akout/openage/forks","keys_url":"https://api.github.com/repos/fr3akout/openage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fr3akout/openage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fr3akout/openage/teams","hooks_url":"https://api.github.com/repos/fr3akout/openage/hooks","issue_events_url":"https://api.github.com/repos/fr3akout/openage/issues/events{/number}","events_url":"https://api.github.com/repos/fr3akout/openage/events","assignees_url":"https://api.github.com/repos/fr3akout/openage/assignees{/user}","branches_url":"https://api.github.com/repos/fr3akout/openage/branches{/branch}","tags_url":"https://api.github.com/repos/fr3akout/openage/tags","blobs_url":"https://api.github.com/repos/fr3akout/openage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fr3akout/openage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fr3akout/openage/git/refs{/sha}","trees_url":"https://api.github.com/repos/fr3akout/openage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fr3akout/openage/statuses/{sha}","languages_url":"https://api.github.com/repos/fr3akout/openage/languages","stargazers_url":"https://api.github.com/repos/fr3akout/openage/stargazers","contributors_url":"https://api.github.com/repos/fr3akout/openage/contributors","subscribers_url":"https://api.github.com/repos/fr3akout/openage/subscribers","subscription_url":"https://api.github.com/repos/fr3akout/openage/subscription","commits_url":"https://api.github.com/repos/fr3akout/openage/commits{/sha}","git_commits_url":"https://api.github.com/repos/fr3akout/openage/git/commits{/sha}","comments_url":"https://api.github.com/repos/fr3akout/openage/comments{/number}","issue_comment_url":"https://api.github.com/repos/fr3akout/openage/issues/comments/{number}","contents_url":"https://api.github.com/repos/fr3akout/openage/contents/{+path}","compare_url":"https://api.github.com/repos/fr3akout/openage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fr3akout/openage/merges","archive_url":"https://api.github.com/repos/fr3akout/openage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fr3akout/openage/downloads","issues_url":"https://api.github.com/repos/fr3akout/openage/issues{/number}","pulls_url":"https://api.github.com/repos/fr3akout/openage/pulls{/number}","milestones_url":"https://api.github.com/repos/fr3akout/openage/milestones{/number}","notifications_url":"https://api.github.com/repos/fr3akout/openage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fr3akout/openage/labels{/name}","releases_url":"https://api.github.com/repos/fr3akout/openage/releases{/id}","created_at":"2014-12-30T10:01:11Z","updated_at":"2014-12-30T10:01:12Z","pushed_at":"2015-01-19T23:28:50Z","git_url":"git://github.com/fr3akout/openage.git","ssh_url":"git@github.com:fr3akout/openage.git","clone_url":"https://github.com/fr3akout/openage.git","svn_url":"https://github.com/fr3akout/openage","homepage":"http://openage.sft.mx","size":4298,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"SFTtech:master","ref":"master","sha":"f365ed55972e5c6ced6e4e500cf8b4be38238ce7","user":{"login":"SFTtech","id":1783325,"avatar_url":"https://avatars.githubusercontent.com/u/1783325?v=3","gravatar_id":"","url":"https://api.github.com/users/SFTtech","html_url":"https://github.com/SFTtech","followers_url":"https://api.github.com/users/SFTtech/followers","following_url":"https://api.github.com/users/SFTtech/following{/other_user}","gists_url":"https://api.github.com/users/SFTtech/gists{/gist_id}","starred_url":"https://api.github.com/users/SFTtech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SFTtech/subscriptions","organizations_url":"https://api.github.com/users/SFTtech/orgs","repos_url":"https://api.github.com/users/SFTtech/repos","events_url":"https://api.github.com/users/SFTtech/events{/privacy}","received_events_url":"https://api.github.com/users/SFTtech/received_events","type":"Organization","site_admin":false},"repo":{"id":14095175,"name":"openage","full_name":"SFTtech/openage","owner":{"login":"SFTtech","id":1783325,"avatar_url":"https://avatars.githubusercontent.com/u/1783325?v=3","gravatar_id":"","url":"https://api.github.com/users/SFTtech","html_url":"https://github.com/SFTtech","followers_url":"https://api.github.com/users/SFTtech/followers","following_url":"https://api.github.com/users/SFTtech/following{/other_user}","gists_url":"https://api.github.com/users/SFTtech/gists{/gist_id}","starred_url":"https://api.github.com/users/SFTtech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SFTtech/subscriptions","organizations_url":"https://api.github.com/users/SFTtech/orgs","repos_url":"https://api.github.com/users/SFTtech/repos","events_url":"https://api.github.com/users/SFTtech/events{/privacy}","received_events_url":"https://api.github.com/users/SFTtech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SFTtech/openage","description":"Free (as in freedom) open source clone of the Age of Empires II engine.","fork":false,"url":"https://api.github.com/repos/SFTtech/openage","forks_url":"https://api.github.com/repos/SFTtech/openage/forks","keys_url":"https://api.github.com/repos/SFTtech/openage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SFTtech/openage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SFTtech/openage/teams","hooks_url":"https://api.github.com/repos/SFTtech/openage/hooks","issue_events_url":"https://api.github.com/repos/SFTtech/openage/issues/events{/number}","events_url":"https://api.github.com/repos/SFTtech/openage/events","assignees_url":"https://api.github.com/repos/SFTtech/openage/assignees{/user}","branches_url":"https://api.github.com/repos/SFTtech/openage/branches{/branch}","tags_url":"https://api.github.com/repos/SFTtech/openage/tags","blobs_url":"https://api.github.com/repos/SFTtech/openage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SFTtech/openage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SFTtech/openage/git/refs{/sha}","trees_url":"https://api.github.com/repos/SFTtech/openage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SFTtech/openage/statuses/{sha}","languages_url":"https://api.github.com/repos/SFTtech/openage/languages","stargazers_url":"https://api.github.com/repos/SFTtech/openage/stargazers","contributors_url":"https://api.github.com/repos/SFTtech/openage/contributors","subscribers_url":"https://api.github.com/repos/SFTtech/openage/subscribers","subscription_url":"https://api.github.com/repos/SFTtech/openage/subscription","commits_url":"https://api.github.com/repos/SFTtech/openage/commits{/sha}","git_commits_url":"https://api.github.com/repos/SFTtech/openage/git/commits{/sha}","comments_url":"https://api.github.com/repos/SFTtech/openage/comments{/number}","issue_comment_url":"https://api.github.com/repos/SFTtech/openage/issues/comments/{number}","contents_url":"https://api.github.com/repos/SFTtech/openage/contents/{+path}","compare_url":"https://api.github.com/repos/SFTtech/openage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SFTtech/openage/merges","archive_url":"https://api.github.com/repos/SFTtech/openage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SFTtech/openage/downloads","issues_url":"https://api.github.com/repos/SFTtech/openage/issues{/number}","pulls_url":"https://api.github.com/repos/SFTtech/openage/pulls{/number}","milestones_url":"https://api.github.com/repos/SFTtech/openage/milestones{/number}","notifications_url":"https://api.github.com/repos/SFTtech/openage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SFTtech/openage/labels{/name}","releases_url":"https://api.github.com/repos/SFTtech/openage/releases{/id}","created_at":"2013-11-03T22:35:23Z","updated_at":"2015-01-22T08:16:27Z","pushed_at":"2015-01-18T23:42:17Z","git_url":"git://github.com/SFTtech/openage.git","ssh_url":"git@github.com:SFTtech/openage.git","clone_url":"https://github.com/SFTtech/openage.git","svn_url":"https://github.com/SFTtech/openage","homepage":"http://openage.sft.mx","size":6454,"stargazers_count":2846,"watchers_count":2846,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":233,"mirror_url":null,"open_issues_count":54,"forks":233,"open_issues":54,"watchers":2846,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SFTtech/openage/pulls/192"},"html":{"href":"https://github.com/SFTtech/openage/pull/192"},"issue":{"href":"https://api.github.com/repos/SFTtech/openage/issues/192"},"comments":{"href":"https://api.github.com/repos/SFTtech/openage/issues/192/comments"},"review_comments":{"href":"https://api.github.com/repos/SFTtech/openage/pulls/192/comments"},"review_comment":{"href":"https://api.github.com/repos/SFTtech/openage/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/SFTtech/openage/pulls/192/commits"},"statuses":{"href":"https://api.github.com/repos/SFTtech/openage/statuses/3fda9b66f9a6126349a985357f6cd42c513157bb"}}}}