| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class LinuxDeviceWatcher | 53 class LinuxDeviceWatcher |
| 54 : public DeviceWatcher, | 54 : public DeviceWatcher, |
| 55 private rtc::Dispatcher { | 55 private rtc::Dispatcher { |
| 56 public: | 56 public: |
| 57 explicit LinuxDeviceWatcher(DeviceManagerInterface* dm); | 57 explicit LinuxDeviceWatcher(DeviceManagerInterface* dm); |
| 58 virtual ~LinuxDeviceWatcher(); | 58 virtual ~LinuxDeviceWatcher(); |
| 59 virtual bool Start(); | 59 virtual bool Start(); |
| 60 virtual void Stop(); | 60 virtual void Stop(); |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 virtual uint32 GetRequestedEvents(); | 63 virtual uint32_t GetRequestedEvents(); |
| 64 virtual void OnPreEvent(uint32 ff); | 64 virtual void OnPreEvent(uint32_t ff); |
| 65 virtual void OnEvent(uint32 ff, int err); | 65 virtual void OnEvent(uint32_t ff, int err); |
| 66 virtual int GetDescriptor(); | 66 virtual int GetDescriptor(); |
| 67 virtual bool IsDescriptorClosed(); | 67 virtual bool IsDescriptorClosed(); |
| 68 | 68 |
| 69 DeviceManagerInterface* manager_; | 69 DeviceManagerInterface* manager_; |
| 70 LibUDevSymbolTable libudev_; | 70 LibUDevSymbolTable libudev_; |
| 71 struct udev* udev_; | 71 struct udev* udev_; |
| 72 struct udev_monitor* udev_monitor_; | 72 struct udev_monitor* udev_monitor_; |
| 73 bool registered_; | 73 bool registered_; |
| 74 }; | 74 }; |
| 75 | 75 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 libudev_.udev_monitor_unref()(udev_monitor_); | 361 libudev_.udev_monitor_unref()(udev_monitor_); |
| 362 udev_monitor_ = NULL; | 362 udev_monitor_ = NULL; |
| 363 } | 363 } |
| 364 if (udev_) { | 364 if (udev_) { |
| 365 libudev_.udev_unref()(udev_); | 365 libudev_.udev_unref()(udev_); |
| 366 udev_ = NULL; | 366 udev_ = NULL; |
| 367 } | 367 } |
| 368 libudev_.Unload(); | 368 libudev_.Unload(); |
| 369 } | 369 } |
| 370 | 370 |
| 371 uint32 LinuxDeviceWatcher::GetRequestedEvents() { | 371 uint32_t LinuxDeviceWatcher::GetRequestedEvents() { |
| 372 return rtc::DE_READ; | 372 return rtc::DE_READ; |
| 373 } | 373 } |
| 374 | 374 |
| 375 void LinuxDeviceWatcher::OnPreEvent(uint32 ff) { | 375 void LinuxDeviceWatcher::OnPreEvent(uint32_t ff) { |
| 376 // Nothing to do. | 376 // Nothing to do. |
| 377 } | 377 } |
| 378 | 378 |
| 379 void LinuxDeviceWatcher::OnEvent(uint32 ff, int err) { | 379 void LinuxDeviceWatcher::OnEvent(uint32_t ff, int err) { |
| 380 udev_device* device = libudev_.udev_monitor_receive_device()(udev_monitor_); | 380 udev_device* device = libudev_.udev_monitor_receive_device()(udev_monitor_); |
| 381 if (!device) { | 381 if (!device) { |
| 382 // Probably the socket connection to the udev daemon was terminated (perhaps | 382 // Probably the socket connection to the udev daemon was terminated (perhaps |
| 383 // the daemon crashed or is being restarted?). | 383 // the daemon crashed or is being restarted?). |
| 384 LOG_ERR(LS_WARNING) << "udev_monitor_receive_device()"; | 384 LOG_ERR(LS_WARNING) << "udev_monitor_receive_device()"; |
| 385 // Stop listening to avoid potential livelock (an fd with EOF in it is | 385 // Stop listening to avoid potential livelock (an fd with EOF in it is |
| 386 // always considered readable). | 386 // always considered readable). |
| 387 CurrentSocketServer()->Remove(this); | 387 CurrentSocketServer()->Remove(this); |
| 388 registered_ = false; | 388 registered_ = false; |
| 389 return; | 389 return; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 401 } | 401 } |
| 402 | 402 |
| 403 bool LinuxDeviceWatcher::IsDescriptorClosed() { | 403 bool LinuxDeviceWatcher::IsDescriptorClosed() { |
| 404 // If it is closed then we will just get an error in | 404 // If it is closed then we will just get an error in |
| 405 // udev_monitor_receive_device and unregister, so we don't need to check for | 405 // udev_monitor_receive_device and unregister, so we don't need to check for |
| 406 // it separately. | 406 // it separately. |
| 407 return false; | 407 return false; |
| 408 } | 408 } |
| 409 | 409 |
| 410 }; // namespace cricket | 410 }; // namespace cricket |
| OLD | NEW |