{"action":"created","issue":{"url":"https://api.github.com/repos/mono/MonoGame/issues/4442","labels_url":"https://api.github.com/repos/mono/MonoGame/issues/4442/labels{/name}","comments_url":"https://api.github.com/repos/mono/MonoGame/issues/4442/comments","events_url":"https://api.github.com/repos/mono/MonoGame/issues/4442/events","html_url":"https://github.com/mono/MonoGame/pull/4442","id":127473488,"number":4442,"title":"Prevent OpenAL calls with 0 buffers or empty buffers","user":{"login":"mrhelmut","id":3427451,"avatar_url":"https://avatars.githubusercontent.com/u/3427451?v=3","gravatar_id":"","url":"https://api.github.com/users/mrhelmut","html_url":"https://github.com/mrhelmut","followers_url":"https://api.github.com/users/mrhelmut/followers","following_url":"https://api.github.com/users/mrhelmut/following{/other_user}","gists_url":"https://api.github.com/users/mrhelmut/gists{/gist_id}","starred_url":"https://api.github.com/users/mrhelmut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrhelmut/subscriptions","organizations_url":"https://api.github.com/users/mrhelmut/orgs","repos_url":"https://api.github.com/users/mrhelmut/repos","events_url":"https://api.github.com/users/mrhelmut/events{/privacy}","received_events_url":"https://api.github.com/users/mrhelmut/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-01-19T15:40:46Z","updated_at":"2016-01-20T12:17:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mono/MonoGame/pulls/4442","html_url":"https://github.com/mono/MonoGame/pull/4442","diff_url":"https://github.com/mono/MonoGame/pull/4442.diff","patch_url":"https://github.com/mono/MonoGame/pull/4442.patch"},"body":"This fixes an error related to differences across OpenAL implementations.\r\n>```AL.BufferData()``` generates an \"invalid value\" error if the ```size``` parameter is ```0``` on OS X, while it does nothing on Windows. Same applies to ```AL.SourceQueueBuffers()```.\r\n\r\nI've simply added checks so that it doesn't crash ```Song``` anymore.\r\n\r\nFixes #4440\r\n\r\nThis however raises another issue: this shouldn't be happening. The original cause is ```VorbisReader.ReadSamples()``` occasionally failing to read the ogg stream by returning ```0``` and skipping a few samples or simply reset the stream (it loses track of the stream position). Which means that there is a bug in NVorbis, or something that Mono don't like in NVorbis.\r\n\r\nThis means that, even though it doesn't crash anymore, it may occasionally skip a few seconds of a ```Song```, replay a previous buffer, or reset it at worse. It also seems to break the stream initial position, make ```Song``` to start at random position after the first occurrence of this issue.\r\n\r\n@dellis1972 Do you find acceptable to merge this until I can figure out what's wrong with NVorbis?\r\n\r\nEven though the original ```OggStreamer``` may be a couple years old now, maybe @renaudbedard could have some thoughts about this (did you experienced similar NVorbis issues on Mono?)."},"comment":{"url":"https://api.github.com/repos/mono/MonoGame/issues/comments/173186523","html_url":"https://github.com/mono/MonoGame/pull/4442#issuecomment-173186523","issue_url":"https://api.github.com/repos/mono/MonoGame/issues/4442","id":173186523,"user":{"login":"mrhelmut","id":3427451,"avatar_url":"https://avatars.githubusercontent.com/u/3427451?v=3","gravatar_id":"","url":"https://api.github.com/users/mrhelmut","html_url":"https://github.com/mrhelmut","followers_url":"https://api.github.com/users/mrhelmut/followers","following_url":"https://api.github.com/users/mrhelmut/following{/other_user}","gists_url":"https://api.github.com/users/mrhelmut/gists{/gist_id}","starred_url":"https://api.github.com/users/mrhelmut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrhelmut/subscriptions","organizations_url":"https://api.github.com/users/mrhelmut/orgs","repos_url":"https://api.github.com/users/mrhelmut/repos","events_url":"https://api.github.com/users/mrhelmut/events{/privacy}","received_events_url":"https://api.github.com/users/mrhelmut/received_events","type":"User","site_admin":false},"created_at":"2016-01-20T12:17:21Z","updated_at":"2016-01-20T12:17:21Z","body":"This is getting weird...\r\n\r\nIf I play a ```Song```, stop it, dispose it, reload it and play it again, it starts where the previously disposed one stopped.  o_O\r\n\r\nI don't know what's this about, but it only happens on Mono, and it seems to totally wreak the file stream while ```VorbisReader``` assume it to be in sync from the given starting position. This may be why ```VorbisReader``` fails (it tries to read behind the stream size).\r\n\r\nI really don't know what to do about this, even though I dispose everything, ```GC.Collect()```, and all streams are correctly recreated and set to 0 position, it starts the file stream where one of a previous ```Song``` stopped."}}