Merge branch 'staged' into dev

This commit is contained in:
Xiao YiFang 2022-11-16 21:09:44 +08:00
commit 13b7e7cba9
21 changed files with 725 additions and 737 deletions

223
.github/workflows/ffmpeg-macos-build.yml vendored Normal file
View file

@ -0,0 +1,223 @@
name: ffmpeg-macos-build
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12]
steps:
# macos 11.0 默认环境变了,要指定
- name: prepare env
if: ${{ matrix.os == 'macos-11' }}
run: |
softwareupdate --all --install --force
sudo xcode-select --print-path
sudo xcode-select --switch /Library/Developer/CommandLineTools
- name: build ffmpeg
run: |
mkdir build
brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 x265 xvid nasm
brew install speex
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --prefix=../build/ \
--enable-shared \
--disable-static \
--disable-debug \
--disable-programs \
--disable-network \
--disable-avdevice \
--disable-avfilter \
--disable-swscale \
--disable-network \
--disable-muxers \
--disable-demuxers \
--enable-rdft \
--enable-demuxer=aac \
--enable-demuxer=ac3 \
--enable-demuxer=aiff \
--enable-demuxer=ape \
--enable-demuxer=asf \
--enable-demuxer=flac \
--enable-demuxer=matroska \
--enable-demuxer=mp3 \
--enable-demuxer=mpc \
--enable-demuxer=mov \
--enable-demuxer=mpc8 \
--enable-demuxer=ogg \
--enable-demuxer=tta \
--enable-demuxer=wav \
--enable-demuxer=wv \
--disable-bsfs \
--disable-filters \
--disable-parsers \
--enable-parser=aac \
--enable-parser=ac3 \
--enable-parser=mpegaudio \
--disable-protocols \
--disable-indevs \
--disable-outdevs \
--disable-encoders \
--disable-decoders \
--enable-decoder=eightsvx_exp \
--enable-decoder=eightsvx_fib \
--enable-decoder=aac \
--enable-decoder=aac_latm \
--enable-decoder=ac3 \
--enable-decoder=adpcm_4xm \
--enable-decoder=adpcm_adx \
--enable-decoder=adpcm_afc \
--enable-decoder=adpcm_ct \
--enable-decoder=adpcm_ea \
--enable-decoder=adpcm_ea_maxis_xa \
--enable-decoder=adpcm_ea_r1 \
--enable-decoder=adpcm_ea_r2 \
--enable-decoder=adpcm_ea_r3 \
--enable-decoder=adpcm_ea_xas \
--enable-decoder=adpcm_g722 \
--enable-decoder=adpcm_g726 \
--enable-decoder=adpcm_ima_amv \
--enable-decoder=adpcm_ima_apc \
--enable-decoder=adpcm_ima_dk3 \
--enable-decoder=adpcm_ima_dk4 \
--enable-decoder=adpcm_ima_ea_eacs \
--enable-decoder=adpcm_ima_ea_sead \
--enable-decoder=adpcm_ima_iss \
--enable-decoder=adpcm_ima_oki \
--enable-decoder=adpcm_ima_qt \
--enable-decoder=adpcm_ima_smjpeg \
--enable-decoder=adpcm_ima_wav \
--enable-decoder=adpcm_ima_ws \
--enable-decoder=adpcm_ms \
--enable-decoder=adpcm_sbpro_2 \
--enable-decoder=adpcm_sbpro_3 \
--enable-decoder=adpcm_sbpro_4 \
--enable-decoder=adpcm_swf \
--enable-decoder=adpcm_thp \
--enable-decoder=adpcm_xa \
--enable-decoder=adpcm_yamaha \
--enable-decoder=alac \
--enable-decoder=amrnb \
--enable-decoder=libopencore_amrnb \
--enable-decoder=amrwb \
--enable-decoder=libopencore_amrwb \
--enable-decoder=ape \
--enable-decoder=atrac1 \
--enable-decoder=atrac3 \
--enable-decoder=binkaudio_dct \
--enable-decoder=binkaudio_rdft \
--enable-decoder=bmv_audio \
--enable-decoder=comfortnoise \
--enable-decoder=cook \
--enable-decoder=dsicinaudio \
--enable-decoder=dca \
--enable-decoder=eac3 \
--enable-decoder=flac \
--enable-decoder=g723_1 \
--enable-decoder=g729 \
--enable-decoder=gsm \
--enable-decoder=libgsm \
--enable-decoder=gsm_ms \
--enable-decoder=libgsm_ms \
--enable-decoder=iac \
--enable-decoder=imc \
--enable-decoder=interplay_dpcm \
--enable-decoder=mace3 \
--enable-decoder=mace6 \
--enable-decoder=mlp \
--enable-decoder=mp1 \
--enable-decoder=mp1float \
--enable-decoder=mp2 \
--enable-decoder=mp2float \
--enable-decoder=mp3 \
--enable-decoder=mp3float \
--enable-decoder=mp3adu \
--enable-decoder=mp3adufloat \
--enable-decoder=mp3on4 \
--enable-decoder=mp3on4float \
--enable-decoder=als \
--enable-decoder=mpc7 \
--enable-decoder=mpc8 \
--enable-decoder=nellymoser \
--enable-decoder=libopus \
--enable-decoder=paf_audio \
--enable-decoder=pcm_alaw \
--enable-decoder=pcm_bluray \
--enable-decoder=pcm_dvd \
--enable-decoder=pcm_f32be \
--enable-decoder=pcm_f32le \
--enable-decoder=pcm_f64be \
--enable-decoder=pcm_f64le \
--enable-decoder=pcm_lxf \
--enable-decoder=pcm_mulaw \
--enable-decoder=pcm_s16be \
--enable-decoder=pcm_s16be_planar \
--enable-decoder=pcm_s16le \
--enable-decoder=pcm_s16le_planar \
--enable-decoder=pcm_s24be \
--enable-decoder=pcm_s24daud \
--enable-decoder=pcm_s24le \
--enable-decoder=pcm_s24le_planar \
--enable-decoder=pcm_s32be \
--enable-decoder=pcm_s32le \
--enable-decoder=pcm_s32le_planar \
--enable-decoder=pcm_s8 \
--enable-decoder=pcm_s8_planar \
--enable-decoder=pcm_u16be \
--enable-decoder=pcm_u16le \
--enable-decoder=pcm_u24be \
--enable-decoder=pcm_u24le \
--enable-decoder=pcm_u32be \
--enable-decoder=pcm_u32le \
--enable-decoder=pcm_u8 \
--enable-decoder=pcm_zork \
--enable-decoder=qcelp \
--enable-decoder=qdm2 \
--enable-decoder=ra_144 \
--enable-decoder=ra_288 \
--enable-decoder=ralf \
--enable-decoder=roq_dpcm \
--enable-decoder=s302m \
--enable-decoder=shorten \
--enable-decoder=sipr \
--enable-decoder=smackaud \
--enable-decoder=sol_dpcm \
--enable-decoder=sonic \
--enable-decoder=libspeex \
--enable-decoder=tak \
--enable-decoder=truehd \
--enable-decoder=truespeech \
--enable-decoder=tta \
--enable-decoder=twinvq \
--enable-decoder=vima \
--enable-decoder=vmdaudio \
--enable-decoder=vorbis \
--enable-decoder=ffwavesynth \
--enable-decoder=wavpack \
--enable-decoder=ws_snd1 \
--enable-decoder=wmalossless \
--enable-decoder=wmapro \
--enable-decoder=wmav1 \
--enable-decoder=wmav2 \
--enable-decoder=wmavoice \
--enable-decoder=xan_dpcm \
--enable-libspeex
make
sudo make install
ls -al ../build
# otool -L build/*.dylib
# - uses: actions/upload-artifact@v2
# with:
# name: build
# path: build/*

