3838import com .smartdevicelink .protocol .enums .SessionType ;
3939import com .smartdevicelink .proxy .interfaces .IAudioStreamListener ;
4040import com .smartdevicelink .proxy .interfaces .IVideoStreamListener ;
41+ import com .smartdevicelink .util .DebugTool ;
4142
4243import java .io .IOException ;
4344import java .io .InputStream ;
@@ -79,6 +80,7 @@ public StreamPacketizer(IStreamListener streamListener, InputStream is, SessionT
7980 if (bufferSize == 0 ) {
8081 // fail safe
8182 bufferSize = BUFF_READ_SIZE ;
83+ buffer = new byte [bufferSize ];
8284 }
8385 if (isServiceProtected ){ //If our service is encrypted we can only use 1024 as the max buffer size.
8486 bufferSize = BUFF_READ_SIZE ;
@@ -147,6 +149,9 @@ public void run() {
147149 frame = byteBufferWithListener .byteBuffer ;
148150 completionListener = byteBufferWithListener .completionListener ;
149151 } catch (InterruptedException e ) {
152+ if (DebugTool .isDebugEnabled ()){
153+ e .printStackTrace ();
154+ }
150155 Thread .currentThread ().interrupt ();
151156 break ;
152157 }
@@ -169,7 +174,7 @@ public void run() {
169174 frame .position (frame .position () + len );
170175 }
171176
172- if (! frame . hasRemaining () && completionListener != null ){
177+ if (completionListener != null ){
173178 completionListener .onComplete (true );
174179 }
175180 }
@@ -187,8 +192,6 @@ public void run() {
187192 }else {
188193 _session .endService (_serviceType ,_rpcSessionID );
189194 }
190-
191-
192195 }
193196 }
194197
@@ -297,8 +300,8 @@ private void sendByteBufferData(ByteBuffer data, CompletionListener completionLi
297300 }
298301
299302 private class ByteBufferWithListener {
300- ByteBuffer byteBuffer ;
301- CompletionListener completionListener ;
303+ final ByteBuffer byteBuffer ;
304+ final CompletionListener completionListener ;
302305 ByteBufferWithListener (ByteBuffer byteBuffer , CompletionListener completionListener ){
303306 this .byteBuffer = byteBuffer ;
304307 this .completionListener = completionListener ;
0 commit comments