summaryrefslogtreecommitdiff
path: root/gr-audio/include/gnuradio/audio/osx_impl.h
blob: 891685a33542a54421839f198ea21ee3051bb2ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* -*- c++ -*- */
/*
 * Copyright 2006, 2013-2014 Free Software Foundation, Inc.
 *
 * This file is part of GNU Radio.
 *
 * GNU Radio is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * GNU Radio is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNU Radio; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */

#ifndef INCLUDED_AUDIO_OSX_IMPL_H
#define INCLUDED_AUDIO_OSX_IMPL_H

#include <gnuradio/audio/api.h>

#include <iostream>
#include <vector>

#include <string.h>

#include <AudioToolbox/AudioToolbox.h>
#include <AudioUnit/AudioUnit.h>

namespace gr {
namespace audio {
namespace osx {

// Check the version of MacOSX being used
#ifdef __APPLE_CC__
#include <AvailabilityMacros.h>
#ifndef MAC_OS_X_VERSION_10_6
#define MAC_OS_X_VERSION_10_6 1060
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
#define GR_USE_OLD_AUDIO_UNIT
#endif
#endif

// helper function to print an ASBD

extern std::ostream& GR_AUDIO_API
operator<<
(std::ostream& s,
 const AudioStreamBasicDescription& asbd);

// returns the number of channels for the provided AudioDeviceID,
// input and/or output depending on if the pointer is valid.

extern void GR_AUDIO_API
get_num_channels_for_audio_device_id
(AudioDeviceID ad_id,
 UInt32* n_input,
 UInt32* n_output);

// search all known audio devices, input or output, for all that
// match the provided device_name string (in part or in whole).
// Returns a vector of all matching IDs, and another of all
// matching names.  If the device name is empty, then match all
// input or output devices.

extern void GR_AUDIO_API
find_audio_devices
(const std::string& device_name,
 bool is_input,
 std::vector < AudioDeviceID >* all_ad_ids,
 std::vector < std::string >* all_names);

} /* namespace osx */
} /* namespace audio */
} /* namespace gr */

#endif /* INCLUDED_AUDIO_OSX_IMPL_H */