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

Unified Diff: media/audio/cras/cras_output.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: Save params, other cleanups suggested by Dale Created 7 years, 9 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/cras/cras_input.cc ('k') | media/audio/cras/cras_output.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/cras/cras_output.h
diff --git a/media/audio/cras/cras_output.h b/media/audio/cras/cras_output.h
deleted file mode 100644
index dca792384d88a86df96d7f4e1c8f2915fa042e07..0000000000000000000000000000000000000000
--- a/media/audio/cras/cras_output.h
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// 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.
-//
-// CrasOutputStream object is *not* thread-safe and should only be used
-// from the audio thread.
-
-#ifndef MEDIA_AUDIO_CRAS_CRAS_OUTPUT_H_
-#define MEDIA_AUDIO_CRAS_CRAS_OUTPUT_H_
-
-#include <alsa/asoundlib.h>
-#include <cras_client.h>
-#include <ostream>
-
-#include "base/compiler_specific.h"
-#include "base/gtest_prod_util.h"
-#include "media/audio/audio_io.h"
-
-namespace media {
-
-class AudioManagerCras;
-class AudioParameters;
-
-// Implementation of AudioOuputStream for Chrome OS using the Chrome OS audio
-// server.
-class MEDIA_EXPORT CrasOutputStream : 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, AudioManagerCras* manager);
-
- // The dtor is typically called by the AudioManager only and it is usually
- // triggered by calling AudioOutputStream::Close().
- virtual ~CrasOutputStream();
-
- // Implementation of AudioOutputStream.
- virtual bool Open() OVERRIDE;
- virtual void Close() OVERRIDE;
- virtual void Start(AudioSourceCallback* callback) OVERRIDE;
- virtual void Stop() OVERRIDE;
- 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 notificaiton that there was an error with the playback stream.
- static int StreamError(cras_client* client,
- cras_stream_id_t stream_id,
- int err,
- void* arg);
-
- // Actually fills buffer with audio data. Called from PutSamples().
- uint32 Render(size_t frames, uint8* buffer, const timespec* sample_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_;
-
- // ID of the playing stream.
- cras_stream_id_t stream_id_;
-
- // Packet size in samples.
- uint32 samples_per_packet_;
-
- // Size of frame in bytes.
- uint32 bytes_per_frame_;
-
- // Rate in Hz.
- size_t frame_rate_;
-
- // Number of channels.
- size_t num_channels_;
-
- // PCM format for Alsa.
- const snd_pcm_format_t pcm_format_;
-
- // Current state.
- InternalState state_;
-
- // Volume level from 0.0 to 1.0.
- float volume_;
-
- // Audio manager that created us. Used to report that we've been closed.
- AudioManagerCras* manager_;
-
- // Callback to get audio samples.
- AudioSourceCallback* source_callback_;
-
- // Container for retrieving data from AudioSourceCallback::OnMoreData().
- scoped_ptr<AudioBus> audio_bus_;
-
- DISALLOW_COPY_AND_ASSIGN(CrasOutputStream);
-};
-
-} // namespace media
-
-#endif // MEDIA_AUDIO_CRAS_CRAS_OUTPUT_H_
« no previous file with comments | « media/audio/cras/cras_input.cc ('k') | media/audio/cras/cras_output.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698