Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1071)

Side by Side Diff: media/audio/cras/cras_unified.h

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Changes based on comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // Creates a unified stream based on the cras (ChromeOS audio server) interface. 5 // Creates a unified stream based on the cras (ChromeOS audio server) interface.
6 // 6 //
7 // CrasUnifiedStream object is *not* thread-safe and should only be used 7 // CrasUnifiedStream object is *not* thread-safe and should only be used
8 // from the audio thread. 8 // from the audio thread.
9 9
10 #ifndef MEDIA_AUDIO_CRAS_CRAS_UNIFIED_H_ 10 #ifndef MEDIA_AUDIO_CRAS_CRAS_UNIFIED_H_
11 #define MEDIA_AUDIO_CRAS_CRAS_UNIFIED_H_ 11 #define MEDIA_AUDIO_CRAS_CRAS_UNIFIED_H_
12 12
13 #include <cras_client.h> 13 #include <cras_client.h>
14 #include <stddef.h> 14 #include <stddef.h>
15 #include <stdint.h> 15 #include <stdint.h>
16 16
17 #include <memory> 17 #include <memory>
18 18
19 #include "base/compiler_specific.h" 19 #include "base/compiler_specific.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/time/time.h"
21 #include "media/audio/audio_io.h" 22 #include "media/audio/audio_io.h"
22 #include "media/base/audio_parameters.h" 23 #include "media/base/audio_parameters.h"
23 24
24 namespace media { 25 namespace media {
25 26
26 class AudioManagerCras; 27 class AudioManagerCras;
27 28
28 // Implementation of AudioOuputStream for Chrome OS using the Chrome OS audio 29 // Implementation of AudioOuputStream for Chrome OS using the Chrome OS audio
29 // server. 30 // server.
30 // TODO(dgreid): This class is used for only output, either remove all the 31 // TODO(dgreid): This class is used for only output, either remove all the
(...skipping 12 matching lines...) Expand all
43 // Implementation of AudioOutputStream. 44 // Implementation of AudioOutputStream.
44 bool Open() override; 45 bool Open() override;
45 void Close() override; 46 void Close() override;
46 void Start(AudioSourceCallback* callback) override; 47 void Start(AudioSourceCallback* callback) override;
47 void Stop() override; 48 void Stop() override;
48 void SetVolume(double volume) override; 49 void SetVolume(double volume) override;
49 void GetVolume(double* volume) override; 50 void GetVolume(double* volume) override;
50 51
51 private: 52 private:
52 // Convert Latency in time to bytes. 53 // Convert Latency in time to bytes.
53 uint32_t GetBytesLatency(const struct timespec& latency); 54 base::TimeTicks GetTargetPlayoutTime(const struct timespec& latency_ts);
54 55
55 // Handles captured audio and fills the ouput with audio to be played. 56 // Handles captured audio and fills the ouput with audio to be played.
56 static int UnifiedCallback(cras_client* client, 57 static int UnifiedCallback(cras_client* client,
57 cras_stream_id_t stream_id, 58 cras_stream_id_t stream_id,
58 uint8_t* input_samples, 59 uint8_t* input_samples,
59 uint8_t* output_samples, 60 uint8_t* output_samples,
60 unsigned int frames, 61 unsigned int frames,
61 const timespec* input_ts, 62 const timespec* input_ts,
62 const timespec* output_ts, 63 const timespec* output_ts,
63 void* arg); 64 void* arg);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 113
113 // Direciton of the stream. 114 // Direciton of the stream.
114 CRAS_STREAM_DIRECTION stream_direction_; 115 CRAS_STREAM_DIRECTION stream_direction_;
115 116
116 DISALLOW_COPY_AND_ASSIGN(CrasUnifiedStream); 117 DISALLOW_COPY_AND_ASSIGN(CrasUnifiedStream);
117 }; 118 };
118 119
119 } // namespace media 120 } // namespace media
120 121
121 #endif // MEDIA_AUDIO_CRAS_CRAS_UNIFIED_H_ 122 #endif // MEDIA_AUDIO_CRAS_CRAS_UNIFIED_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698