AudioDecoder class is responsible for last stage in Software Define Radio process. It allows sdrdab to play and/or record audio to file. It is not simple to synchronize input data with output effect. A steady stream of data is complicated by playing sounds. To simplify this process we use GStreamer-1.0 library, as well as some plugins for this library.
GStreamer is a pipeline-based multimedia framework written in the C programming language with the type system based on
GObject. GStreamer allows a programmer to create a variety of media-handling components, including simple audio playback, audio and video playback, recording, streaming and editing. It is multiplatform library, so it can be used on almost every operation system.
GStreamer uses a plug-in architecture which makes the most of GStreamer's functionality implemented as shared libraries. GStreamer's base functionality contains functions for registering and loading plug-ins and for providing the fundamentals of all classes in the form of base classes. Plug-in libraries get dynamically loaded to support a wide spectrum of codecs, container formats, input/output drivers and effects.
In our case player is core element of
AudioDecoder work. It is important to synchronize and properly send output data to speakers.
Player is used to manage GStreamer pipeline. In this class we separate all tags and decide which tag should be saved and which parser function should be called.
Null_sink is responsible for queuing elements for GStreamer and sinking it.
Ring_src is used to read data from buffer. It introduces internal ring buffer and threshold for audio time-stretching.
AudioDecoder class we use resampling method. It is mandatory in order to keep all data in one piece. Without it, output data would not sound like radio. If data falls apart, our player will not work properly. If we lose synchronization, we can easily synchronize it using resampling.
Altogether for properly working
AudioDecoder class we need to pass to constructor three parameters: threshold, length of internal blocking ring buffer and type of
Player. This parameters are necessary to avoid losing any data in player. Ring buffer is core component of this class, because it queues data and synchronizes it. We can clearly decide when we want to start and stop streaming audio and when we want to record audio to file.