[FFmpeg-devel] [PATCH 2/2] dshow: Make dshow device buildable on Cygwin

Moriyoshi Koizumi mozo at mozo.jp
Fri May 6 10:53:12 CEST 2016


From: Moriyoshi koizumi <mozo at mozo.jp>

wchar_t is not always the same thing as WCHAR.

Signed-off-by: Moriyoshi koizumi <mozo at mozo.jp>
---
 libavdevice/dshow.c         |  6 +++---
 libavdevice/dshow_capture.h | 10 +++++-----
 libavdevice/dshow_filter.c  | 16 ++++++++--------
 libavdevice/dshow_pin.c     | 10 +++++-----
 4 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index 678861d..432b643 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -129,7 +129,7 @@ dshow_read_close(AVFormatContext *s)
     return 0;
 }
 
-static char *dup_wchar_to_utf8(wchar_t *w)
+static char *dup_wchar_to_utf8(WCHAR *w)
 {
     char *s = NULL;
     int l = WideCharToMultiByte(CP_UTF8, 0, w, -1, 0, 0, 0, 0);
@@ -599,7 +599,7 @@ dshow_cycle_pins(AVFormatContext *avctx, enum dshowDeviceType devtype,
         GUID category;
         DWORD r2;
         char *name_buf = NULL;
-        wchar_t *pin_id = NULL;
+        WCHAR *pin_id = NULL;
         char *pin_buf = NULL;
         char *desired_pin_name = devtype == VideoDevice ? ctx->video_pin_name : ctx->audio_pin_name;
 
@@ -734,7 +734,7 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum,
     IStream *ofile_stream = NULL;
     IPersistStream *pers_stream = NULL;
 
-    const wchar_t *filter_name[2] = { L"Audio capture filter", L"Video capture filter" };
+    const WCHAR *filter_name[2] = { L"Audio capture filter", L"Video capture filter" };
 
 
     if ( ((ctx->audio_filter_load_file) && (strlen(ctx->audio_filter_load_file)>0) && (sourcetype == AudioSourceDevice)) ||
diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h
index f26eaf9..860b782 100644
--- a/libavdevice/dshow_capture.h
+++ b/libavdevice/dshow_capture.h
@@ -176,7 +176,7 @@ long          WINAPI libAVPin_ConnectedTo             (libAVPin *, IPin **);
 long          WINAPI libAVPin_ConnectionMediaType     (libAVPin *, AM_MEDIA_TYPE *);
 long          WINAPI libAVPin_QueryPinInfo            (libAVPin *, PIN_INFO *);
 long          WINAPI libAVPin_QueryDirection          (libAVPin *, PIN_DIRECTION *);
-long          WINAPI libAVPin_QueryId                 (libAVPin *, wchar_t **);
+long          WINAPI libAVPin_QueryId                 (libAVPin *, WCHAR **);
 long          WINAPI libAVPin_QueryAccept             (libAVPin *, const AM_MEDIA_TYPE *);
 long          WINAPI libAVPin_EnumMediaTypes          (libAVPin *, IEnumMediaTypes **);
 long          WINAPI libAVPin_QueryInternalConnections(libAVPin *, IPin **, unsigned long *);
@@ -249,7 +249,7 @@ libAVEnumMediaTypes *libAVEnumMediaTypes_Create(const AM_MEDIA_TYPE *type);
 struct libAVFilter {
     IBaseFilterVtbl *vtbl;
     long ref;
-    const wchar_t *name;
+    const WCHAR *name;
     libAVPin *pin;
     FILTER_INFO info;
     FILTER_STATE state;
@@ -272,10 +272,10 @@ long          WINAPI libAVFilter_GetState       (libAVFilter *, DWORD, FILTER_ST
 long          WINAPI libAVFilter_SetSyncSource  (libAVFilter *, IReferenceClock *);
 long          WINAPI libAVFilter_GetSyncSource  (libAVFilter *, IReferenceClock **);
 long          WINAPI libAVFilter_EnumPins       (libAVFilter *, IEnumPins **);
-long          WINAPI libAVFilter_FindPin        (libAVFilter *, const wchar_t *, IPin **);
+long          WINAPI libAVFilter_FindPin        (libAVFilter *, const WCHAR *, IPin **);
 long          WINAPI libAVFilter_QueryFilterInfo(libAVFilter *, FILTER_INFO *);
-long          WINAPI libAVFilter_JoinFilterGraph(libAVFilter *, IFilterGraph *, const wchar_t *);
-long          WINAPI libAVFilter_QueryVendorInfo(libAVFilter *, wchar_t **);
+long          WINAPI libAVFilter_JoinFilterGraph(libAVFilter *, IFilterGraph *, const WCHAR *);
+long          WINAPI libAVFilter_QueryVendorInfo(libAVFilter *, WCHAR **);
 
 void                 libAVFilter_Destroy(libAVFilter *);
 libAVFilter         *libAVFilter_Create (void *, void *, enum dshowDeviceType);
diff --git a/libavdevice/dshow_filter.c b/libavdevice/dshow_filter.c
index 7360adc..3ba3871 100644
--- a/libavdevice/dshow_filter.c
+++ b/libavdevice/dshow_filter.c
@@ -20,6 +20,8 @@
  */
 
 #include "dshow_capture.h"
+#include <shlwapi.h>
+#include <strsafe.h>
 
 DECLARE_QUERYINTERFACE(libAVFilter,
     { {&IID_IUnknown,0}, {&IID_IBaseFilter,0} })
@@ -108,14 +110,14 @@ libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
     return S_OK;
 }
 long WINAPI
-libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
+libAVFilter_FindPin(libAVFilter *this, const WCHAR *id, IPin **pin)
 {
     libAVPin *found = NULL;
     dshowdebug("libAVFilter_FindPin(%p)\n", this);
 
     if (!id || !pin)
         return E_POINTER;
-    if (!wcscmp(id, L"In")) {
+    if (!StrCmpW(id, L"In")) {
         found = this->pin;
         libAVPin_AddRef(found);
     }
@@ -140,26 +142,24 @@ libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
 }
 long WINAPI
 libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph,
-                            const wchar_t *name)
+                            const WCHAR *name)
 {
     dshowdebug("libAVFilter_JoinFilterGraph(%p)\n", this);
 
     this->info.pGraph = graph;
     if (name)
-        wcscpy(this->info.achName, name);
+        StringCchCopyW(this->info.achName, MAX_FILTER_NAME, name);
 
     return S_OK;
 }
 long WINAPI
-libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
+libAVFilter_QueryVendorInfo(libAVFilter *this, WCHAR **info)
 {
     dshowdebug("libAVFilter_QueryVendorInfo(%p)\n", this);
 
     if (!info)
         return E_POINTER;
-    *info = wcsdup(L"libAV");
-
-    return S_OK;
+    return SHStrDupW(L"libAV", info);
 }
 
 static int
diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c
index 664246d..73e3887 100644
--- a/libavdevice/dshow_pin.c
+++ b/libavdevice/dshow_pin.c
@@ -21,6 +21,8 @@
 
 #include "dshow_capture.h"
 
+#include <shlwapi.h>
+#include <strsafe.h>
 #include <stddef.h>
 #define imemoffset offsetof(libAVPin, imemvtbl)
 
@@ -117,7 +119,7 @@ libAVPin_QueryPinInfo(libAVPin *this, PIN_INFO *info)
 
     info->pFilter = (IBaseFilter *) this->filter;
     info->dir     = PINDIR_INPUT;
-    wcscpy(info->achName, L"Capture");
+    StringCchCopyW(info->achName, MAX_FILTER_NAME, L"Capture");
 
     return S_OK;
 }
@@ -131,16 +133,14 @@ libAVPin_QueryDirection(libAVPin *this, PIN_DIRECTION *dir)
     return S_OK;
 }
 long WINAPI
-libAVPin_QueryId(libAVPin *this, wchar_t **id)
+libAVPin_QueryId(libAVPin *this, WCHAR **id)
 {
     dshowdebug("libAVPin_QueryId(%p)\n", this);
 
     if (!id)
         return E_POINTER;
 
-    *id = wcsdup(L"libAV Pin");
-
-    return S_OK;
+    return SHStrDupW(L"libAV Pin", id);
 }
 long WINAPI
 libAVPin_QueryAccept(libAVPin *this, const AM_MEDIA_TYPE *type)
-- 
2.8.0



More information about the ffmpeg-devel mailing list