Commit 3ed4adba authored by Ken Self's avatar Ken Self

Fix choppy audio on live play - caching enabled properly

Discard samples before demux is ready
Timeout if no samples received
Header file tidy up
parent f9c2070c
......@@ -23,14 +23,6 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vlc/vlc.h>
#include <vlc_input.h>
#include <vlc_access.h>
#include "bda.h"
/*****************************************************************************
......@@ -246,14 +238,14 @@ static int Open( vlc_object_t *p_this )
access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys;
const char* psz_module = "dvb";
const int i_param_count = 8;
const int i_param_count = 9;
const char* psz_param[] = { "frequency", "bandwidth",
"srate", "azimuth", "elevation", "longitude", "polarisation",
"modulation" };
"modulation", "caching" };
const int i_type[] = { VLC_VAR_INTEGER, VLC_VAR_INTEGER,
VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER,
VLC_VAR_STRING, VLC_VAR_INTEGER };
VLC_VAR_STRING, VLC_VAR_INTEGER, VLC_VAR_INTEGER };
char psz_full_name[128];
int i_ret;
......@@ -506,8 +498,7 @@ static block_t *Block( access_t *p_access )
return NULL;
p_block = block_New( p_access, l_buffer_len );
if( dvb_ReadBuffer( p_access, &l_buffer_len, p_block->p_buffer )
< 0 )
if( dvb_ReadBuffer( p_access, &l_buffer_len, p_block->p_buffer ) < 0 )
return NULL;
return p_block;
......
......@@ -23,6 +23,14 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vlc/vlc.h>
#include <vlc_input.h>
#include <vlc_access.h>
#ifndef _MSC_VER
# include <wtypes.h>
# include <unknwn.h>
......@@ -69,4 +77,3 @@ struct access_sys_t
vlc_cond_t wait;
BDAGraph *p_bda_module;
};
......@@ -489,3 +489,51 @@ public:
virtual HRESULT __stdcall get_EnumTuningSpaces(
IEnumTuningSpaces** p_p_enum )=0;
};
extern "C" {
extern const GUID CLSID_ATSCLocator;
extern const GUID CLSID_ATSCNetworkProvider;
extern const GUID CLSID_DVBCLocator;
extern const GUID CLSID_DVBCNetworkProvider;
extern const GUID CLSID_DVBSLocator;
extern const GUID CLSID_DVBSNetworkProvider;
extern const GUID CLSID_DVBSTuningSpace;
extern const GUID CLSID_DVBTLocator;
extern const GUID CLSID_DVBTNetworkProvider;
extern const GUID CLSID_FilterGraph;
extern const GUID CLSID_InfTee;
extern const GUID CLSID_MPEG2Demultiplexer;
extern const GUID CLSID_NullRenderer;
extern const GUID CLSID_SampleGrabber;
extern const GUID CLSID_SystemDeviceEnum;
extern const GUID CLSID_SystemTuningSpaces;
extern const GUID IID_IATSCChannelTuneRequest;
extern const GUID IID_IATSCLocator;
extern const GUID IID_IBaseFilter;
extern const GUID IID_ICreateDevEnum;
extern const GUID IID_IDVBTLocator;
extern const GUID IID_IDVBCLocator;
extern const GUID IID_IDVBSLocator;
extern const GUID IID_IDVBSTuningSpace;
extern const GUID IID_IDVBTuneRequest;
extern const GUID IID_IGraphBuilder;
extern const GUID IID_IMediaControl;
extern const GUID IID_IMpeg2Demultiplexer;
extern const GUID IID_ISampleGrabber;
extern const GUID IID_IScanningTuner;
extern const GUID IID_ITuner;
extern const GUID IID_ITuningSpace;
extern const GUID IID_ITuningSpaceContainer;
extern const GUID MEDIATYPE_MPEG2_SECTIONS;
extern const GUID MEDIASUBTYPE_None;
extern const GUID FORMAT_None;
const GUID KSCATEGORY_BDA_TRANSPORT_INFORMATION =
{0xa2e3074f,0x6c3d,0x11d3,{0xb6,0x53,0x00,0xc0,0x4f,0x79,0x49,0x8e}};
const GUID KSCATEGORY_BDA_RECEIVER_COMPONENT =
{0xFD0A5AF4,0xB41D,0x11d2,{0x9c,0x95,0x00,0xc0,0x4f,0x79,0x71,0xe0}};
const GUID KSCATEGORY_BDA_NETWORK_TUNER =
{0x71985f48,0x1ca1,0x11d3,{0x9c,0xc8,0x00,0xc0,0x4f,0x79,0x71,0xe0}};
};
......@@ -23,105 +23,8 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vlc/vlc.h>
#include <vlc_input.h>
#include <vlc_access.h>
/* Needed to call CoInitializeEx */
#define _WIN32_DCOM
/* Work-around a bug in w32api-2.5 */
/*#ifndef _MSC_VER
# define QACONTAINERFLAGS QACONTAINERFLAGS_SOMETHINGELSE
#endif */
#include "bdagraph.h"
const GUID CLSID_ATSCLocator =
{0x8872FF1B,0x98FA,0x4D7A,{0x8D,0x93,0xC9,0xF1,0x05,0x5F,0x85,0xBB}};
const GUID CLSID_ATSCNetworkProvider =
{0x0dad2fdd,0x5fd7,0x11d3,{0x8f,0x50,0x00,0xc0,0x4f,0x79,0x71,0xe2}};
const GUID CLSID_DVBCLocator =
{0xc531d9fd,0x9685,0x4028,{0x8b,0x68,0x6e,0x12,0x32,0x07,0x9f,0x1e}};
const GUID CLSID_DVBCNetworkProvider =
{0xdc0c0fe7,0x0485,0x4266,{0xb9,0x3f,0x68,0xfb,0xf8,0xe,0xd8,0x34}};
const GUID CLSID_DVBSLocator =
{0x1df7d126,0x4050,0x47f0,{0xa7,0xcf,0x4c,0x4c,0xa9,0x24,0x13,0x33}};
const GUID CLSID_DVBSNetworkProvider =
{0xfa4b375a,0x45b4,0x4d45,{0x84,0x40,0x26,0x39,0x57,0xb1,0x16,0x23}};
const GUID CLSID_DVBSTuningSpace =
{0xb64016f3,0xc9a2,0x4066,{0x96,0xf0,0xbd,0x95,0x63,0x31,0x47,0x26}};
const GUID CLSID_DVBTLocator =
{0x9cd64701,0xbdf3,0x4d14,{0x8e,0x03,0xf1,0x29,0x83,0xd8,0x66,0x64}};
const GUID CLSID_DVBTNetworkProvider =
{0x216c62df,0x6d7f,0x4e9a,{0x85,0x71,0x05,0xf1,0x4e,0xdb,0x76,0x6a}};
const GUID CLSID_FilterGraph =
{0xe436ebb3,0x524f,0x11ce,{0x9f,0x53,0x00,0x20,0xaf,0x0b,0xa7,0x70}};
const GUID CLSID_InfTee =
{0xf8388a40,0xd5bb,0x11d0,{0xbe,0x5a,0x00,0x80,0xc7,0x06,0x56,0x8e}};
const GUID CLSID_MPEG2Demultiplexer =
{0xafb6c280,0x2c41,0x11d3,{0x8a,0x60,0x00,0x00,0xf8,0x1e,0x0e,0x4a}};
const GUID CLSID_NullRenderer =
{0xc1f400a4,0x3f08,0x11d3,{0x9f,0x0b,0x00,0x60,0x08,0x03,0x9e,0x37}};
const GUID CLSID_SampleGrabber =
{0xc1f400a0,0x3f08,0x11d3,{0x9f,0x0b,0x00,0x60,0x08,0x03,0x9e,0x37}};
const GUID CLSID_SystemDeviceEnum =
{0x62be5d10,0x60eb,0x11d0,{0xbd,0x3b,0x00,0xa0,0xc9,0x11,0xce,0x86}};
const GUID CLSID_SystemTuningSpaces =
{0xd02aac50,0x027e,0x11d3,{0x9d,0x8e,0x00,0xc0,0x4f,0x72,0xd9,0x80}};
const GUID IID_IATSCChannelTuneRequest =
{0x0369B4E1,0x45B6,0x11d3,{0xB6,0x50,0x00,0xC0,0x4F,0x79,0x49,0x8E}};
const GUID IID_IATSCLocator =
{0xbf8d986f,0x8c2b,0x4131,{0x94,0xd7,0x4d,0x3d,0x9f,0xcc,0x21,0xef}};
const GUID IID_IBaseFilter =
{0x56a86895,0x0ad4,0x11ce,{0xb0,0x3a,0x00,0x20,0xaf,0x0b,0xa7,0x70}};
const GUID IID_ICreateDevEnum =
{0x29840822,0x5b84,0x11d0,{0xbd,0x3b,0x00,0xa0,0xc9,0x11,0xce,0x86}};
const GUID IID_IDVBTLocator =
{0x8664da16,0xdda2,0x42ac,{0x92,0x6a,0xc1,0x8f,0x91,0x27,0xc3,0x02}};
const GUID IID_IDVBCLocator =
{0x6e42f36e,0x1dd2,0x43c4,{0x9f,0x78,0x69,0xd2,0x5a,0xe3,0x90,0x34}};
const GUID IID_IDVBSLocator =
{0x3d7c353c,0x0d04,0x45f1,{0xa7,0x42,0xf9,0x7c,0xc1,0x18,0x8d,0xc8}};
const GUID IID_IDVBSTuningSpace =
{0xcdf7be60,0xd954,0x42fd,{0xa9,0x72,0x78,0x97,0x19,0x58,0xe4,0x70}};
const GUID IID_IDVBTuneRequest =
{0x0D6F567E,0xA636,0x42bb,{0x83,0xBA,0xCE,0x4C,0x17,0x04,0xAF,0xA2}};
const GUID IID_IGraphBuilder =
{0x56a868a9,0x0ad4,0x11ce,{0xb0,0x3a,0x00,0x20,0xaf,0x0b,0xa7,0x70}};
const GUID IID_IMediaControl =
{0x56a868b1,0x0ad4,0x11ce,{0xb0,0x3a,0x00,0x20,0xaf,0x0b,0xa7,0x70}};
const GUID IID_IMpeg2Demultiplexer =
{0x436eee9c,0x264f,0x4242,{0x90,0xe1,0x4e,0x33,0x0c,0x10,0x75,0x12}};
const GUID IID_ISampleGrabber =
{0x6b652fff,0x11fe,0x4fce,{0x92,0xad,0x02,0x66,0xb5,0xd7,0xc7,0x8f}};
const GUID IID_IScanningTuner =
{0x1dfd0a5c,0x0284,0x11d3,{0x9d,0x8e,0x00,0xc0,0x4f,0x72,0xd9,0x80}};
const GUID IID_ITuner =
{0x28C52640,0x018A,0x11d3,{0x9D,0x8E,0x00,0xC0,0x4F,0x72,0xD9,0x80}};
const GUID IID_ITuningSpace =
{0x061c6e30,0xe622,0x11d2,{0x94,0x93,0x00,0xc0,0x4f,0x72,0xd9,0x80}};
const GUID IID_ITuningSpaceContainer =
{0x5B692E84,0xE2F1,0x11d2,{0x94,0x93,0x00,0xC0,0x4F,0x72,0xD9,0x80}};
const GUID KSCATEGORY_BDA_TRANSPORT_INFORMATION =
{0xa2e3074f,0x6c3d,0x11d3,{0xb6,0x53,0x00,0xc0,0x4f,0x79,0x49,0x8e}};
const GUID KSCATEGORY_BDA_RECEIVER_COMPONENT =
{0xFD0A5AF4,0xB41D,0x11d2,{0x9c,0x95,0x00,0xc0,0x4f,0x79,0x71,0xe0}};
const GUID KSCATEGORY_BDA_NETWORK_TUNER =
{0x71985f48,0x1ca1,0x11d3,{0x9c,0xc8,0x00,0xc0,0x4f,0x79,0x71,0xe0}};
const GUID MEDIATYPE_MPEG2_SECTIONS =
{0x455f176c,0x4b06,0x47ce,{0x9a,0xef,0x8c,0xae,0xf7,0x3d,0xf7,0xb5}};
const GUID MEDIASUBTYPE_None =
{0xe436eb8e,0x524f,0x11ce,{0x9f,0x53,0x00,0x20,0xaf,0x0b,0xa7,0x70}};
const GUID FORMAT_None =
{0x0f6417d6,0xc318,0x11d0,{0xa4,0x3f,0x00,0xa0,0xc9,0x22,0x31,0x96}};
/****************************************************************************
* Interfaces for calls from C
****************************************************************************/
......@@ -167,7 +70,6 @@ extern "C" {
return p_access->p_sys->p_bda_module->ReadBuffer( l_buffer_len,
p_buff );
};
};
/*****************************************************************************
......@@ -179,6 +81,7 @@ BDAGraph::BDAGraph( access_t* p_this ):
l_tuner_used(-1),
d_graph_register( 0 )
{
b_ready = FALSE;
p_tuning_space = NULL;
p_tune_request = NULL;
p_media_control = NULL;
......@@ -981,7 +884,7 @@ HRESULT BDAGraph::FindFilter( REFCLSID clsid, long* i_moniker_used,
p_moniker_enum(NULL),
p_filter(NULL),
p_property_bag(NULL)
{ ::VariantInit(&var_bstr); };
{ ::VariantInit(&var_bstr); };
~localComPtr()
{
if( p_moniker )
......@@ -1000,16 +903,16 @@ HRESULT BDAGraph::FindFilter( REFCLSID clsid, long* i_moniker_used,
{
hr = ::CoCreateInstance( CLSID_SystemDeviceEnum, 0, CLSCTX_INPROC,
IID_ICreateDevEnum, (void**)&p_system_dev_enum );
if( FAILED( hr ) )
{
msg_Warn( p_access, "FindFilter: "\
"Cannot CoCreate SystemDeviceEnum: hr=0x%8lx", hr );
return hr;
if( FAILED( hr ) )
{
msg_Warn( p_access, "FindFilter: "\
"Cannot CoCreate SystemDeviceEnum: hr=0x%8lx", hr );
return hr;
}
}
hr = p_system_dev_enum->CreateClassEnumerator( clsid,
&l.p_moniker_enum, 0 );
&l.p_moniker_enum, 0 );
if( hr != S_OK )
{
msg_Warn( p_access, "FindFilter: "\
......@@ -1261,15 +1164,23 @@ HRESULT BDAGraph::Start()
*****************************************************************************/
long BDAGraph::GetBufferSize()
{
while( queue_sample.empty() )
Sleep( 50 );
long l_buffer_size = 0;
long l_queue_size;
b_ready = true;
for( int i_timer = 0; queue_sample.empty() && i_timer < 200; i_timer++ )
Sleep( 10 );
l_queue_size = queue_sample.size();
if( l_queue_size <= 0 )
{
msg_Warn( p_access, "BDA GetBufferSize: Timed Out waiting for sample" );
return -1;
}
/* Establish the length of the queue as it grows quickly. If the queue
* size is checked dynamically there is a risk of not exiting the loop */
l_queue_size = queue_sample.size();
for( long l_queue_count=0; l_queue_count < l_queue_size; l_queue_count++ )
{
l_buffer_size += queue_sample.front()->GetActualDataLength();
......@@ -1311,8 +1222,15 @@ long BDAGraph::ReadBuffer( long* pl_buffer_len, BYTE* p_buffer )
******************************************************************************/
STDMETHODIMP BDAGraph::SampleCB( double d_time, IMediaSample *p_sample )
{
p_sample->AddRef();
queue_sample.push( p_sample );
if( b_ready )
{
p_sample->AddRef();
queue_sample.push( p_sample );
}
else
{
msg_Warn( p_access, "BDA SampleCB: Not ready - dropped sample" );
}
return S_OK;
}
......@@ -1426,17 +1344,28 @@ HRESULT BDAGraph::Register()
wsprintfW( psz_w_graph_name, L"VLC BDA Graph %08x Pid %08x",
(DWORD_PTR) p_filter_graph, ::GetCurrentProcessId() );
hr = CreateItemMoniker( L"!", psz_w_graph_name, &l.p_moniker );
if( SUCCEEDED( hr ) )
hr = l.p_ro_table->Register( ROTFLAGS_REGISTRATIONKEEPSALIVE,
p_filter_graph, l.p_moniker, &d_graph_register );
if( FAILED( hr ) )
{
msg_Warn( p_access, "Register: Cannot Create Moniker: hr=0x%8lx", hr );
return hr;
}
hr = l.p_ro_table->Register( ROTFLAGS_REGISTRATIONKEEPSALIVE,
p_filter_graph, l.p_moniker, &d_graph_register );
if( FAILED( hr ) )
{
msg_Warn( p_access, "Register: Cannot Register Graph: hr=0x%8lx", hr );
return hr;
}
msg_Dbg( p_access, "Register: registered Graph: %S", psz_w_graph_name );
return hr;
}
void BDAGraph::Deregister()
{
HRESULT hr;
IRunningObjectTable* p_ro_table;
if( SUCCEEDED( ::GetRunningObjectTable( 0, &p_ro_table ) ) )
hr = ::GetRunningObjectTable( 0, &p_ro_table );
if( SUCCEEDED( hr ) )
p_ro_table->Revoke( d_graph_register );
d_graph_register = 0;
p_ro_table->Release();
......
......@@ -40,7 +40,11 @@ using namespace std;
# undef _X86_
# define _I64_MAX LONG_LONG_MAX
# define LONGLONG long long
/* Work-around a bug in w32api-2.5 */
/* # define QACONTAINERFLAGS QACONTAINERFLAGS_SOMETHINGELSE */
#endif
/* Needed to call CoInitializeEx */
#define _WIN32_DCOM
#include <dshow.h>
#include <comcat.h>
......@@ -78,6 +82,7 @@ private:
queue<IMediaSample*> queue_sample;
queue<IMediaSample*> queue_buffer;
BOOL b_ready;
IMediaControl* p_media_control;
IGraphBuilder* p_filter_graph;
......@@ -105,4 +110,3 @@ private:
HRESULT Register( );
void Deregister( );
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment