autoreconnect and pyaudio fix
This commit is contained in:
parent
28cedae342
commit
e78ba3942b
2 changed files with 23 additions and 3 deletions
|
@ -80,6 +80,8 @@ class Profile(contact.Contact, Singleton):
|
|||
super(Profile, self).set_status(status)
|
||||
if status is not None:
|
||||
self._tox.self_set_status(status)
|
||||
else:
|
||||
QtCore.QTimer.singleShot(30000, self.reconnect)
|
||||
|
||||
def set_name(self, value):
|
||||
if self.name == value:
|
||||
|
@ -787,8 +789,14 @@ class Profile(contact.Contact, Singleton):
|
|||
self.status = None
|
||||
for friend in self._friends:
|
||||
friend.status = None
|
||||
friend.number = self._tox.friend_by_public_key(friend.tox_id)
|
||||
self.update_filtration()
|
||||
|
||||
def reconnect(self):
|
||||
if self.status is None:
|
||||
self.reset(self._screen.reset)
|
||||
QtCore.QTimer.singleShot(30000, self.reconnect)
|
||||
|
||||
def close(self):
|
||||
if hasattr(self, '_call'):
|
||||
self._call.stop()
|
||||
|
@ -1116,6 +1124,8 @@ class Profile(contact.Contact, Singleton):
|
|||
"""User clicked audio button in main window"""
|
||||
num = self.get_active_number()
|
||||
if num not in self._call and self.is_active_online(): # start call
|
||||
if not Settings.get_instance().audio['enabled']:
|
||||
return
|
||||
self._call(num, audio, video)
|
||||
self._screen.active_call()
|
||||
if video:
|
||||
|
@ -1134,6 +1144,8 @@ class Profile(contact.Contact, Singleton):
|
|||
"""
|
||||
Incoming call from friend. Only audio is supported now
|
||||
"""
|
||||
if not Settings.get_instance().audio['enabled']:
|
||||
return
|
||||
friend = self.get_friend_by_number(friend_number)
|
||||
if video:
|
||||
text = QtGui.QApplication.translate("incoming_call", "Incoming video call", None,
|
||||
|
|
|
@ -34,10 +34,18 @@ class Settings(dict, Singleton):
|
|||
super(Settings, self).__init__(Settings.get_default_settings())
|
||||
self.save()
|
||||
smileys.SmileyLoader(self)
|
||||
p = pyaudio.PyAudio()
|
||||
self.locked = False
|
||||
self.audio = {'input': p.get_default_input_device_info()['index'],
|
||||
'output': p.get_default_output_device_info()['index']}
|
||||
p = pyaudio.PyAudio()
|
||||
input_devices = output_devices = 0
|
||||
for i in range(p.get_device_count()):
|
||||
device = p.get_device_info_by_index(i)
|
||||
if device["maxInputChannels"]:
|
||||
input_devices += 1
|
||||
if device["maxOutputChannels"]:
|
||||
output_devices += 1
|
||||
self.audio = {'input': p.get_default_input_device_info()['index'] if input_devices else -1,
|
||||
'output': p.get_default_output_device_info()['index'] if output_devices else -1,
|
||||
'enabled': input_devices and output_devices}
|
||||
|
||||
@staticmethod
|
||||
def get_auto_profile():
|
||||
|
|
Loading…
Reference in a new issue