| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // AlsaWrapper is a simple stateless class that wraps the alsa library commands | 5 // AlsaWrapper is a simple stateless class that wraps the alsa library commands |
| 6 // we want to use. It's purpose is to allow injection of a mock so that the | 6 // we want to use. It's purpose is to allow injection of a mock so that the |
| 7 // higher level code is testable. | 7 // higher level code is testable. |
| 8 | 8 |
| 9 #include <alsa/asoundlib.h> | 9 #include <alsa/asoundlib.h> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 13 | 13 |
| 14 class MEDIA_EXPORT AlsaWrapper { | 14 class MEDIA_EXPORT AlsaWrapper { |
| 15 public: | 15 public: |
| 16 AlsaWrapper(); | 16 AlsaWrapper(); |
| 17 virtual ~AlsaWrapper(); | 17 virtual ~AlsaWrapper(); |
| 18 | 18 |
| 19 virtual int DeviceNameHint(int card, const char* iface, void*** hints); | 19 virtual int DeviceNameHint(int card, const char* iface, void*** hints); |
| 20 virtual char* DeviceNameGetHint(const void* hint, const char* id); | 20 virtual char* DeviceNameGetHint(const void* hint, const char* id); |
| 21 virtual int DeviceNameFreeHint(void** hints); | 21 virtual int DeviceNameFreeHint(void** hints); |
| 22 virtual int CardNext(int* rcard); |
| 22 | 23 |
| 23 virtual int PcmOpen(snd_pcm_t** handle, const char* name, | 24 virtual int PcmOpen(snd_pcm_t** handle, const char* name, |
| 24 snd_pcm_stream_t stream, int mode); | 25 snd_pcm_stream_t stream, int mode); |
| 25 virtual int PcmClose(snd_pcm_t* handle); | 26 virtual int PcmClose(snd_pcm_t* handle); |
| 26 virtual int PcmPrepare(snd_pcm_t* handle); | 27 virtual int PcmPrepare(snd_pcm_t* handle); |
| 27 virtual int PcmDrop(snd_pcm_t* handle); | 28 virtual int PcmDrop(snd_pcm_t* handle); |
| 28 virtual int PcmDelay(snd_pcm_t* handle, snd_pcm_sframes_t* delay); | 29 virtual int PcmDelay(snd_pcm_t* handle, snd_pcm_sframes_t* delay); |
| 29 virtual snd_pcm_sframes_t PcmWritei(snd_pcm_t* handle, | 30 virtual snd_pcm_sframes_t PcmWritei(snd_pcm_t* handle, |
| 30 const void* buffer, | 31 const void* buffer, |
| 31 snd_pcm_uframes_t size); | 32 snd_pcm_uframes_t size); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 46 | 47 |
| 47 virtual const char* StrError(int errnum); | 48 virtual const char* StrError(int errnum); |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 int ConfigureHwParams(snd_pcm_t* handle, snd_pcm_hw_params_t* hw_params, | 51 int ConfigureHwParams(snd_pcm_t* handle, snd_pcm_hw_params_t* hw_params, |
| 51 snd_pcm_format_t format, snd_pcm_access_t access, | 52 snd_pcm_format_t format, snd_pcm_access_t access, |
| 52 unsigned int channels, unsigned int rate, | 53 unsigned int channels, unsigned int rate, |
| 53 int soft_resample, unsigned int latency); | 54 int soft_resample, unsigned int latency); |
| 54 DISALLOW_COPY_AND_ASSIGN(AlsaWrapper); | 55 DISALLOW_COPY_AND_ASSIGN(AlsaWrapper); |
| 55 }; | 56 }; |
| OLD | NEW |