Closed Bug 811649 Opened 12 years ago Closed 12 years ago

[camera] Start video recording, audio clip keeps on playing in background

Categories

(Firefox OS Graveyard :: Gaia::Camera, defect, P3)

All
Gonk (Firefox OS)

Tracking

(blocking-basecamp:+, firefox18 fixed, firefox19 fixed)

VERIFIED FIXED
B2G C3 (12dec-1jan)
blocking-basecamp +
Tracking Status
firefox18 --- fixed
firefox19 --- fixed

People

(Reporter: ikumar, Assigned: mchen)

References

Details

Attachments

(1 file, 2 obsolete files)

Steps to reproduce:
1. Start playing an audio clip
2. Goto camera and switch to camcorder
3. Start recording
4. On starting the recording, camcorder crashes with camera just crashed message
blocking-basecamp: --- → ?
basecamp+ assuming that the user is going to need to figure out that they have to kill the audio clip before they can use the camera. ie. When the camera crashes it will continue to crash until the user manually stops the audio stream.

Note that we need a public version of this bug to complete the work.
blocking-basecamp: ? → +
Mike, can you take a look?
Assignee: nobody → mhabicher
(In reply to Lawrence Mandel [:lmandel] from comment #1)
> basecamp+ assuming that the user is going to need to figure out that they
> have to kill the audio clip before they can use the camera. ie. When the
> camera crashes it will continue to crash until the user manually stops the
> audio stream.

I don't think the user should have to do this manually.  When I open the camera on my BlackBerry, it automatically suspends any playing audio.  (I assume this is because the DSP can't support both operations at the same time.)

