Skip to content

Commit

Permalink
Sets the stream icon to "google-chrome" when using pulseaudio
Browse files Browse the repository at this point in the history
BUG=429494

Review URL: https://codereview.chromium.org/705343003

Cr-Commit-Position: refs/heads/master@{#303868}
  • Loading branch information
leopardb authored and Commit bot committed Nov 12, 2014
1 parent d6ffc1d commit 66f88cc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Felix H. Dahlke <fhd@ubercode.de>
Fernando Jiménez Moreno <ferjmoreno@gmail.com>
François Beaufort <beaufort.francois@gmail.com>
Francois Kritzinger <francoisk777@gmail.com>
Francois Rauch <leopardb@gmail.com>
Frédéric Wang <fred.wang@free.fr>
Gaetano Mendola <mendola@gmail.com>
Gajendra N <gajendra.n@samsung.com>
Expand Down
4 changes: 4 additions & 0 deletions media/audio/pulse/pulse.sigs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ uint32_t pa_stream_get_device_index(pa_stream* s);
int pa_stream_get_latency(pa_stream* s, pa_usec_t* r_usec, int* negative);
pa_stream_state_t pa_stream_get_state(pa_stream* p);
pa_stream* pa_stream_new(pa_context* c, const char* name, const pa_sample_spec* ss, const pa_channel_map * map);
pa_stream* pa_stream_new_with_proplist(pa_context* c, const char* name, const pa_sample_spec* ss, const pa_channel_map* map, pa_proplist* p);
pa_proplist* pa_proplist_new(void);
void pa_proplist_free(pa_proplist* p);
int pa_proplist_sets(pa_proplist* p, const char* key, const char* value);
size_t pa_stream_readable_size(pa_stream *p);
int pa_stream_peek(pa_stream* p, const void** data, size_t* nbytes);
void pa_stream_set_read_callback(pa_stream* p, pa_stream_request_cb_t cb, void* userdata);
Expand Down
44 changes: 40 additions & 4 deletions media/audio/pulse/pulse_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace pulse {

namespace {

static const std::string kGoogleChromeDisplayName = "google-chrome";
static const std::string kChromiumBrowserDisplayName = "chromium-browser";

pa_channel_position ChromiumToPAChannelPosition(Channels channel) {
switch (channel) {
// PulseAudio does not differentiate between left/right and
Expand Down Expand Up @@ -47,6 +50,18 @@ pa_channel_position ChromiumToPAChannelPosition(Channels channel) {
}
}

class ScopedPropertyList {
public:
ScopedPropertyList() : property_list_(pa_proplist_new()) {}
~ScopedPropertyList() { pa_proplist_free(property_list_); }

pa_proplist* get() const { return property_list_; }

private:
pa_proplist* property_list_;
DISALLOW_COPY_AND_ASSIGN(ScopedPropertyList);
};

} // namespace

// static, pa_stream_success_cb_t
Expand Down Expand Up @@ -157,8 +172,18 @@ bool CreateInputStream(pa_threaded_mainloop* mainloop,
pa_channel_map* map = (source_channel_map.channels != 0) ?
&source_channel_map : NULL;

// Create a new recording stream.
*stream = pa_stream_new(context, "RecordStream", &sample_specifications, map);
// Create a new recording stream and
// tells PulseAudio what the stream icon should be.
ScopedPropertyList property_list;
pa_proplist_sets(property_list.get(), PA_PROP_APPLICATION_ICON_NAME,
#if defined(GOOGLE_CHROME_BUILD)
kGoogleChromeDisplayName.c_str());
#else
kChromiumBrowserDisplayName.c_str());
#endif
*stream = pa_stream_new_with_proplist(context, "RecordStream",
&sample_specifications, map,
property_list.get());
RETURN_ON_FAILURE(*stream, "failed to create PA recording stream");

pa_stream_set_state_callback(*stream, stream_callback, user_data);
Expand Down Expand Up @@ -250,7 +275,7 @@ bool CreateOutputStream(pa_threaded_mainloop** mainloop,
sample_specifications.rate = params.sample_rate();
sample_specifications.channels = params.channels();

// Get channel mapping and open playback stream.
// Get channel mapping.
pa_channel_map* map = NULL;
pa_channel_map source_channel_map = ChannelLayoutToPAChannelMap(
params.channel_layout());
Expand All @@ -259,7 +284,18 @@ bool CreateOutputStream(pa_threaded_mainloop** mainloop,
// than the default channel map (NULL).
map = &source_channel_map;
}
*stream = pa_stream_new(*context, "Playback", &sample_specifications, map);

// Open playback stream and
// tell PulseAudio what the stream icon should be.
ScopedPropertyList property_list;
pa_proplist_sets(property_list.get(), PA_PROP_APPLICATION_ICON_NAME,
#if defined(GOOGLE_CHROME_BUILD)
kGoogleChromeDisplayName.c_str());
#else
kChromiumBrowserDisplayName.c_str());
#endif
*stream = pa_stream_new_with_proplist(
*context, "Playback", &sample_specifications, map, property_list.get());
RETURN_ON_FAILURE(*stream, "failed to create PA playback stream");

pa_stream_set_state_callback(*stream, stream_callback, user_data);
Expand Down

0 comments on commit 66f88cc

Please sign in to comment.