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

Unified Diff: media/audio/linux/cras_unified.h

Issue 11959018: Add a unified audio I/O backend for ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 11 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
« no previous file with comments | « media/audio/linux/audio_manager_linux.cc ('k') | media/audio/linux/cras_unified.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/linux/cras_unified.h
diff --git a/media/audio/linux/cras_output.h b/media/audio/linux/cras_unified.h
similarity index 54%
copy from media/audio/linux/cras_output.h
copy to media/audio/linux/cras_unified.h
index 8dffbcec90924ac9da5fd8b2f170dcc47626106a..68dadffff03b76b0aa1649f25d37b274a30d4b89 100644
--- a/media/audio/linux/cras_output.h
+++ b/media/audio/linux/cras_unified.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Creates an output stream based on the cras (ChromeOS audio server) interface.
+// Creates a unified stream based on the cras (ChromeOS audio server) interface.
//
-// CrasOutputStream object is *not* thread-safe and should only be used
+// CrasUnifiedStream object is *not* thread-safe and should only be used
scherkus (not reviewing) 2013/01/23 20:51:21 This diff makes it pretty clear that unified imple
// from the audio thread.
-#ifndef MEDIA_AUDIO_LINUX_CRAS_OUTPUT_H_
-#define MEDIA_AUDIO_LINUX_CRAS_OUTPUT_H_
+#ifndef MEDIA_AUDIO_LINUX_CRAS_UNIFIED_H_
+#define MEDIA_AUDIO_LINUX_CRAS_UNIFIED_H_
#include <alsa/asoundlib.h>
#include <cras_client.h>
@@ -25,15 +25,15 @@ class AudioParameters;
// Implementation of AudioOuputStream for Chrome OS using the Chrome OS audio
// server.
-class MEDIA_EXPORT CrasOutputStream : public AudioOutputStream {
+class MEDIA_EXPORT CrasUnifiedStream : public AudioOutputStream {
public:
// The ctor takes all the usual parameters, plus |manager| which is the
// audio manager who is creating this object.
- CrasOutputStream(const AudioParameters& params, AudioManagerLinux* manager);
+ CrasUnifiedStream(const AudioParameters& params, AudioManagerLinux* manager);
// The dtor is typically called by the AudioManager only and it is usually
- // triggered by calling AudioOutputStream::Close().
- virtual ~CrasOutputStream();
+ // triggered by calling AudioUnifiedStream::Close().
+ virtual ~CrasUnifiedStream();
// Implementation of AudioOutputStream.
virtual bool Open() OVERRIDE;
@@ -43,28 +43,16 @@ class MEDIA_EXPORT CrasOutputStream : public AudioOutputStream {
virtual void SetVolume(double volume) OVERRIDE;
virtual void GetVolume(double* volume) OVERRIDE;
- // Flags indicating the state of the stream.
- enum InternalState {
- kInError = 0,
- kCreated,
- kIsOpened,
- kIsPlaying,
- kIsStopped,
- kIsClosed
- };
- friend std::ostream& operator<<(std::ostream& os, InternalState);
- // Reports the current state for unit testing.
- InternalState state();
-
private:
- // Handles requests to put samples in the provided buffer. This will be
- // called by the audio server when it needs more data.
- static int PutSamples(cras_client* client,
- cras_stream_id_t stream_id,
- uint8* samples,
- size_t frames,
- const timespec* sample_ts,
- void* arg);
+ // Handles captured audio and fills the ouput with audio to be played.
+ static int UnifiedCallback(cras_client* client,
+ cras_stream_id_t stream_id,
+ uint8* input_samples,
+ uint8* output_samples,
+ unsigned int frames,
+ const timespec* input_ts,
+ const timespec* output_ts,
+ void* arg);
// Handles notificaiton that there was an error with the playback stream.
static int StreamError(cras_client* client,
@@ -72,17 +60,16 @@ class MEDIA_EXPORT CrasOutputStream : public AudioOutputStream {
int err,
void* arg);
- // Actually fills buffer with audio data. Called from PutSamples().
- uint32 Render(size_t frames, uint8* buffer, const timespec* sample_ts);
+ // Fills buffer with audio data. Called from UnifiedSamples().
+ uint32 Render(size_t frames,
+ uint8* input_samples,
+ uint8* output_samples,
+ const timespec* input_ts,
+ const timespec* output_ts);
// Deals with an error that occured in the stream. Called from StreamError().
void NotifyStreamError(int err);
- // Functions to safeguard state transitions. All changes to the object state
- // should go through these functions.
- bool CanTransitionTo(InternalState to);
- InternalState TransitionTo(InternalState to);
-
// The client used to communicate with the audio server.
cras_client* client_;
@@ -104,8 +91,8 @@ class MEDIA_EXPORT CrasOutputStream : public AudioOutputStream {
// PCM format for Alsa.
const snd_pcm_format_t pcm_format_;
- // Current state.
- InternalState state_;
+ // True if stream is playing.
+ bool is_playing_;
// Volume level from 0.0 to 1.0.
float volume_;
@@ -116,12 +103,13 @@ class MEDIA_EXPORT CrasOutputStream : public AudioOutputStream {
// Callback to get audio samples.
AudioSourceCallback* source_callback_;
- // Container for retrieving data from AudioSourceCallback::OnMoreData().
- scoped_ptr<AudioBus> audio_bus_;
+ // Container for exchanging data with AudioSourceCallback::OnMoreIOData().
+ scoped_ptr<AudioBus> input_bus_;
+ scoped_ptr<AudioBus> output_bus_;
- DISALLOW_COPY_AND_ASSIGN(CrasOutputStream);
+ DISALLOW_COPY_AND_ASSIGN(CrasUnifiedStream);
};
} // namespace media
-#endif // MEDIA_AUDIO_LINUX_CRAS_OUTPUT_H_
+#endif // MEDIA_AUDIO_LINUX_CRAS_UNIFIED_H_
« no previous file with comments | « media/audio/linux/audio_manager_linux.cc ('k') | media/audio/linux/cras_unified.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698