Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
backend_dispatcher.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Roc Streaming authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_sndio/backend_dispatcher.h
10 //! @brief Backend dispatcher.
11 
12 #ifndef ROC_SNDIO_BACKEND_DISPATCHER_H_
13 #define ROC_SNDIO_BACKEND_DISPATCHER_H_
14 
15 #include "roc_address/io_uri.h"
16 #include "roc_audio/sample_spec.h"
17 #include "roc_core/attributes.h"
18 #include "roc_core/iarena.h"
19 #include "roc_core/noncopyable.h"
20 #include "roc_core/singleton.h"
21 #include "roc_core/string_list.h"
22 #include "roc_sndio/device_type.h"
23 #include "roc_sndio/driver.h"
24 #include "roc_sndio/ibackend.h"
25 #include "roc_sndio/isink.h"
26 #include "roc_sndio/isource.h"
27 
28 namespace roc {
29 namespace sndio {
30 
31 //! Backend dispatcher.
33 public:
34  //! Initialize.
36 
37  //! Create and open default sink.
38  ISink* open_default_sink(const Config& config);
39 
40  //! Create and open default source.
42 
43  //! Create and open a sink.
44  ISink*
45  open_sink(const address::IoUri& uri, const char* force_format, const Config& config);
46 
47  //! Create and open a source.
49  const char* force_format,
50  const Config& config);
51 
52  //! Get all supported URI schemes.
54 
55  //! Get all supported file formats.
57 
58 private:
59  IDevice* open_default_device_(DeviceType device_type, const Config& config);
60 
61  IDevice* open_device_(DeviceType device_type,
62  DriverType driver_type,
63  const char* driver_name,
64  const char* path,
65  const Config& config);
66 
67  core::IArena& arena_;
68 };
69 
70 } // namespace sndio
71 } // namespace roc
72 
73 #endif // ROC_SNDIO_BACKEND_DISPATCHER_H_
Compiler attributes.
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition: attributes.h:31
Audio file or device URI.
Definition: io_uri.h:25
Memory arena interface.
Definition: iarena.h:23
Base class for non-copyable objects.
Definition: noncopyable.h:23
Dynamic list of strings.
Definition: string_list.h:36
ISink * open_default_sink(const Config &config)
Create and open default sink.
BackendDispatcher(core::IArena &arena)
Initialize.
ISource * open_default_source(const Config &config)
Create and open default source.
ROC_ATTR_NODISCARD bool get_supported_schemes(core::StringList &result)
Get all supported URI schemes.
ROC_ATTR_NODISCARD bool get_supported_formats(core::StringList &result)
Get all supported file formats.
ISink * open_sink(const address::IoUri &uri, const char *force_format, const Config &config)
Create and open a sink.
ISource * open_source(const address::IoUri &uri, const char *force_format, const Config &config)
Create and open a source.
Base interface for sinks and sources.
Definition: idevice.h:25
Sink interface.
Definition: isink.h:22
Source interface.
Definition: isource.h:23
Device type.
Driver types.
Memory arena interface.
Backend interface.
Audio file or device URI.
Sink interface.
Source interface.
DeviceType
Device type.
Definition: device_type.h:19
DriverType
Driver type.
Definition: driver.h:27
Root namespace.
Non-copyable object.
Sample specifications.
Singleton.
Dynamic list of strings.
Sink and source config.
Definition: config.h:29