On Tue, Mar 25, 2008 at 01:56:45AM +0000, Jacob Meuser wrote: > On Mon, Mar 24, 2008 at 10:13:08PM +0000, Jacob Meuser wrote: > > > > currently, akode always* tries to resample to 44100 Hz. this has > > interesting effects. when you play a 22050 Hz file on a device > > that supports 22050 Hz, it plays 2x too slowly. the fix is simple, > > delete the resampler when it's not needed. same with sample format > > conversions. this makes the auto-resampling feature work in > > both akodeplay and juk (when juk is configured to use akode for > > audio output, that is). > > > > * the default "fast" resampler does at least. the libsamplerate "src" > > resampler seems to be completely broken. > > > > this patch also enables jack support and fixes a couple issues in > > akode's jack support. akodeplay makes for a "small" and fast cli > > player for jack, capable of playing flac, ogg, mp3, wav. > > and aac. > > small addition. don't spam stdout with messages from the ffmpeg > decoder.
I got the src resampler working, but it introduces artifacts, probably because it converts short to float and then back to short through a bunch of casts. I tried using the libsamplerate short/float conversions, but that just used more cpu, dampened the output and still had clipping artifacts. so, disable libsamplerate. last version, I promise ;) -- [EMAIL PROTECTED] SDF Public Access UNIX System - http://sdf.lonestar.org Index: Makefile =================================================================== RCS file: /home/cvs/OpenBSD/ports/audio/akode/Makefile,v retrieving revision 1.9 diff -u -r1.9 Makefile --- Makefile 24 Mar 2008 05:50:05 -0000 1.9 +++ Makefile 25 Mar 2008 23:42:07 -0000 @@ -2,7 +2,7 @@ COMMENT= Decoding Library for KDE Multimedia DISTNAME= akode-2.0.2 -PKGNAME= ${DISTNAME}p2 +PKGNAME= ${DISTNAME}p3 SHARED_LIBS += akode 2.1 # .2.0 CATEGORIES= audio multimedia x11/kde @@ -25,10 +25,10 @@ vorbis,vorbisfile,vorbisenc::audio/libvorbis \ ltdl::devel/libtool,-ltdl \ avcodec.>=10,avformat.>=10,avutil.>=3::graphics/ffmpeg \ - samplerate.>=1::audio/libsamplerate + jack::audio/jack -WANTLIB= X11 Xau Xdmcp Xext a52 c faac faad m mp3lame \ - ogg ossaudio pthread stdc++ theora x264 z +WANTLIB= a52 c faac faad m mp3lame ogg ossaudio pthread stdc++ \ + theora x264 z USE_X11= Yes USE_GMAKE= Yes @@ -40,7 +40,8 @@ CONFIGURE_ENV= PTHREAD_LIBS=-pthread CONFIGURE_ARGS+= --with-extra-includes=${LOCALBASE}/include \ --with-extra-libs=${LOCALBASE}/lib \ - --without-jack \ - --without-polyaudio + --with-jack \ + --without-polyaudio \ + --without-libsamplerate .include <bsd.port.mk> Index: patches/patch-akode_lib_player_cpp =================================================================== RCS file: patches/patch-akode_lib_player_cpp diff -N patches/patch-akode_lib_player_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-akode_lib_player_cpp 25 Mar 2008 23:42:07 -0000 @@ -0,0 +1,27 @@ +$OpenBSD$ +--- akode/lib/player.cpp.orig Mon Mar 24 01:59:23 2008 ++++ akode/lib/player.cpp Mon Mar 24 02:54:46 2008 +@@ -398,7 +398,10 @@ bool Player::load() { + if (d->sample_rate != first_frame.sample_rate) { + AKODE_DEBUG("Resampling to " << d->sample_rate); + d->resampler->setSampleRate(d->sample_rate); +- } ++ } else { ++ delete d->resampler; ++ d->resampler = 0; ++ } + int out_channels = d->sink->audioConfiguration()->channels; + int in_channels = first_frame.channels; + if (in_channels != out_channels) { +@@ -419,7 +422,10 @@ bool Player::load() { + d->converter = new Converter(out_width); + else + d->converter->setSampleWidth(out_width); +- } ++ } else { ++ delete d->converter; ++ d->converter = 0; ++ } + } + else + { Index: patches/patch-akode_plugins_ffmpeg_decoder_ffmpeg_decoder_cpp =================================================================== RCS file: /home/cvs/OpenBSD/ports/audio/akode/patches/patch-akode_plugins_ffmpeg_decoder_ffmpeg_decoder_cpp,v retrieving revision 1.1 diff -u -r1.1 patch-akode_plugins_ffmpeg_decoder_ffmpeg_decoder_cpp --- patches/patch-akode_plugins_ffmpeg_decoder_ffmpeg_decoder_cpp 1 Oct 2007 17:39:50 -0000 1.1 +++ patches/patch-akode_plugins_ffmpeg_decoder_ffmpeg_decoder_cpp 25 Mar 2008 23:42:07 -0000 @@ -1,6 +1,6 @@ $OpenBSD: patch-akode_plugins_ffmpeg_decoder_ffmpeg_decoder_cpp,v 1.1 2007/10/01 17:39:50 jakemsr Exp $ ---- akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp.orig Sun Sep 30 16:42:06 2007 -+++ akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp Sun Sep 30 16:42:46 2007 +--- akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp.orig Thu Aug 10 11:37:20 2006 ++++ akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp Mon Mar 24 18:14:43 2008 @@ -26,9 +26,11 @@ #include "decoder.h" @@ -13,3 +13,12 @@ #include "ffmpeg_decoder.h" #include <iostream> +@@ -349,7 +351,7 @@ retry: + assert(false); + } + if (length == 0) return readFrame(frame); +- std::cout << "akode: FFMPEG: Frame length: " << length << "\n"; ++ // std::cout << "akode: FFMPEG: Frame length: " << length << "\n"; + + if( d->packetSize <= 0 ) + av_free_packet( &d->packet ); Index: patches/patch-akode_plugins_jack_sink_jack_sink_cpp =================================================================== RCS file: patches/patch-akode_plugins_jack_sink_jack_sink_cpp diff -N patches/patch-akode_plugins_jack_sink_jack_sink_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-akode_plugins_jack_sink_jack_sink_cpp 25 Mar 2008 23:42:07 -0000 @@ -0,0 +1,28 @@ +$OpenBSD$ +--- akode/plugins/jack_sink/jack_sink.cpp.orig Mon Mar 24 03:18:18 2008 ++++ akode/plugins/jack_sink/jack_sink.cpp Mon Mar 24 03:54:26 2008 +@@ -84,7 +84,7 @@ static int process (jack_nframes_t nframes, void *arg) + m_data->pos++; + } + +- return n; ++ return 0; + } + + static void shutdown (void *arg) +@@ -147,13 +147,13 @@ int JACKSink::setAudioConfiguration(const AudioConfigu + + if (config->channel_config != MonoStereo ) return -1; + m_data->left_port = jack_port_register (m_data->client, "left", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); +- if (jack_connect (m_data->client, jack_port_name (m_data->left_port), "alsa_pcm:playback_1")) { ++ if (jack_connect (m_data->client, jack_port_name (m_data->left_port), "system:playback_1")) { + m_data->error = true; + return -1; + } + if (config->channels > 1) { + m_data->right_port = jack_port_register (m_data->client, "right", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); +- if (jack_connect (m_data->client, jack_port_name (m_data->right_port), "alsa_pcm:playback_2")) { ++ if (jack_connect (m_data->client, jack_port_name (m_data->right_port), "system:playback_2")) { + m_data->config.channels = 1; + res = 1; + } Index: patches/patch-akode_plugins_src_resampler_src_resampler_cpp =================================================================== RCS file: patches/patch-akode_plugins_src_resampler_src_resampler_cpp diff -N patches/patch-akode_plugins_src_resampler_src_resampler_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-akode_plugins_src_resampler_src_resampler_cpp 25 Mar 2008 23:42:07 -0000 @@ -0,0 +1,55 @@ +$OpenBSD$ +--- akode/plugins/src_resampler/src_resampler.cpp.orig Sat Jul 22 10:25:08 2006 ++++ akode/plugins/src_resampler/src_resampler.cpp Tue Mar 25 15:23:03 2008 +@@ -114,9 +114,12 @@ bool SRCResampler::doFrame(AudioFrame* in, AudioFrame* + _convert1_Int<int8_t>(in, tmp1); + } else + if (in->sample_width <= 16) { +- _convert1_Int<int16_t>(in, tmp1); +- } else +- _convert1_Int<int32_t>(in, tmp1); ++ // _convert1_Int<int16_t>(in, tmp1); ++ src_short_to_float_array(*((short**)in->data), tmp1, in->length); ++ } else { ++ // _convert1_Int<int32_t>(in, tmp1); ++ src_int_to_float_array(*((int**)in->data), tmp1, in->length); ++ } + + float ratio = (sample_rate/(float)in->sample_rate) / speed; + long outlength = (long)((in->length + ratio) * ratio); // max size +@@ -137,28 +140,28 @@ bool SRCResampler::doFrame(AudioFrame* in, AudioFrame* + // } + + AudioConfiguration config = *in; +- config.sample_width = -32; ++ // config.sample_width = -32; + config.sample_rate = sample_rate; + out->reserveSpace(&config, src_data.output_frames_gen); + out->pos = in->pos; + + // convert from float frames +-#if 0 + if (out->sample_width > 0) { + if (out->sample_width <= 8) { + _convert2_Int<int8_t>(tmp2, out); + } else + if (out->sample_width <= 16) { +- _convert2_Int<int16_t>(tmp2, out); +- } else +- _convert2_Int<int32_t>(tmp2, out); ++ // _convert2_Int<int16_t>(tmp2, out); ++ src_float_to_short_array(tmp2, *((short**)out->data), outlength); ++ } else { ++ // _convert2_Int<int32_t>(tmp2, out); ++ src_float_to_int_array(tmp2, *((int**)out->data), outlength); ++ } + } else + if (out->sample_width == -64) + _convert2_FP<double>(tmp2, out); + else +-#endif + _convert2_FP<float>(tmp2, out); +- + + delete[] tmp1; + delete[] tmp2; Index: pkg/PFRAG.shared =================================================================== RCS file: /home/cvs/OpenBSD/ports/audio/akode/pkg/PFRAG.shared,v retrieving revision 1.2 diff -u -r1.2 PFRAG.shared --- pkg/PFRAG.shared 1 Oct 2007 17:39:50 -0000 1.2 +++ pkg/PFRAG.shared 25 Mar 2008 23:42:07 -0000 @@ -1,9 +1,9 @@ @comment $OpenBSD: PFRAG.shared,v 1.2 2007/10/01 17:39:50 jakemsr Exp $ @lib lib/libakode.so.${LIBakode_VERSION} lib/libakode_ffmpeg_decoder.so +lib/libakode_jack_sink.so lib/libakode_mpc_decoder.so lib/libakode_mpeg_decoder.so lib/libakode_oss_sink.so -lib/libakode_src_resampler.so lib/libakode_sun_sink.so lib/libakode_xiph_decoder.so Index: pkg/PLIST =================================================================== RCS file: /home/cvs/OpenBSD/ports/audio/akode/pkg/PLIST,v retrieving revision 1.3 diff -u -r1.3 PLIST --- pkg/PLIST 1 Oct 2007 17:39:50 -0000 1.3 +++ pkg/PLIST 25 Mar 2008 23:42:07 -0000 @@ -32,14 +32,14 @@ lib/libakode.la @comment lib/libakode_ffmpeg_decoder.a @comment lib/libakode_ffmpeg_decoder.la [EMAIL PROTECTED] lib/libakode_jack_sink.a [EMAIL PROTECTED] lib/libakode_jack_sink.la @comment lib/libakode_mpc_decoder.a @comment lib/libakode_mpc_decoder.la @comment lib/libakode_mpeg_decoder.a @comment lib/libakode_mpeg_decoder.la @comment lib/libakode_oss_sink.a @comment lib/libakode_oss_sink.la [EMAIL PROTECTED] lib/libakode_src_resampler.a [EMAIL PROTECTED] lib/libakode_src_resampler.la @comment lib/libakode_sun_sink.a @comment lib/libakode_sun_sink.la @comment lib/libakode_xiph_decoder.a
