Skip to content

Commit

Permalink
lint and minor logic edits
Browse files Browse the repository at this point in the history
  • Loading branch information
FieryRMS committed Nov 26, 2022
1 parent ba1d296 commit 3e9e84b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions scrcpy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ def __stream_loop(self) -> None:
while self.alive:
try:
raw_h264 = self.__video_socket.recv(0x10000)
if(raw_h264==b''):
raise ConnectionAbortedError
if raw_h264 == b"":
ConnectionError("Video stream is disconnected")
packets = codec.parse(raw_h264)
for packet in packets:
frames = codec.decode(packet)
Expand All @@ -246,15 +246,11 @@ def __stream_loop(self) -> None:
time.sleep(0.01)
if not self.block_frame:
self.__send_to_listeners(EVENT_FRAME, None)
except ConnectionAbortedError as e:
except (ConnectionError, OSError) as e: # Socket Closed
if self.alive:
self.__send_to_listeners(EVENT_DISCONNECT)
self.stop()
raise e
except OSError as e: # Socket Closed
if self.alive:
self.stop()
raise e

def add_listener(self, cls: str, listener: Callable[..., Any]) -> None:
"""
Expand Down

0 comments on commit 3e9e84b

Please sign in to comment.