OSDN Git Service

OOMは改善したが、通信が詰まる...。間隔を短くする。
authorMRSa <mrsa@myad.jp>
Mon, 30 Sep 2019 15:39:19 +0000 (00:39 +0900)
committerMRSa <mrsa@myad.jp>
Mon, 30 Sep 2019 15:39:19 +0000 (00:39 +0900)
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/PtpIpCommandPublisher.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/PtpIpScreennailImageReceiver.java

index 44d2bbf..aa57526 100644 (file)
@@ -22,9 +22,9 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
 
     private static final int SEQUENCE_START_NUMBER = 1;
     private static final int BUFFER_SIZE = 1024 * 256 + 16;  // バッファは 256kB
-    private static final int COMMAND_SEND_RECEIVE_DURATION_MS = 30;
+    private static final int COMMAND_SEND_RECEIVE_DURATION_MS = 10;
     private static final int COMMAND_SEND_RECEIVE_DURATION_MAX = 1000;
-    private static final int COMMAND_POLL_QUEUE_MS = 30;
+    private static final int COMMAND_POLL_QUEUE_MS = 10;
 
     private final String ipAddress;
     private final int portNumber;
@@ -604,6 +604,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
         catch (Throwable e)
         {
             e.printStackTrace();
+            System.gc();
         }
         return (false);
     }
@@ -626,6 +627,11 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
                 lenlen = ((((int) byte_array[15]) & 0xff) << 24) + ((((int) byte_array[14]) & 0xff) << 16) + ((((int) byte_array[13]) & 0xff) << 8) + (((int) byte_array[12]) & 0xff);
             }
             Log.v(TAG, " --- <<< RECEIVED LARGE BLOCK MESSAGE : " + len + " bytes. (" + byte_array.length + " bytes.)" + " lenlen : " + lenlen + " >>> --- ");
+            if (lenlen == 0)
+            {
+                // データとしては変なので、なにもしない
+                return (receivedBuffer);
+            }
             ByteArrayOutputStream outputStream =  new ByteArrayOutputStream();
             //outputStream.write(byte_array, 0, 20);  //
             int position = 20;  // ヘッダ込の先頭
@@ -638,9 +644,10 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
             }
             return (outputStream);
         }
-        catch (Exception e)
+        catch (Throwable e)
         {
             e.printStackTrace();
+            System.gc();
         }
         return (receivedBuffer);
     }
index 55e5f8d..00d534f 100644 (file)
@@ -142,6 +142,7 @@ public class PtpIpScreennailImageReceiver  implements IPtpIpCommandCallback
             catch (Exception ex)
             {
                 ex.printStackTrace();
+                System.gc();
             }
             // 画像の縮小サイズを決定する (縦幅、横幅の小さいほうにあわせる)
             int widthBounds = opt.outWidth / BITMAP_MAX_PIXEL;