summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-09 00:39:27 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-09 00:39:27 +0000
commit635437c0531761ca0cf7a9de06ba1c4b3bbb9c44 (patch)
tree7ed604ee939e9fd374d0843d961b17a825641ffc /media
parentc5dda11e87fa50bdbfd121aeecce2a96171c6635 (diff)
downloadchromium_src-635437c0531761ca0cf7a9de06ba1c4b3bbb9c44.zip
chromium_src-635437c0531761ca0cf7a9de06ba1c4b3bbb9c44.tar.gz
chromium_src-635437c0531761ca0cf7a9de06ba1c4b3bbb9c44.tar.bz2
Retry 35837 linux: grab device name before closing it
PcmClose frees the handle regardless of whether there's an error while shutting down, so grab the PcmName result first in case we want to use it in an error message. Original Review URL: http://codereview.chromium.org/538005 BUG=20006 Review URL: http://codereview.chromium.org/542002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35854 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/audio/linux/alsa_output.cc5
-rw-r--r--media/audio/linux/alsa_output_unittest.cc12
2 files changed, 14 insertions, 3 deletions
diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc
index 1ee85e7..d878a74 100644
--- a/media/audio/linux/alsa_output.cc
+++ b/media/audio/linux/alsa_output.cc
@@ -756,10 +756,11 @@ snd_pcm_t* AlsaPcmOutputStream::OpenDevice(const std::string& device_name,
}
bool AlsaPcmOutputStream::CloseDevice(snd_pcm_t* handle) {
+ std::string name = wrapper_->PcmName(handle);
int error = wrapper_->PcmClose(handle);
if (error < 0) {
- LOG(ERROR) << "Cannot close audio device (" << wrapper_->PcmName(handle)
- << "): " << wrapper_->StrError(error);
+ LOG(ERROR) << "Error closing audio device (" << name << "): "
+ << wrapper_->StrError(error);
return false;
}
diff --git a/media/audio/linux/alsa_output_unittest.cc b/media/audio/linux/alsa_output_unittest.cc
index 72c4c90..70949b5 100644
--- a/media/audio/linux/alsa_output_unittest.cc
+++ b/media/audio/linux/alsa_output_unittest.cc
@@ -227,7 +227,9 @@ TEST_F(AlsaPcmOutputStreamTest, LatencyFloor) {
message_loop_.RunAllPending();
// Now close it and test that everything was released.
- EXPECT_CALL(mock_alsa_wrapper_, PcmClose(kFakeHandle)) .WillOnce(Return(0));
+ EXPECT_CALL(mock_alsa_wrapper_, PcmClose(kFakeHandle)).WillOnce(Return(0));
+ EXPECT_CALL(mock_alsa_wrapper_, PcmName(kFakeHandle))
+ .WillOnce(Return(kTestDeviceName));
EXPECT_CALL(mock_manager_, ReleaseStream(test_stream_.get()));
test_stream_->Close();
message_loop_.RunAllPending();
@@ -258,6 +260,8 @@ TEST_F(AlsaPcmOutputStreamTest, LatencyFloor) {
// Now close it and test that everything was released.
EXPECT_CALL(mock_alsa_wrapper_, PcmClose(kFakeHandle))
.WillOnce(Return(0));
+ EXPECT_CALL(mock_alsa_wrapper_, PcmName(kFakeHandle))
+ .WillOnce(Return(kTestDeviceName));
EXPECT_CALL(mock_manager_, ReleaseStream(test_stream_.get()));
test_stream_->Close();
message_loop_.RunAllPending();
@@ -303,6 +307,8 @@ TEST_F(AlsaPcmOutputStreamTest, OpenClose) {
// Now close it and test that everything was released.
EXPECT_CALL(mock_alsa_wrapper_, PcmClose(kFakeHandle))
.WillOnce(Return(0));
+ EXPECT_CALL(mock_alsa_wrapper_, PcmName(kFakeHandle))
+ .WillOnce(Return(kTestDeviceName));
EXPECT_CALL(mock_manager_, ReleaseStream(test_stream_.get()));
test_stream_->Close();
message_loop_.RunAllPending();
@@ -346,6 +352,8 @@ TEST_F(AlsaPcmOutputStreamTest, PcmSetParamsFailed) {
.WillOnce(Return(kTestFailedErrno));
EXPECT_CALL(mock_alsa_wrapper_, PcmClose(kFakeHandle))
.WillOnce(Return(0));
+ EXPECT_CALL(mock_alsa_wrapper_, PcmName(kFakeHandle))
+ .WillOnce(Return(kTestDeviceName));
EXPECT_CALL(mock_alsa_wrapper_, StrError(kTestFailedErrno))
.WillOnce(Return(kDummyMessage));
@@ -414,6 +422,8 @@ TEST_F(AlsaPcmOutputStreamTest, StartStop) {
EXPECT_CALL(mock_callback, OnClose(test_stream_.get()));
EXPECT_CALL(mock_alsa_wrapper_, PcmClose(kFakeHandle))
.WillOnce(Return(0));
+ EXPECT_CALL(mock_alsa_wrapper_, PcmName(kFakeHandle))
+ .WillOnce(Return(kTestDeviceName));
test_stream_->Close();
message_loop_.RunAllPending();
}