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

Side by Side Diff: services/media/audio/platform/linux/alsa_output.cc

Issue 1902183002: Motown: Change media type (stream type) representation (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <limits> 5 #include <limits>
6 #include <set> 6 #include <set>
7 7
8 #include "mojo/services/media/common/cpp/local_time.h" 8 #include "mojo/services/media/common/cpp/local_time.h"
9 #include "services/media/audio/platform/linux/alsa_output.h" 9 #include "services/media/audio/platform/linux/alsa_output.h"
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // output's configuration, and disabling resampling at the ALSA level. 44 // output's configuration, and disabling resampling at the ALSA level.
45 // 45 //
46 // If we could own the output entirely and bypass the mixer to achieve lower 46 // If we could own the output entirely and bypass the mixer to achieve lower
47 // latency, that would be even better. 47 // latency, that would be even better.
48 AudioOutputPtr audio_out(audio::AlsaOutput::New(manager)); 48 AudioOutputPtr audio_out(audio::AlsaOutput::New(manager));
49 if (!audio_out) { return nullptr; } 49 if (!audio_out) { return nullptr; }
50 50
51 AlsaOutput* alsa_out = static_cast<AlsaOutput*>(audio_out.get()); 51 AlsaOutput* alsa_out = static_cast<AlsaOutput*>(audio_out.get());
52 DCHECK(alsa_out); 52 DCHECK(alsa_out);
53 53
54 LpcmMediaTypeDetailsPtr config(LpcmMediaTypeDetails::New()); 54 AudioMediaTypeDetailsPtr config(AudioMediaTypeDetails::New());
55 config->frames_per_second = 48000; 55 config->frames_per_second = 48000;
56 config->channels = 2; 56 config->channels = 2;
57 config->sample_format = LpcmSampleFormat::SIGNED_16; 57 config->sample_format = AudioSampleFormat::SIGNED_16;
58 58
59 if (alsa_out->Configure(config.Pass()) != MediaResult::OK) { 59 if (alsa_out->Configure(config.Pass()) != MediaResult::OK) {
60 return nullptr; 60 return nullptr;
61 } 61 }
62 62
63 return audio_out; 63 return audio_out;
64 } 64 }
65 65
66 AlsaOutput::AlsaOutput(AudioOutputManager* manager) 66 AlsaOutput::AlsaOutput(AudioOutputManager* manager)
67 : StandardOutputBase(manager) {} 67 : StandardOutputBase(manager) {}
68 68
69 AlsaOutput::~AlsaOutput() { 69 AlsaOutput::~AlsaOutput() {
70 // We should have been cleaned up already, but in release builds, call cleanup 70 // We should have been cleaned up already, but in release builds, call cleanup
71 // anyway, just in case something got missed. 71 // anyway, just in case something got missed.
72 DCHECK(!alsa_device_); 72 DCHECK(!alsa_device_);
73 Cleanup(); 73 Cleanup();
74 } 74 }
75 75
76 AudioOutputPtr AlsaOutput::New(AudioOutputManager* manager) { 76 AudioOutputPtr AlsaOutput::New(AudioOutputManager* manager) {
77 return AudioOutputPtr(new AlsaOutput(manager)); 77 return AudioOutputPtr(new AlsaOutput(manager));
78 } 78 }
79 79
80 MediaResult AlsaOutput::Configure(LpcmMediaTypeDetailsPtr config) { 80 MediaResult AlsaOutput::Configure(AudioMediaTypeDetailsPtr config) {
81 if (!config) { return MediaResult::INVALID_ARGUMENT; } 81 if (!config) { return MediaResult::INVALID_ARGUMENT; }
82 if (output_formatter_) { return MediaResult::BAD_STATE; } 82 if (output_formatter_) { return MediaResult::BAD_STATE; }
83 83
84 output_formatter_ = OutputFormatter::Select(config); 84 output_formatter_ = OutputFormatter::Select(config);
85 if (!output_formatter_) { return MediaResult::UNSUPPORTED_CONFIG; } 85 if (!output_formatter_) { return MediaResult::UNSUPPORTED_CONFIG; }
86 86
87 MediaResult res = AlsaSelectFormat(config); 87 MediaResult res = AlsaSelectFormat(config);
88 if (res != MediaResult::OK) { return res; } 88 if (res != MediaResult::OK) { return res; }
89 DCHECK_GE(alsa_format_, 0); 89 DCHECK_GE(alsa_format_, 0);
90 90
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (code == -EPIPE) { 339 if (code == -EPIPE) {
340 HandleAsUnderflow(); 340 HandleAsUnderflow();
341 } else { 341 } else {
342 HandleAsError(code); 342 HandleAsError(code);
343 } 343 }
344 } 344 }
345 345
346 } // namespace audio 346 } // namespace audio
347 } // namespace media 347 } // namespace media
348 } // namespace mojo 348 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698