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

Unified Diff: media/audio/mac/audio_manager_mac.h

Issue 1903753002: Restores larger output buffer size when output stream requiring smaller size is closed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/mac/audio_manager_mac.h
diff --git a/media/audio/mac/audio_manager_mac.h b/media/audio/mac/audio_manager_mac.h
index f5159e956cc44a249af38a698cf4e3399969f6b5..7c9823931a78475eaed1e14adeab9c2a585fd3ed 100644
--- a/media/audio/mac/audio_manager_mac.h
+++ b/media/audio/mac/audio_manager_mac.h
@@ -111,6 +111,12 @@ class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase {
}
size_t basic_input_streams() const { return basic_input_streams_.size(); }
+#if !defined(NDEBUG)
+ // Prints a list of all existing output streams and there current buffer size
+ // state (required and actual). Does nothing in Release builds.
+ void PrintOutputBufferSizes();
+#endif // !defined(NDEBUG)
+
protected:
~AudioManagerMac() override;
@@ -127,6 +133,22 @@ class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase {
// sample rate has changed, otherwise does nothing.
void HandleDeviceChanges();
+ // Returns true if any active input stream is using the specified |device_id|.
+ bool AudioDeviceIsUsedForInput(AudioDeviceID device_id);
+
+ // This method is called when an output stream has been released and it takes
+ // the given |device_id| and scans all active output streams that are
+ // using this id. The goal is to find a new (larger) I/O buffer size which
+ // can be applied to all active output streams since doing so will save
+ // system resources.
+ // Note that, it is only called if no input stream is also using the device.
+ // Example: two active output streams where #1 wants 1024 as buffer size but
+ // is using 256 since stream #2 wants it. Now, if stream #2 is closed down,
+ // the native I/O buffer size will be increased to 1024 instead of 256.
+ // TODO(henrika): possibly extend the scheme to also take input streams into
+ // account.
+ bool IncreaseIOBufferSizeIfPossible(AudioDeviceID device_id);
+
std::unique_ptr<AudioDeviceListenerMac> output_device_listener_;
// Track the output sample-rate and the default output device

Powered by Google App Engine
This is Rietveld 408576698