View file

@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
os: [macos-11,macos-12]
qt_ver: [6.4.0]
qt_ver: [6.3.2]
qt_arch: [clang_64]
env:
targetName: GoldenDict
@ -65,8 +65,200 @@ jobs:
brew install autoconf
brew install libtool
brew install opencc
brew install ffmpeg
brew install libao
brew install speex
brew install wavpack
brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 x265 xvid nasm
brew install speex
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --prefix=/usr/local \
--enable-shared \
--disable-static \
--disable-debug \
--disable-programs \
--disable-network \
--disable-avdevice \
--disable-avfilter \
--disable-swscale \
--disable-network \
--disable-muxers \
--disable-demuxers \
--enable-rdft \
--enable-demuxer=aac \
--enable-demuxer=ac3 \
--enable-demuxer=aiff \
--enable-demuxer=ape \
--enable-demuxer=asf \
--enable-demuxer=flac \
--enable-demuxer=matroska \
--enable-demuxer=mp3 \
--enable-demuxer=mpc \
--enable-demuxer=mov \
--enable-demuxer=mpc8 \
--enable-demuxer=ogg \
--enable-demuxer=tta \
--enable-demuxer=wav \
--enable-demuxer=wv \
--disable-bsfs \
--disable-filters \
--disable-parsers \
--enable-parser=aac \
--enable-parser=ac3 \
--enable-parser=mpegaudio \
--disable-protocols \
--disable-indevs \
--disable-outdevs \
--disable-encoders \
--disable-decoders \
--enable-decoder=eightsvx_exp \
--enable-decoder=eightsvx_fib \
--enable-decoder=aac \
--enable-decoder=aac_latm \
--enable-decoder=ac3 \
--enable-decoder=adpcm_4xm \
--enable-decoder=adpcm_adx \
--enable-decoder=adpcm_afc \
--enable-decoder=adpcm_ct \
--enable-decoder=adpcm_ea \
--enable-decoder=adpcm_ea_maxis_xa \
--enable-decoder=adpcm_ea_r1 \
--enable-decoder=adpcm_ea_r2 \
--enable-decoder=adpcm_ea_r3 \
--enable-decoder=adpcm_ea_xas \
--enable-decoder=adpcm_g722 \
--enable-decoder=adpcm_g726 \
--enable-decoder=adpcm_ima_amv \
--enable-decoder=adpcm_ima_apc \
--enable-decoder=adpcm_ima_dk3 \
--enable-decoder=adpcm_ima_dk4 \
--enable-decoder=adpcm_ima_ea_eacs \
--enable-decoder=adpcm_ima_ea_sead \
--enable-decoder=adpcm_ima_iss \
--enable-decoder=adpcm_ima_oki \
--enable-decoder=adpcm_ima_qt \
--enable-decoder=adpcm_ima_smjpeg \
--enable-decoder=adpcm_ima_wav \
--enable-decoder=adpcm_ima_ws \
--enable-decoder=adpcm_ms \
--enable-decoder=adpcm_sbpro_2 \
--enable-decoder=adpcm_sbpro_3 \
--enable-decoder=adpcm_sbpro_4 \
--enable-decoder=adpcm_swf \
--enable-decoder=adpcm_thp \
--enable-decoder=adpcm_xa \
--enable-decoder=adpcm_yamaha \
--enable-decoder=alac \
--enable-decoder=amrnb \
--enable-decoder=libopencore_amrnb \
--enable-decoder=amrwb \
--enable-decoder=libopencore_amrwb \
--enable-decoder=ape \
--enable-decoder=atrac1 \
--enable-decoder=atrac3 \
--enable-decoder=binkaudio_dct \
--enable-decoder=binkaudio_rdft \
--enable-decoder=bmv_audio \
--enable-decoder=comfortnoise \
--enable-decoder=cook \
--enable-decoder=dsicinaudio \
--enable-decoder=dca \
--enable-decoder=eac3 \
--enable-decoder=flac \
--enable-decoder=g723_1 \
--enable-decoder=g729 \
--enable-decoder=gsm \
--enable-decoder=libgsm \
--enable-decoder=gsm_ms \
--enable-decoder=libgsm_ms \
--enable-decoder=iac \
--enable-decoder=imc \
--enable-decoder=interplay_dpcm \
--enable-decoder=mace3 \
--enable-decoder=mace6 \
--enable-decoder=mlp \
--enable-decoder=mp1 \
--enable-decoder=mp1float \
--enable-decoder=mp2 \
--enable-decoder=mp2float \
--enable-decoder=mp3 \
--enable-decoder=mp3float \
--enable-decoder=mp3adu \
--enable-decoder=mp3adufloat \
--enable-decoder=mp3on4 \
--enable-decoder=mp3on4float \
--enable-decoder=als \
--enable-decoder=mpc7 \
--enable-decoder=mpc8 \
--enable-decoder=mp3*,pcm* \
--enable-decoder=nellymoser \
--enable-decoder=libopus \
--enable-decoder=paf_audio \
--enable-decoder=pcm_alaw \
--enable-decoder=pcm_bluray \
--enable-decoder=pcm_dvd \
--enable-decoder=pcm_f32be \
--enable-decoder=pcm_f32le \
--enable-decoder=pcm_f64be \
--enable-decoder=pcm_f64le \
--enable-decoder=pcm_lxf \
--enable-decoder=pcm_mulaw \
--enable-decoder=pcm_s16be \
--enable-decoder=pcm_s16be_planar \
--enable-decoder=pcm_s16le \
--enable-decoder=pcm_s16le_planar \
--enable-decoder=pcm_s24be \
--enable-decoder=pcm_s24daud \
--enable-decoder=pcm_s24le \
--enable-decoder=pcm_s24le_planar \
--enable-decoder=pcm_s32be \
--enable-decoder=pcm_s32le \
--enable-decoder=pcm_s32le_planar \
--enable-decoder=pcm_s8 \
--enable-decoder=pcm_s8_planar \
--enable-decoder=pcm_u16be \
--enable-decoder=pcm_u16le \
--enable-decoder=pcm_u24be \
--enable-decoder=pcm_u24le \
--enable-decoder=pcm_u32be \
--enable-decoder=pcm_u32le \
--enable-decoder=pcm_u8 \
--enable-decoder=pcm_zork \
--enable-decoder=qcelp \
--enable-decoder=qdm2 \
--enable-decoder=ra_144 \
--enable-decoder=ra_288 \
--enable-decoder=ralf \
--enable-decoder=roq_dpcm \
--enable-decoder=s302m \
--enable-decoder=shorten \
--enable-decoder=sipr \
--enable-decoder=smackaud \
--enable-decoder=sol_dpcm \
--enable-decoder=sonic \
--enable-decoder=libspeex \
--enable-decoder=tak \
--enable-decoder=truehd \
--enable-decoder=truespeech \
--enable-decoder=tta \
--enable-decoder=twinvq \
--enable-decoder=vima \
--enable-decoder=vmdaudio \
--enable-decoder=vorbis \
--enable-decoder=ffwavesynth \
--enable-decoder=wavpack \
--enable-decoder=ws_snd1 \
--enable-decoder=wmalossless \
--enable-decoder=wmapro \
--enable-decoder=wmav1 \
--enable-decoder=wmav2 \
--enable-decoder=wmavoice \
--enable-decoder=xan_dpcm \
--enable-libmp3lame \
--enable-libspeex
make
sudo make install
cd ..
brew install libiconv
brew install lzo bzip2
brew install libogg
@ -74,10 +266,8 @@ jobs:
brew install libtiff
brew install libvorbis
brew install hunspell
wget ftp://ftp.sra.co.jp/pub/misc/eb/eb-4.4.3.tar.bz2
tar xvjf eb-4.4.3.tar.bz2
cd eb-4.4.3 && ./configure && make -j 8 && sudo make install && cd ..
#brew install qt # or use official offline installer
git clone https://github.com/xiaoyifang/eb.git
cd eb && ./configure && make -j 8 && sudo make install && cd ..
brew install xz lzo
brew install pkg-config
brew install create-dmg
@ -85,8 +275,6 @@ jobs:
run: |
qmake CONFIG+=release CONFIG+=no_macos_universal CONFIG+=zim_support CONFIG+=no_extra_tiff_handler #CONFIG+=no_epwing_support # CONFIG+=no_ffmpeg_player #CONFIG+=no_qtmultimedia_player
make -j8
# libao was specificly build https://github.com/goldendict/goldendict/pull/377
cp -fR maclibs/lib/libao* GoldenDict.app/Contents/Frameworks/
# # 打包
# - name: package

