{"action":"created","issue":{"url":"https://api.github.com/repos/rdio/api/issues/178","labels_url":"https://api.github.com/repos/rdio/api/issues/178/labels{/name}","comments_url":"https://api.github.com/repos/rdio/api/issues/178/comments","events_url":"https://api.github.com/repos/rdio/api/issues/178/events","html_url":"https://github.com/rdio/api/issues/178","id":113942645,"number":178,"title":"Android - AudioPlayer not being cleaned up, results in rdio eventually being unable to play songs","user":{"login":"troymolnar","id":9320171,"avatar_url":"https://avatars.githubusercontent.com/u/9320171?v=3","gravatar_id":"","url":"https://api.github.com/users/troymolnar","html_url":"https://github.com/troymolnar","followers_url":"https://api.github.com/users/troymolnar/followers","following_url":"https://api.github.com/users/troymolnar/following{/other_user}","gists_url":"https://api.github.com/users/troymolnar/gists{/gist_id}","starred_url":"https://api.github.com/users/troymolnar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troymolnar/subscriptions","organizations_url":"https://api.github.com/users/troymolnar/orgs","repos_url":"https://api.github.com/users/troymolnar/repos","events_url":"https://api.github.com/users/troymolnar/events{/privacy}","received_events_url":"https://api.github.com/users/troymolnar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rdio/api/labels/android%20sdk","name":"android sdk","color":"1F7B67"},{"url":"https://api.github.com/repos/rdio/api/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-28T22:50:24Z","updated_at":"2015-10-29T17:45:34Z","closed_at":null,"body":"Whenever an rdio song is played, RdioAudioPlayer (RdioNativePlayer) creates a new PcmAudioPlayer. After the song is done, or stopped, a new rdio song request will create a new PcmAudioPlayer. When this happens enough times (27 times on one test device, 26 on another, but the android max is supposedly 32) rdio can no longer play audio. \r\n\r\nI can watch them count up in the log:\r\nI/libNativeAudio: [RdioNativeAudio.NA] : Setting active audio player to ID: 1\r\nI/libNativeAudio: [RdioNativeAudio.NA] : Setting active audio player to ID: 2\r\n..\r\nI/libNativeAudio: [RdioNativeAudio.NA] : Setting active audio player to ID: 26\r\nI/libNativeAudio: [RdioNativeAudio.NA] : Setting active audio player to ID: 27\r\n\r\nAndroid is printing this log after the 27th for me:\r\nE/AudioTrack: AudioFlinger could not create track, status: -12\r\nWhat this means is described here http://stackoverflow.com/a/12024769/5481752\r\n\r\n\r\nI don't think that the PcmAudioPlayers are being cleaned up. RdioAudioPlayer.release() calls RdioAudioPlayer.this.releaseAudio(), which is a method with an empty body. \r\n\r\nRdioNativePlayer appears to have a method for this:\r\npublic static void shutdown() {\r\n        nativeAudio.releasePcmAudioPlayer();\r\n    }\r\nBut I can't tell if it is ever used or works."},"comment":{"url":"https://api.github.com/repos/rdio/api/issues/comments/152262484","html_url":"https://github.com/rdio/api/issues/178#issuecomment-152262484","issue_url":"https://api.github.com/repos/rdio/api/issues/178","id":152262484,"user":{"login":"troymolnar","id":9320171,"avatar_url":"https://avatars.githubusercontent.com/u/9320171?v=3","gravatar_id":"","url":"https://api.github.com/users/troymolnar","html_url":"https://github.com/troymolnar","followers_url":"https://api.github.com/users/troymolnar/followers","following_url":"https://api.github.com/users/troymolnar/following{/other_user}","gists_url":"https://api.github.com/users/troymolnar/gists{/gist_id}","starred_url":"https://api.github.com/users/troymolnar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troymolnar/subscriptions","organizations_url":"https://api.github.com/users/troymolnar/orgs","repos_url":"https://api.github.com/users/troymolnar/repos","events_url":"https://api.github.com/users/troymolnar/events{/privacy}","received_events_url":"https://api.github.com/users/troymolnar/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T17:45:34Z","updated_at":"2015-10-29T17:45:34Z","body":"Thank you! I am able to reproduce on 4.0.0 by the way, though the logcat appeared a bit different:\r\n\r\nI/RdioNativePlayer: Creating native PCM audio player\r\nI/libNativeAudio: [RdioNativeAudio.NA] : Creating PcmAudioPlayer\r\nI/libNativeAudio: [RdioNativeAudio.NA] : Acquired AudioEngine without effects\r\nI/libNativeAudio: [PcmBufferSource.NA] : PcmBufferSource created with native sampling rate 44100 Hz, frame count 768,\r\nI/libNativeAudio: [PcmBufferSource.NA] :   2 buffer(s) of size 3072 bytes,\r\nI/libNativeAudio: [PcmBufferSource.NA] :   ring buffer of size 529200 bytes, high water mark is 352800 bytes\r\nI/libNativeAudio: [RdioNativeAudio.NA] : AudioPlayer created\r\nE/libOpenSLES: Too many objects\r\nW/libOpenSLES: Leaving Engine::CreateAudioPlayer (SL_RESULT_MEMORY_FAILURE)\r\nE/libNativeAudio: [AudioPlayer.NA] : engine->CreateAudioPlayer() failed!\r\nE/libNativeAudio: [AudioPlayer.NA] : Error occurred while trying to initialize AudioPlayer\r\nI/libNativeAudio: [RdioNativeAudio.NA] : Setting active audio player to ID: 31\r\n"}}