(In reply to Doug Turner (:dougt) from comment #2)
> Mike, can you take a look?

Yep.
(In reply to Mike Habicher [:mikeh] from comment #3)
> (In reply to Lawrence Mandel [:lmandel] from comment #1)
> > basecamp+ assuming that the user is going to need to figure out that they
> > have to kill the audio clip before they can use the camera. ie. When the
> > camera crashes it will continue to crash until the user manually stops the
> > audio stream.
> 
> I don't think the user should have to do this manually.  When I open the
> camera on my BlackBerry, it automatically suspends any playing audio.  (I
> assume this is because the DSP can't support both operations at the same
> time.)

Seems I wasn't clear in my first post. I agree with your statement. What I was trying to say is that this bug is marked basecamp+ assuming that the current scenario requires the user to do this manually. The fix should make this automatic and significantly easier for the user.
I don't see this on recent builds:
Gecko: 801806df98e56233382293eb4c4adadbc59772cb
Gaia : 00717bb9304393ee9b38c346f4b97f9bdeeb2d5d

If I start playing a song and then switch to the camera, I can:
1. take a picture
2. switch to video mode
3. start recording a video
4. stop recording a video

When I do this, at (3) the audio playback stops (though apparently not the progress in the track); and at (4), the audio resumes from its current position (i.e. it was not paused between steps 3 and 4).

No crashes observed.
I also noticed that it doesn't crash anymore. But I am noticing that the audio playback doesn't stop while we are recording. It keeps on playing the audio. The expected behavior is the audio should pause when we switch to camcorder mode. So, this is still an issue, right?

I am on following revisions:
Gecko: fbee23615cebc9348a1db4ec1021eb863b98aa2d
Gaia: 5dcc1b1155e8c99b4d8ef738530fb9505a15aee0
Summary: [camera] Camera crashes on starting video recording with audio clip running in background → [camera] Start video recording, audio clip keeps on playing in background
Marking for C2, given this meets the criteria of known P1/P2 blocking-basecamp+ bugs at the end of C1.
Target Milestone: --- → B2G C2 (20nov-10dec)
Group: qualcomm-confidential
I think any fix for this will have to happen in gaia.
Assignee: mhabicher → nobody
renom because this bug has been morphed to another bug.
blocking-basecamp: + → ?
Component: General → Gaia::Camera
Hardware: ARM → All
Status: UNCONFIRMED → NEW
Ever confirmed: true
Looks like we'll need some notification or event that is dispatched when the user starts recording a video. The music app should then pause (or quit?).
Dear all,

According to mechanism from bug 805333, it will monitor all media elements then adjudge who should be muted or paused. But this issue didn't create any media elements so audio channel service introduced from 805333 will not handle this.

A new bug 815069 will be created to build a general mechanism related to bug 805333 for those Apps without media elements to join audio competing policy.

Welcome for any suggestion to that bug.

Thanks.
Depends on: 815069
Assignee: nobody → dale
blocking-basecamp: ? → +
Priority: P2 → P3
I attempted a workaround that jonas suggested, 

  _silentSound: new Audio('./resources/sounds/silent.wav'),

  this._silentSound.mozAudioChannel = 'content';
  this._silentSound.loop = true;

  this._silentSound.play();

This crashed the video recorder, if I was using headphones the music get sent to the speaker and the headphones were blank, once I stopped recording the music started playing in the headphones again.
Whiteboard: [caf:blocking]
The automatic silencing of lower-priority channels isn't yet implemented. That's bug 805333. But we still shouldn't crash, we never should, so please file a separate bug on that. Ideally with a crash stack.
Depends on: 805333
Priority: P3 → P1
Given this is no longer crashing, marking as P3.
Priority: P1 → P3
Whiteboard: [caf:blocking]
Target Milestone: B2G C2 (20nov-10dec) → B2G C3 (12dec-1jan)
renoming as clee has downgraded priority.
blocking-basecamp: + → ?
blocking-basecamp: ? → +
Andrea thinks this may already be fixed now that the changes in bug 805333 have landed.  Can someone verify?
Flags: needinfo?(ikumar)
This bug also depends on bug 815069.
It introduced a new component called AudioChannelAgent and used to let FM and Video recording join AudioChannelService. 

Hi Dale,
I plan to use bug 815069 for solving this bug.
May I help here and provide the patch?

Thanks.
mchen, happy to
Attached patch WIPv1 (obsolete) (deleted) — Splinter Review
To use the AudioChannelAgent introduced from Bug 815069 for Video Recording to join AudioChannelService.
Attachment #689639 - Flags: feedback?(mhabicher)
Comment on attachment 689639 [details] [diff] [review]
WIPv1

Review of attachment 689639 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good, but I wonder if it makes more sense to disable audio playback sooner, such as when the camera switches into video recording mode, instead of later when it starts recording.

I think this would provide a better user experience.

Look for getPreviewStreamVideoMode(); the clean-up could go into getPreviewStream() (for when the camera switches to picture mode) and OnNavigation() (for when the camera app is closed).

::: dom/camera/DOMCameraControl.cpp
@@ +264,5 @@
>                         NS_LITERAL_STRING("starting").get());
>  
> +  if (!mAudioChannelAgent) {
> +    nsresult rv;
> +    mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1", &rv);

Is it okay to ignore rv?

@@ +266,5 @@
> +  if (!mAudioChannelAgent) {
> +    nsresult rv;
> +    mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1", &rv);
> +    if (mAudioChannelAgent) {
> +      // Camera App will stop recording while it falls to background, so no necessary to hear callback.

"Camera app will stop recording when it falls to the background, so no callback is necessary."

@@ +267,5 @@
> +    nsresult rv;
> +    mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1", &rv);
> +    if (mAudioChannelAgent) {
> +      // Camera App will stop recording while it falls to background, so no necessary to hear callback.
> +      mAudioChannelAgent->Init( AUDIO_CHANNEL_CONTENT, nullptr);

No space before AUDIO_CHANNEL_CONTENT.

@@ +268,5 @@
> +    mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1", &rv);
> +    if (mAudioChannelAgent) {
> +      // Camera App will stop recording while it falls to background, so no necessary to hear callback.
> +      mAudioChannelAgent->Init( AUDIO_CHANNEL_CONTENT, nullptr);
> +      // Video Recording doesn't have output sound so no necessary to check canPlay.

"Video recording doesn't output any sound, so it's not necessary to check canPlay."

::: dom/camera/DOMCameraControl.h
@@ +42,5 @@
>    /* additional members */
>    nsRefPtr<ICameraControl>        mCameraControl; // non-DOM camera control
>    nsCOMPtr<nsICameraCapabilities> mDOMCapabilities;
> +  // An agent used to join audio channel service.
> +  nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;

An extra space before mAudioChannelAgent, please.
Attachment #689639 - Flags: feedback?(mhabicher) → feedback+
Attached patch Patch v1 (obsolete) (deleted) — Splinter Review
1. Following the comment.
2. From my point of view, I would like to stop another one's audio as necessary as possible. So I still keep the codes on start/stopRecording(). Of course, if there is another opinion for this, we may pass it to the UX export to do decision.

Thanks.
Attachment #689639 - Attachment is obsolete: true
Attachment #690246 - Flags: review?(mhabicher)
Attachment #690246 - Flags: review?(mhabicher) → review+
(In reply to Marco Chen [:mchen] from comment #21)
> 
> 2. From my point of view, I would like to stop another one's audio as
> necessary as possible. So I still keep the codes on start/stopRecording().
> Of course, if there is another opinion for this, we may pass it to the UX
> export to do decision.

Josh, can you or someone else in UX comment on stopping/restarting background audio (i.e. the music player) only when the camera starts/stops video recording (as opposed to, say, when the camera enters/leaves video recording mode, or when the camera is opened/closed)?
Flags: needinfo?(jcarpenter)
Attached patch patch CheckInVersion (deleted) — Splinter Review
Add the reviewer and checkin the code first.
If there is any further comment from UX we can follow it on another bug.
Attachment #690246 - Attachment is obsolete: true
Attachment #690785 - Flags: review+
Keywords: checkin-needed
Assignee: dale → mchen
Let's file a followup if we want to adjust the time when the audio gets muted. It's not obvious to me that that is a blocker.

https://hg.mozilla.org/integration/mozilla-inbound/rev/97c5efcc2115
https://hg.mozilla.org/releases/mozilla-aurora/rev/1e834b77370c
https://hg.mozilla.org/releases/mozilla-beta/rev/7c372d234b13
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
QA Contact: fyen
wait for code landing to verify
Build: unagi_2012-12-13_eng.zip from https://releases.mozilla.com/b2g/

The music will stop/resume on start/stop recording, same as Comment 21 said.
(In reply to Mike Habicher [:mikeh] from comment #22)
> (In reply to Marco Chen [:mchen] from comment #21)
> > 
> > 2. From my point of view, I would like to stop another one's audio as
> > necessary as possible. So I still keep the codes on start/stopRecording().
> > Of course, if there is another opinion for this, we may pass it to the UX
> > export to do decision.
> 
> Josh, can you or someone else in UX comment on stopping/restarting
> background audio (i.e. the music player) only when the camera starts/stops
> video recording (as opposed to, say, when the camera enters/leaves video
> recording mode, or when the camera is opened/closed)?

Deferring to Casey, who is working on media apps and audio issues.
Flags: needinfo?(jcarpenter) → needinfo?(kyee)
I don't see any reason why someone would want to have their music to continue to play in the background while recording video.  Unless it was intentional and was included in the recorded audio.  A neat idea but certainly OOS.

For this reason I think it would make sense to:
When the user starts recording video background audio should be muted/paused until the recording is stopped.   Once stopped the background audio should continue.   

This behavior is consistent with resuming audio after receiving/making a phone call.

Taking photos is a little different.   We will want to continue to play background audio so that the user can continue to listen to music/content while they take photos.   The shutter sound should also be played back so that the user knows when they have taken a photo.
Flags: needinfo?(kyee)
Works fine now.
Flags: needinfo?(ikumar)
Build ID: 20130107110332

The music will stop/resume on start/stop recording, same as Comment 21/Comment 30 said.

Verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: