[Xfce4-commits] <parole:master> Properly handle WriteReady callback.

Ali Abdallah noreply at xfce.org
Wed Jan 13 21:24:05 CET 2010


Updating branch refs/heads/master
         to d6347f62a186486a4c79e422709968b0c44cbcd0 (commit)
       from fab9e65fdf878b30bab3e41ebb6253ba91f7a324 (commit)

commit d6347f62a186486a4c79e422709968b0c44cbcd0
Author: Ali Abdallah <aliov at xfce.org>
Date:   Wed Jan 13 21:20:25 2010 +0100

    Properly handle WriteReady callback.

 browser-plugin/npp_gate.cpp |    2 --
 browser-plugin/plugin.cpp   |   27 ++++++++++++++++++++++++---
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/browser-plugin/npp_gate.cpp b/browser-plugin/npp_gate.cpp
index 3fbb03b..90c1d00 100644
--- a/browser-plugin/npp_gate.cpp
+++ b/browser-plugin/npp_gate.cpp
@@ -71,7 +71,6 @@ NPError NPP_New(NPMIMEType pluginType,
 
     NPError rv = NPERR_NO_ERROR;
 
-    printf("NPP_New called\n");
     CPlugin *pPlugin = new CPlugin(instance);
     if (pPlugin == NULL)
         return NPERR_OUT_OF_MEMORY_ERROR;
@@ -132,7 +131,6 @@ NPError NPP_SetWindow(NPP instance, NPWindow * pNPWindow)
 
     // window resized
     if (pPlugin->isInitialized() && (pNPWindow->window != NULL)) {
-        printf("Window resized\n");
         pPlugin->SetWindow(pNPWindow);
         return NPERR_NO_ERROR;
     }
diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp
index a37f504..2caeea6 100644
--- a/browser-plugin/plugin.cpp
+++ b/browser-plugin/plugin.cpp
@@ -407,6 +407,23 @@ NPError CPlugin::NewStream (NPMIMEType type, NPStream * stream, NPBool seekable,
 
 NPError CPlugin::DestroyStream(NPStream * stream, NPError reason)
 {
+    /*
+    g_debug ("DestroyStream reason = %i for %s\n", reason, stream->url);
+    
+    if ( reason == NPRES_DONE )
+    {
+	g_debug ("NPRES_DONE");
+    }
+    else if ( reason == NPRES_USER_BREAK )
+    {
+	g_debug ("NPRES_USER_BREAK");
+	
+    }
+    else if ( reason == NPRES_NETWORK_ERR )
+    {
+	g_debug ("NPRES_NETWORK_ERR");
+    }
+    */
     return NPERR_NO_ERROR;
 }
 
@@ -424,6 +441,12 @@ int32_t CPlugin::WriteReady (NPStream * stream)
 {
     //g_debug ("WriteReady url=%s", stream->url);
     
+    if ( mode != NP_FULL )
+    {
+	NPN_DestroyStream (mInstance, stream, NPRES_DONE);
+	return -1;
+    }
+    
     return  player_ready ? STREAMBUFSIZE  : 0;
 }
     
@@ -464,10 +487,8 @@ int32_t CPlugin::Write (NPStream * stream, int32_t offset, int32_t len, void *bu
 	if ( cache )
 	{
 	    fseek (cache, offset, SEEK_SET);
-	    wrotebytes += fwrite (buffer, 1, len, cache);
-#ifdef DEBUG
+	    wrotebytes += fwrite (buffer, 1, MAX (len, STREAMBUFSIZE), cache);
 	    //g_debug ("Wrotebytes=%d offset=%d data=%s", wrotebytes, offset, (gchar*)buffer);
-#endif
 	}
 	
 	if ( wrotebytes >= 0 )



More information about the Xfce4-commits mailing list