OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/midi/midi_manager_alsa.h" | 5 #include "media/midi/midi_manager_alsa.h" |
6 | 6 |
7 #include <alsa/asoundlib.h> | 7 #include <alsa/asoundlib.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 void MidiManagerAlsa::EventReset() { | 385 void MidiManagerAlsa::EventReset() { |
386 event_thread_.message_loop()->PostTask( | 386 event_thread_.message_loop()->PostTask( |
387 FROM_HERE, | 387 FROM_HERE, |
388 base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this))); | 388 base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this))); |
389 } | 389 } |
390 | 390 |
391 void MidiManagerAlsa::EventLoop() { | 391 void MidiManagerAlsa::EventLoop() { |
392 // Read available incoming MIDI data. | 392 // Read available incoming MIDI data. |
393 snd_seq_event_t* event; | 393 snd_seq_event_t* event; |
394 int err = snd_seq_event_input(in_client_, &event); | 394 int err = snd_seq_event_input(in_client_, &event); |
395 double timestamp = | 395 double timestamp = (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
396 (base::TimeTicks::HighResNow() - base::TimeTicks()).InSecondsF(); | |
397 if (err == -ENOSPC) { | 396 if (err == -ENOSPC) { |
398 VLOG(1) << "snd_seq_event_input detected buffer overrun"; | 397 VLOG(1) << "snd_seq_event_input detected buffer overrun"; |
399 | 398 |
400 // We've lost events: check another way to see if we need to shut down. | 399 // We've lost events: check another way to see if we need to shut down. |
401 base::AutoLock lock(shutdown_lock_); | 400 base::AutoLock lock(shutdown_lock_); |
402 if (event_thread_shutdown_) { | 401 if (event_thread_shutdown_) { |
403 return; | 402 return; |
404 } | 403 } |
405 } else if (err < 0) { | 404 } else if (err < 0) { |
406 VLOG(1) << "snd_seq_event_input fails: " << snd_strerror(err); | 405 VLOG(1) << "snd_seq_event_input fails: " << snd_strerror(err); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 event_thread_.message_loop()->PostTask( | 443 event_thread_.message_loop()->PostTask( |
445 FROM_HERE, | 444 FROM_HERE, |
446 base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this))); | 445 base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this))); |
447 } | 446 } |
448 | 447 |
449 MidiManager* MidiManager::Create() { | 448 MidiManager* MidiManager::Create() { |
450 return new MidiManagerAlsa(); | 449 return new MidiManagerAlsa(); |
451 } | 450 } |
452 | 451 |
453 } // namespace media | 452 } // namespace media |
OLD | NEW |