Skip to content

Commit 1c58318

Browse files
committed
incorporated some of the pull request comments
1 parent d147f11 commit 1c58318

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

audiostream/src/ni/media/audio/source/gstreamer_file_source.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,9 @@
2525
#include <ni/media/audio/iotools.h>
2626
#include <ni/media/iostreams/positioning.h>
2727

28-
#include <boost/algorithm/clamp.hpp>
29-
#include <boost/algorithm/cxx11/any_of.hpp>
30-
#include <boost/format.hpp>
3128
#include <boost/make_unique.hpp>
3229

3330
#include <algorithm>
34-
#include <codecvt>
35-
#include <functional>
36-
#include <iostream>
37-
#include <locale>
38-
3931
#include <gst/app/gstappsink.h>
4032

4133
namespace detail
@@ -196,15 +188,21 @@ void gstreamer_file_source::fill_format_info( GstStructure*
196188
m_info.lossless( false );
197189

198190
gint64 num_frames = 0;
199-
gst_element_query_duration( m_pipeline.get(), GST_FORMAT_DEFAULT, &num_frames );
191+
if ( !gst_element_query_duration( m_pipeline.get(), GST_FORMAT_DEFAULT, &num_frames ) )
192+
throw std::runtime_error( "gstreamer_file_source: could not query duration from gstreamer" );
193+
200194
m_info.num_frames( num_frames );
201195

202196
int sample_rate = 0;
203-
gst_structure_get_int( caps_struct, "rate", &sample_rate );
197+
if ( !gst_structure_get_int( caps_struct, "rate", &sample_rate ) )
198+
throw std::runtime_error( "gstreamer_file_source: could not query sample rate from gstreamer" );
199+
204200
m_info.sample_rate( sample_rate );
205201

206202
int num_channels = 0;
207-
gst_structure_get_int( caps_struct, "channels", &num_channels );
203+
if ( !gst_structure_get_int( caps_struct, "channels", &num_channels ) )
204+
throw std::runtime_error( "gstreamer_file_source: could not query number of channels from gstreamer" );
205+
208206
m_info.num_channels( num_channels );
209207

210208
m_info.format( create_runtime_format( caps_struct ) );
@@ -214,11 +212,14 @@ void gstreamer_file_source::fill_format_info( GstStructure*
214212

215213
pcm::runtime_format gstreamer_file_source::create_runtime_format( GstStructure* caps_struct )
216214
{
217-
const gchar* format = gst_structure_get_string( caps_struct, "format" );
218-
pcm::number_type number_type = gst_format_char_to_number_type( format[0] );
219-
auto srcDepth = std::atol( format + 1 );
220-
auto endian = ( strcmp( format, "BE" ) == 0 ) ? pcm::big_endian : pcm::little_endian;
221-
return pcm::runtime_format( number_type, srcDepth, endian );
215+
if ( auto format = gst_structure_get_string( caps_struct, "format" ) )
216+
{
217+
pcm::number_type number_type = gst_format_char_to_number_type( format[0] );
218+
auto srcDepth = std::atol( format + 1 );
219+
auto endian = ( strcmp( format, "BE" ) == 0 ) ? pcm::big_endian : pcm::little_endian;
220+
return pcm::runtime_format( number_type, srcDepth, endian );
221+
}
222+
throw std::runtime_error( "gstreamer_file_source: could not get runtime format from gstreamer caps" );
222223
}
223224

224225
//----------------------------------------------------------------------------------------------------------------------

audiostream/src/ni/media/audio/source/gstreamer_file_source.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
#pragma once
2424

25-
#include <boost/icl/interval_set.hpp>
26-
#include <boost/icl/right_open_interval.hpp>
2725
#include <boost/iostreams/categories.hpp>
2826
#include <boost/iostreams/positioning.hpp>
2927

@@ -43,12 +41,6 @@ class gstreamer_file_source
4341

4442
using offset_type = boost::iostreams::stream_offset;
4543

46-
using FrameRange = boost::icl::right_open_interval<offset_type>;
47-
using FrameRangeSet = boost::icl::interval_set<FrameRange::domain_type, std::less, FrameRange>;
48-
49-
template <typename MfType>
50-
using MfTypePtr = std::unique_ptr<MfType, std::function<void( MfType* )>>;
51-
5244
//----------------------------------------------------------------------------------------------------------------------
5345

5446
explicit gstreamer_file_source( const std::string& path,

0 commit comments

Comments
 (0)