提交 f4c1039a authored 作者: Anthony Minessale's avatar Anthony Minessale

add prototype for local_stream test it and let me know what you think

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5461 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 ed0076eb
...@@ -38,6 +38,7 @@ event_handlers/mod_event_socket ...@@ -38,6 +38,7 @@ event_handlers/mod_event_socket
formats/mod_native_file formats/mod_native_file
formats/mod_sndfile formats/mod_sndfile
#formats/mod_shout #formats/mod_shout
#formats/mod_local_stream
#languages/mod_perl #languages/mod_perl
#languages/mod_python #languages/mod_python
#languages/mod_spidermonkey #languages/mod_spidermonkey
......
...@@ -125,6 +125,7 @@ ...@@ -125,6 +125,7 @@
<!-- Say --> <!-- Say -->
<!-- none for mod_say_en --> <!-- none for mod_say_en -->
<!--#include "mod_cdr.conf.xml"--> <!--#include "mod_cdr.conf.xml"-->
<!--#include "mod_local_stream.conf.xml"-->
</section> </section>
<section name="dialplan" description="Regex/XML Dialplan"> <section name="dialplan" description="Regex/XML Dialplan">
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
<load module="mod_native_file"/> <load module="mod_native_file"/>
<!--For icecast/mp3 streams/files--> <!--For icecast/mp3 streams/files-->
<!--<load module="mod_shout"/>--> <!--<load module="mod_shout"/>-->
<!--For local streams (play all the files in a directory)-->
<!--<load module="mod_local_stream"/>-->
<!-- Timers --> <!-- Timers -->
<load module="mod_softtimer"/> <load module="mod_softtimer"/>
......
MODNAME=mod_native_file
include ../../../../build/modmake.rules
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="mod_local_stream"
ProjectGUID="{9254C4B0-6F60-42B6-BB3A-36D63FC001C7}"
RootNamespace="mod_local_stream"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\win32\liblocal_stream\&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;..\..\..\..\libs\liblocal_stream\Win32\$(OutDir)&quot;;&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/mod_local_stream.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\win32\liblocal_stream\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;..\..\..\..\libs\liblocal_stream\Win32\$(OutDir)&quot;;&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="1"
ImportLibrary="$(OutDir)/mod_local_stream.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\mod_local_stream.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
...@@ -194,12 +194,13 @@ switch_status_t mod_mono_load_modules(const char *module_dir) ...@@ -194,12 +194,13 @@ switch_status_t mod_mono_load_modules(const char *module_dir)
iter = NULL; iter = NULL;
mono_plugin *plugin = NULL; mono_plugin *plugin = NULL;
const char *fname = NULL; const char *fname = NULL;
char buf[512] = "";
if (switch_dir_open(&module_dir_handle, module_dir, mono_pool) != SWITCH_STATUS_SUCCESS) if (switch_dir_open(&module_dir_handle, module_dir, mono_pool) != SWITCH_STATUS_SUCCESS)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not open directory: %s\n", module_dir); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not open directory: %s\n", module_dir);
/* Read the modules directory */ /* Read the modules directory */
while ((fname = switch_dir_next_file(module_dir_handle))) { while ((fname = switch_dir_next_file(module_dir_handle, buf, sizeof(buf)))) {
assembly = (MonoAssembly *) switch_core_alloc(mono_pool, sizeof(assembly)); assembly = (MonoAssembly *) switch_core_alloc(mono_pool, sizeof(assembly));
image = (MonoImage *) switch_core_alloc(mono_pool, sizeof(image)); image = (MonoImage *) switch_core_alloc(mono_pool, sizeof(image));
......
...@@ -43,6 +43,7 @@ static switch_memory_pool_t *module_pool = NULL; ...@@ -43,6 +43,7 @@ static switch_memory_pool_t *module_pool = NULL;
static struct { static struct {
int32_t RUNNING; int32_t RUNNING;
int32_t STARTED;
switch_mutex_t *mutex; switch_mutex_t *mutex;
} globals; } globals;
...@@ -76,6 +77,14 @@ static timer_matrix_t TIMER_MATRIX[MAX_ELEMENTS + 1]; ...@@ -76,6 +77,14 @@ static timer_matrix_t TIMER_MATRIX[MAX_ELEMENTS + 1];
static inline switch_status_t timer_init(switch_timer_t *timer) static inline switch_status_t timer_init(switch_timer_t *timer)
{ {
timer_private_t *private_info; timer_private_t *private_info;
int sanity = 0;
while(globals.STARTED == 0) {
switch_yield(100000);
if (++sanity == 10) {
break;
}
}
if (globals.RUNNING != 1 || !globals.mutex) { if (globals.RUNNING != 1 || !globals.mutex) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
...@@ -220,9 +229,9 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_softtimer_runtime) ...@@ -220,9 +229,9 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_softtimer_runtime)
memset(&globals, 0, sizeof(globals)); memset(&globals, 0, sizeof(globals));
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool); switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
globals.RUNNING = 1; globals.STARTED = globals.RUNNING = 1;
while (globals.RUNNING == 1) { while (globals.RUNNING == 1) {
reference += STEP_MIC; reference += STEP_MIC;
......
...@@ -391,26 +391,46 @@ struct switch_dir { ...@@ -391,26 +391,46 @@ struct switch_dir {
SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool) SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool)
{ {
switch_status_t status; switch_status_t status;
switch_dir_t *dir = switch_core_alloc(pool, sizeof(switch_dir_t)); switch_dir_t *dir = malloc(sizeof(*dir));
status = apr_dir_open(&(dir->dir_handle), dirname, pool);
*new_dir = dir; memset(dir, 0, sizeof(*dir));
if ((status = apr_dir_open(&(dir->dir_handle), dirname, pool)) == APR_SUCCESS) {
*new_dir = dir;
} else {
free(dir);
*new_dir = NULL;
}
return status; return status;
} }
SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir) SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir)
{ {
return apr_dir_close(thedir->dir_handle); return apr_dir_close(thedir->dir_handle);
free(thedir);
} }
SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len) SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len)
{ {
const char *fname = NULL; const char *fname = NULL;
apr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME; apr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME;
const char *name;
while (apr_dir_read(&(thedir->finfo), finfo_flags, thedir->dir_handle) == SWITCH_STATUS_SUCCESS) { while (apr_dir_read(&(thedir->finfo), finfo_flags, thedir->dir_handle) == SWITCH_STATUS_SUCCESS) {
if (thedir->finfo.filetype != APR_REG) if (thedir->finfo.filetype != APR_REG) {
continue; continue;
if (thedir->finfo.fname) { }
switch_copy_string(buf, thedir->finfo.fname, len); if (!(name = thedir->finfo.fname)) {
name = thedir->finfo.name;
}
if (!name) {
continue;
}
if (name) {
switch_copy_string(buf, name, len);
fname = buf; fname = buf;
} else { } else {
continue; continue;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论