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

Side by Side Diff: media/audio/pulse/pulse_util.cc

Issue 1317033006: Linux: Do not use a hard coded app name for PulseAudio output. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « media/audio/pulse/pulse_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/audio/pulse/pulse_util.h" 5 #include "media/audio/pulse/pulse_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "media/audio/audio_manager_base.h" 9 #include "media/audio/audio_manager_base.h"
10 #include "media/audio/audio_parameters.h" 10 #include "media/audio/audio_parameters.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 base::Time::kMicrosecondsPerSecond; 149 base::Time::kMicrosecondsPerSecond;
150 } 150 }
151 151
152 // Helper macro for CreateInput/OutputStream() to avoid code spam and 152 // Helper macro for CreateInput/OutputStream() to avoid code spam and
153 // string bloat. 153 // string bloat.
154 #define RETURN_ON_FAILURE(expression, message) do { \ 154 #define RETURN_ON_FAILURE(expression, message) do { \
155 if (!(expression)) { \ 155 if (!(expression)) { \
156 DLOG(ERROR) << message; \ 156 DLOG(ERROR) << message; \
157 return false; \ 157 return false; \
158 } \ 158 } \
159 } while(0) 159 } while (0)
160 160
161 bool CreateInputStream(pa_threaded_mainloop* mainloop, 161 bool CreateInputStream(pa_threaded_mainloop* mainloop,
162 pa_context* context, 162 pa_context* context,
163 pa_stream** stream, 163 pa_stream** stream,
164 const AudioParameters& params, 164 const AudioParameters& params,
165 const std::string& device_id, 165 const std::string& device_id,
166 pa_stream_notify_cb_t stream_callback, 166 pa_stream_notify_cb_t stream_callback,
167 void* user_data) { 167 void* user_data) {
168 DCHECK(mainloop); 168 DCHECK(mainloop);
169 DCHECK(context); 169 DCHECK(context);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 227 }
228 228
229 return true; 229 return true;
230 } 230 }
231 231
232 bool CreateOutputStream(pa_threaded_mainloop** mainloop, 232 bool CreateOutputStream(pa_threaded_mainloop** mainloop,
233 pa_context** context, 233 pa_context** context,
234 pa_stream** stream, 234 pa_stream** stream,
235 const AudioParameters& params, 235 const AudioParameters& params,
236 const std::string& device_id, 236 const std::string& device_id,
237 const std::string& app_name,
237 pa_stream_notify_cb_t stream_callback, 238 pa_stream_notify_cb_t stream_callback,
238 pa_stream_request_cb_t write_callback, 239 pa_stream_request_cb_t write_callback,
239 void* user_data) { 240 void* user_data) {
240 DCHECK(!*mainloop); 241 DCHECK(!*mainloop);
241 DCHECK(!*context); 242 DCHECK(!*context);
242 243
243 *mainloop = pa_threaded_mainloop_new(); 244 *mainloop = pa_threaded_mainloop_new();
244 RETURN_ON_FAILURE(*mainloop, "Failed to create PulseAudio main loop."); 245 RETURN_ON_FAILURE(*mainloop, "Failed to create PulseAudio main loop.");
245 246
246 pa_mainloop_api* pa_mainloop_api = pa_threaded_mainloop_get_api(*mainloop); 247 pa_mainloop_api* pa_mainloop_api = pa_threaded_mainloop_get_api(*mainloop);
247 *context = pa_context_new(pa_mainloop_api, "Chromium"); 248 *context = pa_context_new(pa_mainloop_api,
249 app_name.empty() ? "Chromium" : app_name.c_str());
248 RETURN_ON_FAILURE(*context, "Failed to create PulseAudio context."); 250 RETURN_ON_FAILURE(*context, "Failed to create PulseAudio context.");
249 251
250 // A state callback must be set before calling pa_threaded_mainloop_lock() or 252 // A state callback must be set before calling pa_threaded_mainloop_lock() or
251 // pa_threaded_mainloop_wait() calls may lead to dead lock. 253 // pa_threaded_mainloop_wait() calls may lead to dead lock.
252 pa_context_set_state_callback(*context, &ContextStateCallback, *mainloop); 254 pa_context_set_state_callback(*context, &ContextStateCallback, *mainloop);
253 255
254 // Lock the main loop while setting up the context. Failure to do so may lead 256 // Lock the main loop while setting up the context. Failure to do so may lead
255 // to crashes as the PulseAudio thread tries to run before things are ready. 257 // to crashes as the PulseAudio thread tries to run before things are ready.
256 AutoPulseLock auto_lock(*mainloop); 258 AutoPulseLock auto_lock(*mainloop);
257 259
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 352 }
351 353
352 return true; 354 return true;
353 } 355 }
354 356
355 #undef RETURN_ON_FAILURE 357 #undef RETURN_ON_FAILURE
356 358
357 } // namespace pulse 359 } // namespace pulse
358 360
359 } // namespace media 361 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/pulse/pulse_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698