sys/: Wait until the window is created before using it; guard unistd.h includes with HAVE_UNISTD_H. (#366523)

Original commit message from CVS:
Patch by: Sergey Scobich  <sergey dot scobich at gmail com>
* sys/directdraw/gstdirectdrawsink.c:
(gst_directdrawsink_window_thread),
(gst_directdrawsink_create_default_window):
* sys/directdraw/gstdirectdrawsink.h:
* sys/directsound/gstdirectsoundsink.c:
Wait until the window is created before using it; guard unistd.h
includes with HAVE_UNISTD_H. (#366523)
* win32/vs8/libgstdirectdraw.vcproj:
* win32/vs8/libgstdirectsound.vcproj:
Update project files.
This commit is contained in:
Sergey Scobich 2006-11-01 10:19:18 +00:00 committed by Tim-Philipp Müller
parent eead7e23b7
commit a0eefe10e2
5 changed files with 29 additions and 10 deletions

View file

@ -28,7 +28,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif
#include <string.h> #include <string.h>
GST_DEBUG_CATEGORY_STATIC (directdrawsink_debug); GST_DEBUG_CATEGORY_STATIC (directdrawsink_debug);
@ -1366,6 +1368,8 @@ gst_directdrawsink_window_thread (GstDirectDrawSink * ddrawsink)
if (ddrawsink->video_window == NULL) if (ddrawsink->video_window == NULL)
return FALSE; return FALSE;
ReleaseSemaphore (ddrawsink->window_created_signal, 1, NULL);
/*start message loop processing our default window messages */ /*start message loop processing our default window messages */
while (1) { while (1) {
MSG msg; MSG msg;
@ -1381,15 +1385,27 @@ gst_directdrawsink_window_thread (GstDirectDrawSink * ddrawsink)
static gboolean static gboolean
gst_directdrawsink_create_default_window (GstDirectDrawSink * ddrawsink) gst_directdrawsink_create_default_window (GstDirectDrawSink * ddrawsink)
{ {
ddrawsink->window_created_signal = CreateSemaphore (NULL, 0, 1, NULL);
if (ddrawsink->window_created_signal == NULL)
return FALSE;
ddrawsink->window_thread = g_thread_create ( ddrawsink->window_thread = g_thread_create (
(GThreadFunc) gst_directdrawsink_window_thread, ddrawsink, TRUE, NULL); (GThreadFunc) gst_directdrawsink_window_thread, ddrawsink, TRUE, NULL);
if (ddrawsink->window_thread == NULL) if (ddrawsink->window_thread == NULL)
return FALSE; goto failed;
/*TODO:wait for the window to be created with timeout */ /* wait maximum 10 seconds for windows creating */
if (WaitForSingleObject (ddrawsink->window_created_signal,
10000) != WAIT_OBJECT_0)
goto failed;
CloseHandle (ddrawsink->window_created_signal);
return TRUE; return TRUE;
failed:
CloseHandle (ddrawsink->window_created_signal);
return FALSE;
} }
static gboolean static gboolean

View file

@ -104,6 +104,7 @@ struct _GstDirectDrawSink
/*handle of the video window */ /*handle of the video window */
HWND video_window; HWND video_window;
HANDLE window_created_signal;
gboolean resize_window; gboolean resize_window;
/*video properties */ /*video properties */

View file

@ -27,7 +27,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif
#include <string.h> #include <string.h>
GST_DEBUG_CATEGORY_STATIC (directsoundsink_debug); GST_DEBUG_CATEGORY_STATIC (directsoundsink_debug);

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1251"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8,00" Version="8.00"
Name="libgstdirectdraw" Name="libgstdirectdraw"
ProjectGUID="{1594A623-5529-4B86-BD4A-694CF0BDB5C4}" ProjectGUID="{1594A623-5529-4B86-BD4A-694CF0BDB5C4}"
Keyword="Win32Proj" Keyword="Win32Proj"
@ -61,7 +61,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="ddraw.lib libgstvideo-0.10.lib libgstreamer-0.10.lib libgstbase-0.10.lib glib-2.0.lib gobject-2.0.lib" AdditionalDependencies="ddraw.lib libgstvideo-0.10.lib libgstreamer-0.10.lib libgstbase-0.10.lib glib-2.0.lib gobject-2.0.lib user32.lib gdi32.lib"
OutputFile="$(OutDir)/libgstdirectdraw.dll" OutputFile="$(OutDir)/libgstdirectdraw.dll"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="../../../gstreamer/win32/vs8/$(ConfigurationName);../../../gst-plugins-base/win32/vs8/$(ConfigurationName)" AdditionalLibraryDirectories="../../../gstreamer/win32/vs8/$(ConfigurationName);../../../gst-plugins-base/win32/vs8/$(ConfigurationName)"
@ -141,7 +141,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="ddraw.lib libgstvideo-0.10.lib libgstreamer-0.10.lib libgstbase-0.10.lib glib-2.0.lib gobject-2.0.lib" AdditionalDependencies="ddraw.lib libgstvideo-0.10.lib libgstreamer-0.10.lib libgstbase-0.10.lib glib-2.0.lib gobject-2.0.lib user32.lib gdi32.lib"
OutputFile="$(OutDir)/libgstdirectdraw.dll" OutputFile="$(OutDir)/libgstdirectdraw.dll"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="../../../gstreamer/win32/vs8/$(ConfigurationName);../../../gst-plugins-base/win32/vs8/$(ConfigurationName)" AdditionalLibraryDirectories="../../../gstreamer/win32/vs8/$(ConfigurationName);../../../gst-plugins-base/win32/vs8/$(ConfigurationName)"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1251"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8,00" Version="8.00"
Name="libgstdirectsound" Name="libgstdirectsound"
ProjectGUID="{566A2EB9-984C-4027-86DD-EDC7B390C679}" ProjectGUID="{566A2EB9-984C-4027-86DD-EDC7B390C679}"
Keyword="Win32Proj" Keyword="Win32Proj"
@ -61,7 +61,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="dsound.lib dxerr9.lib libgstaudio-0.10.lib libgstreamer-0.10.lib libgstbase-0.10.lib glib-2.0.lib gobject-2.0.lib" AdditionalDependencies="dsound.lib dxerr9.lib libgstaudio-0.10.lib libgstreamer-0.10.lib libgstbase-0.10.lib glib-2.0.lib gobject-2.0.lib user32.lib"
OutputFile="$(OutDir)/libgstdirectsound.dll" OutputFile="$(OutDir)/libgstdirectsound.dll"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="../../../gstreamer/win32/vs8/$(ConfigurationName);../../../gst-plugins-base/win32/vs8/$(ConfigurationName)" AdditionalLibraryDirectories="../../../gstreamer/win32/vs8/$(ConfigurationName);../../../gst-plugins-base/win32/vs8/$(ConfigurationName)"
@ -141,7 +141,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="dsound.lib dxerr9.lib libgstaudio-0.10.lib libgstreamer-0.10.lib libgstbase-0.10.lib glib-2.0.lib gobject-2.0.lib" AdditionalDependencies="dsound.lib dxerr9.lib libgstaudio-0.10.lib libgstreamer-0.10.lib libgstbase-0.10.lib glib-2.0.lib gobject-2.0.lib user32.lib"
OutputFile="$(OutDir)/libgstdirectsound.dll" OutputFile="$(OutDir)/libgstdirectsound.dll"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="../../../gstreamer/win32/vs8/$(ConfigurationName);../../../gst-plugins-base/win32/vs8/$(ConfigurationName)" AdditionalLibraryDirectories="../../../gstreamer/win32/vs8/$(ConfigurationName);../../../gst-plugins-base/win32/vs8/$(ConfigurationName)"