View file

@ -2029,8 +2029,8 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
if ( result == saveSoundAction )
{
// Audio data
if ( name.indexOf( '.' ) < 0 )
name += ".wav";
// if ( name.indexOf( '.' ) < 0 )
// name += ".wav";
fileName = savePath + "/" + name;
fileName = QFileDialog::getSaveFileName( parentWidget(), tr( "Save sound" ),

190
audiooutput.cpp Normal file
View file

@ -0,0 +1,190 @@
#include "audiooutput.h"
#include <QAudioFormat>
#include <QDebug>
#include <QtConcurrent/qtconcurrentrun.h>
#include <QFuture>
#include <QWaitCondition>
#include <QCoreApplication>
#include <QThreadPool>
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#include <QAudioOutput>
#else
#include <QAudioSink>
#endif
#include <QtGlobal>
#include <QBuffer>
// take reference from this file (https://github.com/valbok/QtAVPlayer/blob/6cc30e484b354d59511c9a60fabced4cb7c57c8e/src/QtAVPlayer/qavaudiooutput.cpp)
// and make some changes.
static QAudioFormat format( int sampleRate, int channelCount )
{
QAudioFormat out;
out.setSampleRate( sampleRate );
out.setChannelCount( channelCount );
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
out.setByteOrder( QAudioFormat::LittleEndian );
out.setCodec( QLatin1String( "audio/pcm" ) );
#endif
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
out.setSampleSize( 16 );
out.setSampleType( QAudioFormat::SignedInt );
#else
out.setSampleFormat( QAudioFormat::Int16 );
#endif
return out;
}
class AudioOutputPrivate: public QIODevice
{
public:
AudioOutputPrivate()
{
open( QIODevice::ReadOnly );
threadPool.setMaxThreadCount( 1 );
}
QFuture< void > audioPlayFuture;
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
using AudioOutput = QAudioOutput;
#else
using AudioOutput = QAudioSink;
#endif
AudioOutput * audioOutput = nullptr;
QByteArray buffer;
qint64 offset = 0;
bool quit = 0;
QMutex mutex;
QWaitCondition cond;
QThreadPool threadPool;
int sampleRate = 0;
int channels = 0;
void setAudioFormat( int _sampleRate, int _channels )
{
sampleRate = _sampleRate;
channels = _channels;
}
qint64 readData( char * data, qint64 len ) override
{
if( !len )
return 0;
QMutexLocker locker( &mutex );
qint64 bytesWritten = 0;
while( len && !quit )
{
if( buffer.isEmpty() )
{
// Wait for more frames
if( bytesWritten == 0 )
cond.wait( &mutex );
if( buffer.isEmpty() )
break;
}
auto sampleData = buffer.data();
const int toWrite = qMin( (qint64) buffer.size(), len );
memcpy( &data[bytesWritten], sampleData, toWrite );
buffer.remove( 0, toWrite );
bytesWritten += toWrite;
// data += toWrite;
len -= toWrite;
}
return bytesWritten;
}
qint64 writeData( const char *, qint64 ) override { return 0; }
qint64 size() const override { return buffer.size(); }
qint64 bytesAvailable() const override { return buffer.size(); }
bool isSequential() const override { return true; }
bool atEnd() const override { return buffer.isEmpty(); }
void init( const QAudioFormat & fmt )
{
if( !audioOutput || ( fmt.isValid() && audioOutput->format() != fmt )
|| audioOutput->state() == QAudio::StoppedState )
{
if( audioOutput )
audioOutput->deleteLater();
audioOutput = new AudioOutput( fmt );
QObject::connect( audioOutput, &AudioOutput::stateChanged, audioOutput, [ & ]( QAudio::State state ) {
switch( state )
{
case QAudio::StoppedState:
if( audioOutput->error() != QAudio::NoError )
qWarning() << "QAudioOutput stopped:" << audioOutput->error();
break;
default:
break;
}
} );
audioOutput->start( this );
}
// audioOutput->setVolume(volume);
}
void doPlayAudio()
{
while( !quit )
{
QMutexLocker locker( &mutex );
cond.wait( &mutex, 10 );
auto fmt = sampleRate == 0 ? QAudioFormat() : format( sampleRate, channels );
locker.unlock();
if( fmt.isValid() )
init( fmt );
QCoreApplication::processEvents();
}
if( audioOutput )
{
audioOutput->stop();
audioOutput->deleteLater();
}
audioOutput = nullptr;
}
};
AudioOutput::AudioOutput( QObject * parent ): QObject( parent ), d_ptr( new AudioOutputPrivate )
{
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
d_ptr->audioPlayFuture = QtConcurrent::run( &d_ptr->threadPool, d_ptr.data(), &AudioOutputPrivate::doPlayAudio );
#else
d_ptr->audioPlayFuture = QtConcurrent::run( &d_ptr->threadPool, &AudioOutputPrivate::doPlayAudio, d_ptr.data() );
#endif
}
void AudioOutput::setAudioFormat( int sampleRate, int channels ) { d_ptr->setAudioFormat( sampleRate, channels ); }
AudioOutput::~AudioOutput()
{
Q_D( AudioOutput );
d->quit = true;
d->cond.wakeAll();
d->audioPlayFuture.waitForFinished();
}
bool AudioOutput::play( const uint8_t * data, qint64 len )
{
Q_D( AudioOutput );
if( d->quit )
return false;
QMutexLocker locker( &d->mutex );
auto cuint = const_cast< uint8_t * >( data );
auto cptr = reinterpret_cast< char * >( cuint );
d->buffer.append( cptr, len );
d->cond.wakeAll();
return true;
}

25
audiooutput.h Normal file
View file

@ -0,0 +1,25 @@
#ifndef AUDIOOUTPUT_H
#define AUDIOOUTPUT_H
#include <QObject>
#include <QScopedPointer>
class AudioOutputPrivate;
class AudioOutput: public QObject
{
public:
AudioOutput( QObject * parent = nullptr );
~AudioOutput();
bool play( const uint8_t * data, qint64 len );
void setAudioFormat( int sampleRate, int channels );
protected:
QScopedPointer< AudioOutputPrivate > d_ptr;
private:
Q_DISABLE_COPY( AudioOutput )
Q_DECLARE_PRIVATE( AudioOutput )
};
#endif // AUDIOOUTPUT_H

View file

@ -224,7 +224,7 @@ public:
private:
#ifdef MAKE_FFMPEG_PLAYER
static InternalPlayerBackend ffmpeg()
{ return InternalPlayerBackend( "FFmpeg+libao" ); }
{ return InternalPlayerBackend( "FFmpeg" ); }
#endif
#ifdef MAKE_QTMULTIMEDIA_PLAYER

View file

@ -281,6 +281,11 @@ bool FavoritesPaneWidget::setDataFromXml( QString const & dataStr )
return m_favoritesModel->setDataFromXml( dataStr );
}
bool FavoritesPaneWidget::setDataFromTxt( QString const & dataStr )
{
return m_favoritesModel->setDataFromTxt( dataStr );
}
void FavoritesPaneWidget::setSaveInterval( unsigned interval )
{
if( timerId )
@ -1163,3 +1168,23 @@ bool FavoritesModel::setDataFromXml( QString const & dataStr )
dirty = true;
return true;
}
bool FavoritesModel::setDataFromTxt( QString const & dataStr )
{
auto words = dataStr.split('\n',Qt::SkipEmptyParts);
beginResetModel();
if( rootItem )
delete rootItem;
rootItem = new TreeItem( QVariant(), 0, TreeItem::Root );
for(auto const & word : words){
rootItem->appendChild( new TreeItem( word, rootItem, TreeItem::Word ) );
}
endResetModel();
dirty = true;
return true;
}

View file

@ -46,6 +46,7 @@ public:
void getDataInXml( QByteArray & dataStr );
void getDataInPlainText( QString & dataStr );
bool setDataFromXml( QString const & dataStr );
bool setDataFromTxt( QString const & dataStr );
void setFocusOnTree()
{ m_favoritesTree->setFocus(); }
@ -216,6 +217,7 @@ public:
void getDataInXml( QByteArray & dataStr );
void getDataInPlainText( QString & dataStr );
bool setDataFromXml( QString const & dataStr );
bool setDataFromTxt( QString const & dataStr );
void saveData();

View file

@ -1,20 +1,11 @@
#ifdef MAKE_FFMPEG_PLAYER
#include "audiooutput.h"
#include "ffmpegaudio.hh"
#include <math.h>
#include <errno.h>
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#endif
#ifndef UINT64_C
#define UINT64_C(c) (c ## ULL)
#endif
#include <ao/ao.h>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
@ -27,7 +18,11 @@ extern "C" {
#include <QDebug>
#include <vector>
#if( QT_VERSION >= QT_VERSION_CHECK( 6, 2, 0 ) )
#include <QMediaDevices>
#include <QAudioDevice>
#endif
#include "gddebug.hh"
#include "utils.hh"
@ -53,13 +48,13 @@ AudioService & AudioService::instance()
AudioService::AudioService()
{
ao_initialize();
// ao_initialize();
}
AudioService::~AudioService()
{
emit cancelPlaying( true );
ao_shutdown();
// ao_shutdown();
}
void AudioService::playMemory( const char * ptr, int size )
@ -100,7 +95,8 @@ struct DecoderContext
AVCodecContext * codecContext_;
AVIOContext * avioContext_;
AVStream * audioStream_;
ao_device * aoDevice_;
// ao_device * aoDevice_;
AudioOutput * audioOutput;
bool avformatOpened_;
SwrContext *swr_;
@ -113,7 +109,7 @@ struct DecoderContext
bool openOutputDevice( QString & errorString );
void closeOutputDevice();
bool play( QString & errorString );
bool normalizeAudio( AVFrame * frame, vector<char> & samples );
bool normalizeAudio( AVFrame * frame, vector<uint8_t> & samples );
void playFrame( AVFrame * frame );
};
@ -126,7 +122,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
codecContext_( NULL ),
avioContext_( NULL ),
audioStream_( NULL ),
aoDevice_( NULL ),
audioOutput( new AudioOutput ),
avformatOpened_( false ),
swr_( NULL )
{
@ -243,12 +239,6 @@ bool DecoderContext::openCodec( QString & errorString )
gdDebug( "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
if ( codecContext_->sample_fmt == AV_SAMPLE_FMT_S32 ||
codecContext_->sample_fmt == AV_SAMPLE_FMT_S32P ||
codecContext_->sample_fmt == AV_SAMPLE_FMT_FLT ||
codecContext_->sample_fmt == AV_SAMPLE_FMT_FLTP ||
codecContext_->sample_fmt == AV_SAMPLE_FMT_DBL ||
codecContext_->sample_fmt == AV_SAMPLE_FMT_DBLP )
{
swr_ = swr_alloc_set_opts( NULL,
codecContext_->channel_layout,
@ -317,75 +307,25 @@ void DecoderContext::closeCodec()
bool DecoderContext::openOutputDevice( QString & errorString )
{
// Prepare for audio output
int aoDriverId = ao_default_driver_id();
ao_info * aoDrvInfo = ao_driver_info( aoDriverId );
if ( aoDriverId < 0 || !aoDrvInfo )
{
errorString = QObject::tr( "Cannot find usable audio output device." );
return false;
}
ao_sample_format aoSampleFormat;
memset (&aoSampleFormat, 0, sizeof(aoSampleFormat) );
aoSampleFormat.channels = codecContext_->channels;
aoSampleFormat.rate = codecContext_->sample_rate;
aoSampleFormat.byte_format = AO_FMT_NATIVE;
aoSampleFormat.matrix = 0;
aoSampleFormat.bits = qMin( 16, av_get_bytes_per_sample( codecContext_->sample_fmt ) << 3 );
if ( aoSampleFormat.bits == 0 )
{
errorString = QObject::tr( "Unsupported sample format." );
return false;
}
gdDebug( "ao_open_live(): %s: channels: %d, rate: %d, bits: %d\n",
aoDrvInfo->name, aoSampleFormat.channels, aoSampleFormat.rate, aoSampleFormat.bits );
aoDevice_ = ao_open_live( aoDriverId, &aoSampleFormat, NULL );
if ( !aoDevice_ )
{
errorString = QObject::tr( "ao_open_live() failed: " );
switch ( errno )
{
case AO_ENODRIVER:
errorString += QObject::tr( "No driver." );
break;
case AO_ENOTLIVE:
errorString += QObject::tr( "This driver is not a live output device." );
break;
case AO_EBADOPTION:
errorString += QObject::tr( "A valid option key has an invalid value." );
break;
case AO_EOPENDEVICE:
errorString += QObject::tr( "Cannot open the device: %1, channels: %2, rate: %3, bits: %4." )
.arg( aoDrvInfo->short_name )
.arg( aoSampleFormat.channels )
.arg( aoSampleFormat.rate )
.arg( aoSampleFormat.bits );
break;
default:
errorString += QObject::tr( "Unknown error." );
break;
}
// only check device when qt version is greater than 6.2
#if (QT_VERSION >= QT_VERSION_CHECK(6,2,0))
QAudioDevice m_outputDevice = QMediaDevices::defaultAudioOutput();
if(m_outputDevice.isNull()){
errorString += QObject::tr( "Can not found default audio output device" );
return false;
}
#endif
audioOutput->setAudioFormat( codecContext_->sample_rate, codecContext_->channels );
return true;
}
void DecoderContext::closeOutputDevice()
{
// ao_close() is synchronous, it will wait until all audio streams flushed
if ( aoDevice_ )
{
ao_close( aoDevice_ );
aoDevice_ = NULL;
}
// if(audioOutput){
// delete audioOutput;
// audioOutput = 0;
// }
}
bool DecoderContext::play( QString & errorString )
@ -440,12 +380,11 @@ bool DecoderContext::play( QString & errorString )
return true;
}
bool DecoderContext::normalizeAudio( AVFrame * frame, vector<char> & samples )
bool DecoderContext::normalizeAudio( AVFrame * frame, vector<uint8_t > & samples )
{
int lineSize = 0;
int dataSize = av_samples_get_buffer_size( &lineSize, codecContext_->channels,
frame->nb_samples, codecContext_->sample_fmt, 1 );
// Portions from: https://code.google.com/p/lavfilters/source/browse/decoder/LAVAudio/LAVAudio.cpp
// But this one use 8, 16, 32 bits integer, respectively.
switch ( codecContext_->sample_fmt )
@ -522,9 +461,12 @@ void DecoderContext::playFrame( AVFrame * frame )
if ( !frame )
return;
vector<char> samples;
vector<uint8_t> samples;
if ( normalizeAudio( frame, samples ) )
ao_play( aoDevice_, &samples.front(), samples.size() );
{
// ao_play( aoDevice_, &samples.front(), samples.size() );
audioOutput->play(&samples.front(), samples.size());
}
}
DecoderThread::DecoderThread( QByteArray const & audioData, QObject * parent ) :

View file

@ -46,13 +46,14 @@ greaterThan(QT_MAJOR_VERSION, 5): QT += webenginecore core5compat
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00
# QMediaPlayer is not available in Qt4.
!CONFIG( no_qtmultimedia_player ) {
QT += multimedia
DEFINES += MAKE_QTMULTIMEDIA_PLAYER
}
!CONFIG( no_ffmpeg_player ) {
# ffmpeg depended on multimedia now.
QT += multimedia
DEFINES += MAKE_FFMPEG_PLAYER
}
@ -115,8 +116,7 @@ win32 {
-lvorbis \
-logg
!CONFIG( no_ffmpeg_player ) {
LIBS += -lao \
-lswresample \
LIBS += -lswresample \
-lavutil \
-lavformat \
-lavcodec
@ -151,8 +151,7 @@ unix:!mac {
ogg \
hunspell
!CONFIG( no_ffmpeg_player ) {
PKGCONFIG += ao \
libavutil \
PKGCONFIG += libavutil \
libavformat \
libavcodec \
libswresample \
@ -205,8 +204,7 @@ mac {
-llzo2
!CONFIG( no_ffmpeg_player ) {
LIBS += -lao \
-lswresample \
LIBS += -lswresample \
-lavutil \
-lavformat \
-lavcodec
@ -263,6 +261,7 @@ HEADERS += folding.hh \
ankiconnector.h \
article_inspect.h \
articlewebpage.h \
audiooutput.h \
base/globalregex.hh \
globalbroadcaster.h \
headwordsmodel.h \
@ -407,6 +406,7 @@ SOURCES += folding.cc \
ankiconnector.cpp \
article_inspect.cpp \
articlewebpage.cpp \
audiooutput.cpp \
base/globalregex.cc \
globalbroadcaster.cpp \
headwordsmodel.cpp \

View file

@ -1,139 +0,0 @@
/*
*
* ao.h
*
* Original Copyright (C) Aaron Holtzman - May 1999
* Modifications Copyright (C) Stan Seibert - July 2000, July 2001
* More Modifications Copyright (C) Jack Moffitt - October 2000
*
* This file is part of libao, a cross-platform audio outputlibrary. See
* README for a history of this source code.
*
* libao is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* libao is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __AO_H__
#define __AO_H__
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "os_types.h"
/* --- Constants ---*/
#define AO_TYPE_LIVE 1
#define AO_TYPE_FILE 2
#define AO_ENODRIVER 1
#define AO_ENOTFILE 2
#define AO_ENOTLIVE 3
#define AO_EBADOPTION 4
#define AO_EOPENDEVICE 5
#define AO_EOPENFILE 6
#define AO_EFILEEXISTS 7
#define AO_EBADFORMAT 8
#define AO_EFAIL 100
#define AO_FMT_LITTLE 1
#define AO_FMT_BIG 2
#define AO_FMT_NATIVE 4
/* --- Structures --- */
typedef struct ao_info {
int type; /* live output or file output? */
char *name; /* full name of driver */
char *short_name; /* short name of driver */
char *author; /* driver author */
char *comment; /* driver comment */
int preferred_byte_format;
int priority;
char **options;
int option_count;
} ao_info;
typedef struct ao_functions ao_functions;
typedef struct ao_device ao_device;
typedef struct ao_sample_format {
int bits; /* bits per sample */
int rate; /* samples per second (in a single channel) */
int channels; /* number of audio channels */
int byte_format; /* Byte ordering in sample, see constants below */
char *matrix; /* input channel location/ordering */
} ao_sample_format;
typedef struct ao_option {
char *key;
char *value;
struct ao_option *next;
} ao_option;
#if defined(AO_BUILDING_LIBAO)
#include "ao_private.h"
#endif
/* --- Functions --- */
/* library setup/teardown */
void ao_initialize(void);
void ao_shutdown(void);
/* device setup/playback/teardown */
int ao_append_global_option(const char *key,
const char *value);
int ao_append_option(ao_option **options,
const char *key,
const char *value);
void ao_free_options(ao_option *options);
ao_device* ao_open_live(int driver_id,
ao_sample_format *format,
ao_option *option);
ao_device* ao_open_file(int driver_id,
const char *filename,
int overwrite,
ao_sample_format *format,
ao_option *option);
int ao_play(ao_device *device,
char *output_samples,
uint_32 num_bytes);
int ao_close(ao_device *device);
/* driver information */
int ao_driver_id(const char *short_name);
int ao_default_driver_id(void);
ao_info *ao_driver_info(int driver_id);
ao_info **ao_driver_info_list(int *driver_count);
const char *ao_file_extension(int driver_id);
/* miscellaneous */
int ao_is_big_endian(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __AO_H__ */

View file

@ -1,211 +0,0 @@
/*
*
* ao_private.c
*
* Copyright (C) Stan Seibert - July 2001
*
* This file is part of libao, a cross-platform audio output library. See
* README for a history of this source code.
*
* libao is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* libao is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __AO_PRIVATE_H__
#define __AO_PRIVATE_H__
/* --- Operating System Compatibility --- */
/*
OpenBSD systems with a.out binaries require dlsym()ed symbols to be
prepended with an underscore, so we need the following nasty #ifdef
hack.
*/
#if defined(__OpenBSD__) && !defined(__ELF__)
#define dlsym(h,s) dlsym(h, "_" s)
#endif
/* RTLD_NOW is the preferred symbol resolution behavior, but
* some platforms do not support it. The autoconf script will have
* already defined DLOPEN_FLAG if the default is unacceptable on the
* current platform.
*
* ALSA requires RTLD_GLOBAL.
*/
#if !defined(DLOPEN_FLAG)
#define DLOPEN_FLAG (RTLD_NOW | RTLD_GLOBAL)
#endif
/* --- Constants --- */
#ifndef AO_SYSTEM_CONFIG
#define AO_SYSTEM_CONFIG "/etc/libao.conf"
#endif
#ifndef AO_USER_CONFIG
#define AO_USER_CONFIG "/.libao"
#endif
/* --- Structures --- */
typedef struct ao_config {
char *default_driver;
} ao_config;
typedef enum {
AO_OUTPUT_MATRIX_UNDEFINED=0, /* matrix unset */
AO_OUTPUT_MATRIX_FIXED=1, /* fixed, immutable channel order, eg, ALSA */
AO_OUTPUT_MATRIX_COLLAPSIBLE=2, /* fixed order but only used channels sent, eg MACOS */
AO_OUTPUT_MATRIX_PERMUTABLE=3, /* channel map is fully permutable. eg Pulse */
} ao_outorder;
struct ao_device {
int type; /* live output or file output? */
int driver_id;
ao_functions *funcs;
FILE *file; /* File for output if this is a file driver */
/* input not necessarily == output. Right now, byte order, channel
count, and channel mappings may be altered. */
int client_byte_format;
int machine_byte_format;
int driver_byte_format;
char *swap_buffer;
int swap_buffer_size; /* Bytes allocated to swap_buffer */
int input_channels;
int output_channels;
int bytewidth;
int rate;
ao_outorder output_matrix_order;
char *output_matrix; /* physical output channel
ordering/numbering matrix set by
driver if there's a channel
name->number mapping useful to the
backend driver in some way. Eg,
Pulse has fully permutable input
channel masks, but specific channels
locations (eg, 'Center') still have
assigned numbers even if not a
specific slot int he input
interleave. */
int output_mask;
int *input_map; /* input permutation mapping from each
input channel to a location in the
output_matrix. Made by ao_open,
intended for convenience use by
driver in device open. */
char *inter_matrix; /* channel matrix as presented to the
backend API */
int *inter_permute; /* maps from each channel in the
inter_matrix back to an input channel
(if any) */
void *internal; /* Pointer to driver-specific data */
int verbose;
};
struct ao_functions {
int (*test)(void);
ao_info* (*driver_info)(void);
int (*device_init)(ao_device *device);
int (*set_option)(ao_device *device, const char *key,
const char *value);
int (*open)(ao_device *device, ao_sample_format *format);
int (*play)(ao_device *device, const char *output_samples,
uint_32 num_bytes);
int (*close)(ao_device *device);
void (*device_clear)(ao_device *device);
const char* (*file_extension)(void);
};
/* --- Functions --- */
void ao_read_config_files (ao_config *config);
#define adebug(format, args...) {\
if(!device || device->verbose==2){ \
if(strcmp(format,"\n")){ \
if(device && device->funcs->driver_info()->short_name){ \
fprintf(stderr,"ao_%s debug: " format,device->funcs->driver_info()->short_name,## args); \
}else{ \
fprintf(stderr,"debug: " format,## args); \
} \
}else{ \
fprintf(stderr,"\n"); \
} \
} \
}
#define averbose(format, args...) {\
if(!device || device->verbose>0){ \
if(strcmp(format,"\n")){ \
if(device && device->funcs->driver_info()->short_name){ \
fprintf(stderr,"ao_%s info: " format,device->funcs->driver_info()->short_name,## args); \
}else{ \
fprintf(stderr,"info: " format,## args); \
} \
}else{ \
fprintf(stderr,"\n"); \
} \
} \
}
#define ainfo(format, args...) {\
if(!device || device->verbose>=0){ \
if(strcmp(format,"\n")){ \
if(device && device->funcs->driver_info()->short_name){ \
fprintf(stderr,"ao_%s info: " format,device->funcs->driver_info()->short_name,## args); \
}else{ \
fprintf(stderr,"info: " format,## args); \
} \
}else{ \
fprintf(stderr,"\n"); \
} \
} \
}
#define awarn(format, args...) {\
if(!device || device->verbose>=0){ \
if(strcmp(format,"\n")){ \
if(device && device->funcs->driver_info()->short_name){ \
fprintf(stderr,"ao_%s WARNING: " format,device->funcs->driver_info()->short_name,## args); \
}else{ \
fprintf(stderr,"WARNING: " format,## args); \
} \
}else{ \
fprintf(stderr,"\n"); \
} \
} \
}
#define aerror(format, args...) { \
if(!device || device->verbose>=0){ \
if(strcmp(format,"\n")){ \
if(device && device->funcs->driver_info()->short_name){ \
fprintf(stderr,"ao_%s ERROR: " format,device->funcs->driver_info()->short_name,## args); \
}else{ \
fprintf(stderr,"ERROR: " format,## args); \
} \
}else{ \
fprintf(stderr,"\n"); \
} \
} \
}
#endif /* __AO_PRIVATE_H__ */

View file

@ -1,39 +0,0 @@
/*
*
* os_types.h
*
* Original Copyright (C) Aaron Holtzman - May 1999
* Modifications Copyright (C) Stan Seibert - July 2000
*
* This file is part of libao, a cross-platform audio output library. See
* README for a history of this source code.
*
* libao is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* libao is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/* Set type sizes for this platform (Requires Autoconf) */
#ifndef __OS_TYPES_H__
#define __OS_TYPES_H__
typedef unsigned char uint_8;
typedef unsigned short uint_16;
typedef unsigned int uint_32;
typedef signed char sint_8;
typedef signed short sint_16;
typedef signed int sint_32;
#endif /* __OS_TYPES_H__ */

Binary file not shown.

View file

@ -3780,8 +3780,13 @@ void MainWindow::applyWordsZoomLevel()
}
wordsZoomBase->setEnabled( cfg.preferences.wordsZoomLevel != 0 );
// groupList->setFixedHeight(translateLine->height());
groupList->parentWidget()->layout()->activate();
if( !cfg.preferences.searchInDock )
{
// Invalidating navToolbar's layout displays translateBoxWidget w/o the need to press the toolbar
// extension button when Words Zoom level decreases enough for translateBoxWidget to fit in the toolbar.
navToolbar->layout()->invalidate();
}
if ( scanPopup.get() )
scanPopup->applyWordsZoomLevel();
@ -4120,7 +4125,7 @@ void MainWindow::on_importFavorites_triggered()
QString fileName = QFileDialog::getOpenFileName( this, tr( "Import Favorites from file" ),
importPath,
tr( "XML files (*.xml);;All files (*.*)" ) );
tr( "XML files (*.xml);;Txt files (*.txt);;All files (*.*)" ) );
if( fileName.size() == 0)
return;
@ -4139,8 +4144,14 @@ void MainWindow::on_importFavorites_triggered()
QByteArray data = file.readAll();
if(fileInfo.suffix().compare("txt",Qt::CaseInsensitive)==0){
if( !ui.favoritesPaneWidget->setDataFromTxt( QString::fromUtf8( data.data(), data.size() ) ) )
break;
}
else{
if( !ui.favoritesPaneWidget->setDataFromXml( QString::fromUtf8( data.data(), data.size() ) ) )
break;
}
file.close();
mainStatusBar->showMessage( tr( "Favorites import complete" ), 5000 );

4
mdx.cc
View file

@ -1603,8 +1603,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
idxHeader.formatVersion = kCurrentFormatVersion;
idxHeader.parserVersion = MdictParser::kParserVersion;
idxHeader.foldingVersion = Folding::Version;
idxHeader.articleCount = parser.wordCount();
idxHeader.wordCount = parser.wordCount();
idxHeader.articleCount = indexedWords.size();
idxHeader.wordCount = indexedWords.size();
idx.rewind();
idx.write( &idxHeader, sizeof( idxHeader ) );

View file

@ -1,139 +0,0 @@
/*
*
* ao.h
*
* Original Copyright (C) Aaron Holtzman - May 1999
* Modifications Copyright (C) Stan Seibert - July 2000, July 2001
* More Modifications Copyright (C) Jack Moffitt - October 2000
*
* This file is part of libao, a cross-platform audio outputlibrary. See
* README for a history of this source code.
*
* libao is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* libao is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __AO_H__
#define __AO_H__
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "os_types.h"
/* --- Constants ---*/
#define AO_TYPE_LIVE 1
#define AO_TYPE_FILE 2
#define AO_ENODRIVER 1
#define AO_ENOTFILE 2
#define AO_ENOTLIVE 3
#define AO_EBADOPTION 4
#define AO_EOPENDEVICE 5
#define AO_EOPENFILE 6
#define AO_EFILEEXISTS 7
#define AO_EBADFORMAT 8
#define AO_EFAIL 100
#define AO_FMT_LITTLE 1
#define AO_FMT_BIG 2
#define AO_FMT_NATIVE 4
/* --- Structures --- */
typedef struct ao_info {
int type; /* live output or file output? */
char *name; /* full name of driver */
char *short_name; /* short name of driver */
char *author; /* driver author */
char *comment; /* driver comment */
int preferred_byte_format;
int priority;
char **options;
int option_count;
} ao_info;
typedef struct ao_functions ao_functions;
typedef struct ao_device ao_device;
typedef struct ao_sample_format {
int bits; /* bits per sample */
int rate; /* samples per second (in a single channel) */
int channels; /* number of audio channels */
int byte_format; /* Byte ordering in sample, see constants below */
char *matrix; /* input channel location/ordering */
} ao_sample_format;
typedef struct ao_option {
char *key;
char *value;
struct ao_option *next;
} ao_option;
#if defined(AO_BUILDING_LIBAO)
#include "ao_private.h"
#endif
/* --- Functions --- */
/* library setup/teardown */
void ao_initialize(void);
void ao_shutdown(void);
/* device setup/playback/teardown */
int ao_append_global_option(const char *key,
const char *value);
int ao_append_option(ao_option **options,
const char *key,
const char *value);
void ao_free_options(ao_option *options);
ao_device* ao_open_live(int driver_id,
ao_sample_format *format,
ao_option *option);
ao_device* ao_open_file(int driver_id,
const char *filename,
int overwrite,
ao_sample_format *format,
ao_option *option);
int ao_play(ao_device *device,
char *output_samples,
uint_32 num_bytes);
int ao_close(ao_device *device);
/* driver information */
int ao_driver_id(const char *short_name);
int ao_default_driver_id(void);
ao_info *ao_driver_info(int driver_id);
ao_info **ao_driver_info_list(int *driver_count);
const char *ao_file_extension(int driver_id);
/* miscellaneous */
int ao_is_big_endian(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __AO_H__ */

View file

@ -1,39 +0,0 @@
/*
*
* os_types.h
*
* Original Copyright (C) Aaron Holtzman - May 1999
* Modifications Copyright (C) Stan Seibert - July 2000
*
* This file is part of libao, a cross-platform audio output library. See
* README for a history of this source code.
*
* libao is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* libao is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/* Set type sizes for this platform (Requires Autoconf) */
#ifndef __OS_TYPES_H__
#define __OS_TYPES_H__
typedef unsigned char uint_8;
typedef unsigned short uint_16;
typedef unsigned int uint_32;
typedef signed char sint_8;
typedef signed short sint_16;
typedef signed int sint_32;
#endif /* __OS_TYPES_H__ */

View file

@ -1,51 +0,0 @@
/*
*
* plugin.h - function declarations for libao plugins
*
* Copyright (C) Stan Seibert - June 2001
*
* This file is part of libao, a cross-platform audio outputlibrary. See
* README for a history of this source code.
*
* libao is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* libao is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __PLUGIN_H__
#define __PLUGIN_H__
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include <stdlib.h>
#include "os_types.h"
int ao_plugin_test();
ao_info *ao_plugin_driver_info();
int ao_plugin_device_init(ao_device *device);
int ao_plugin_set_option(ao_device *device, const char *key, const char *value);
int ao_plugin_open(ao_device *device, ao_sample_format *format);
int ao_plugin_play(ao_device *device, const char *output_samples,
uint_32 num_bytes);
int ao_plugin_close(ao_device *device);
void ao_plugin_device_clear(ao_device *device);
const char *ao_plugin_file_extension();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __PLUGIN_H__ */

Binary file not shown.

Binary file not shown.