Index: head/www/iridium/Makefile =================================================================== --- head/www/iridium/Makefile (revision 477548) +++ head/www/iridium/Makefile (revision 477549) @@ -1,258 +1,259 @@ # Created by: Carlos J. Puga Medina # $FreeBSD$ PORTNAME= iridium PORTVERSION= 2018.5.67 PORTREVISION= 1 CATEGORIES= www MASTER_SITES= https://downloads.iridiumbrowser.de/source/ PKGNAMESUFFIX= -browser DISTNAME= ${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION} MAINTAINER= chromium@FreeBSD.org COMMENT= Iridium browser LICENSE= BSD3CLAUSE LGPL21 MPL11 LICENSE_COMB= multi BUILD_DEPENDS= gperf:devel/gperf \ yasm:devel/yasm \ ffmpeg>=3.2.2,1:multimedia/ffmpeg \ bash:shells/bash \ flock:sysutils/flock \ node:www/node \ ${LOCALBASE}/include/linux/videodev2.h:multimedia/v4l_compat \ ${LOCALBASE}/share/usbids/usb.ids:misc/usbids \ ${PYTHON_PKGNAMEPREFIX}Jinja2>0:devel/py-Jinja2@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}ply>0:devel/py-ply@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}html5lib>0:www/py-html5lib@${PY_FLAVOR} LIB_DEPENDS= libatk-bridge-2.0.so:accessibility/at-spi2-atk \ libspeechd.so:accessibility/speech-dispatcher \ libsnappy.so:archivers/snappy \ libFLAC.so:audio/flac \ libopus.so:audio/opus \ libspeex.so:audio/speex \ libdbus-1.so:devel/dbus \ libdbus-glib-1.so:devel/dbus-glib \ libicuuc.so:devel/icu \ libjsoncpp.so:devel/jsoncpp \ libpci.so:devel/libpci \ libnspr4.so:devel/nspr \ libre2.so:devel/re2 \ libcairo.so:graphics/cairo \ libdrm.so:graphics/libdrm \ libexif.so:graphics/libexif \ libpng.so:graphics/png \ libwebp.so:graphics/webp \ libavcodec.so:multimedia/ffmpeg \ libopenh264.so:multimedia/openh264 \ libfreetype.so:print/freetype2 \ libharfbuzz.so:print/harfbuzz \ libharfbuzz-icu.so:print/harfbuzz-icu \ libgcrypt.so:security/libgcrypt \ libsecret-1.so:security/libsecret \ libnss3.so:security/nss \ libexpat.so:textproc/expat2 \ libfontconfig.so:x11-fonts/fontconfig RUN_DEPENDS= xdg-open:devel/xdg-utils \ noto-lite>0:x11-fonts/noto-lite ONLY_FOR_ARCHS= amd64 i386 + USES= bison desktop-file-utils jpeg ninja perl5 pkgconfig \ python:2.7,build shebangfix tar:xz USE_GL= gl USE_LDCONFIG= ${DATADIR} USE_PERL5= build USE_XORG= x11 xcb xcomposite xcursor xext xdamage xfixes xi \ xorgproto xrandr xrender xscrnsaver xtst USE_GNOME= atk dconf glib20 gtk30 libxml2 libxslt MAKE_ARGS= -C out/${BUILDTYPE} BINARY_ALIAS= python=${PYTHON_CMD} ALL_TARGET= chrome INSTALLS_ICONS= yes EXTRA_PATCHES+= ${FILESDIR}/extra-patch-clang # Run "./out/${BUILDTYPE}/gn args out/${BUILDTYPE} --list" for all variables. # Some parts don't have use_system_* flag, and can be turned on/off by using # replace_gn_files.py script, some parts just turned on/off for target host # OS "target_os == is_bsd", like libusb, libpci. GN_ARGS+= clang_use_chrome_plugins=false \ enable_nacl=false \ enable_one_click_signin=true \ enable_remoting=false \ fieldtrial_testing_like_official_build=true \ is_clang=true \ toolkit_views=true \ treat_warnings_as_errors=false \ use_allocator="none" \ use_allocator_shim=false \ use_aura=true \ use_bundled_fontconfig=false \ use_custom_libcxx=false \ use_gnome_keyring=false \ use_gtk3=true \ use_lld=true \ use_sysroot=false \ use_system_freetype=true \ use_system_harfbuzz=true \ use_system_libjpeg=true \ extra_cxxflags="-I${LOCALBASE}/include" \ extra_ldflags="-L${LOCALBASE}/lib" # TODO: investigate building with these options: # use_system_minigbm GN_BOOTSTRAP_FLAGS= --no-clean --no-rebuild SUB_FILES= iridium-browser.desktop iridium pkg-message SUB_LIST+= COMMENT="${COMMENT}" OPTIONS_DEFINE= CODECS CUPS DEBUG KERBEROS CODECS_DESC= Compile and enable patented codecs like H.264 OPTIONS_GROUP= AUDIO OPTIONS_GROUP_AUDIO= ALSA PULSEAUDIO SNDIO OPTIONS_DEFAULT= ALSA CODECS CUPS KERBEROS OPTIONS_SUB= yes ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib ALSA_RUN_DEPENDS= ${LOCALBASE}/lib/alsa-lib/libasound_module_pcm_oss.so:audio/alsa-plugins \ alsa-lib>=1.1.1_1:audio/alsa-lib ALSA_VARS= GN_ARGS+=use_alsa=true ALSA_VARS_OFF= GN_ARGS+=use_alsa=false CODECS_VARS= GN_ARGS+=ffmpeg_branding="Chrome" \ GN_ARGS+=proprietary_codecs=true \ GN_ARGS+=enable_hevc_demuxing=true CODECS_VARS_OFF= GN_ARGS+=ffmpeg_branding="Chromium" \ GN_ARGS+=proprietary_codecs=false \ GN_ARGS+=enable_hevc_demuxing=false CUPS_LIB_DEPENDS= libcups.so:print/cups CUPS_VARS= GN_ARGS+=use_cups=true CUPS_VARS_OFF= GN_ARGS+=use_cups=false DEBUG_VARS= BUILDTYPE=Debug \ GN_ARGS+=is_debug=true \ GN_ARGS+=is_component_buils=false \ GN_BOOTSTRAP_FLAGS+=--debug \ WANTSPACE="lots of free diskspace (~ 13GB)" DEBUG_VARS_OFF= BUILDTYPE=Release \ GN_ARGS+=is_debug=false \ GN_ARGS+=is_official_build=true \ GN_ARGS+=symbol_level=0 \ GN_ARGS+=remove_webcore_debug_symbols=true \ WANTSPACE="a fair amount of free diskspace (~ 6.5GB)" KERBEROS_VARS= GN_ARGS+=use_kerberos=true KERBEROS_VARS_OFF= GN_ARGS+=use_kerberos=false PULSEAUDIO_LIB_DEPENDS= libpulse.so:audio/pulseaudio PULSEAUDIO_VARS= GN_ARGS+=use_pulseaudio=true PULSEAUDIO_VARS_OFF= GN_ARGS+=use_pulseaudio=false # With SNDIO=on we exclude audio_manager_linux from the build (see # media/audio/BUILD.gn) and use audio_manager_openbsd which does not # support falling back to ALSA. In theory it supports falling back to # PulseAudio, but this is untested. SNDIO_PREVENTS= ALSA PULSEAUDIO SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio SNDIO_VARS= GN_ARGS+=use_sndio=true SNDIO_VARS_OFF= GN_ARGS+=use_sndio=false .include .if ${OPSYS} == FreeBSD && ${OSVERSION} < 1101513 BUILD_DEPENDS+= clang60:devel/llvm60 CC= clang60 CXX= clang++60 EXTRA_PATCHES+= ${FILESDIR}/extra-patch-llvm-port .else BUILD_DEPENDS+= ${LOCALBASE}/bin/ar:devel/binutils EXTRA_PATCHES+= ${FILESDIR}/extra-patch-llvm-base .endif # TODO: -isystem, would be just as ugly as this approach, but more reliably # build would fail without C_INCLUDE_PATH/CPLUS_INCLUDE_PATH env var set. MAKE_ENV+= C_INCLUDE_PATH=${LOCALBASE}/include \ CPLUS_INCLUDE_PATH=${LOCALBASE}/include pre-everything:: @${ECHO_MSG} @${ECHO_MSG} "To build Iridium, you should have around 2GB of memory" @${ECHO_MSG} "and ${WANTSPACE}." @${ECHO_MSG} post-patch: @${REINPLACE_CMD} -e 's|@@PACKAGE@@|iridium|' \ -e 's|@@MENUNAME@@|Iridium Web Browser|' \ ${WRKSRC}/chrome/app/resources/manpage.1.in post-patch-SNDIO-on: @${MKDIR} ${WRKSRC}/media/audio/sndio ${WRKSRC}/media/audio/openbsd @${CP} ${FILESDIR}/sndio_output.* ${WRKSRC}/media/audio/sndio @${CP} ${FILESDIR}/sndio_input.* ${WRKSRC}/media/audio/sndio @${CP} ${FILESDIR}/audio_manager_openbsd.* ${WRKSRC}/media/audio/openbsd pre-configure: # We used to remove bundled libraries to be sure that iridium uses # system libraries and not shippen ones. # cd ${WRKSRC} && ${PYTHON_CMD} \ #./build/linux/unbundle/remove_bundled_libraries.py [list of preserved] cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ${PYTHON_CMD} \ ./build/linux/unbundle/replace_gn_files.py --system-libraries \ ffmpeg flac freetype harfbuzz-ng libdrm libusb libwebp libxml libxslt openh264 opus snappy yasm || ${FALSE} do-configure: # GN generator bootstrapping and generating ninja files cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} CC=${CC} CXX=${CXX} LD=${CXX} \ READELF=${READELF} AR=${AR} NM=${NM} ${PYTHON_CMD} \ ./tools/gn/bootstrap/bootstrap.py ${GN_BOOTSTRAP_FLAGS} cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ./out/${BUILDTYPE}/gn \ gen --args='${GN_ARGS}' out/${BUILDTYPE} # Setup nodejs dependency @${MKDIR} ${WRKSRC}/third_party/node/freebsd/node-freebsd-x64/bin ${LN} -sf ${LOCALBASE}/bin/node ${WRKSRC}/third_party/node/freebsd/node-freebsd-x64/bin/node do-install: @${MKDIR} ${STAGEDIR}${DATADIR} ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.service ${STAGEDIR}${DATADIR} ${INSTALL_MAN} ${WRKSRC}/chrome/app/resources/manpage.1.in \ ${STAGEDIR}${MANPREFIX}/man/man1/iridium.1 .for s in 22 24 48 64 128 256 @${MKDIR} ${STAGEDIR}${PREFIX}/share/icons/hicolor/${s}x${s}/apps ${INSTALL_DATA} ${WRKSRC}/chrome/app/theme/chromium/product_logo_${s}.png \ ${STAGEDIR}${PREFIX}/share/icons/hicolor/${s}x${s}/apps/iridium.png .endfor ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.png ${STAGEDIR}${DATADIR} ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.pak ${STAGEDIR}${DATADIR} .for d in protoc icudtl.dat mksnapshot natives_blob.bin snapshot_blob.bin v8_context_snapshot.bin ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/${d} ${STAGEDIR}${DATADIR} .endfor ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/chrome \ ${STAGEDIR}${DATADIR}/iridium cd ${WRKSRC}/out/${BUILDTYPE} && \ ${COPYTREE_SHARE} "locales resources" ${STAGEDIR}${DATADIR} @${MKDIR} ${STAGEDIR}${DESKTOPDIR} ${INSTALL_DATA} ${WRKDIR}/iridium-browser.desktop \ ${STAGEDIR}${DESKTOPDIR} ${INSTALL_SCRIPT} ${WRKDIR}/iridium ${STAGEDIR}${PREFIX}/bin .for f in libEGL.so libGLESv2.so ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/${f} ${STAGEDIR}${DATADIR} .endfor @${MKDIR} ${STAGEDIR}${DATADIR}/swiftshader .for g in libEGL.so libGLESv2.so ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/swiftshader/${g} \ ${STAGEDIR}${DATADIR}/swiftshader .endfor post-install-DEBUG-on: ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/*.so \ ${STAGEDIR}${DATADIR} ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/character_data_generator \ ${STAGEDIR}${DATADIR} .include Index: head/www/iridium/files/audio_manager_openbsd.cc =================================================================== --- head/www/iridium/files/audio_manager_openbsd.cc (revision 477548) +++ head/www/iridium/files/audio_manager_openbsd.cc (revision 477549) @@ -1,177 +1,179 @@ // 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. #include "base/metrics/histogram_macros.h" #include "base/memory/ptr_util.h" #include "media/audio/openbsd/audio_manager_openbsd.h" #include "media/audio/audio_device_description.h" #include "media/audio/audio_output_dispatcher.h" #if defined(USE_SNDIO) #include "media/audio/sndio/sndio_input.h" #include "media/audio/sndio/sndio_output.h" #else #include "media/audio/fake_audio_manager.h" #endif #include "media/base/limits.h" #include "media/base/media_switches.h" namespace media { enum OpenBSDAudioIO { kPulse, kSndio, kAudioIOMax = kSndio }; #if defined(USE_SNDIO) // Maximum number of output streams that can be open simultaneously. static const int kMaxOutputStreams = 4; // Default sample rate for input and output streams. static const int kDefaultSampleRate = 48000; void AddDefaultDevice(AudioDeviceNames* device_names) { DCHECK(device_names->empty()); device_names->push_front(AudioDeviceName::CreateDefault()); } bool AudioManagerOpenBSD::HasAudioOutputDevices() { return true; } bool AudioManagerOpenBSD::HasAudioInputDevices() { return true; } void AudioManagerOpenBSD::GetAudioInputDeviceNames( AudioDeviceNames* device_names) { DCHECK(device_names->empty()); AddDefaultDevice(device_names); } void AudioManagerOpenBSD::GetAudioOutputDeviceNames( AudioDeviceNames* device_names) { AddDefaultDevice(device_names); } #if defined(USE_SNDIO) const char* AudioManagerOpenBSD::GetName() { return "SNDIO"; } #endif AudioParameters AudioManagerOpenBSD::GetInputStreamParameters( const std::string& device_id) { static const int kDefaultInputBufferSize = 1024; int user_buffer_size = GetUserBufferSize(); int buffer_size = user_buffer_size ? user_buffer_size : kDefaultInputBufferSize; return AudioParameters( AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, - kDefaultSampleRate, buffer_size); + kDefaultSampleRate, 16, buffer_size); } AudioManagerOpenBSD::AudioManagerOpenBSD(std::unique_ptr audio_thread, AudioLogFactory* audio_log_factory) : AudioManagerBase(std::move(audio_thread), audio_log_factory) { DLOG(WARNING) << "AudioManagerOpenBSD"; SetMaxOutputStreamsAllowed(kMaxOutputStreams); } AudioManagerOpenBSD::~AudioManagerOpenBSD() { Shutdown(); } AudioOutputStream* AudioManagerOpenBSD::MakeLinearOutputStream( const AudioParameters& params, const LogCallback& log_callback) { DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); return MakeOutputStream(params); } AudioOutputStream* AudioManagerOpenBSD::MakeLowLatencyOutputStream( const AudioParameters& params, const std::string& device_id, const LogCallback& log_callback) { DLOG_IF(ERROR, !device_id.empty()) << "Not implemented!"; DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); return MakeOutputStream(params); } AudioInputStream* AudioManagerOpenBSD::MakeLinearInputStream( const AudioParameters& params, const std::string& device_id, const LogCallback& log_callback) { DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); return MakeInputStream(params); } AudioInputStream* AudioManagerOpenBSD::MakeLowLatencyInputStream( const AudioParameters& params, const std::string& device_id, const LogCallback& log_callback) { DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); return MakeInputStream(params); } AudioParameters AudioManagerOpenBSD::GetPreferredOutputStreamParameters( const std::string& output_device_id, const AudioParameters& input_params) { // TODO(tommi): Support |output_device_id|. DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!"; static const int kDefaultOutputBufferSize = 2048; ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; int sample_rate = kDefaultSampleRate; int buffer_size = kDefaultOutputBufferSize; + int bits_per_sample = 16; if (input_params.IsValid()) { sample_rate = input_params.sample_rate(); + bits_per_sample = input_params.bits_per_sample(); channel_layout = input_params.channel_layout(); buffer_size = std::min(buffer_size, input_params.frames_per_buffer()); } int user_buffer_size = GetUserBufferSize(); if (user_buffer_size) buffer_size = user_buffer_size; return AudioParameters( AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, - sample_rate, buffer_size); + sample_rate, bits_per_sample, buffer_size); } AudioInputStream* AudioManagerOpenBSD::MakeInputStream( const AudioParameters& params) { DLOG(WARNING) << "MakeInputStream"; return new SndioAudioInputStream(this, AudioDeviceDescription::kDefaultDeviceId, params); } AudioOutputStream* AudioManagerOpenBSD::MakeOutputStream( const AudioParameters& params) { DLOG(WARNING) << "MakeOutputStream"; return new SndioAudioOutputStream(params, this); } #endif std::unique_ptr CreateAudioManager( std::unique_ptr audio_thread, AudioLogFactory* audio_log_factory) { DLOG(WARNING) << "CreateAudioManager"; #if defined(USE_SNDIO) UMA_HISTOGRAM_ENUMERATION("Media.OpenBSDAudioIO", kSndio, kAudioIOMax + 1); return std::make_unique(std::move(audio_thread), audio_log_factory); #else return std::make_unique(std::move(audio_thread), audio_log_factory); #endif } } // namespace media Index: head/www/iridium/files/sndio_input.cc =================================================================== --- head/www/iridium/files/sndio_input.cc (revision 477548) +++ head/www/iridium/files/sndio_input.cc (revision 477549) @@ -1,170 +1,165 @@ // Copyright 2013 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. #include "media/audio/sndio/sndio_input.h" #include #include "base/bind.h" #include "base/logging.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "media/audio/openbsd/audio_manager_openbsd.h" #include "media/audio/audio_manager.h" namespace media { -static const SampleFormat kSampleFormat = kSampleFormatS16; - void sndio_in_onmove(void *arg, int delta) { NOTIMPLEMENTED(); SndioAudioInputStream* self = static_cast(arg); - self->hw_delay_ = delta - self->params_.GetBytesPerFrame(kSampleFormat); + self->hw_delay_ = delta - self->params_.GetBytesPerFrame(); } void *sndio_in_threadstart(void *arg) { NOTIMPLEMENTED(); SndioAudioInputStream* self = static_cast(arg); self->ReadAudio(); return NULL; } SndioAudioInputStream::SndioAudioInputStream(AudioManagerBase* audio_manager, const std::string& device_name, const AudioParameters& params) : audio_manager_(audio_manager), device_name_(device_name), params_(params), - bytes_per_buffer_(params.GetBytesPerBuffer(kSampleFormat)), + bytes_per_buffer_(params.frames_per_buffer() * + (params.channels() * params.bits_per_sample()) / + 8), buffer_duration_(base::TimeDelta::FromMicroseconds( params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond / static_cast(params.sample_rate()))), callback_(NULL), device_handle_(NULL), read_callback_behind_schedule_(false), audio_bus_(AudioBus::Create(params)) { } SndioAudioInputStream::~SndioAudioInputStream() {} bool SndioAudioInputStream::Open() { struct sio_par par; int sig; if (device_handle_) return false; // Already open. if (params_.format() != AudioParameters::AUDIO_PCM_LINEAR && params_.format() != AudioParameters::AUDIO_PCM_LOW_LATENCY) { LOG(WARNING) << "Unsupported audio format."; return false; } sio_initpar(&par); par.rate = params_.sample_rate(); par.pchan = params_.channels(); - par.bits = SampleFormatToBytesPerChannel(kSampleFormat); + par.bits = params_.bits_per_sample(); par.bps = par.bits / 8; par.sig = sig = par.bits != 8 ? 1 : 0; par.le = SIO_LE_NATIVE; par.appbufsz = params_.frames_per_buffer(); sndio_rec_bufsz_ = par.bufsz; sndio_rec_bufsize_ = par.round * par.bps * par.rchan; device_handle_ = sio_open(SIO_DEVANY, SIO_REC, 0); if (device_handle_ == NULL) { LOG(ERROR) << "Couldn't open audio device."; return false; } if (!sio_setpar(device_handle_, &par) || !sio_getpar(device_handle_, &par)) { LOG(ERROR) << "Couldn't set audio parameters."; goto bad_close; } if (par.rate != (unsigned int)params_.sample_rate() || par.pchan != (unsigned int)params_.channels() || - par.bits != (unsigned int)SampleFormatToBytesPerChannel(kSampleFormat) || + par.bits != (unsigned int)params_.bits_per_sample() || par.sig != (unsigned int)sig || (par.bps > 1 && par.le != SIO_LE_NATIVE) || (par.bits != par.bps * 8)) { LOG(ERROR) << "Unsupported audio parameters."; goto bad_close; } sio_onmove(device_handle_, sndio_in_onmove, this); audio_buffer_.reset(new uint8_t[bytes_per_buffer_]); return true; bad_close: sio_close(device_handle_); return false; } void SndioAudioInputStream::Start(AudioInputCallback* callback) { DCHECK(!callback_ && callback); callback_ = callback; StartAgc(); // We start reading data half |buffer_duration_| later than when the // buffer might have got filled, to accommodate some delays in the audio // driver. This could also give us a smooth read sequence going forward. base::TimeDelta delay = buffer_duration_ + buffer_duration_ / 2; next_read_time_ = base::TimeTicks::Now() + delay; if (pthread_create(&thread_, NULL, sndio_in_threadstart, this) != 0) LOG(ERROR) << "Failed to create real-time thread."; } void SndioAudioInputStream::ReadAudio() { NOTIMPLEMENTED(); } void SndioAudioInputStream::Stop() { if (!device_handle_ || !callback_) return; StopAgc(); pthread_join(thread_, NULL); sio_stop(device_handle_); callback_ = NULL; } void SndioAudioInputStream::Close() { if (device_handle_) { sio_close(device_handle_); audio_buffer_.reset(); device_handle_ = NULL; } audio_manager_->ReleaseInputStream(this); } double SndioAudioInputStream::GetMaxVolume() { return static_cast(SIO_MAXVOL); } void SndioAudioInputStream::SetVolume(double volume) { NOTIMPLEMENTED(); } double SndioAudioInputStream::GetVolume() { long current_volume = 0; return static_cast(current_volume); } bool SndioAudioInputStream::IsMuted() { return false; -} - -void SndioAudioInputStream::SetOutputDeviceForAec( - const std::string& output_device_id) { -// Not supported. Do nothing. } } // namespace media Index: head/www/iridium/files/sndio_input.h =================================================================== --- head/www/iridium/files/sndio_input.h (revision 477548) +++ head/www/iridium/files/sndio_input.h (revision 477549) @@ -1,109 +1,108 @@ // Copyright 2013 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. #ifndef MEDIA_AUDIO_SNDIO_SNDIO_INPUT_H_ #define MEDIA_AUDIO_SNDIO_SNDIO_INPUT_H_ #include #include #include #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "media/audio/agc_audio_stream.h" #include "media/audio/audio_io.h" #include "media/audio/audio_device_description.h" #include "media/base/audio_parameters.h" namespace media { class AudioManagerBase; // call-backs invoked from C libraries, thus requiring C linkage extern "C" { // Invoked (on the real-time thread) at each sound card clock tick void sndio_in_onmove(void *arg, int delta); // Invoked (on the real-time thread) whenever the volume changes void sndio_in_onvol(void *arg, unsigned int vol); // Real-time thread entry point void *sndio_in_threadstart(void *arg); } // Provides an input stream for audio capture based on the SNDIO PCM interface. // This object is not thread safe and all methods should be invoked in the // thread that created the object. class SndioAudioInputStream : public AgcAudioStream { public: // Pass this to the constructor if you want to attempt auto-selection // of the audio recording device. static const char kAutoSelectDevice[]; // Create a PCM Output stream for the SNDIO device identified by // |device_name|. If unsure of what to use for |device_name|, use // |kAutoSelectDevice|. SndioAudioInputStream(AudioManagerBase* audio_manager, const std::string& device_name, const AudioParameters& params); ~SndioAudioInputStream() override; // Implementation of AudioInputStream. bool Open() override; void Start(AudioInputCallback* callback) override; void Stop() override; void Close() override; double GetMaxVolume() override; void SetVolume(double volume) override; double GetVolume() override; bool IsMuted() override; - void SetOutputDeviceForAec(const std::string& output_device_id) override; // C-linkage call-backs are friends to access private data friend void sndio_in_onmove(void *arg, int delta); friend void sndio_in_onvol(void *arg, unsigned int vol); friend void *sndio_in_threadstart(void *arg); private: // Logs the error and invokes any registered callbacks. void HandleError(const char* method, int error); // Reads one or more buffers of audio from the device, passes on to the // registered callback and schedules the next read. void ReadAudio(); // Recovers from any device errors if possible. bool Recover(int error); // Non-refcounted pointer back to the audio manager. // The AudioManager indirectly holds on to stream objects, so we don't // want circular references. Additionally, stream objects live on the audio // thread, which is owned by the audio manager and we don't want to addref // the manager from that thread. AudioManagerBase* audio_manager_; std::string device_name_; AudioParameters params_; int bytes_per_buffer_; base::TimeDelta buffer_duration_; // Length of each recorded buffer. AudioInputCallback* callback_; // Valid during a recording session. base::TimeTicks next_read_time_; // Scheduled time for next read callback. struct sio_hdl* device_handle_; // Handle to the SNDIO PCM recording device. std::unique_ptr audio_buffer_; // Buffer used for reading audio data. bool read_callback_behind_schedule_; std::unique_ptr audio_bus_; int hw_delay_; int sndio_rec_bufsize_; int sndio_rec_bufsz_; // High priority thread running RealTimeThread() pthread_t thread_; DISALLOW_COPY_AND_ASSIGN(SndioAudioInputStream); }; } // namespace media #endif // MEDIA_AUDIO_SNDIO_SNDIO_INPUT_H_ Index: head/www/iridium/files/sndio_output.cc =================================================================== --- head/www/iridium/files/sndio_output.cc (revision 477548) +++ head/www/iridium/files/sndio_output.cc (revision 477549) @@ -1,179 +1,177 @@ // 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. #include "base/logging.h" #include "base/time/time.h" #include "base/time/default_tick_clock.h" #include "media/audio/audio_manager_base.h" #include "media/base/audio_timestamp_helper.h" #include "media/audio/sndio/sndio_output.h" namespace media { -static const SampleFormat kSampleFormat = kSampleFormatS16; - void sndio_onmove(void *arg, int delta) { SndioAudioOutputStream* self = static_cast(arg); self->hw_delay = delta; } void sndio_onvol(void *arg, unsigned int vol) { SndioAudioOutputStream* self = static_cast(arg); self->vol = vol; } void *sndio_threadstart(void *arg) { SndioAudioOutputStream* self = static_cast(arg); self->RealTimeThread(); return NULL; } SndioAudioOutputStream::SndioAudioOutputStream(const AudioParameters& params, AudioManagerBase* manager) : manager(manager), params(params), audio_bus(AudioBus::Create(params)), - bytes_per_frame(params.GetBytesPerFrame(kSampleFormat)), + bytes_per_frame(params.GetBytesPerFrame()), state(kClosed), mutex(PTHREAD_MUTEX_INITIALIZER) { } SndioAudioOutputStream::~SndioAudioOutputStream() { if (state != kClosed) Close(); } bool SndioAudioOutputStream::Open() { struct sio_par par; int sig; if (params.format() != AudioParameters::AUDIO_PCM_LINEAR && params.format() != AudioParameters::AUDIO_PCM_LOW_LATENCY) { LOG(WARNING) << "Unsupported audio format."; return false; } sio_initpar(&par); par.rate = params.sample_rate(); par.pchan = params.channels(); - par.bits = SampleFormatToBitsPerChannel(kSampleFormat); + par.bits = params.bits_per_sample(); par.bps = par.bits / 8; par.sig = sig = par.bits != 8 ? 1 : 0; par.le = SIO_LE_NATIVE; par.appbufsz = params.frames_per_buffer(); hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0); if (hdl == NULL) { LOG(ERROR) << "Couldn't open audio device."; return false; } if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par)) { LOG(ERROR) << "Couldn't set audio parameters."; goto bad_close; } if (par.rate != (unsigned int)params.sample_rate() || par.pchan != (unsigned int)params.channels() || - par.bits != (unsigned int)SampleFormatToBitsPerChannel(kSampleFormat) || + par.bits != (unsigned int)params.bits_per_sample() || par.sig != (unsigned int)sig || (par.bps > 1 && par.le != SIO_LE_NATIVE) || (par.bits != par.bps * 8)) { LOG(ERROR) << "Unsupported audio parameters."; goto bad_close; } state = kStopped; volpending = 0; vol = 0; - buffer = new char[audio_bus->frames() * params.GetBytesPerFrame(kSampleFormat)]; + buffer = new char[audio_bus->frames() * params.GetBytesPerFrame()]; sio_onmove(hdl, sndio_onmove, this); sio_onvol(hdl, sndio_onvol, this); return true; bad_close: sio_close(hdl); return false; } void SndioAudioOutputStream::Close() { if (state == kClosed) return; if (state == kRunning) Stop(); state = kClosed; delete [] buffer; sio_close(hdl); manager->ReleaseOutputStream(this); // Calls the destructor } void SndioAudioOutputStream::Start(AudioSourceCallback* callback) { state = kRunning; hw_delay = 0; source = callback; sio_start(hdl); if (pthread_create(&thread, NULL, sndio_threadstart, this) != 0) { LOG(ERROR) << "Failed to create real-time thread."; sio_stop(hdl); state = kStopped; } } void SndioAudioOutputStream::Stop() { if (state == kStopped) return; state = kStopWait; pthread_join(thread, NULL); sio_stop(hdl); state = kStopped; } void SndioAudioOutputStream::SetVolume(double v) { pthread_mutex_lock(&mutex); vol = v * SIO_MAXVOL; volpending = 1; pthread_mutex_unlock(&mutex); } void SndioAudioOutputStream::GetVolume(double* v) { pthread_mutex_lock(&mutex); *v = vol * (1. / SIO_MAXVOL); pthread_mutex_unlock(&mutex); } void SndioAudioOutputStream::RealTimeThread(void) { int avail, count; while (state == kRunning) { // Update volume if needed pthread_mutex_lock(&mutex); if (volpending) { volpending = 0; sio_setvol(hdl, vol); } pthread_mutex_unlock(&mutex); // Get data to play const base::TimeDelta delay = AudioTimestampHelper::FramesToTime(hw_delay, params.sample_rate() * 1000); count = source->OnMoreData(delay, base::TimeTicks::Now(), 0, audio_bus.get()); - audio_bus->ToInterleaved(count, SampleFormatToBytesPerChannel(kSampleFormat), buffer); + audio_bus->ToInterleaved(count, params.bits_per_sample() / 8, buffer); if (count == 0) { // We have to submit something to the device count = audio_bus->frames(); - memset(buffer, 0, count * params.GetBytesPerFrame(kSampleFormat)); + memset(buffer, 0, count * params.GetBytesPerFrame()); LOG(WARNING) << "No data to play, running empty cycle."; } // Submit data to the device - avail = count * params.GetBytesPerFrame(kSampleFormat); + avail = count * params.GetBytesPerFrame(); count = sio_write(hdl, buffer, avail); if (count == 0) { LOG(WARNING) << "Audio device disconnected."; break; } // Update hardware pointer hw_delay += count; } } } // namespace media