gr-baz Package
audio_portaudio_source.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2006-2011 Free Software Foundation, Inc.
4
*
5
* This file is part of GNU Radio
6
*
7
* GNU Radio is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3, or (at your option)
10
* any later version.
11
*
12
* GNU Radio is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with GNU Radio; see the file COPYING. If not, write to
19
* the Free Software Foundation, Inc., 51 Franklin Street,
20
* Boston, MA 02110-1301, USA.
21
*/
22
#ifndef INCLUDED_AUDIO_PORTAUDIO_SOURCE_H
23
#define INCLUDED_AUDIO_PORTAUDIO_SOURCE_H
24
25
#include <
gr_audio_source.h
>
26
#include <
gr_buffer.h
>
27
#include <
gruel/thread.h
>
28
#include <string>
29
#include <portaudio.h>
30
#include <stdexcept>
31
32
PaStreamCallback
portaudio_source_callback
;
33
34
35
/*!
36
* \brief Audio source using PORTAUDIO
37
* \ingroup audio_blk
38
*
39
* Input samples must be in the range [-1,1].
40
*/
41
class
audio_portaudio_source
:
public
audio_source
{
42
43
friend
PaStreamCallback
portaudio_source_callback
;
44
45
46
unsigned
int
d_sampling_rate;
47
std::string d_device_name;
48
bool
d_ok_to_block;
49
bool
d_verbose;
50
51
unsigned
int
d_portaudio_buffer_size_frames;
// number of frames in a portaudio buffer
52
53
PaStream *d_stream;
54
PaStreamParameters d_input_parameters;
55
56
gr_buffer_sptr
d_writer;
// buffer used between work and callback
57
gr_buffer_reader_sptr
d_reader;
58
59
gruel::mutex
d_ringbuffer_mutex;
60
gruel::condition_variable
d_ringbuffer_cond;
61
bool
d_ringbuffer_ready;
62
63
// random stats
64
int
d_noverruns;
// count of overruns
65
66
void
output_error_msg (
const
char
*msg,
int
err);
67
void
bail (
const
char
*msg,
int
err)
throw
(std::runtime_error);
68
void
create_ringbuffer();
69
70
71
public
:
72
audio_portaudio_source
(
int
sampling_rate,
const
std::string device_name,
73
bool
ok_to_block);
74
75
~audio_portaudio_source
();
76
77
bool
check_topology
(
int
ninputs,
int
noutputs);
78
79
int
work
(
int
ninput_items,
80
gr_vector_const_void_star
&input_items,
81
gr_vector_void_star
&output_items);
82
};
83
84
#endif
/* INCLUDED_AUDIO_PORTAUDIO_SOURCE_H */
gnuradio
gr-audio
lib
portaudio
audio_portaudio_source.h
Generated by
1.8.1.1