{"action":"created","issue":{"url":"https://api.github.com/repos/kcat/openal-soft/issues/325","repository_url":"https://api.github.com/repos/kcat/openal-soft","labels_url":"https://api.github.com/repos/kcat/openal-soft/issues/325/labels{/name}","comments_url":"https://api.github.com/repos/kcat/openal-soft/issues/325/comments","events_url":"https://api.github.com/repos/kcat/openal-soft/issues/325/events","html_url":"https://github.com/kcat/openal-soft/issues/325","id":480659560,"node_id":"MDU6SXNzdWU0ODA2NTk1NjA=","number":325,"title":"[Suggestion] On demand source buffer?","user":{"login":"shangjiaxuan","id":34389517,"node_id":"MDQ6VXNlcjM0Mzg5NTE3","avatar_url":"https://avatars0.githubusercontent.com/u/34389517?v=4","gravatar_id":"","url":"https://api.github.com/users/shangjiaxuan","html_url":"https://github.com/shangjiaxuan","followers_url":"https://api.github.com/users/shangjiaxuan/followers","following_url":"https://api.github.com/users/shangjiaxuan/following{/other_user}","gists_url":"https://api.github.com/users/shangjiaxuan/gists{/gist_id}","starred_url":"https://api.github.com/users/shangjiaxuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shangjiaxuan/subscriptions","organizations_url":"https://api.github.com/users/shangjiaxuan/orgs","repos_url":"https://api.github.com/users/shangjiaxuan/repos","events_url":"https://api.github.com/users/shangjiaxuan/events{/privacy}","received_events_url":"https://api.github.com/users/shangjiaxuan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2019-08-14T12:47:49Z","updated_at":"2019-08-17T02:47:33Z","closed_at":null,"author_association":"NONE","body":"Is there any plans to implement a software synthesizer when OpenAL needs a source? \r\n\r\nSimilar to the current use case of using a loopback device to implement custom backend, maybe there can be a extension that registers a function to be called when the data is needed? (Of course, also need some non-block guarantee here.) \r\n\r\nThis can reduce the resource usage when playing compressed long audio without the need for extra memory copying and usage (e.g. plugging a decoder via a user pointer, and requesting a number of frames on the interface) compared to buffer queuing (and also more flexible if the user want a dynamic software synthesizer as source (also less latency when user wants to change the buffer contents)).\r\n\r\nMaybe some interface like this to bind a generator to a buffer?\r\n`void alBufferFuncSOFT(ALuint abo, ALenum format, ALsizei freq, alSourceFunc_t func, ALvoid* usr_ptr)`\r\n`typedef Alsizei(*alSourceFunc_t)(Aluint abo, ALvoid* to_fill, ALuint min_frames, ALuint max_frames, ALvoid* usr_ptr /*, ALuint alignment, Alenum format, ...*/)`\r\n\r\n(There may need to be format conversion set up after each call to callback, so maybe setting up format beforehand or providing more parameters to the callback and avoiding this conversion may be better but will require more effort on the user side).\r\n\r\nThe format, sample rate, etc can still be accessed the `alBufferxx`, `alGetBufferxx` interface, and buffer queuing and other things will still work, since it's still basically just a buffer on demand.\r\n\r\n(If there is any plan on implementing this, I'm happy to dig down to the source and help...)"},"comment":{"url":"https://api.github.com/repos/kcat/openal-soft/issues/comments/522198032","html_url":"https://github.com/kcat/openal-soft/issues/325#issuecomment-522198032","issue_url":"https://api.github.com/repos/kcat/openal-soft/issues/325","id":522198032,"node_id":"MDEyOklzc3VlQ29tbWVudDUyMjE5ODAzMg==","user":{"login":"shangjiaxuan","id":34389517,"node_id":"MDQ6VXNlcjM0Mzg5NTE3","avatar_url":"https://avatars0.githubusercontent.com/u/34389517?v=4","gravatar_id":"","url":"https://api.github.com/users/shangjiaxuan","html_url":"https://github.com/shangjiaxuan","followers_url":"https://api.github.com/users/shangjiaxuan/followers","following_url":"https://api.github.com/users/shangjiaxuan/following{/other_user}","gists_url":"https://api.github.com/users/shangjiaxuan/gists{/gist_id}","starred_url":"https://api.github.com/users/shangjiaxuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shangjiaxuan/subscriptions","organizations_url":"https://api.github.com/users/shangjiaxuan/orgs","repos_url":"https://api.github.com/users/shangjiaxuan/repos","events_url":"https://api.github.com/users/shangjiaxuan/events{/privacy}","received_events_url":"https://api.github.com/users/shangjiaxuan/received_events","type":"User","site_admin":false},"created_at":"2019-08-17T02:47:33Z","updated_at":"2019-08-17T02:47:33Z","author_association":"NONE","body":"The reasoning on making callback a kind of buffer is that it's basically a buffer on demand, and the user may still queue the buffer and use it as static. The indicator of termination, however, would be that the returned number of samples (the return value) is smaller than the requested value (the value passed into the callback)(currently it's size of filled, though). This could avoid the frequent use of `alSourcePlay` and `alSourceStop`, since it's still the same source.\r\n\r\nBut I think you are right, implementing this as a separate kind of source would be much more straightforward and much less work to do with existing code."}}
{"actor":{"display_login":"shangjiaxuan"}}