summaryrefslogtreecommitdiffstats
path: root/media/audio/linux/alsa_wrapper.cc
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-04 21:49:12 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-04 21:49:12 +0000
commit83337270c01c66378d443f5c3d15926cac164747 (patch)
treea94d2b86aa74a0fa15a5f9404f4abc6c7cc725e4 /media/audio/linux/alsa_wrapper.cc
parentcdf6cc8f2b5036894359123804d28b92b9cfa9ee (diff)
downloadchromium_src-83337270c01c66378d443f5c3d15926cac164747.zip
chromium_src-83337270c01c66378d443f5c3d15926cac164747.tar.gz
chromium_src-83337270c01c66378d443f5c3d15926cac164747.tar.bz2
Reimplement the AlsaPcmOutputStream and fix the threading issues.
Changes the threading model from one thread per stream to one shared thread. Also, redoes the alsa reading/buffering logic to assume an asynchronous data source, and respect the different packet sizes. The Alsa device is set to non-blocking now. State transitions are cleaned up, and the threading semantics are reworked. Now linux audio will no longer crash on shutdown, seek, pause, or tab close. This implementation does still leak though. :( The leak will be fixed in another CL. Review URL: http://codereview.chromium.org/160497 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22414 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/linux/alsa_wrapper.cc')
-rw-r--r--media/audio/linux/alsa_wrapper.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/media/audio/linux/alsa_wrapper.cc b/media/audio/linux/alsa_wrapper.cc
new file mode 100644
index 0000000..9557cac
--- /dev/null
+++ b/media/audio/linux/alsa_wrapper.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/audio/linux/alsa_wrapper.h"
+
+#include <alsa/asoundlib.h>
+
+AlsaWrapper::AlsaWrapper() {
+}
+
+AlsaWrapper::~AlsaWrapper() {
+}
+
+int AlsaWrapper::PcmOpen(snd_pcm_t** handle, const char* name,
+ snd_pcm_stream_t stream, int mode) {
+ return snd_pcm_open(handle, name, stream, mode);
+}
+
+int AlsaWrapper::PcmClose(snd_pcm_t* handle) {
+ return snd_pcm_close(handle);
+}
+
+int AlsaWrapper::PcmPrepare(snd_pcm_t* handle) {
+ return snd_pcm_prepare(handle);
+}
+
+int AlsaWrapper::PcmDrop(snd_pcm_t* handle) {
+ return snd_pcm_drop(handle);
+}
+
+snd_pcm_sframes_t AlsaWrapper::PcmWritei(snd_pcm_t* handle,
+ const void* buffer,
+ snd_pcm_uframes_t size) {
+ return snd_pcm_writei(handle, buffer, size);
+}
+
+int AlsaWrapper::PcmRecover(snd_pcm_t* handle, int err, int silent) {
+ return snd_pcm_recover(handle, err, silent);
+}
+
+const char* AlsaWrapper::PcmName(snd_pcm_t* handle) {
+ return snd_pcm_name(handle);
+}
+
+int AlsaWrapper::PcmSetParams(snd_pcm_t* handle, snd_pcm_format_t format,
+ snd_pcm_access_t access, unsigned int channels,
+ unsigned int rate, int soft_resample,
+ unsigned int latency) {
+ return snd_pcm_set_params(handle, format, access, channels, rate,
+ soft_resample, latency);
+}
+
+snd_pcm_sframes_t AlsaWrapper::PcmAvailUpdate(snd_pcm_t* handle) {
+ return snd_pcm_avail_update(handle);
+}
+
+const char* AlsaWrapper::StrError(int errnum) {
+ return snd_strerror(errnum);
+}