Return-Path: X-Original-To: apmail-cordova-issues-archive@minotaur.apache.org Delivered-To: apmail-cordova-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 74869F7EB for ; Thu, 11 Apr 2013 13:09:23 +0000 (UTC) Received: (qmail 31966 invoked by uid 500); 11 Apr 2013 13:09:23 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 31886 invoked by uid 500); 11 Apr 2013 13:09:23 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 30632 invoked by uid 99); 11 Apr 2013 13:09:17 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Apr 2013 13:09:17 +0000 Date: Thu, 11 Apr 2013 13:09:17 +0000 (UTC) From: "Bob Flavin (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CB-1599) successCallback not called after stopRecording, duplicate AudioPlayer objects created MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-1599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Bob Flavin updated CB-1599: --------------------------- Attachment: graycol.gif I thought I provided a detailed explanation and fix and that would be enough. I think that creating a test case will be complicated. It will help the system if the issue is fixed. Bob Flavin Research Staff Member, IBM Research From: "Joe Bowser (JIRA)" To: Robert Flavin/Watson/IBM@IBMUS Date: 04/10/2013 01:38 PM Subject: [jira] [Resolved] (CB-1599) successCallback not called after stopRecording, duplicate AudioPlayer objects created [ https://issues.apache.org/jira/browse/CB-1599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Joe Bowser resolved CB-1599. ---------------------------- Resolution: Later I wish I could mark "Abandoned" on this. If you want this fixed, and can help with it, please re-open this bug and provide a use case! objects created ------------------------------------------------------------------------------------- called. 'mediaObj.startRecord() are dispatched by androidExec (prompt) to new threads on the java side and are not synchronized. Thus org.apache.cordova.AudioHandler.execute for action='create', calls new AudioPlayer(). Asynchronously, ...AudioHandler.execute for action='startAudioRecording' calls AudioHandler.startAudioRecording(), which gets a null from this.players.get(id) which causes the if statement to call new AudioRecorder which creates a second instance of AudioRecorder for that id. remains in MEDIA_NONE. it may get the instance of AudioPlayer that is in MEDIA_NONE. This prevents AudioPlayer.stopRecording() from calling this.recorder.stop() and this.setState(STATE.MEDIA_STOPPED) because that AudioPlayer instance is in STATE MEDIA_NONE. Thus AudioPlayer.setState doesn't call the handler.sendJavascript to call the javascript Media.onStatus method that would call the statusCallback and the successCallback. prevents 'create' and 'startRecordingAudio from running at the same time and that 'create' should use the same code that startRecodingAudio does: startRecordingAudio thread executes before the 'create' thread. synchronization as well. never called (after stopRecord) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira > successCallback not called after stopRecording, duplicate AudioPlayer objects created > ------------------------------------------------------------------------------------- > > Key: CB-1599 > URL: https://issues.apache.org/jira/browse/CB-1599 > Project: Apache Cordova > Issue Type: Bug > Components: Android, CordovaJS > Affects Versions: 2.1.0, 2.2.0, 2.3.0, 2.4.0 > Environment: Android 2.3? > Reporter: Bob Flavin > Assignee: Joe Bowser > Attachments: AudioHandler.java, graycol.gif > > > A successCallback is not called sometimes after stopRecording() is called. > The problem is that javascript cordova calls to 'new Media()' and 'mediaObj.startRecord() are dispatched by androidExec (prompt) to new threads on the java side and are not synchronized. Thus org.apache.cordova.AudioHandler.execute for action='create', calls new AudioPlayer(). Asynchronously, ...AudioHandler.execute for action='startAudioRecording' calls AudioHandler.startAudioRecording(), which gets a null from this.players.get(id) which causes the if statement to call new AudioRecorder which creates a second instance of AudioRecorder for that id. > public void startRecordingAudio(String id, String file) { > AudioPlayer audio = this.players.get(id); > if ( audio == null) { > audio = new AudioPlayer(this, id, file); > this.players.put(id, audio); > } > audio.startRecording(file); > } > One instance of AudioPlayer goes into STATE MEDIA_RUNNING the other remains in MEDIA_NONE. > When the javascript calls mediaObj.stopRecord() (and mediaObj.release()) it may get the instance of AudioPlayer that is in MEDIA_NONE. This prevents AudioPlayer.stopRecording() from calling this.recorder.stop() and this.setState(STATE.MEDIA_STOPPED) because that AudioPlayer instance is in STATE MEDIA_NONE. Thus AudioPlayer.setState doesn't call the handler.sendJavascript to call the javascript Media.onStatus method that would call the statusCallback and the successCallback. > I think that the AudioHandler should have a synchronized block that prevents 'create' and 'startRecordingAudio from running at the same time and that 'create' should use the same code that startRecodingAudio does: > AudioPlayer audio = this.players.get(id); > if ( audio == null) { > audio = new AudioPlayer(this, id, file); > this.players.put(id, audio); > } > to prevent creating a second AudioPlayer instance if the startRecordingAudio thread executes before the 'create' thread. > There may be other actions in AudioHandler.execute that need this synchronization as well. > One effect of this problem is that the javascript successCallback is never called (after stopRecord) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira