Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / media / audio / linux / alsa_wrapper.h
blob30d94635dd5cdd6c636b9a065d465f6948d20e81
1 // Copyright (c) 2012 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 #include <alsa/asoundlib.h>
11 #include "base/basictypes.h"
12 #include "media/base/media_export.h"
14 namespace media {
16 class MEDIA_EXPORT AlsaWrapper {
17 public:
18 AlsaWrapper();
19 virtual ~AlsaWrapper();
21 virtual int DeviceNameHint(int card, const char* iface, void*** hints);
22 virtual char* DeviceNameGetHint(const void* hint, const char* id);
23 virtual int DeviceNameFreeHint(void** hints);
24 virtual int CardNext(int* rcard);
26 virtual int PcmOpen(snd_pcm_t** handle, const char* name,
27 snd_pcm_stream_t stream, int mode);
28 virtual int PcmClose(snd_pcm_t* handle);
29 virtual int PcmPrepare(snd_pcm_t* handle);
30 virtual int PcmDrop(snd_pcm_t* handle);
31 virtual int PcmDelay(snd_pcm_t* handle, snd_pcm_sframes_t* delay);
32 virtual snd_pcm_sframes_t PcmWritei(snd_pcm_t* handle,
33 const void* buffer,
34 snd_pcm_uframes_t size);
35 virtual snd_pcm_sframes_t PcmReadi(snd_pcm_t* handle,
36 void* buffer,
37 snd_pcm_uframes_t size);
38 virtual int PcmRecover(snd_pcm_t* handle, int err, int silent);
39 virtual int PcmSetParams(snd_pcm_t* handle, snd_pcm_format_t format,
40 snd_pcm_access_t access, unsigned int channels,
41 unsigned int rate, int soft_resample,
42 unsigned int latency);
43 virtual int PcmGetParams(snd_pcm_t* handle, snd_pcm_uframes_t* buffer_size,
44 snd_pcm_uframes_t* period_size);
45 virtual const char* PcmName(snd_pcm_t* handle);
46 virtual snd_pcm_sframes_t PcmAvailUpdate(snd_pcm_t* handle);
47 virtual snd_pcm_state_t PcmState(snd_pcm_t* handle);
48 virtual int PcmStart(snd_pcm_t* handle);
50 virtual int MixerOpen(snd_mixer_t** mixer, int mode);
51 virtual int MixerAttach(snd_mixer_t* mixer, const char* name);
52 virtual int MixerElementRegister(snd_mixer_t* mixer,
53 struct snd_mixer_selem_regopt* options,
54 snd_mixer_class_t** classp);
55 virtual void MixerFree(snd_mixer_t* mixer);
56 virtual int MixerDetach(snd_mixer_t* mixer, const char* name);
57 virtual int MixerClose(snd_mixer_t* mixer);
58 virtual int MixerLoad(snd_mixer_t* mixer);
59 virtual snd_mixer_elem_t* MixerFirstElem(snd_mixer_t* mixer);
60 virtual snd_mixer_elem_t* MixerNextElem(snd_mixer_elem_t* elem);
61 virtual int MixerSelemIsActive(snd_mixer_elem_t* elem);
62 virtual const char* MixerSelemName(snd_mixer_elem_t* elem);
63 virtual int MixerSelemSetCaptureVolumeAll(snd_mixer_elem_t* elem, long value);
64 virtual int MixerSelemGetCaptureVolume(snd_mixer_elem_t* elem,
65 snd_mixer_selem_channel_id_t channel,
66 long* value);
67 virtual int MixerSelemHasCaptureVolume(snd_mixer_elem_t* elem);
68 virtual int MixerSelemGetCaptureVolumeRange(snd_mixer_elem_t* elem,
69 long* min, long* max);
71 virtual const char* StrError(int errnum);
73 private:
74 int ConfigureHwParams(snd_pcm_t* handle, snd_pcm_hw_params_t* hw_params,
75 snd_pcm_format_t format, snd_pcm_access_t access,
76 unsigned int channels, unsigned int rate,
77 int soft_resample, unsigned int latency);
78 DISALLOW_COPY_AND_ASSIGN(AlsaWrapper);
81 } // namespace media