]> git.parisson.com Git - deefuzzer.git/commitdiff
better network disconnexion management
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 14 Jul 2011 13:01:20 +0000 (13:01 +0000)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 14 Jul 2011 13:01:20 +0000 (13:01 +0000)
deefuzzer/tools/player.py
deefuzzer/tools/station.py

index dec963ea43072f4c5944af9bd0229e29cb6a88ec..69b6e154df6f7b267a4620b74ae30f8a6fdf1f55 100644 (file)
@@ -43,7 +43,7 @@ class Player:
 
     def __init__(self):
         self.main_buffer_size = 0x100000
-        self.relay_queue_size = 0x2000
+        self.relay_queue_size = 0x100000
         self.sub_buffer_size = 0x10000
 
     def set_media(self, media):
index 70d56e3911845f7fd71e5f6004444b135ee0789a..226617dfe2228e12ada06bcb24465b79ba308902 100644 (file)
@@ -522,22 +522,25 @@ class Station(Thread):
             self.q.task_done()
 
             for self.chunk in self.stream:
-                self.q.get(1)
                 if self.next_media or not self.run_mode:
                     break
-                try:
-                    if self.record_mode:
+                if self.record_mode:
+                    try:
+                        self.q.get(1)
                         self.recorder.write(self.chunk)
-                except:
-                    self.logger.write_error('Station ' + self.channel_url + ' : could not write the buffer to the file')
-                    continue
+                        self.q.task_done()
+                    except:
+                        self.logger.write_error('Station ' + self.channel_url + ' : could not write the buffer to the file')
+                        self.q.task_done()
+                        continue
                 try:
+                    self.q.get(1)
                     self.channel.send(self.chunk)
                     self.channel.sync()
+                    self.q.task_done()
                 except:
                     self.logger.write_error('Station ' + self.channel_url + ' : could not send the buffer')
                     self.q.task_done()
-                    self.ping_server()
                     try:
                         self.q.get(1)
                         self.channel.close()
@@ -548,20 +551,17 @@ class Station(Thread):
                         self.q.task_done()
                         continue
                     try:
+                        self.ping_server()
                         self.q.get(1)
                         self.channel_open()
                         self.channel.set_metadata({'song': self.song, 'charset': 'utf8',})
-                        self.channel.send(self.chunk)
-                        self.channel.sync()
                         self.logger.write_info('Station ' + self.channel_url + ' : channel restarted')
+                        self.q.task_done()
                     except:
                         self.logger.write_error('Station ' + self.channel_url + ' : could not restart the channel')
+                        self.q.task_done()
                         continue
                     continue
-                self.q.task_done()
-        
-        if not self.run_mode:
-            self.q.task_done()
 
         if self.record_mode:
             self.recorder.close()