MythTV master
audioinputalsa.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2007 Anand K. Mistry
3 * Copyright (C) 2008 Alan Calvert
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */
20
21#ifndef AUDIOINPUTALSA_H
22#define AUDIOINPUTALSA_H
23
24#include "libmythbase/mythconfig.h"
25
26#include "audioinput.h"
27
28#if CONFIG_AUDIO_ALSA
29#include <alsa/asoundlib.h>
30#else
31using snd_pcm_t = int;
33#endif // CONFIG_AUDIO_ALSA
34
36{
37 public:
38 explicit AudioInputALSA(const QString &device)
39 : AudioInput(device)
40 , m_alsaDevice(device.right(device.size()-5).toLatin1()) {}
42
43 bool Open(uint sample_bits, uint sample_rate, uint channels) override; // AudioInput
44 bool IsOpen(void) override // AudioInput
45 { return (m_pcmHandle != nullptr); }
46 void Close(void) override; // AudioInput
47
48 bool Start(void) override // AudioInput
49 { return (m_pcmHandle != nullptr); }
50 bool Stop(void) override; // AudioInput
51
52 int GetBlockSize(void) override // AudioInput
53 { return m_mythBlockBytes; }
54 int GetSamples(void* buf, uint nbytes) override; // AudioInput
55 int GetNumReadyBytes(void) override; // AudioInput
56
57 private:
58 bool PrepHwParams(void);
59 bool PrepSwParams(void);
60 int PcmRead(void* buf, uint nbytes);
61 bool Recovery(int err);
62 bool AlsaBad(int op_result, const QString& errmsg);
63
64 QByteArray m_alsaDevice;
68};
69#endif /* AUDIOINPUTALSA_H */
70/* vim: set expandtab tabstop=4 shiftwidth=4: */
71
int snd_pcm_uframes_t
int snd_pcm_t
AudioInputALSA(const QString &device)
int GetBlockSize(void) override
int GetSamples(void *buf, uint nbytes) override
bool PrepSwParams(void)
bool Start(void) override
bool Stop(void) override
bool AlsaBad(int op_result, const QString &errmsg)
QByteArray m_alsaDevice
~AudioInputALSA() override
bool Recovery(int err)
snd_pcm_uframes_t m_periodSize
bool Open(uint sample_bits, uint sample_rate, uint channels) override
bool PrepHwParams(void)
snd_pcm_t * m_pcmHandle
bool IsOpen(void) override
void Close(void) override
int PcmRead(void *buf, uint nbytes)
int GetNumReadyBytes(void) override
unsigned int uint
Definition: freesurround.h:24