summaryrefslogtreecommitdiffstats
path: root/media/audio/linux/alsa_output_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Support use_alsa==0 on Linuxspang@chromium.org2013-11-281-870/+0
| | | | | | | | | | | | | | | | | | | | This moves the ALSA audio code from media/audio/linux to media/audio/alsa and splits Linux's CreateAudioManager() into a new file. This function chooses which AudioManager subclass to use on Linux. When use_alsa==0 on Linux, the fallback audio manager is changed from ALSA to a new fake implementation that always has an empty set of devices and will only return fake streams. This allows us to compile with no audio support on Linux. In particular, we can compile for targets that don't have the ALSA libraries available. Obviously, it's not (yet) possible to play audio in this configuration. BUG=318315, 318413 Review URL: https://codereview.chromium.org/89793003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237696 0039d316-1c4b-4281-b951-d872f2087c98
* Add the necessary scaffolding to allow creation of non-default audio output ↵tommi@chromium.org2013-09-031-2/+4
| | | | | | | | | | | | | devices. The implementation still assumes an empty device id (aka the default device), so this is only updating virtual methods and call sites. BUG=276894 R=henrika@chromium.org Review URL: https://codereview.chromium.org/23452009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220927 0039d316-1c4b-4281-b951-d872f2087c98
* Use a direct include of the message_loop header in media/.avi@chromium.org2013-07-181-1/+1
| | | | | | | | | | BUG=260807 TEST=none TBR=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/19622002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212247 0039d316-1c4b-4281-b951-d872f2087c98
* Refactored DataBuffer to use unix_hacker style methods.tyoverby@chromium.org2013-06-251-8/+8
| | | | | | | | | | | | | DataBuffer went from having pure virtual methods to having concrete implementations. However, the style of the method name remained in UpperCamelCase. This patch renames the methods to fit with the unix_hacker_style that is used for concrete implementations. BUG=251986 Review URL: https://chromiumcodereview.appspot.com/17315021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208453 0039d316-1c4b-4281-b951-d872f2087c98
* Use a direct include of strings headers in ipc/, jingle/, media/.avi@chromium.org2013-06-111-1/+1
| | | | | | | | | | BUG=247723 TEST=none TBR=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/16684003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205436 0039d316-1c4b-4281-b951-d872f2087c98
* Try relanding this CL, the original CL passed the try bots but failed the ↵xians@chromium.org2013-06-031-2/+2
| | | | | | | | | | | | | | | | | | | | mac 10.7 bot because the oroginal CL queried the device info while there is no device on the bot. Hook up the device selection to the WebAudio live audio. WebAudio live audio needs to pass the session_id to the browser process so that Chrome can open the correct input device for unitfied IO. This CL looks big because it touches quite some interfaces from the render to the browser. But the change is simple and basically adding a session_id/device_id to the classes. All the changes some together and it is very hard to break it down. It also makes the media output code more similar to the media input code as well, and it will be easier to merge them for the future. TBR=henrika@chormium.org BUG=147327 TEST=http://chromium.googlecode.com/svn/trunk/samples/audio/visualizer-live.html Change the device using the camera icon on the right of the omnibox, then reload. Verify the sound is coming from the correct input device. Review URL: https://codereview.chromium.org/15979015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203695 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 203686 "Trying relanding this CL, the original CL passed ..."xians@chromium.org2013-06-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | > Trying relanding this CL, the original CL passed the try bots but failed the mac 10.7 bot, I am keeping an eye on the bots and will revert it if it fails the bot again. > > Hook up the device selection to the WebAudio live audio. > WebAudio live audio needs to pass the session_id to the browser process so that Chrome can open the correct input device for unitfied IO. > > This CL looks big because it touches quite some interfaces from the render to the browser. But the change is simple and basically adding a session_id/device_id to the classes. All the changes some together and it is very hard to break it down. > It also makes the media output code more similar to the media input code as well, and it will be easier to merge them for the future. > > TBR=henrika@chormium.org > > BUG=147327 > TEST=http://chromium.googlecode.com/svn/trunk/samples/audio/visualizer-live.html > Change the device using the camera icon on the right of the omnibox, then reload. Verify the sound is coming from the correct input device. > > Review URL: https://codereview.chromium.org/15836006 TBR=xians@chromium.org Review URL: https://codereview.chromium.org/16325002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203690 0039d316-1c4b-4281-b951-d872f2087c98
* Trying relanding this CL, the original CL passed the try bots but failed the ↵xians@chromium.org2013-06-031-2/+2
| | | | | | | | | | | | | | | | | | | | mac 10.7 bot, I am keeping an eye on the bots and will revert it if it fails the bot again. Hook up the device selection to the WebAudio live audio. WebAudio live audio needs to pass the session_id to the browser process so that Chrome can open the correct input device for unitfied IO. This CL looks big because it touches quite some interfaces from the render to the browser. But the change is simple and basically adding a session_id/device_id to the classes. All the changes some together and it is very hard to break it down. It also makes the media output code more similar to the media input code as well, and it will be easier to merge them for the future. TBR=henrika@chormium.org BUG=147327 TEST=http://chromium.googlecode.com/svn/trunk/samples/audio/visualizer-live.html Change the device using the camera icon on the right of the omnibox, then reload. Verify the sound is coming from the correct input device. Review URL: https://codereview.chromium.org/15836006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203686 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 203427 "Hook up the device selection to the WebAudio live..."justinlin@chromium.org2013-05-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | Possibly caused content_browsertests to fail on Mac. > Hook up the device selection to the WebAudio live audio. > WebAudio live audio needs to pass the session_id to the browser process so that Chrome can open the correct input device for unitfied IO. > > This CL looks big because it touches quite some interfaces from the render to the browser. But the change is simple and basically adding a session_id/device_id to the classes. All the changes some together and it is very hard to break it down. > It also makes the media output code more similar to the media input code as well, and it will be easier to merge them for the future. > > > BUG=147327 > TEST=http://chromium.googlecode.com/svn/trunk/samples/audio/visualizer-live.html > Change the device using the camera icon on the right of the omnibox, then reload. Verify the sound is coming from the correct input device. > > Review URL: https://chromiumcodereview.appspot.com/15721002 TBR=xians@chromium.org Review URL: https://codereview.chromium.org/15725013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203434 0039d316-1c4b-4281-b951-d872f2087c98
* Hook up the device selection to the WebAudio live audio.xians@chromium.org2013-05-311-2/+2
| | | | | | | | | | | | | | | | WebAudio live audio needs to pass the session_id to the browser process so that Chrome can open the correct input device for unitfied IO. This CL looks big because it touches quite some interfaces from the render to the browser. But the change is simple and basically adding a session_id/device_id to the classes. All the changes some together and it is very hard to break it down. It also makes the media output code more similar to the media input code as well, and it will be easier to merge them for the future. BUG=147327 TEST=http://chromium.googlecode.com/svn/trunk/samples/audio/visualizer-live.html Change the device using the camera icon on the right of the omnibox, then reload. Verify the sound is coming from the correct input device. Review URL: https://chromiumcodereview.appspot.com/15721002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203427 0039d316-1c4b-4281-b951-d872f2087c98
* Use base::MessageLoop in media code.xhwang@chromium.org2013-04-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | MessageLoop is moved to base namespace in r191566. This CL is the followup cleanup in media code. The following folders are replaced: chrome/browser/media content/browser/renderer_host/media content/common/gpu/media content/common/media content/renderer/media media webkit/media The following command is used to make sure all instances in these folders are updated: grep -rin '[^a-zA-Z]MessageLoop[^a-zA-Z]' media chrome/browser/media content/browser/renderer_host/media content/common/gpu/media content/common/media content/renderer/media webkit/media | grep -v 'base::MessageLoop' | grep -v 'class MessageLoop' Review URL: https://chromiumcodereview.appspot.com/14385002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195626 0039d316-1c4b-4281-b951-d872f2087c98
* Remove unused parameter to OnError()jrummell@chromium.org2013-03-231-1/+1
| | | | | | | | | | | | This change removes the error_code parameter to OnError() calls as the parameter is not used when ending up in AudioRendererHost. BUG=218641 Review URL: https://chromiumcodereview.appspot.com/12611030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190087 0039d316-1c4b-4281-b951-d872f2087c98
* Reduce Linux low latency buffer size to 512.dalecurtis@google.com2013-02-071-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since ALSA uses an internally large buffer that we fill piecemeal by our internal buffer size, we can reduce our internal size in exchange for more frequent callbacks. This change: - Removes kernel timeslice adjustment. Shouldn't be necessary on modern kernels. - Removes minimum callback time between OnMoreData() calls in favor of locking the shared memory (192kHz audio isn't possible otherwise). - Fixes jitter introduced by premature clipping of delay information. - Removes useless code paths. - Switches to using TimeDelta throughout for accuracy. - Initializes playback with silence to avoid 192kHz startup glitches. This resolves playback issues with 192kHz content and latency issues as noted by our performance tests. With the shared memory block in place we should not see any glitching from the new buffer size. I believe the benefits of a 512-frame buffer w/ blocking shared mem are worth it in comparison to a 2048-frame buffer w/o blocking. BUG=172030 TEST=audio playback is smooth, doesn't glitch, latency tests show ~60ms which is inline with Windows/Mac. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=181105 Review URL: https://codereview.chromium.org/12051082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181131 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 181105vitalybuka@chromium.org2013-02-071-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compialtion error: media/audio/linux/alsa_output.cc: In member function 'snd_pcm_sframes_t media::AlsaPcmOutputStream::GetCurrentDelay()': media/audio/linux/alsa_output.cc:600: error: no matching function for call to 'max(long int, long unsigned int)' make: *** [out/Debug/obj.target/media/media/audio/linux/alsa_output.o] Error 1 > Reduce Linux low latency buffer size to 512. > > Since ALSA uses an internally large buffer that we fill piecemeal > by our internal buffer size, we can reduce our internal size in > exchange for more frequent callbacks. This change: > > - Removes kernel timeslice adjustment. Shouldn't be necessary on > modern kernels. > - Removes minimum callback time between OnMoreData() calls in favor > of locking the shared memory (192kHz audio isn't possible otherwise). > - Fixes jitter introduced by premature clipping of delay information. > - Removes useless code paths. > - Switches to using TimeDelta throughout for accuracy. > - Initializes playback with silence to avoid 192kHz startup glitches. > > This resolves playback issues with 192kHz content and latency issues > as noted by our performance tests. With the shared memory block in > place we should not see any glitching from the new buffer size. > > I believe the benefits of a 512-frame buffer w/ blocking shared mem > are worth it in comparison to a 2048-frame buffer w/o blocking. > > BUG=172030 > TEST=audio playback is smooth, doesn't glitch, latency tests show ~60ms > which is inline with Windows/Mac. > > > Review URL: https://chromiumcodereview.appspot.com/12051082 TBR=dalecurtis@chromium.org Review URL: https://codereview.chromium.org/12217052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181117 0039d316-1c4b-4281-b951-d872f2087c98
* Reduce Linux low latency buffer size to 512.dalecurtis@chromium.org2013-02-071-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since ALSA uses an internally large buffer that we fill piecemeal by our internal buffer size, we can reduce our internal size in exchange for more frequent callbacks. This change: - Removes kernel timeslice adjustment. Shouldn't be necessary on modern kernels. - Removes minimum callback time between OnMoreData() calls in favor of locking the shared memory (192kHz audio isn't possible otherwise). - Fixes jitter introduced by premature clipping of delay information. - Removes useless code paths. - Switches to using TimeDelta throughout for accuracy. - Initializes playback with silence to avoid 192kHz startup glitches. This resolves playback issues with 192kHz content and latency issues as noted by our performance tests. With the shared memory block in place we should not see any glitching from the new buffer size. I believe the benefits of a 512-frame buffer w/ blocking shared mem are worth it in comparison to a 2048-frame buffer w/o blocking. BUG=172030 TEST=audio playback is smooth, doesn't glitch, latency tests show ~60ms which is inline with Windows/Mac. Review URL: https://chromiumcodereview.appspot.com/12051082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181105 0039d316-1c4b-4281-b951-d872f2087c98
* Fix hang in AlsaPcmOutputStreamTest.StartStop test.dalecurtis@chromium.org2012-11-081-1/+5
| | | | | | | | | | | | | | | | | On slower test runs the message loop may never be idle, so if we don't call AlsPcmOutputStream::Stop() new WriteTask() calls cause the message loop to never reach the idle state and thus RunUntilIdle() will hang forever. I'm not sure why we're just seeing this now. I also don't think this is the root cause of http://crbug.com/157793, but should be fixed in any case. BUG=157793 TEST=debug tsan build doesn't hang. Review URL: https://chromiumcodereview.appspot.com/11359112 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166805 0039d316-1c4b-4281-b951-d872f2087c98
* Use ChannelMixer where applicable. Remove FoldChannels.dalecurtis@chromium.org2012-10-201-2/+3
| | | | | | | | | | | | | | - Adds ChannelMixer to AudioOutputResampler. - Switches all users of FoldChannels over to ChannelMixer. - Removes channel mixing from WASAPIAudioOutputStream. BUG=138762 TEST=unit tests, manual playback on all platforms. Review URL: https://chromiumcodereview.appspot.com/11188019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163163 0039d316-1c4b-4281-b951-d872f2087c98
* Allow audio system to handle synchronized low-latency audio I/Ocrogers@google.com2012-09-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | As an important part of WebAudio/WebRTC integration, we need to be able to process and analyse live audio. This change adds the ability to our audio system for handling synchronized audio input and output in the same callback (same thread) which is important for good performance and low-latency. As a part of this change, the audio IPC system now takes an optional |input_channels| argument in the CreateStream() message and associated browser-side code in AudioRendererHost::OnCreateStream(), etc. |input_channels| will be 0 during normal operation of audio output (and no input). But when synchronized audio I/O is needed, then a non-zero value can be passed in here. The |params| passed in represents both the input and output format, particularly the frames_per_buffer() and sample_rate(). AudioRendererSink now has an new InitializeIO() method which will allow the use of synchronized I/O with the |input_channels| argument. AudioRendererSink::RenderCallback now has a new RenderIO() which will be called instead of Render() in the case where a non-zero value is passed in for |input_channels|. BUG=none TEST=none (manual testing on early Mac OS X and Windows audio back-ends) Review URL: https://chromiumcodereview.appspot.com/10830268 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156234 0039d316-1c4b-4281-b951-d872f2087c98
* Fix unitialized reads in AudioOutputController unittest.dalecurtis@google.com2012-09-051-7/+6
| | | | | | | | | | | | | | | | | http://crrev.com/154951 introduced a bug where these buffers were used, but the mocked methods were not initializing the data. Also removes the suppression and fixes scherkus's comments from: http://codereview.chromium.org/10920092/ BUG=114700 TEST=media_unittests + valgrind. TBR=timurrr,scherkus Review URL: https://chromiumcodereview.appspot.com/10916120 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154968 0039d316-1c4b-4281-b951-d872f2087c98
* Fix unitialized data access in AlsaOutputUnittest.dalecurtis@google.com2012-09-051-4/+10
| | | | | | | | | | | | | http://crrev.com/154951 introduced a bug where these buffers were used, but the mocked methods were not initializing the data. BUG=none TEST=media_unittests + valgrind. TBR=timurrrr, scherkus Review URL: https://chromiumcodereview.appspot.com/10920092 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154954 0039d316-1c4b-4281-b951-d872f2087c98
* Switch OnMoreData() to use AudioBus.dalecurtis@chromium.org2012-09-051-14/+14
| | | | | | | | | | | | | | | | | | | As titled, with this change we're now piping float data around the pipeline from end to end. This change is in preparation for browser side channel remixing and resampling. As a consequence of this change the shared memory now represents the contents of an AudioBus object, which is essentially audio data in a float planar format. BUG=114700 TEST=Should be no audible change. Ran all existing tests. Compiled ran WebAudio/HTML5/WebRTC on all platforms and PPAPI on Linux. Review URL: https://chromiumcodereview.appspot.com/10832285 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154951 0039d316-1c4b-4281-b951-d872f2087c98
* Dead code elimination: scythe.chrome_functions:segment.path %media% edition, ↵fischman@chromium.org2012-08-071-4/+0
| | | | | | | | round 2. Review URL: https://chromiumcodereview.appspot.com/10826174 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150302 0039d316-1c4b-4281-b951-d872f2087c98
* Dead code elimination: scythe.chrome_functions:segment.path %media% edition, ↵fischman@chromium.org2012-08-061-5/+0
| | | | | | | | | | round 1. Internal-only site: http://go/videostack/engineering/dead-code-elimination Review URL: https://chromiumcodereview.appspot.com/10837118 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150129 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 138939 - alsa_output: Drain and pause pcm when stopping.scherkus@chromium.org2012-06-051-6/+0
| | | | | | | | | | | | | | | | | | | | | Call snd_pcm_drain when the output's Stop() function is called. This will keep some alsa interfaces from repeating the last samples played until Close() is called. This will also guarantee that all samples are played back if Close() is called immediately following Stop(). BUG=chromium-os:31211 TEST=Manual, play and pause youtube, both FLASH and HTML5 videos using the following alsa plugins as a sink for alsa_output: plug, hw, dmix, pulse, cras, jack. Observe that pauses are clean without repeated samples. Review URL: https://chromiumcodereview.appspot.com/10413075 TBR=dgreid@chromium.org Review URL: https://chromiumcodereview.appspot.com/10533007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140538 0039d316-1c4b-4281-b951-d872f2087c98
* Remove logspam from media_unittests.fischman@chromium.org2012-05-301-4/+4
| | | | | | Review URL: https://chromiumcodereview.appspot.com/10458007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139503 0039d316-1c4b-4281-b951-d872f2087c98
* Audio in linux became choppy after some system update, I suppose one of the ↵xians@chromium.org2012-05-291-25/+57
| | | | | | | | | | | | | | | | | | | | | | reasons is that previously we try to write to the ALSA with more frames than the available buffer from the snd_pcm_avail_update(), this worked fine before, but in my new test, snd_pcm_writei returns -EAGAIN. Then we have two cases here: #1 Part of data has been written to the ALSA. #2 None of the data has been put into ALSA. The first case will give us glitches because we don't update our local buffer after the writing. The second case may give us potential glitches depending on what we get from GetAvailableFrames(). We should avoid this by checking the snd_pcm_avail_update() and only write what we can write instead. We also add a catch-up scheme when the available space in the buffer is more than kTargetFramesAvailable to avoid underrun. BUG=110375 TEST=http://www.eksor.de/songs/symphonie/02-Dawning.mp3 http://chromium.googlecode.com/svn/trunk/samples/audio/shiny-drum-machine.html demo 5 Review URL: https://chromiumcodereview.appspot.com/10310061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139345 0039d316-1c4b-4281-b951-d872f2087c98
* Better handle error condition in ALSA output.enal@chromium.org2012-05-261-1/+8
| | | | | | | | | | | | | | | | | | | Linux-only change. We were not stopped scheduled WritePacket() when stopping the stream. In normal situation that is Ok, WritePacket() would immediately return is state is "stopped", and we would delete scheduled task when deleting the stream, but problem can happen if some call leaves the stream in the error state -- WritePacket() was checking only for "stopped" state. Fix is simple -- WritePacket() should bail out if state is anything but "playing". BUG=47927 TEST=On Linux we should not see crash 'crashed_thread_function_name.contains:"AudioRendererBase::GetPlaybackRate()"' Review URL: https://chromiumcodereview.appspot.com/10421019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139183 0039d316-1c4b-4281-b951-d872f2087c98
* alsa_output: Drain and pause pcm when stopping.dgreid@chromium.org2012-05-251-0/+5
| | | | | | | | | | | | | | | | | | Call snd_pcm_drain when the output's Stop() function is called. This will keep some alsa interfaces from repeating the last samples played until Close() is called. This will also guarantee that all samples are played back if Close() is called immediately following Stop(). BUG=chromium-os:31211 TEST=Manual, play and pause youtube, both FLASH and HTML5 videos using the following alsa plugins as a sink for alsa_output: plug, hw, dmix, pulse, cras, jack. Observe that pauses are clean without repeated samples. Review URL: https://chromiumcodereview.appspot.com/10413075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138939 0039d316-1c4b-4281-b951-d872f2087c98
* Remove unused parameter "stream" from all variants of OnMoreData().enal@chromium.org2012-04-241-8/+5
| | | | | | | | (Also fixing some minor lint errors...) Review URL: http://codereview.chromium.org/10184011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133726 0039d316-1c4b-4281-b951-d872f2087c98
* Move media/audio files into media namespace (relanding)vrk@google.com2012-04-031-0/+4
| | | | | | | | | | BUG=115187 TEST=compiles and runs without breaking audio tag; media_unittests, content_unittests TBR=scherkus,jam Review URL: https://chromiumcodereview.appspot.com/9968054 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130288 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 130180 - Move media/audio files into media namespacevrk@google.com2012-04-021-4/+0
| | | | | | | | | | | | BUG=115187 TEST=compiles and runs without breaking audio tag; media_unittests, content_unittests Review URL: https://chromiumcodereview.appspot.com/9805001 TBR=vrk@google.com Review URL: https://chromiumcodereview.appspot.com/9965076 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130182 0039d316-1c4b-4281-b951-d872f2087c98
* Move media/audio files into media namespacevrk@google.com2012-04-021-0/+4
| | | | | | | | | BUG=115187 TEST=compiles and runs without breaking audio tag; media_unittests, content_unittests Review URL: https://chromiumcodereview.appspot.com/9805001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130180 0039d316-1c4b-4281-b951-d872f2087c98
* Replace size_t with int in a few media classes.scherkus@chromium.org2012-03-271-8/+8
| | | | | | | | This addressed TODOs in DataSource::Read() and AudioRendererAlgorithmBase, which led to converting Buffer and SeekableBuffer as well. Review URL: https://chromiumcodereview.appspot.com/9854031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129140 0039d316-1c4b-4281-b951-d872f2087c98
* Make AudioParameters a class instead of a structvrk@google.com2012-03-211-7/+7
| | | | | | | | | | | | | Also collapses some long parameter lists into AudioParameters and moves some of the hardcoded values (e.g. 16 bit audio in AudioDevice) to more appropriate locations. BUG=115902 TEST=manually testing everything works out Review URL: https://chromiumcodereview.appspot.com/9655018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128054 0039d316-1c4b-4281-b951-d872f2087c98
* Moved the implementations of ReleaseOutputStream() and ReleaseInputStream() ↵xians@chromium.org2012-03-071-139/+175
| | | | | | | | | | | | | | | to AudioManagerBase and let all the AudioManagerPlatforms inherit the same implementations. Also moved the MakeAudioOutputStream() and MakeAudioInputStream() to AudioManagerBase, separate the AUDIO_PCM_LINEAR mode and AUDIO_PCM_LOW_LATENCY mode into two different functions inside the AudioManagerPlatforms. So that the structure is clearer and also easier to deprecate the AUDIO_PCM_LINEAR for the future. Made the destructor of the AudioManagerPlatforms protected so it can be called by only the AudioManagerBase. BUG=116064 TEST=media_unittests Review URL: http://codereview.chromium.org/9570014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125389 0039d316-1c4b-4281-b951-d872f2087c98
* Make AudioManager non-refcounted.tommi@chromium.org2012-02-151-9/+9
| | | | | | | | | BUG=107087 TEST=media and content unit tests Review URL: https://chromiumcodereview.appspot.com/9382040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122102 0039d316-1c4b-4281-b951-d872f2087c98
* Detect errors in audio output and report them upstream.fischman@chromium.org2012-01-271-6/+4
| | | | | | | | | | | | Stop feeding audio packets to AUDIO DemuxerStreams once audio has been disabled. BUG=111409 TEST=uninstall pulseaudio, make /dev/snd inaccessible, and observe <video> plays correctly (muted) instead of hanging. Review URL: http://codereview.chromium.org/9234066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119488 0039d316-1c4b-4281-b951-d872f2087c98
* Add thread safety to AudioManagerBase to protect access to the audio thread ↵tommi@chromium.org2012-01-191-3/+3
| | | | | | | | | | | | | | | | member variable. This is is a tentative fix for an issue where the AudioManager can crash while tearing down the audio thread. I suspect that this happens because more than one cleanup attempts were made since the class wasn't thread safe. I'm also changing direct access to the thread's MessageLoop* to use MessageLoopProxy based on the same theory. BUG=110051 TEST=Run media tests. Review URL: https://chromiumcodereview.appspot.com/9255017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118272 0039d316-1c4b-4281-b951-d872f2087c98
* Make linux output streams consistent with other output stream implementations.tommi@chromium.org2011-12-141-23/+9
| | | | | | | | | | | | | | | | | | | | | This include the following changes: * The implementation of Start() for ALSA was implemented "asynchronously" on the audio thread. This isn't necessary since Start() is already called on the audio thread and when it eventually runs, it would block the audio thread anyway. Also, the OnPlaying() notification could be fired before the stream is actually at the 'playing' state, which is not consistent with other implementations. * The pulse and alsa output stream classes use the message loop that the AudioManager owns - not a separate pointer. In practice this only removes a member variable but the message loop being used previously belonged to the AudioManager anyaway. * Close is now synchronous like it is in other implementations. * Updated documentation. This also simplifies the threading model for these classes and they are now (like the other stream classes) for all intents and purposes, single threaded. Background: We're working on making more of our tests work across all supported platforms. We identified this problem with these particular implementations when running tests that previously only ran for other platforms. Review URL: http://codereview.chromium.org/8930006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114415 0039d316-1c4b-4281-b951-d872f2087c98
* Remove the AudioManager singleton.tommi@chromium.org2011-12-121-13/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unit tests now instantiate their own AudioManager and can choose to use the default one or provide their own mock implementation without having to worry about conflicting with the singleton. The teardown sequence of the AudioManager and its thread has been cleaned up significantly and I don't think it has been completely tested before as the audio thread was terminated before all objects that belonged to the thread had a chance to do cleanup. The AudioManager unit tests do not use the actual audio thread, so this part seems to have been left out. In Chrome, the AudioManager instance is now owned by BrowserProcessImpl and always constructed on the UI thread. This instance is then shared in the same way that several other 'manager' type objects are shared to 'content' code, via content::ResourceContext. Audio specific classes do though receive a direct pointer to the AudioManager and are required to do proper reference counting if they need to hold onto the instance. I chose to use the ResourceContext rather than direct use of g_browser_process to avoid requiring another singleton when writing relatively simple tests that touch the AudioManager. I added a couple of safeguards to guard against future regressions: - Not more than one instance of the AudioManager should be created. - The AudioManager should not be addrefed by its own thread. This can basically become a circular reference and prevent deterministic shutdown. Reviewers: Of course you're free to review everything, but here's the breakdown in terms of the bare minimum from the standpoint of "Owners approval". I'm asking Henrik to be the main reviewer of the entire patch (sorry!). Henrik: Everything minus the below, but it would be great if you could take a look at the whole thing, specifically media/audio. Pawel: I'd like you to take a generic look at this approach. The key areas as far as the singleton itself goes are in media/audio/audio_manager[_base].* and chrome/browser/browser_process*.* Satish: content/browser/speech/* media/audio/audio_manager_base.* (new reference counting code) Andrew: content/browser/renderer_host/media/* content/renderer/media/webrtc_audio_device_unittest.cc (Owner) Avi: content/browser/renderer_host/render_process_host_impl.cc content/browser/resource_context.* William: chrome/browser/profiles/profile_io_data.cc chrome/browser/browser_process*.* Robert: This is basically a heads up. I hope that I didn't break the OpenBSD implementation, but unfortunately I have no way of knowing for sure. Shijing: Please take a look at AudioManagerLinux. I replaced the set of active streams with a simple counter. BUG=105249 TEST=content_unittests, media_unittests, browser_tests. Review URL: http://codereview.chromium.org/8818012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114084 0039d316-1c4b-4281-b951-d872f2087c98
* Enable the device selection for linux and mac by passing a device unique id ↵xians@chromium.org2011-11-221-2/+2
| | | | | | | | | | | | | | | from renderer down to the browser. With this patch, users should be able to create a audio stream with a non-default device, and feature is only available for low-latency audio. TEST=media_unittests, webrtc test app BUG=None Review URL: http://codereview.chromium.org/8491044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111153 0039d316-1c4b-4281-b951-d872f2087c98
* Revert r104043, which causes audio not to play smoothly on Chrome OS.enal@chromium.org2011-10-181-8/+7
| | | | | | | | BUG=chromium-os:21491 Review URL: http://codereview.chromium.org/8329004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105996 0039d316-1c4b-4281-b951-d872f2087c98
* Re-write the alsa polling scheduling to make it work with low buffer audio, ↵xians@chromium.org2011-10-051-8/+9
| | | | | | | | | | | | | | | | | | for example, 10ms for playout. Before this patch, the alsa scheme sets a frame_avail_wanted as half of the ALSA buffer size, then it checks if the available_frame buffer slot in ALSA is smaller than frame_avail_wanted, if it is, which means that ALSA has more buffer than we need, then it schedule the next time to be FrameToMills(frame_avail_wanted - available_frame). Otherwise, we invoke the next write immediately. But this scheduling scheme doesn't handle the following cases well: #1, It has a chance running into a dead lock that we always have less than half of the buffer filled, where it runs into a busy looping. This happens mostly when the buffer size is small. #2, We can write more data to ALSA than what it needs. This patch fixes the problems by initiating the next time for the moment when half of packet is played out. Then it checks with ALSA on how many frames are available, and do a re-scheduling: if the available frames are not enough for a packet, it schedules the next write for the moment when the buffer for a packet becomes available, if the next write happens in less than 10ms, then it will use 10ms in order to avoid back to back writing; if the existing frames are less than half packet, it make next write to be immediate. Review URL: http://codereview.chromium.org/7976047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104043 0039d316-1c4b-4281-b951-d872f2087c98
* PulseAudio Sound Playback on Linuxslock@chromium.org2011-08-191-1/+1
| | | | | | | | | | | | This is the preliminary implementation of a PulseAudio sound backend for Chrome on Linux. At first, PulseAudio's mainloop, mainloop_api, and context constructs will be used instead of the message loop system used in alsa_output. This will be stereo only at first. Also, at first, PulseAudio will be dynamically linked in media.gyp as opposed to the final solution which will dynamically link PulseAudio in runtime if it is available. BUG=32757 TEST= Review URL: http://codereview.chromium.org/7473021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97408 0039d316-1c4b-4281-b951-d872f2087c98
* Fix clang.jhawkins@chromium.org2011-06-221-2/+2
| | | | | | | | | | | BUG=none TEST=none R=vandebo@chromium.org Review URL: http://codereview.chromium.org/7241004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90123 0039d316-1c4b-4281-b951-d872f2087c98
* Simplify AlsaPcmOutputStream and AudioManagerLinux. Code was thread-safe, ↵enal@chromium.org2011-06-081-49/+41
| | | | | | | | | | | | | | but now client and audio threads are the same, so we don't need locks/ref counts/etc. http://codereview.chromium.org/7117001 BUG=62588 Review URL: http://codereview.chromium.org/7117001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88369 0039d316-1c4b-4281-b951-d872f2087c98
* Description:annacc@chromium.org2011-05-161-22/+33
| | | | | | | | | | | | | | | | | This patch gets the channel layout for surround sound channel order from ffmpeg and stores it so that chromium will be able to re-order the channels for various sound cards and OSes later. - AudioParameters gets a new field (channel_layout). - channel_layout.h stores an enum that we will use in chromium for channel values. - ffmpeg_common.h gets a new method for mapping the channel layout received from ffmpeg to an internal chromium enum value. BUG=None (though storing the channel order should help us solve some other bugs soon) TEST=media_unittests Review URL: http://codereview.chromium.org/6930039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85541 0039d316-1c4b-4281-b951-d872f2087c98
* iwyu: Include stringprintf.h where appropriate, part 3.jhawkins@chromium.org2011-05-121-2/+2
| | | | | | | | | | | BUG=82098 TEST=none R=csilv@chromium.org Review URL: http://codereview.chromium.org/7016011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85088 0039d316-1c4b-4281-b951-d872f2087c98
* Fix Linux audio playbackdavej@chromium.org2011-04-141-2/+2
| | | | | | | | | | | | | Playing audio files shorter than about 11000 samples on Linux was either not working at all, or re-playing (starting and stopping on the same audio object) was working only intermittently. It was possible to stop audio playback before the first buffer was played, resulting in no sound at all. Also, if replaying, the buffer may have been dirty from the previous playback on the same device. So on Linux at least, these issues appear fixed. BUG=73045,47761,59367,59369,59370,65618 TEST=Manual, quickly playing short audio files on Linux should work Review URL: http://codereview.chromium.org/6776024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81669 0039d316-1c4b-4281-b951-d872f2087c98
* clang: Fix several -Woverloaded-virtual warnings.thakis@chromium.org2011-02-111-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Real bugs: net/http/http_network_transaction_unittest.cc:273:16:error: 'net::CaptureGroupNameSocketPool<net::HttpProxyClientSocketPool>::ReleaseSocket' hides overloaded virtual function [-Woverloaded-virtual] virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_network_transaction_unittest.cc:310:1: note: in instantiation of template class 'net::CaptureGroupNameSocketPool<net::HttpProxyClientSocketPool>' requested here CaptureGroupNameHttpProxySocketPool::CaptureGroupNameSocketPool( ^ In file included from ./net/http/http_network_session_peer.h:10: ./net/http/http_proxy_client_socket_pool.h:200:16: note: hidden overloaded virtual function 'net::HttpProxyClientSocketPool::ReleaseSocket' declared here virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_network_transaction_unittest.cc:273:16:error: 'net::CaptureGroupNameSocketPool<net::SSLClientSocketPool>::ReleaseSocket' hides overloaded virtual function [-Woverloaded-virtual] virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_network_transaction_unittest.cc:316:1: note: in instantiation of template class 'net::CaptureGroupNameSocketPool<net::SSLClientSocketPool>' requested here CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool( ^ In file included from ./net/http/http_network_session_peer.h:12: ./net/socket/ssl_client_socket_pool.h:208:16: note: hidden overloaded virtual function 'net::SSLClientSocketPool::ReleaseSocket' declared here virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_network_transaction_unittest.cc:273:16:error: 'net::CaptureGroupNameSocketPool<net::TCPClientSocketPool>::ReleaseSocket' hides overloaded virtual function [-Woverloaded-virtual] virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_network_transaction_unittest.cc:5511:13: note: in instantiation of template class 'net::CaptureGroupNameSocketPool<net::TCPClientSocketPool>' requested here new CaptureGroupNameTCPSocketPool(NULL, NULL); ^ In file included from ./net/socket/socket_test_util.h:34: ./net/socket/tcp_client_socket_pool.h:134:16: note: hidden overloaded virtual function 'net::TCPClientSocketPool::ReleaseSocket' declared here virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_network_transaction_unittest.cc:273:16:error: 'net::CaptureGroupNameSocketPool<net::SOCKSClientSocketPool>::ReleaseSocket' hides overloaded virtual function [-Woverloaded-virtual] virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_network_transaction_unittest.cc:5630:13: note: in instantiation of template class 'net::CaptureGroupNameSocketPool<net::SOCKSClientSocketPool>' requested here new CaptureGroupNameSOCKSSocketPool(NULL, NULL); ^ In file included from ./net/http/http_network_session_peer.h:11: ./net/socket/socks_client_socket_pool.h:133:16: note: hidden overloaded virtual function 'net::SOCKSClientSocketPool::ReleaseSocket' declared here virtual void ReleaseSocket(const std::string& group_name, ^ CXX(target) out/Debug/obj.target/net_unittests/net/http/http_response_body_drainer_unittest.o 4 errors generated. net/http/http_stream_factory_unittest.cc:126:16:error: 'net::<anonymous namespace>::CapturePreconnectsSocketPool<net::HttpProxyClientSocketPool>::ReleaseSocket' hides overloaded virtual function [-Woverloaded-virtual] virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_stream_factory_unittest.cc:170:1: note: in instantiation of template class 'net::<anonymous>::CapturePreconnectsSocketPool<net::HttpProxyClientSocketPool>' requested here CapturePreconnectsHttpProxySocketPool::CapturePreconnectsSocketPool( ^ In file included from ./net/http/http_network_session_peer.h:10: ./net/http/http_proxy_client_socket_pool.h:200:16: note: hidden overloaded virtual function 'net::HttpProxyClientSocketPool::ReleaseSocket' declared here virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_stream_factory_unittest.cc:126:16:error: 'net::<anonymous namespace>::CapturePreconnectsSocketPool<net::SSLClientSocketPool>::ReleaseSocket' hides overloaded virtual function [-Woverloaded-virtual] virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_stream_factory_unittest.cc:176:1: note: in instantiation of template class 'net::<anonymous>::CapturePreconnectsSocketPool<net::SSLClientSocketPool>' requested here CapturePreconnectsSSLSocketPool::CapturePreconnectsSocketPool( ^ In file included from ./net/http/http_network_session_peer.h:12: ./net/socket/ssl_client_socket_pool.h:208:16: note: hidden overloaded virtual function 'net::SSLClientSocketPool::ReleaseSocket' declared here virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_stream_factory_unittest.cc:126:16:error: 'net::<anonymous namespace>::CapturePreconnectsSocketPool<net::TCPClientSocketPool>::ReleaseSocket' hides overloaded virtual function [-Woverloaded-virtual] virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_stream_factory_unittest.cc:188:13: note: in instantiation of template class 'net::<anonymous>::CapturePreconnectsSocketPool<net::TCPClientSocketPool>' requested here new CapturePreconnectsTCPSocketPool( ^ In file included from ./net/socket/socket_test_util.h:34: ./net/socket/tcp_client_socket_pool.h:134:16: note: hidden overloaded virtual function 'net::TCPClientSocketPool::ReleaseSocket' declared here virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_stream_factory_unittest.cc:126:16:error: 'net::<anonymous namespace>::CapturePreconnectsSocketPool<net::SOCKSClientSocketPool>::ReleaseSocket' hides overloaded virtual function [-Woverloaded-virtual] virtual void ReleaseSocket(const std::string& group_name, ^ net/http/http_stream_factory_unittest.cc:237:13: note: in instantiation of template class 'net::<anonymous>::CapturePreconnectsSocketPool<net::SOCKSClientSocketPool>' requested here new CapturePreconnectsSOCKSSocketPool( ^ In file included from net/http/http_stream_factory_unittest.cc:17: In file included from ./net/http/http_network_session_peer.h:11: ./net/socket/socks_client_socket_pool.h:133:16: note: hidden overloaded virtual function 'net::SOCKSClientSocketPool::ReleaseSocket' declared here virtual void ReleaseSocket(const std::string& group_name, ^ CXX(target) out/Debug/obj.target/net_unittests/net/http/http_vary_data_unittest.o 4 errors generated. make: *** [out/Debug/obj.target/net_unittests/net/http/http_stream_factory_unittest.o] Error 1 media/audio/linux/alsa_output_unittest.cc:83:3:error: 'MockAudioManagerLinux::MakeAudioInputStream' hides overloaded virtual function [-Woverloaded-virtual] MOCK_METHOD5(MakeAudioInputStream, AudioInputStream*( ^ In file included from media/audio/linux/alsa_output_unittest.cc:12: In file included from ./testing/gmock/include/gmock/gmock.h:61: testing/gmock/include/gmock/gmock-generated-function-mockers.h:632:28: note: instantiated from: ^ media/audio/linux/alsa_output_unittest.cc:83:3: note: instantiated from: MOCK_METHOD5(MakeAudioInputStream, AudioInputStream*( ^ media/audio/linux/alsa_output_unittest.cc:83:16: note: instantiated from: MOCK_METHOD5(MakeAudioInputStream, AudioInputStream*( ^ In file included from media/audio/linux/alsa_output_unittest.cc:9: ./media/audio/linux/audio_manager_linux.h:30:29: note: hidden overloaded virtual function 'AudioManagerLinux::MakeAudioInputStream' declared here virtual AudioInputStream* MakeAudioInputStream(AudioParameters params); ^ CXX(target) out/Debug/obj.target/media_unittests/media/base/data_buffer_unittest.o CXX(target) out/Debug/obj.target/media_unittests/media/base/djb2_unittest.o 1 error generated. No bug, just confusing: In file included from webkit/plugins/npapi/test/plugin_schedule_timer_test.cc:5: ./webkit/plugins/npapi/test/plugin_schedule_timer_test.h:59:8:error: 'NPAPIClient::ScheduleTimerTest::HandleEvent' hides overloaded virtual function [-Woverloaded-virtual] void HandleEvent(int event_index); ^ In file included from webkit/plugins/npapi/test/plugin_schedule_timer_test.cc:5: In file included from ./webkit/plugins/npapi/test/plugin_schedule_timer_test.h:9: ./webkit/plugins/npapi/test/plugin_test.h:43:19: note: hidden overloaded virtual function 'NPAPIClient::PluginTest::HandleEvent' declared here virtual int16 HandleEvent(void* event); ^ 1 error generated. make: *** [out/Debug/obj.target/npapi_test_plugin/webkit/plugins/npapi/test/plugin_schedule_timer_test.o] Error 1 CXX(target) out/Debug/obj.target/npapi_test_plugin/webkit/plugins/npapi/test/plugin_private_test.o CXX(target) out/Debug/obj.target/npapi_test_plugin/webkit/plugins/npapi/test/plugin_test_factory.o In file included from webkit/plugins/npapi/test/plugin_test_factory.cc:17: ./webkit/plugins/npapi/test/plugin_schedule_timer_test.h:59:8:error: 'NPAPIClient::ScheduleTimerTest::HandleEvent' hides overloaded virtual function [-Woverloaded-virtual] void HandleEvent(int event_index); ^ In file included from webkit/plugins/npapi/test/plugin_test_factory.cc:7: In file included from ./webkit/plugins/npapi/test/plugin_arguments_test.h:8: ./webkit/plugins/npapi/test/plugin_test.h:43:19: note: hidden overloaded virtual function 'NPAPIClient::PluginTest::HandleEvent' declared here virtual int16 HandleEvent(void* event); ^ 1 error generated. BUG=72205 TEST=none Review URL: http://codereview.chromium.org/6503001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74642 0039d316-1c4b-4281-b951-d872f2087c98