chromium/media/audio/alsa/alsa_util.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/audio/alsa/alsa_util.h"

#include <stddef.h>

#include <functional>
#include <memory>

#include "base/logging.h"
#include "base/time/time.h"
#include "media/audio/alsa/alsa_wrapper.h"

namespace alsa_util {

namespace {

// Set hardware parameters of PCM. It does the same thing as the corresponding
// part in snd_pcm_set_params() (https://www.alsa-project.org, source code:
// https://github.com/tiwai/alsa-lib/blob/master/src/pcm/pcm.c#L8459), except
// that it configures buffer size and period size both to closest available
// values instead of forcing the buffer size be 4 times of the period size.
int ConfigureHwParams(media::AlsaWrapper* wrapper,
                      snd_pcm_t* handle,
                      snd_pcm_format_t format,
                      snd_pcm_access_t access,
                      unsigned int channels,
                      unsigned int sample_rate,
                      int soft_resample,
                      snd_pcm_uframes_t frames_per_buffer,
                      snd_pcm_uframes_t frames_per_period) {}

// Set software parameters of PCM. It does the same thing as the corresponding
// part in snd_pcm_set_params()
// (https://github.com/tiwai/alsa-lib/blob/master/src/pcm/pcm.c#L8603).
int ConfigureSwParams(media::AlsaWrapper* wrapper,
                      snd_pcm_t* handle,
                      snd_pcm_uframes_t frames_per_buffer,
                      snd_pcm_uframes_t frames_per_period) {}

int SetParams(media::AlsaWrapper* wrapper,
              snd_pcm_t* handle,
              snd_pcm_format_t format,
              unsigned int channels,
              unsigned int rate,
              unsigned int frames_per_buffer,
              unsigned int frames_per_period) {}

}  // namespace

static snd_pcm_t* OpenDevice(media::AlsaWrapper* wrapper,
                             const char* device_name,
                             snd_pcm_stream_t type,
                             int channels,
                             int sample_rate,
                             snd_pcm_format_t pcm_format,
                             int buffer_us,
                             int period_us = 0) {}

static std::string DeviceNameToControlName(const std::string& device_name) {}

int CloseDevice(media::AlsaWrapper* wrapper, snd_pcm_t* handle) {}

snd_pcm_t* OpenCaptureDevice(media::AlsaWrapper* wrapper,
                             const char* device_name,
                             int channels,
                             int sample_rate,
                             snd_pcm_format_t pcm_format,
                             int buffer_us,
                             int period_us) {}

snd_pcm_t* OpenPlaybackDevice(media::AlsaWrapper* wrapper,
                              const char* device_name,
                              int channels,
                              int sample_rate,
                              snd_pcm_format_t pcm_format,
                              int buffer_us) {}

snd_mixer_t* OpenMixer(media::AlsaWrapper* wrapper,
                       const std::string& device_name) {}

void CloseMixer(media::AlsaWrapper* wrapper, snd_mixer_t* mixer,
                const std::string& device_name) {}

snd_mixer_elem_t* LoadCaptureMixerElement(media::AlsaWrapper* wrapper,
                                          snd_mixer_t* mixer) {}

}  // namespace alsa_util