Delete unused downloads page asset.
[chromium-blink-merge.git] / media / audio / alsa / alsa_wrapper.h
blob4b3c295e5827716f2c917feb41bfa0435999dd70
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
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
7 // higher level code is testable.
9 #ifndef MEDIA_AUDIO_ALSA_ALSA_WRAPPER_H_
10 #define MEDIA_AUDIO_ALSA_ALSA_WRAPPER_H_
12 #include <alsa/asoundlib.h>
14 #include "base/basictypes.h"
15 #include "media/base/media_export.h"
17 namespace media {
19 class MEDIA_EXPORT AlsaWrapper {
20 public:
21 AlsaWrapper();
22 virtual ~AlsaWrapper();
24 virtual int DeviceNameHint(int card, const char* iface, void*** hints);
25 virtual char* DeviceNameGetHint(const void* hint, const char* id);
26 virtual int DeviceNameFreeHint(void** hints);
27 virtual int CardNext(int* rcard);
29 virtual int PcmOpen(snd_pcm_t** handle, const char* name,
30 snd_pcm_stream_t stream, int mode);
31 virtual int PcmClose(snd_pcm_t* handle);
32 virtual int PcmPrepare(snd_pcm_t* handle);
33 virtual int PcmDrop(snd_pcm_t* handle);
34 virtual int PcmDelay(snd_pcm_t* handle, snd_pcm_sframes_t* delay);
35 virtual snd_pcm_sframes_t PcmWritei(snd_pcm_t* handle,
36 const void* buffer,
37 snd_pcm_uframes_t size);
38 virtual snd_pcm_sframes_t PcmReadi(snd_pcm_t* handle,
39 void* buffer,
40 snd_pcm_uframes_t size);
41 virtual int PcmRecover(snd_pcm_t* handle, int err, int silent);
42 virtual int PcmSetParams(snd_pcm_t* handle, snd_pcm_format_t format,
43 snd_pcm_access_t access, unsigned int channels,
44 unsigned int rate, int soft_resample,
45 unsigned int latency);
46 virtual int PcmGetParams(snd_pcm_t* handle, snd_pcm_uframes_t* buffer_size,
47 snd_pcm_uframes_t* period_size);
48 virtual const char* PcmName(snd_pcm_t* handle);
49 virtual snd_pcm_sframes_t PcmAvailUpdate(snd_pcm_t* handle);
50 virtual snd_pcm_state_t PcmState(snd_pcm_t* handle);
51 virtual int PcmStart(snd_pcm_t* handle);
53 virtual int MixerOpen(snd_mixer_t** mixer, int mode);
54 virtual int MixerAttach(snd_mixer_t* mixer, const char* name);
55 virtual int MixerElementRegister(snd_mixer_t* mixer,
56 struct snd_mixer_selem_regopt* options,
57 snd_mixer_class_t** classp);
58 virtual void MixerFree(snd_mixer_t* mixer);
59 virtual int MixerDetach(snd_mixer_t* mixer, const char* name);
60 virtual int MixerClose(snd_mixer_t* mixer);
61 virtual int MixerLoad(snd_mixer_t* mixer);
62 virtual snd_mixer_elem_t* MixerFirstElem(snd_mixer_t* mixer);
63 virtual snd_mixer_elem_t* MixerNextElem(snd_mixer_elem_t* elem);
64 virtual int MixerSelemIsActive(snd_mixer_elem_t* elem);
65 virtual const char* MixerSelemName(snd_mixer_elem_t* elem);
66 virtual int MixerSelemSetCaptureVolumeAll(snd_mixer_elem_t* elem, long value);
67 virtual int MixerSelemGetCaptureVolume(snd_mixer_elem_t* elem,
68 snd_mixer_selem_channel_id_t channel,
69 long* value);
70 virtual int MixerSelemHasCaptureVolume(snd_mixer_elem_t* elem);
71 virtual int MixerSelemGetCaptureVolumeRange(snd_mixer_elem_t* elem,
72 long* min, long* max);
74 virtual const char* StrError(int errnum);
76 private:
77 int ConfigureHwParams(snd_pcm_t* handle, snd_pcm_hw_params_t* hw_params,
78 snd_pcm_format_t format, snd_pcm_access_t access,
79 unsigned int channels, unsigned int rate,
80 int soft_resample, unsigned int latency);
81 DISALLOW_COPY_AND_ASSIGN(AlsaWrapper);
84 } // namespace media
86 #endif // MEDIA_AUDIO_ALSA_ALSA_WRAPPER_H_