From martinrb at google.com Mon Sep 1 01:24:16 2008 From: martinrb at google.com (Martin Buchholz) Date: Mon, 1 Sep 2008 01:24:16 -0700 Subject: [patch] Support New NIO in IcedTea In-Reply-To: <20080901064900.GC19370@bamboo.destinee.acro.gen.nz> References: <20080831004043.GA19370@bamboo.destinee.acro.gen.nz> <1220193693.3524.24.camel@hermans.wildebeest.org> <20080901064900.GC19370@bamboo.destinee.acro.gen.nz> Message-ID: <1ccfd1c10809010124s6694bfa5t379d1dfe9998b3ec@mail.gmail.com> On Sun, Aug 31, 2008 at 23:49, C. K. Jester-Young wrote: > (This process is a notorious PITA; I've had to write a fakeuname.so > to ``convince'' the build tools that I'm building on a 32-bit machine, > because some of the scripts don't respect the --build option that I > sent to configure.) Do you know about the linux32(1) command? Martin From mjw at icedtea.classpath.org Mon Sep 1 02:17:36 2008 From: mjw at icedtea.classpath.org (mjw at icedtea.classpath.org) Date: Mon, 01 Sep 2008 09:17:36 +0000 Subject: changeset in /hg/icedtea: Add autogen.sh file from icedtea6. Message-ID: changeset a33a69c34a6a in /hg/icedtea details: http://icedtea.classpath.org/hg/icedtea?cmd=changeset;node=a33a69c34a6a description: Add autogen.sh file from icedtea6. diffstat: 2 files changed, 130 insertions(+) ChangeLog | 4 + autogen.sh | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diffs (141 lines): diff -r 0c5720b9671b -r a33a69c34a6a ChangeLog --- a/ChangeLog Sun Aug 31 20:57:09 2008 +0100 +++ b/ChangeLog Mon Sep 01 09:17:29 2008 +0000 @@ -1,3 +1,7 @@ 2008-08-31 Andrew John Hughes + + * autogen.sh: New file from icedtea6. + 2008-08-31 Andrew John Hughes * Makefile.am: diff -r 0c5720b9671b -r a33a69c34a6a autogen.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autogen.sh Mon Sep 01 09:17:29 2008 +0000 @@ -0,0 +1,126 @@ +#!/bin/sh + +# Test for autoconf commands. + +# Test for autoconf. + +HAVE_AUTOCONF=false + +for AUTOCONF in autoconf autoconf259; do + if ${AUTOCONF} --version > /dev/null 2>&1; then + AUTOCONF_VERSION=`${AUTOCONF} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` +# echo ${AUTOCONF_VERSION} + case ${AUTOCONF_VERSION} in + 2.59* | 2.6[0-9]* ) + HAVE_AUTOCONF=true + break; + ;; + esac + fi +done + +# Test for autoheader. + +HAVE_AUTOHEADER=false + +for AUTOHEADER in autoheader autoheader259; do + if ${AUTOHEADER} --version > /dev/null 2>&1; then + AUTOHEADER_VERSION=`${AUTOHEADER} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` +# echo ${AUTOHEADER_VERSION} + case ${AUTOHEADER_VERSION} in + 2.59* | 2.6[0-9]* ) + HAVE_AUTOHEADER=true + break; + ;; + esac + fi +done + +# Test for autoreconf. + +HAVE_AUTORECONF=false + +for AUTORECONF in autoreconf; do + if ${AUTORECONF} --version > /dev/null 2>&1; then + AUTORECONF_VERSION=`${AUTORECONF} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` +# echo ${AUTORECONF_VERSION} + case ${AUTORECONF_VERSION} in + 2.59* | 2.6[0-9]* ) + HAVE_AUTORECONF=true + break; + ;; + esac + fi +done + +if test ${HAVE_AUTOCONF} = false; then + echo "No proper autoconf was found." + echo "You must have autoconf 2.59 or later installed." + exit 1 +fi + +if test ${HAVE_AUTOHEADER} = false; then + echo "No proper autoheader was found." + echo "You must have autoconf 2.59 or later installed." + exit 1 +fi + +if test ${HAVE_AUTORECONF} = false; then + echo "No proper autoreconf was found." + echo "You must have autoconf 2.59 or later installed." + exit 1 +fi + + +# Test for automake commands. + +# Test for aclocal. + +HAVE_ACLOCAL=false + +for ACLOCAL in aclocal aclocal-1.10; do + if ${ACLOCAL} --version > /dev/null 2>&1; then + ACLOCAL_VERSION=`${ACLOCAL} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` +# echo ${ACLOCAL_VERSION} + case ${ACLOCAL_VERSION} in + 1.1[0-9]* ) + HAVE_ACLOCAL=true + break; + ;; + esac + fi +done + +# Test for automake. + +HAVE_AUTOMAKE=false + +for AUTOMAKE in automake automake-1.10; do + if ${AUTOMAKE} --version > /dev/null 2>&1; then + AUTOMAKE_VERSION=`${AUTOMAKE} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` +# echo ${AUTOMAKE_VERSION} + case ${AUTOMAKE_VERSION} in + 1.1[0-9]* ) + HAVE_AUTOMAKE=true + break; + ;; + esac + fi +done + +if test ${HAVE_ACLOCAL} = false; then + echo "No proper aclocal was found." + echo "You must have automake 1.10 or later installed." + exit 1 +fi + +if test ${HAVE_AUTOMAKE} = false; then + echo "No proper automake was found." + echo "You must have automake 1.10 or later installed." + exit 1 +fi + + +export ACLOCAL AUTOCONF AUTOHEADER AUTOMAKE + +${AUTORECONF} --force --install From mark at klomp.org Mon Sep 1 02:45:40 2008 From: mark at klomp.org (Mark Wielaard) Date: Mon, 01 Sep 2008 11:45:40 +0200 Subject: commit messages (Was: Support BSD and Caciocavallo) In-Reply-To: <17c6771e0808311301x7c7281a5od6ae9a8cbc35084a@mail.gmail.com> References: <17c6771e0808291839y2a26b031pd4cb226c8facb51c@mail.gmail.com> <1220193060.3524.12.camel@hermans.wildebeest.org> <17c6771e0808311301x7c7281a5od6ae9a8cbc35084a@mail.gmail.com> Message-ID: <1220262340.3762.3.camel@hermans.wildebeest.org> On Sun, 2008-08-31 at 21:01 +0100, Andrew John Hughes wrote: > On 31/08/2008, Mark Wielaard wrote: > > You managed to push this without generating a commit message. I cannot > > figure out why that is. Do you have any idea how you got this commit in > > "under the hgext.notify radar"? > Something is broken: > > remote: added 1 changesets with 2 changes to 2 files > remote: error: incoming.notify hook raised an exception: cannot > concatenate 'str' and 'NoneType' objects > > But at least it means merges are quiet ;) Yeah... But this is slightly worrying. I can replicate it when pushing remotely, but only with the icedtea6 repo, not with for example the testrepo (when enabling mail notifications on that one). And when pushing locally I don't get any errors which makes debugging this issue somewhat difficult. The only hint from a quick search was not having diffstat installed (server has hg 0.9.3 installed). But that isn't it because diffstat is, and always was, installed. hmmm, Mark From cky944 at gmail.com Mon Sep 1 05:00:21 2008 From: cky944 at gmail.com (C. K. Jester-Young) Date: Tue, 2 Sep 2008 00:00:21 +1200 Subject: [patch] Support New NIO in IcedTea In-Reply-To: <1ccfd1c10809010124s6694bfa5t379d1dfe9998b3ec@mail.gmail.com> References: <20080831004043.GA19370@bamboo.destinee.acro.gen.nz> <1220193693.3524.24.camel@hermans.wildebeest.org> <20080901064900.GC19370@bamboo.destinee.acro.gen.nz> <1ccfd1c10809010124s6694bfa5t379d1dfe9998b3ec@mail.gmail.com> Message-ID: <20080901120021.GD19370@bamboo.destinee.acro.gen.nz> On Mon, Sep 01, 2008 at 01:24:16AM -0700, Martin Buchholz wrote: > Do you know about the linux32(1) command? Nope; thanks for that! It's nice to know a non-sucky way to fake a different system type, using ``personalities'' rather than overriding uname. The upside is that this approach works for statically-linked programs too. :-) Thanks again, ---Chris K. From gnu_andrew at member.fsf.org Mon Sep 1 07:11:28 2008 From: gnu_andrew at member.fsf.org (Andrew John Hughes) Date: Mon, 1 Sep 2008 15:11:28 +0100 Subject: Support BSD and Caciocavallo In-Reply-To: <20080901055058.GB19370@bamboo.destinee.acro.gen.nz> References: <17c6771e0808291839y2a26b031pd4cb226c8facb51c@mail.gmail.com> <1220193060.3524.12.camel@hermans.wildebeest.org> <17c6771e0808311301x7c7281a5od6ae9a8cbc35084a@mail.gmail.com> <20080901055058.GB19370@bamboo.destinee.acro.gen.nz> Message-ID: <17c6771e0809010711g64eb9384u89548ad220a8f643@mail.gmail.com> On 01/09/2008, C. K. Jester-Young wrote: > Hi Andrew, > > > On Sun, Aug 31, 2008 at 09:01:56PM +0100, Andrew John Hughes wrote: > > 2008-08-31 Andrew John Hughes > > > > * Makefile.am: > > Make enabling hg-only projects sufficient for > > downloading from hg. > > > > This does mean I had to separate out the hg forest check so it wasn't > > duplicated. > > > I like the idea of the fix, though I think the way it's implemented > doesn't do what's intended, and is additionally a maintenance hassle > whenever new Mercurial repositories are added. > > Looking at the forest test, it only applies if !OPENJDK_SRC_DIR_FOUND > && !USE_ALT_OPENJDK_SRC_ZIP && USE_HG && USE_CLOSURES && USE_CVMI && > USE_CACIOCAVALLO && USE_BSD. In other words, this test will never be > invoked. > > I propose an alternative patch, that simply turns --enable-hg on if > --with-project != jdk7. The main caveat is now that the --with-project > stuff must appear before the --enable-hg. But other than that, I think > that this is more robust and easier to maintain, and I hope it works > for you too. :-) > > Many thanks, > ---Chris K. > > This does simplify it quite a bit. Applying with the following addition from myself: 2008-09-01 Andrew John Hughes * Makefile.am: Simply hgforest rule and add corresponding clean rule. 2008-09-01 C. K. Jester-Young * acinclude.m4: Enable hg by default unless building jdk7. * configure.ac: Do project check before hg check. -- Andrew :-) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint: F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8 -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: implicit_enable_hg.diff Url: http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20080901/3f0da90e/attachment.ksh From gnu_andrew at member.fsf.org Mon Sep 1 07:24:08 2008 From: gnu_andrew at member.fsf.org (Andrew John Hughes) Date: Mon, 1 Sep 2008 15:24:08 +0100 Subject: IcedTea6 merged to IcedTea Message-ID: <17c6771e0809010724h212a1c50u206e48f8aded26f7@mail.gmail.com> ChangeLog is as follows: 2008-08-31 Andrew John Hughes Merge from IcedTea6. * config.guess, * config.sub, * install-sh, * patches/icedtea-arm-uname.patch: Removed. * .hgignore, * ChangeLog, * HACKING, * IcedTeaPlugin.cc, * Makefile.am, * README, * acinclude.m4: Merged. * autogen.sh: Added. * configure.ac: Merged. * generated/sun/misc/Version.java, * generated/sun/tools/jconsole/Version.java: Merged and updated for 1.7. * jconsole.desktop, * patches/icedtea-alpha-fixes.patch, * patches/icedtea-alt-jar.patch: Merged. * patches/icedtea-arch.patch: Merged and recreated against jdk7. * patches/icedtea-cacao.patch, * patches/icedtea-clean-crypto.patch, * patches/icedtea-enum-bug-181.patch, * patches/icedtea-hotspot-6b11-7b24.patch: Merged. * patches/icedtea-hotspot-citypeflow.patch: Merged and regenerated against jdk7. * patches/icedtea-hotspot-gcc-pr36917.patch: Merged. * patches/icedtea-hotspot-params-cast-size_t.patch: Merged and regenerated against jdk7. * patches/icedtea-hotspot-use-idx_t.patch, * patches/icedtea-jdk-use-ssize_t.patch, * patches/icedtea-liveconnect.patch, * patches/icedtea-shark.patch, * patches/icedtea-signed-types-hot6.patch: Merged. * patches/icedtea-signed-types.patch: Merged and applied to standard build for JDK7 HotSpot. * patches/icedtea-text-relocations.patch: Merged and regenerated against jdk7. * patches/icedtea-uname.patch: Merged. * patches/icedtea-zero-build.patch: Merged and regenerated against jdk7. * patches/icedtea-zero.patch, * policytool.desktop, * ports/hotspot/src/cpu/zero/vm/assembler_zero.cpp, * ports/hotspot/src/cpu/zero/vm/assembler_zero.hpp, * ports/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.inline.hpp, * ports/hotspot/src/cpu/zero/vm/cppInterpreterGenerator_zero.hpp, * ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp, * ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp, * ports/hotspot/src/cpu/zero/vm/entry_zero.hpp, * ports/hotspot/src/cpu/zero/vm/frame_zero.cpp, * ports/hotspot/src/cpu/zero/vm/frame_zero.hpp, * ports/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp, * ports/hotspot/src/cpu/zero/vm/interpreter_zero.cpp, * ports/hotspot/src/cpu/zero/vm/interpreter_zero.hpp, * ports/hotspot/src/cpu/zero/vm/sharkFrame_zero.hpp, * ports/hotspot/src/cpu/zero/vm/stackPrinter_zero.hpp, * ports/hotspot/src/cpu/zero/vm/stack_zero.hpp, * ports/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp, * ports/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp, * ports/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.hpp, * ports/hotspot/src/share/vm/includeDB_shark, * ports/hotspot/src/share/vm/shark/llvmHeaders.hpp, * ports/hotspot/src/share/vm/shark/sharkBlock.cpp, * ports/hotspot/src/share/vm/shark/sharkBlock.hpp, * ports/hotspot/src/share/vm/shark/sharkBuilder.cpp, * ports/hotspot/src/share/vm/shark/sharkBuilder.hpp, * ports/hotspot/src/share/vm/shark/sharkCompiler.cpp, * ports/hotspot/src/share/vm/shark/sharkCompiler.hpp, * ports/hotspot/src/share/vm/shark/sharkConstantPool.cpp, * ports/hotspot/src/share/vm/shark/sharkConstantPool.hpp, * ports/hotspot/src/share/vm/shark/sharkEntry.cpp, * ports/hotspot/src/share/vm/shark/sharkEntry.hpp, * ports/hotspot/src/share/vm/shark/sharkFunction.cpp, * ports/hotspot/src/share/vm/shark/sharkFunction.hpp, * ports/hotspot/src/share/vm/shark/sharkMonitor.cpp, * ports/hotspot/src/share/vm/shark/sharkMonitor.hpp, * ports/hotspot/src/share/vm/shark/sharkRuntime.cpp, * ports/hotspot/src/share/vm/shark/sharkRuntime.hpp, * ports/hotspot/src/share/vm/shark/sharkState.cpp, * ports/hotspot/src/share/vm/shark/sharkState.hpp, * ports/hotspot/src/share/vm/shark/sharkType.cpp, * ports/hotspot/src/share/vm/shark/sharkType.hpp, * ports/hotspot/src/share/vm/shark/sharkValue.hpp, * ports/hotspot/src/share/vm/shark/shark_globals.hpp: Merged. The patch is 464k bzipped so I'm not posting that, but you're welcome to a copy if you want one. hg diff would be much quicker though ;) -- Andrew :-) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint: F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8 From gnu_andrew at member.fsf.org Mon Sep 1 10:16:43 2008 From: gnu_andrew at member.fsf.org (Andrew John Hughes) Date: Mon, 1 Sep 2008 18:16:43 +0100 Subject: [patch] Support New NIO in IcedTea In-Reply-To: <20080901064900.GC19370@bamboo.destinee.acro.gen.nz> References: <20080831004043.GA19370@bamboo.destinee.acro.gen.nz> <1220193693.3524.24.camel@hermans.wildebeest.org> <20080901064900.GC19370@bamboo.destinee.acro.gen.nz> Message-ID: <17c6771e0809011016y7755358dm5bd9cd7b6eb412ea@mail.gmail.com> On 01/09/2008, C. K. Jester-Young wrote: > Hi Mark, > > > On Sun, Aug 31, 2008 at 04:41:33PM +0200, Mark Wielaard wrote: > > Nice idea. I wasn't aware that NIO2 was progressing already. I now see > > that my ignorance was partly because it seems this work is done in the > > nio/nio forest instead of in the jdk7/nio2 forest. Do you know how they > > relate? > > > Looking at the jdk7/nio2, the last push was in February. The current > nio2 stuff seemed to have been established in April (see, e.g., [1]), > by different parties. But I'm not involved in NIO2 currently, let alone > back then, so I can't really say anything. > > [1] http://mail.openjdk.java.net/pipermail/nio-dev/2008-April/000001.html > > > > Also, how do you keep track of which commits are really nio2 related and > > which ones are the commits that just sync with the master jdk7 repo? It > > would be nice to have an easy way to see just those changes/commits made > > for the new nio support. > > > Yes, I'm much wondering about the same question myself. One of my > aspirations is to have an IcedTea build that incorporates multiple > projects simultaneously (NIO2, MLVM/Da Vinci Machine, and BGGA Closures > are three of the ones I have an interest in), and being able to work > with _just_ the diffs would be nice. > > On that note, the MLVM project works as a set of patches against the > mainline jdk7 code (although I have had some success applying it > against the NIO2 code too). It uses the Mercurial mq extension for > doing all the patching, and patches can be marked as being for specific > releases of jdk7, for example. > > > > Do you need any special tag to get that tag? While building with your > > patch applied and doing just: > > autoreconf --force --install \ > > && ./configure --enable-hg --with-project=nio2 \ > > && make > > > The tip revision is, at the time of writing, at -b94. I successfully > built with the supplied patches on Ubuntu 8.04, on amd64. Just to test > portability, I'm now building within a 32-bit chroot, just to see if > it works correctly there too. > > (This process is a notorious PITA; I've had to write a fakeuname.so > to ``convince'' the build tools that I'm building on a 32-bit machine, > because some of the scripts don't respect the --build option that I > sent to configure.) > > Here are the configure arguments I used: > > ./configure --with-openjdk --with-openjdk-home=/usr/lib/jvm/java-6-openjdk \ > > --enable-hg --with-project=nio2 > > > In other words, I'm building with OpenJDK 6 as supplied with Ubuntu. > (With the icedtea-implicit-enable-hg.diff I recently sent, that makes > the --enable-hg option redundant. My patch is, by the way, designed to > be applied to IcedTea revision 1158.) > > I noticed from your build output that you're also using 1.6 javac for > bootstrapping; is that a Sun build, or from IcedTea? Should it make > a difference? > It's not javac, it's ecj. > > > I got: > > /home/mark/src/icedtea/bootstrap/jdk1.6.0/bin/javac -g \ > > -d lib/hotspot-tools \ > > -source 1.5 \ > > -sourcepath \ > > 'hotspot-tools:openjdk/jdk/src/share/classes:openjdk/jdk/src/solaris/classes:openjdk/langtools/src/share/classes:openjdk/jaxp/src/share/classes:openjdk/corba/src/share/classes:openjdk/jaxws/src/share/classes:/home/mark/src/icedtea/generated:/home/mark/src/icedtea/rt' \ > > -bootclasspath '' @hotspot-tools-source-files.txt ; \ > > fi > > incorrect classpath: hotspot-tools/com/sun/codemodel/internal/ClassType.java > > > This is very odd. The first line in hotspot-tools-source-files.txt is > indeed hotspot-tools/com/sun/codemodel/internal/ClassType.java, which > means that whatever make system you have is not passing the '' argument > before it. Either that, or the javac you have is disregarding it. > Could be the opening " after bootclasspath without a closing one. > > > 1. ERROR in /home/mark/src/icedtea/openjdk/jdk/src/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java (at line 144) > > public void disableInterruptor(AbstractInterruptibleChannel ch) { > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > The method disableInterruptor(AbstractInterruptibleChannel) of type new JavaNioChannelsSpiAccess(){} must override a superclass method > > > This is to do with your javac too. Some compilers support the @Override > annonation being applied to interface methods, it seems, whereas other > ones don't. I haven't quite figured out which ones do/don't allow it. > Only very recent versions of ecj do, not those shipped with distros at present. > I remember seeing some IcedTea patches whose sole purpose is to remove > @Override annotations that would choke some compilers. However, since I > don't have such a compiler, working out which @Override annotation to > remove would be difficult task, since I presume the best way to find > them is by trial and error. :-) > Yes, patches/icedtea-override.patch. Which compiler are you using with IcedTea? The default build should use ecj unless you are building with an existing IcedTea tree (--with-icedtea). > > > Did I get the wrong nio tree, or did I apply the patch wrongly? > > > No, and no, it seems. :-) > > > > There are no real legal requirements except for making sure every > > contribution is free software. But it is encouraged to push anything > > upstream into openjdk of course to keep divergence as low as possible. > > > Cool, thanks for the clarification! > > > > Thanks for working on this, nio2 is very exciting. > > > No worries, and yes, I'm totally keen to get this working on IcedTea! > > Many thanks, > ---Chris K. > Thanks, -- Andrew :-) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint: F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8 From bugzilla-daemon at icedtea.classpath.org Mon Sep 1 14:20:31 2008 From: bugzilla-daemon at icedtea.classpath.org (bugzilla-daemon at icedtea.classpath.org) Date: Mon, 01 Sep 2008 21:20:31 +0000 Subject: [Bug 188] New: Yahoo pool not working (probably not any game at all) Message-ID: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=188 Summary: Yahoo pool not working (probably not any game at all) Product: IcedTea Version: unspecified Platform: PC URL: http://games.yahoo.com/games/login2?page=pl&ss=1 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: IcedTea AssignedTo: unassigned at icedtea.classpath.org ReportedBy: ihernandez at kiusys.com You go to yahoo pool, a heavy java application, and with a yahoo account (you can get one free) you enter the game. Then instead of the app that it's shown with the sun java, it says that you need java. I can try running firefox from console and capturing messages if needed. -- Configure bugmail: http://icedtea.classpath.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. From bugzilla-daemon at icedtea.classpath.org Mon Sep 1 17:07:05 2008 From: bugzilla-daemon at icedtea.classpath.org (bugzilla-daemon at icedtea.classpath.org) Date: Tue, 02 Sep 2008 00:07:05 +0000 Subject: [Bug 189] New: NullPointerException due to confused OBJECT/EMBED/APPLET attributes and PARAMs Message-ID: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=189 Summary: NullPointerException due to confused OBJECT/EMBED/APPLET attributes and PARAMs Product: IcedTea Version: unspecified Platform: All URL: https://bugs.launchpad.net/ubuntu/+bug/199732 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: IcedTea AssignedTo: unassigned at icedtea.classpath.org ReportedBy: java at tjworld.net This is an upstream report based on Ubuntu Bug LP #199732 https://bugs.launchpad.net/ubuntu/+bug/199732 == Overview == Loading some Java applets via Firefox and the plugin with openjdk-6 results in: Exception in thread "main" java.lang.NullPointerException at sun.applet.PluginMain.start(PluginMain.java:211) at sun.applet.PluginMain.main(PluginMain.java:73) See, for example: http://www.jeacle.ie/mortgage/ca/ http://wypte.acislive.com/pda/pda_maps.asp?SysId=30 I'll detail the analysis and the fix after this explanation. == Background == There are an unknown number of Internet sites hosting Java applets that fail when using the icedtea plug-in but work using the Sun Java plug-in. The reason for the failure is usually a result of the historic mess that was made of the HTML EMBED, APPLET, and OBJECT tags. As a result of the various contrived work-arounds that web-site authors used to try and ensure that all browsers managed to load a Java applet, there are many combinations of these tags and the PARAM name/value attribute tags that attempt to use browser quirks to ensure the user does see the Java applet. There has never been a standard for the EMBED tag particularly, it having grown over time from its beginnings in Netscape Navigator. There have likewise been various unofficial extensions to the OBJECT tag - the only properly standardised tag - which should really replace the other two tags in modern browsers and web-applications. As a result users often suffer, caught between a rock and a hard place when things go wrong - such as this NullPointerException - since they have no influence over the web-site operators in most cases, and often get told by developers that it is the web-site's problem, not the plug-in, despite the widespread use of varying combinations of browser-specific tag combinations. (See, for example, the responses in Bug #151). == The Issue == In the cases I've dealt with the failures are caused by the use of the EMBED tag with no "code" attribute. However, the HTML author has attempted to ensure all browsers/Java plug-ins load the applet by including OBJECT and/or APPLET variations as well as using PARAM name/value pairs. The plug-in currently refuses to accept a tag-set passed by the browser plug-in *before it has been completely parsed* if the initial tag isn't of the form: ... It will also then ignore any PARAM name/value pairs as being "outside an APPLET tag". This is unfortunate since in many cases the PARAM pairs contain values that the plug-in can use to load the applet successfully. == The Solution == The patch I've created refines the way PluginAppletViewer.parse() deals with the EMBED tag. It adopts the same logic as is already present for the OBJECT tag, deferring rejection of the attributes until the closing tag, and thus allowing any PARAM name/value pairs after the opening tag to be parsed into the attributes Hash. When the closing EMBED tag is parsed, if there is still no "code" or "object" attribute, the patch makes one last attempt to locate the entry-point class. It first looks for the attribute "classid". If it is found, the patch further checks that the value is prefixed "java:". If so, a new "code" attribute is created and assigned the remaining characters of the "classid" value. This will allow the applet to start. E.g. If any of these attempts fail it nullifies the attributes hash and fails with the same message as previously. This patch allows the plug-in to work with many more combinations of OBJECT, APPLET, and EMBED tags and improves the user experience and perception of openjdk and icedtea. == Exception Analysis == This bug is caused when the Java plug-in hasn't had a window registered using PluginMain.registerWindow(), which will set PluginMain.currentWindow. Without PluginMain.currentWindow set (it is initialised to null), when the gcjwebplugin sends the applet the "width" message, the applet's PluginMain.start() message-reading loop reads the width correctly, but then tries to get the internal height property using: int height = currentWindow.getHeight(); Because currentWindow is NULL it causes the Null Pointer Exception on line 211. The problem is caused in PluginAppletViewer.parse(...). There are several overloaded versions of this function but they all pass through to the work-horse overload that takes a complete set of arguments. In PluginAppletViewer.parse() it scans the HTML APPLET/OBJECT/EMBED tag and extracts the attribute values. When it finds an EMBED tag it passes it to PluginAppletViewer.scanTag(). That method is responsible for scanning the attributes inside the EMBED tag and assigning them to the attributes Hash. When scanTag() returns the EMBED detection-logic does some sanity checks on the attributes to ensure it has what it needs to execute the applet successfully. It checks for the CODE, WIDTH, and HEIGHT attributes not being null. If any one of them is null it sets the attribute reference to null too - effectively wiping them all out. When the logic in PluginAppletViewer.parse() finds the closing tag it checks if the attributes reference IS NOT null and if so calls PluginAppletViewerFactory.createAppletViewer(). That in turn calls PluginMain.registerWindow() which, as I said at the beginning, sets PluginMain.currentWindow. But, because an attribute of the EMBED tag was missing, the attribute Hash reference was null and so PluginMain.registerWindow() wasn't called and PluginMain.currentWindow remained with its initialised value, which is null. Hence the bug. In the case of the sites here the missing attribute is "code", and you can see the warning in the output: Warning: tag requires code attribute. That really should say "Error" since it is fatal. Because the EMBED tag was not part of a W3C standard the definition of legal parameters is hazy. It has been introduced for HTML 5 *but* will not support the CODE attribute. == Patch == Currently the patch is included in a provisional Ubuntu openjdk-6 source package as debian/patches/plugin-embed-use-param-translate-classid-to-code.patch It would be preferable to have it included upstream since other distributions have bugs reported for the same issue. The patch could easily be moved to ./patches/ in the openjdk-6 source package, as long as it is applied after patches/icedtea-plugin.patch -- Configure bugmail: http://icedtea.classpath.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. From bugzilla-daemon at icedtea.classpath.org Mon Sep 1 17:09:14 2008 From: bugzilla-daemon at icedtea.classpath.org (bugzilla-daemon at icedtea.classpath.org) Date: Tue, 02 Sep 2008 00:09:14 +0000 Subject: [Bug 189] NullPointerException due to confused OBJECT/EMBED/APPLET attributes and PARAMs Message-ID: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=189 ------- Comment #1 from java at tjworld.net 2008-09-02 00:09 ------- Created an attachment (id=90) --> (http://icedtea.classpath.org/bugzilla/attachment.cgi?id=90&action=view) Defer EMBED attribute decision; accept wider range of OBJECT/EMBED/APPLET attribute permutations -- Configure bugmail: http://icedtea.classpath.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. From cky944 at gmail.com Mon Sep 1 17:38:45 2008 From: cky944 at gmail.com (C. K. Jester-Young) Date: Tue, 2 Sep 2008 12:38:45 +1200 Subject: [patch] Support New NIO in IcedTea In-Reply-To: <17c6771e0809011016y7755358dm5bd9cd7b6eb412ea@mail.gmail.com> References: <20080831004043.GA19370@bamboo.destinee.acro.gen.nz> <1220193693.3524.24.camel@hermans.wildebeest.org> <20080901064900.GC19370@bamboo.destinee.acro.gen.nz> <17c6771e0809011016y7755358dm5bd9cd7b6eb412ea@mail.gmail.com> Message-ID: <20080902003845.GE19370@bamboo.destinee.acro.gen.nz> Hi Andrew, On Mon, Sep 01, 2008 at 06:16:43PM +0100, Andrew John Hughes wrote: > It's not javac, it's ecj. Ah, thank you. I looked through the build scripts and noticed that whatever compiler is used, there's a symlink called jdk1.6.0 that points to it, so the jdk1.6.0 is no indication of the compiler version or type. > > This is very odd. The first line in hotspot-tools-source-files.txt is > > indeed hotspot-tools/com/sun/codemodel/internal/ClassType.java, which > > means that whatever make system you have is not passing the '' argument > > before it. Either that, or the javac you have is disregarding it. > > Could be the opening " after bootclasspath without a closing one. That's two single quotes, not a double quote, so it should represent an empty string. Nonetheless, I'm testing it with ecj now and I'm seeing the same message. I'll be investigating this further once I have a complete build (by doing all the @Override stripping). > Yes, patches/icedtea-override.patch. Which compiler are you using with IcedTea? > The default build should use ecj unless you are building with an > existing IcedTea tree (--with-icedtea). I do all my builds with the OpenJDK supplied with Ubuntu 8.04, thus the options I use are --with-openjdk-home=/usr/lib/jvm/java-6-openjdk --with-openjdk. I wasn't aware of the default compiler used by IcedTea (probably because I'm a control freak that seldom uses defaults as is), so thanks for pointing that out. I'm doing my testing with ecj now; once I have the fixes for that, I'll be posting another patch! (The nio2 repository has had more updates since, so my new patches are tracking those updates, as well as the recent IcedTea6 merges that have occurred---oh, and by the way, thanks for applying my implicit-enable-hg patch!) Many thanks, ---Chris K. From bugzilla-daemon at icedtea.classpath.org Tue Sep 2 01:32:35 2008 From: bugzilla-daemon at icedtea.classpath.org (bugzilla-daemon at icedtea.classpath.org) Date: Tue, 02 Sep 2008 08:32:35 +0000 Subject: [Bug 189] NullPointerException due to confused OBJECT/EMBED/APPLET attributes and PARAMs Message-ID: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=189 mark at klomp.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dbhole at redhat.com ------- Comment #2 from mark at klomp.org 2008-09-02 08:32 ------- Deepak, you probably want to look into this one. -- Configure bugmail: http://icedtea.classpath.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. From bugzilla-daemon at icedtea.classpath.org Tue Sep 2 05:56:21 2008 From: bugzilla-daemon at icedtea.classpath.org (bugzilla-daemon at icedtea.classpath.org) Date: Tue, 02 Sep 2008 12:56:21 +0000 Subject: [Bug 188] Yahoo pool not working (probably not any game at all) Message-ID: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=188 langel at redhat.com changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at icedtea.classpath|dbhole at redhat.com |.org | -- Configure bugmail: http://icedtea.classpath.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. You are the assignee for the bug, or are watching the assignee. From bugzilla-daemon at icedtea.classpath.org Tue Sep 2 05:56:42 2008 From: bugzilla-daemon at icedtea.classpath.org (bugzilla-daemon at icedtea.classpath.org) Date: Tue, 02 Sep 2008 12:56:42 +0000 Subject: [Bug 189] NullPointerException due to confused OBJECT/EMBED/APPLET attributes and PARAMs Message-ID: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=189 langel at redhat.com changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at icedtea.classpath|dbhole at redhat.com |.org | -- Configure bugmail: http://icedtea.classpath.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. You are the assignee for the bug, or are watching the assignee. From gnu_andrew at member.fsf.org Tue Sep 2 08:25:49 2008 From: gnu_andrew at member.fsf.org (Andrew John Hughes) Date: Tue, 2 Sep 2008 16:25:49 +0100 Subject: [patch] Support New NIO in IcedTea In-Reply-To: <20080902003845.GE19370@bamboo.destinee.acro.gen.nz> References: <20080831004043.GA19370@bamboo.destinee.acro.gen.nz> <1220193693.3524.24.camel@hermans.wildebeest.org> <20080901064900.GC19370@bamboo.destinee.acro.gen.nz> <17c6771e0809011016y7755358dm5bd9cd7b6eb412ea@mail.gmail.com> <20080902003845.GE19370@bamboo.destinee.acro.gen.nz> Message-ID: <17c6771e0809020825y1ca96d87g828ff903e7eb1da2@mail.gmail.com> 2008/9/2 C. K. Jester-Young : > Hi Andrew, > > On Mon, Sep 01, 2008 at 06:16:43PM +0100, Andrew John Hughes wrote: >> It's not javac, it's ecj. > > Ah, thank you. I looked through the build scripts and noticed that > whatever compiler is used, there's a symlink called jdk1.6.0 that > points to it, so the jdk1.6.0 is no indication of the compiler version > or type. > No it isn't, it's just to fake a JDK for the build. For an ecj build, it will be a javac generated from javac.in against the ecj.jar it finds. For an IcedTea build, it will be symlinked to javac. >> > This is very odd. The first line in hotspot-tools-source-files.txt is >> > indeed hotspot-tools/com/sun/codemodel/internal/ClassType.java, which >> > means that whatever make system you have is not passing the '' argument >> > before it. Either that, or the javac you have is disregarding it. >> >> Could be the opening " after bootclasspath without a closing one. > > That's two single quotes, not a double quote, so it should represent an > empty string. Sorry, hard to tell with whatever font GMail is using... Nonetheless, I'm testing it with ecj now and I'm seeing > the same message. I'll be investigating this further once I have a > complete build (by doing all the @Override stripping). > >> Yes, patches/icedtea-override.patch. Which compiler are you using with IcedTea? >> The default build should use ecj unless you are building with an >> existing IcedTea tree (--with-icedtea). > > I do all my builds with the OpenJDK supplied with Ubuntu 8.04, thus the > options I use are --with-openjdk-home=/usr/lib/jvm/java-6-openjdk > --with-openjdk. I wasn't aware of the default compiler used by IcedTea > (probably because I'm a control freak that seldom uses defaults as is), > so thanks for pointing that out. > Well that's actually IcedTea. I'm not sure what the difference is between --with-openjdk and --with-icedtea except that the latter is probably more well-tested. > I'm doing my testing with ecj now; once I have the fixes for that, I'll > be posting another patch! (The nio2 repository has had more updates > since, so my new patches are tracking those updates, as well as the > recent IcedTea6 merges that have occurred---oh, and by the way, thanks > for applying my implicit-enable-hg patch!) > These merges are fun aren't they... at least we aren't stuck with CVS! > Many thanks, > ---Chris K. > Thanks, -- Andrew :-) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint: F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8 From iivan at redhat.com Tue Sep 2 11:04:35 2008 From: iivan at redhat.com (Ioana Ivan) Date: Tue, 02 Sep 2008 18:04:35 +0000 Subject: changeset in /hg/pulseaudio: 2008-08-13 Ioana Ivan changeset fd7d965da555 in /hg/pulseaudio details: http://icedtea.classpath.org/hg/pulseaudio?cmd=changeset;node=fd7d965da555 description: 2008-08-13 Ioana Ivan * src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java: superclass for TargetPort and SourcePort * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java: implements the abstract methods required in PulseAudioPort * src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java: implements the abstract methods required in PulseAudioPort * unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourcePortTest.java * unittests/org/classpath/icedtea/pulseaudio/PulseAudioTargetPortTest.java: new tests diffstat: 14 files changed, 339 insertions(+), 273 deletions(-) ChangeLog | 12 src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java | 2 src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java | 7 src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java | 2 src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java | 143 ++++++++++ src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java | 2 src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java | 113 ------- src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java | 126 -------- src/java/org/classpath/icedtea/pulseaudio/Stream.java | 2 src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c | 65 +++- src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c | 30 -- src/native/org_classpath_icedtea_pulseaudio_Stream.c | 10 unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourcePortTest.java | 49 +++ unittests/org/classpath/icedtea/pulseaudio/PulseAudioTargetPortTest.java | 49 +++ diffs (truncated from 771 to 500 lines): diff -r e99d53a7bcfa -r fd7d965da555 ChangeLog --- a/ChangeLog Fri Aug 29 16:26:10 2008 -0400 +++ b/ChangeLog Tue Sep 02 14:02:34 2008 -0400 @@ -1,3 +1,15 @@ 2008-08-13 Ioana Ivan + * src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java: + superclass for TargetPort and SourcePort + * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java: + implements the abstract methods required in PulseAudioPort + * src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java: + implements the abstract methods required in PulseAudioPort + * unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourcePortTest.java + * unittests/org/classpath/icedtea/pulseaudio/PulseAudioTargetPortTest.java: + new tests + + 2008-08-13 Ioana Ivan * src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java: diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Fri Aug 29 16:26:10 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Tue Sep 02 14:02:34 2008 -0400 @@ -352,7 +352,7 @@ public class PulseAudioClip extends Puls } - public int native_setVolume(float value) { + public long native_setVolume(float value) { return stream.native_setVolume(value); } diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Fri Aug 29 16:26:10 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Tue Sep 02 14:02:34 2008 -0400 @@ -336,8 +336,12 @@ public class PulseAudioMixer implements return clip; } - if ((info.getLineClass() == Port.class) ) { + String portName; + boolean isSource; + + if (Port.Info.class.isInstance(info)) { Port.Info portInfo = (Port.Info) info; + portName = portInfo.getName(); if(portInfo.isSource()){ return new PulseAudioSourcePort(portInfo.getName(), eventLoop); } else { @@ -346,7 +350,6 @@ public class PulseAudioMixer implements } - throw new IllegalArgumentException(); } diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java Fri Aug 29 16:26:10 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java Tue Sep 02 14:02:34 2008 -0400 @@ -2,7 +2,7 @@ package org.classpath.icedtea.pulseaudio interface PulseAudioPlaybackLine { - public int native_setVolume(float value); + long native_setVolume(float value); boolean isMuted(); diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java Tue Sep 02 14:02:34 2008 -0400 @@ -0,0 +1,143 @@ +package org.classpath.icedtea.pulseaudio; + +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Control; +import javax.sound.sampled.FloatControl; +import javax.sound.sampled.LineEvent; +import javax.sound.sampled.LineListener; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.Port; +import javax.sound.sampled.Control.Type; + +public abstract class PulseAudioPort extends PulseAudioLine implements Port, PulseAudioPlaybackLine { + + private String name; + private long contextPointer; + private EventLoop eventLoop; + private int channels; + private float volume; + private boolean muted; + private Control[] controls = null; + private PulseAudioMuteControl muteControl; + private PulseAudioVolumeControl volumeControl; + + + public PulseAudioPort(String name, EventLoop eventLoop) { + this.name = name; + this.contextPointer = eventLoop.getContextPointer(); + this.eventLoop = eventLoop; + updateVolumeInfo(); + + controls = new Control[2]; + volumeControl = new PulseAudioVolumeControl(this, eventLoop); + controls[0] = volumeControl; + muteControl = new PulseAudioMuteControl(this, volumeControl); + controls[1] = muteControl; + isOpen = true; + + System.out.println("Opened Target Port " + name); + } + + public abstract long native_setVolume(float newValue); + + public abstract long native_updateVolumeInfo(); + + public boolean isMuted() { + return muted; + } + + public void setMuted(boolean value) { + muted = value; + } + + public float getVolume() { + return this.volume; + } + + public void setVolume(float value) { + this.volume = value; + + } + + public synchronized void updateVolumeInfo() { + Operation op; + synchronized (eventLoop.threadLock) { + op = new Operation(native_updateVolumeInfo()); + } + + op.waitForCompletion(); + op.releaseReference(); + } + + public void update_channels_and_volume(int channels, float volume) { + this.channels = channels; + this.volume = volume; + } + + + @Override + public void close() { + native_setVolume((float)0); + isOpen = false; + fireLineEvent(new LineEvent(this,LineEvent.Type.CLOSE, AudioSystem.NOT_SPECIFIED)); + } + + + public Control getControl(Type control) { + if (!isOpen) { + throw new IllegalArgumentException( + "Controls only supported when line is open"); + } + + for (int i = 0; i < controls.length; i++) { + if (controls[i].getType().getClass() == control.getClass()) { + return controls[i]; + } + } + throw new IllegalArgumentException("Unsupported control type"); + } + + public Control[] getControls() { + if (isOpen) { + return controls; + } else { + return new Control[] {}; + } + + } + + @Override + public abstract javax.sound.sampled.Line.Info getLineInfo(); + + public boolean isControlSupported(Type control) { + for (Control myControl : controls) { + if (myControl.getType().getClass() == control.getClass()) { + return true; + } + } + return false; + } + + + @Override + public void open() throws LineUnavailableException { + native_setVolume(volume); + isOpen = true; + fireLineEvent(new LineEvent(this,LineEvent.Type.OPEN, AudioSystem.NOT_SPECIFIED)); + } + + public String getName() { + return this.name; + } + + + + + + + +} + + + + diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java Fri Aug 29 16:26:10 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java Tue Sep 02 14:02:34 2008 -0400 @@ -89,7 +89,7 @@ public class PulseAudioSourceDataLine ex } - public int native_setVolume(float value) { + public long native_setVolume(float value) { return stream.native_setVolume(value); } diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java Fri Aug 29 16:26:10 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java Tue Sep 02 14:02:34 2008 -0400 @@ -1,113 +1,22 @@ package org.classpath.icedtea.pulseaudio package org.classpath.icedtea.pulseaudio; +import javax.sound.sampled.Port; -import java.util.LinkedList; -import java.util.List; -import javax.sound.sampled.Control; -import javax.sound.sampled.LineListener; -import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.Port; -import javax.sound.sampled.Control.Type; -public class PulseAudioSourcePort implements Port { - - private String name; - - @SuppressWarnings("unused") - private long contextPointer; - - private EventLoop eventLoop; - - private boolean isOpen; - - private List lineListeners = new LinkedList(); - +public class PulseAudioSourcePort extends PulseAudioPort { + public PulseAudioSourcePort(String name, EventLoop eventLoop) { - System.out.println("new SourcePort constructed"); - this.name = name; - this.contextPointer = eventLoop.getContextPointer(); - this.eventLoop = eventLoop; - System.out.println("Opened Source Port: " + name); + super(name, eventLoop); } - - @Override - public void addLineListener(LineListener listener) { - synchronized (lineListeners) { - lineListeners.add(listener); - } - } - - @Override - public void close() { - Operation operation; - -// synchronized (eventLoop.threadLock) { -// operation = new Operation(nativeClose()); -// } -// -// operation.waitForCompletion(); -// operation.releaseReference(); - - isOpen = false; - } - - private native long nativeClose(); - - @Override - public Control getControl(Type control) { - throw new IllegalArgumentException(control.toString() - + " not supported"); - } - - @Override - public Control[] getControls() { - return new Control[] {}; - } - + + public native long native_setVolume(float newValue); + + + public synchronized native long native_updateVolumeInfo(); + @Override public javax.sound.sampled.Line.Info getLineInfo() { - // TODO Auto-generated method stub - return null; - } - - public String getName() { - return this.name; - - } - - @Override - public boolean isControlSupported(Type control) { - return false; - } - - @Override - public boolean isOpen() { - return isOpen; - } - - @Override - public void open() throws LineUnavailableException { - System.out.println("SourcePort opened"); - Operation operation; - -// synchronized (eventLoop.threadLock) { -// operation = new Operation(nativeOpen()); -// } -// -// operation.waitForCompletion(); -// operation.releaseReference(); - - isOpen = true; - } - - private native long nativeOpen(); - - @Override - public void removeLineListener(LineListener listener) { - synchronized (lineListeners) { - lineListeners.remove(listener); - } - + return new Port.Info(Port.class, getName(), false); } } diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java Fri Aug 29 16:26:10 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java Tue Sep 02 14:02:34 2008 -0400 @@ -1,132 +1,26 @@ package org.classpath.icedtea.pulseaudio package org.classpath.icedtea.pulseaudio; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Control; -import javax.sound.sampled.FloatControl; -import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineListener; -import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.Port; -import javax.sound.sampled.Control.Type; -public class PulseAudioTargetPort extends PulseAudioLine implements Port, PulseAudioPlaybackLine { - - private String name; - private long contextPointer; - private EventLoop eventLoop; - private int channels; - private float volume; - private boolean muted; - private Control[] controls = null; - private PulseAudioMuteControl muteControl; - private PulseAudioVolumeControl volumeControl; +public class PulseAudioTargetPort extends PulseAudioPort { public PulseAudioTargetPort(String name, EventLoop eventLoop) { - this.name = name; - this.contextPointer = eventLoop.getContextPointer(); - this.eventLoop = eventLoop; - updateVolumeInfo(); - - controls = new Control[2]; - volumeControl = new PulseAudioVolumeControl(this, eventLoop); - controls[0] = volumeControl; - muteControl = new PulseAudioMuteControl(this, volumeControl); - controls[1] = muteControl; - isOpen = true; - - System.out.println("Opened Target Port " + name); + super(name, eventLoop); } - public native int native_setVolume(float newValue); + public native long native_setVolume(float newValue); - public boolean isMuted() { - return muted; + + + public synchronized native long native_updateVolumeInfo(); + + @Override + public javax.sound.sampled.Line.Info getLineInfo() { + return new Port.Info(Port.class, getName(), false); } - public void setMuted(boolean value) { - muted = value; - } - public float getVolume() { - return this.volume; - } - - public void setVolume(float value) { - this.volume = value; - - } - - public synchronized native int native_updateVolumeInfo(); - - public synchronized void updateVolumeInfo() { - Operation op; - synchronized (eventLoop.threadLock) { - op = new Operation(native_updateVolumeInfo()); - } - - op.waitForCompletion(); - op.releaseReference(); - } - - public void update_channels_and_volume(int channels, float volume) { - this.channels = channels; - this.volume = volume; - } - - - @Override - public void close() { - native_setVolume((float)0); - isOpen = false; - fireLineEvent(new LineEvent(this,LineEvent.Type.CLOSE, AudioSystem.NOT_SPECIFIED)); - } - - - public Control getControl(Type control) { - if (!isOpen) { - throw new IllegalArgumentException( - "Controls only supported when line is open"); - } - - for (int i = 0; i < controls.length; i++) { - if (controls[i].getType().getClass() == control.getClass()) { - return controls[i]; - } - } - throw new IllegalArgumentException("Unsupported control type"); - } - - public Control[] getControls() { - if (isOpen) { - return controls; - } else { - return new Control[] {}; - } - - } - - @Override - public javax.sound.sampled.Line.Info getLineInfo() { - return new Port.Info(Port.class, name, false); - } - - public boolean isControlSupported(Type control) { - for (Control myControl : controls) { - if (myControl.getType().getClass() == control.getClass()) { - return true; - } - } - return false; - } - - - @Override - public void open() throws LineUnavailableException { - native_setVolume(volume); - isOpen = true; - fireLineEvent(new LineEvent(this,LineEvent.Type.OPEN, AudioSystem.NOT_SPECIFIED)); - } From omajid at redhat.com Wed Sep 3 07:59:35 2008 From: omajid at redhat.com (Omair Majid) Date: Wed, 03 Sep 2008 14:59:35 +0000 Subject: changeset in /hg/pulseaudio: 2008-09-02 Omair Majid changeset 52c81c12f7d0 in /hg/pulseaudio details: http://icedtea.classpath.org/hg/pulseaudio?cmd=changeset;node=52c81c12f7d0 description: 2008-09-02 Omair Majid * src/java/org/classpath/icedtea/pulseaudio/EventLoop.java Formatting fixes. * src/java/org/classpath/icedtea/pulseaudio/Operation.java (waitForCompletion): Removed redundant call to getState and the assert. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java (writeFrames): Fixed the function to not hog the cpu completely even when there is nothing to do. Big performance gain. (open): Add the clip to the source lines currently open in the mixer. (close): Remoce the clip from the list of source lines currently open in the mixer. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Added license text. Removed unneeded imports. (open): Initial implementation of support for START and STOP events. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioLine.java. Added license text. Removed unneeded imports. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java sourceLines and targetLines are now lists of PulseAudioLine. They contain all the source and target lines open to the mixer. (getSourceLines): Return a Line[] instead of a derived class (close): Added a check to make sure all the lines have been closed. (addSourceDataLine): Renamed to addSourceLine. (removeSourceDataLine): Renamed to removeSourceLine. (addTargetDataLine): Renamed to addTargetLine. (removeTargetDataLine): Rename to removeTargetLine. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java Added license text. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java Likewise. (getName): Accessor function for the name of the port. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java (write): Fixed the function to not use ~90% CPU. Now stays around 10%. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java Added license text. (native_updateVolumeInfo): Returns a pointer as a long, not as an int. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java Formatting fixes. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java Added license text. (native_updateVolumeInfo): Return a long instead of an int. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioRecorder.java Added license text. * src/java/org/classpath/icedtea/pulseaudio/Stream.java Likewise. * src/java/org/classpath/icedtea/pulseaudio/StreamBufferAttributes.java Likewise. * src/java/org/classpath/icedtea/pulseaudio/StreamSampleSpecification.java Likewise. * unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java (playTwoSoundFiles): Fixed test - complete playing and then exit properly. * unittests/org/classpath/icedtea/pulseaudio/PulseAudioEventLoopOverhead.java New test class. Tests the performance of the Eventloop when nothing is happeneing. * unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java (testSourceLinesOpenAndClose): Changed the test to work with ports. (testLongWait): Reduce the waiting time. Use PulseAudioEventLoopOverehead for longer durations. * unitests/org/classpath/icedtea/pulseaudio/PulseSourceDataLineTest.java (testStartedStopped): New test. Checks for the START and STOP signals being emitted. diffstat: 20 files changed, 751 insertions(+), 210 deletions(-) src/java/org/classpath/icedtea/pulseaudio/EventLoop.java | 17 - src/java/org/classpath/icedtea/pulseaudio/Operation.java | 8 src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java | 48 ++++ src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java | 70 ++++++- src/java/org/classpath/icedtea/pulseaudio/PulseAudioLine.java | 52 +++-- src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java | 75 +++---- src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java | 51 ++++- src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java | 82 +++++--- src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java | 61 ++++-- src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java | 51 ++++- src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java | 8 src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java | 59 ++++- src/java/org/classpath/icedtea/pulseaudio/SimpleAudioRecorder.java | 100 ++++++---- src/java/org/classpath/icedtea/pulseaudio/Stream.java | 44 +++- src/java/org/classpath/icedtea/pulseaudio/StreamBufferAttributes.java | 41 +++- src/java/org/classpath/icedtea/pulseaudio/StreamSampleSpecification.java | 40 +++- unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java | 13 + unittests/org/classpath/icedtea/pulseaudio/PulseAudioEventLoopOverhead.java | 67 ++++++ unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java | 7 unittests/org/classpath/icedtea/pulseaudio/PulseSourceDataLineTest.java | 67 ++++++ diffs (truncated from 1610 to 500 lines): diff -r fd7d965da555 -r 52c81c12f7d0 src/java/org/classpath/icedtea/pulseaudio/EventLoop.java --- a/src/java/org/classpath/icedtea/pulseaudio/EventLoop.java Tue Sep 02 14:02:34 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/EventLoop.java Tue Sep 02 17:23:01 2008 -0400 @@ -71,7 +71,7 @@ public class EventLoop implements Runnab // private boolean eventLoopIsRunning = false; public Semaphore finished = new Semaphore(0); - + private List targetPortNameList = new ArrayList(); private List sourcePortNameList = new ArrayList(); @@ -243,10 +243,11 @@ public class EventLoop implements Runnab public long getMainLoopPointer() { return mainloopPointer; } - + private native int nativeUpdateTargetPortNameList(); + private native int nativeUpdateSourcePortNameList(); - + protected synchronized List updateTargetPortNameList() { targetPortNameList = new ArrayList(); Operation op; @@ -261,7 +262,7 @@ public class EventLoop implements Runnab op.releaseReference(); return targetPortNameList; } - + protected synchronized List updateSourcePortNameList() { sourcePortNameList = new ArrayList(); Operation op; @@ -276,14 +277,12 @@ public class EventLoop implements Runnab op.releaseReference(); return sourcePortNameList; } - - - public void source_callback(String name ) { + + public void source_callback(String name) { sourcePortNameList.add(name); } - - public void sink_callback(String name ) { + public void sink_callback(String name) { targetPortNameList.add(name); } diff -r fd7d965da555 -r 52c81c12f7d0 src/java/org/classpath/icedtea/pulseaudio/Operation.java --- a/src/java/org/classpath/icedtea/pulseaudio/Operation.java Tue Sep 02 14:02:34 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/Operation.java Tue Sep 02 17:23:01 2008 -0400 @@ -63,7 +63,8 @@ public class Operation { String library = new java.io.File(".").getCanonicalPath() + java.io.File.separatorChar + System.mapLibraryName("pulse-java"); - System.out.println(Operation.class.getCanonicalName() + ": " + library); + System.out.println(Operation.class.getCanonicalName() + ": " + + library); System.load(library); } catch (IOException e) { assert ("Loading failed".endsWith("library")); @@ -77,7 +78,7 @@ public class Operation { private native int native_get_state(); public Operation(long operationPointer) { - assert(operationPointer != 0); + assert (operationPointer != 0); this.operationPointer = operationPointer; this.eventLoop = EventLoop.getEventLoop(); } @@ -132,9 +133,6 @@ public class Operation { public void waitForCompletion() { assert (operationPointer != 0); - State operationState = getState(); - assert (operationState != State.Done); - do { synchronized (eventLoop.threadLock) { if (getState() == Operation.State.Done) { diff -r fd7d965da555 -r 52c81c12f7d0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Tue Sep 02 14:02:34 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Tue Sep 02 17:23:01 2008 -0400 @@ -53,6 +53,8 @@ import javax.sound.sampled.LineListener; import javax.sound.sampled.LineListener; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.Control.Type; + +import org.classpath.icedtea.pulseaudio.Stream.WriteListener; public class PulseAudioClip extends PulseAudioDataLine implements Clip, PulseAudioPlaybackLine { @@ -117,10 +119,41 @@ public class PulseAudioClip extends Puls private void writeFrames(int startingFrame, int lastFrame) { + WriteListener writeListener = new WriteListener() { + @Override + public void update() { + eventLoop.threadLock.notifyAll(); + } + }; + + stream.addWriteListener(writeListener); + int remainingFrames = lastFrame - startingFrame - 1; while (remainingFrames > 0) { synchronized (eventLoop.threadLock) { - int availableSize = stream.getWritableSize(); + int availableSize; + + do { + availableSize = stream.getWritableSize(); + if (availableSize < 0) { + Thread.currentThread().interrupt(); + stream.removeWriteListener(writeListener); + return; + } + if (availableSize == 0) { + try { + eventLoop.threadLock.wait(); + } catch (InterruptedException e) { + // FIXME what to do when this happens? + // e.printStackTrace(); + Thread.currentThread().interrupt(); + stream.removeWriteListener(writeListener); + return; + } + } + + } while (availableSize == 0); + int framesToWrite = Math.min(remainingFrames, availableSize / getFormat().getFrameSize()); stream.write(data, currentFrame * getFormat().getFrameSize(), @@ -134,6 +167,9 @@ public class PulseAudioClip extends Puls // System.out.println("remaining frames" + remainingFrames); } } + + stream.removeWriteListener(writeListener); + } public PulseAudioClip(EventLoop eventLoop, AudioFormat[] formats, @@ -174,6 +210,10 @@ public class PulseAudioClip extends Puls stream.disconnect(); isOpen = false; } + + PulseAudioMixer mixer = PulseAudioMixer.getInstance(); + mixer.removeSourceLine(this); + } @Override @@ -341,7 +381,6 @@ public class PulseAudioClip extends Puls this.data = new byte[bufferSize]; System.arraycopy(data, offset, this.data, 0, bufferSize); frameCount = bufferSize / format.getFrameSize(); - isOpen = true; PulseAudioVolumeControl volumeControl = new PulseAudioVolumeControl( this, eventLoop); @@ -350,6 +389,11 @@ public class PulseAudioClip extends Puls controls.add(volumeControl); controls.add(muteControl); + PulseAudioMixer mixer = PulseAudioMixer.getInstance(); + mixer.addSourceLine(this); + + isOpen = true; + } public long native_setVolume(float value) { diff -r fd7d965da555 -r 52c81c12f7d0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Tue Sep 02 14:02:34 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Tue Sep 02 17:23:01 2008 -0400 @@ -1,17 +1,52 @@ package org.classpath.icedtea.pulseaudio +/* PulseAudioClip.java + Copyright (C) 2008 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea 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, version 2. + +IcedTea 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 IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + */ + package org.classpath.icedtea.pulseaudio; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.Semaphore; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineListener; import javax.sound.sampled.LineUnavailableException; -public abstract class PulseAudioDataLine extends PulseAudioLine implements DataLine { +public abstract class PulseAudioDataLine extends PulseAudioLine implements + DataLine { protected static final int DEFAULT_BUFFER_SIZE = StreamBufferAttributes.SANE_DEFAULT; protected static final String PULSEAUDIO_FORMAT_KEY = "PulseAudioFormatKey"; @@ -20,7 +55,6 @@ public abstract class PulseAudioDataLine // true between open() and close(). ie represents when a line has acquire // resources - // true between start() and stop() protected boolean isStarted = false; @@ -85,6 +119,26 @@ public abstract class PulseAudioDataLine stream.addStateListener(openCloseListener); + Stream.UnderflowListener stoppedListener = new Stream.UnderflowListener() { + @Override + public void update() { + fireLineEvent(new LineEvent(PulseAudioDataLine.this, + LineEvent.Type.STOP, AudioSystem.NOT_SPECIFIED)); + } + }; + stream.addUnderflowListener(stoppedListener); + + Stream.PlaybackStartedListener startedListener = new Stream.PlaybackStartedListener() { + @Override + public void update() { + fireLineEvent(new LineEvent(PulseAudioDataLine.this, + LineEvent.Type.START, AudioSystem.NOT_SPECIFIED)); + } + + }; + + stream.addPlaybackStartedListener(startedListener); + synchronized (eventLoop.threadLock) { connectLine(bufferSize); } @@ -183,16 +237,12 @@ public abstract class PulseAudioDataLine return isEngagedInIo; } - - protected abstract void connectLine(int bufferSize); public abstract void drain(); - - public Stream getStream() { return stream; } - + } diff -r fd7d965da555 -r 52c81c12f7d0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioLine.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioLine.java Tue Sep 02 14:02:34 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioLine.java Tue Sep 02 17:23:01 2008 -0400 @@ -1,22 +1,53 @@ package org.classpath.icedtea.pulseaudio +/* PulseAudioClip.java + Copyright (C) 2008 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea 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, version 2. + +IcedTea 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 IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + */ + package org.classpath.icedtea.pulseaudio; import java.util.ArrayList; import java.util.List; -import javax.sound.sampled.Control; -import javax.sound.sampled.Line; import javax.sound.sampled.LineEvent; import javax.sound.sampled.LineListener; -import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.Control.Type; - abstract class PulseAudioLine { protected List lineListeners = new ArrayList(); protected boolean isOpen = false; - - + public void addLineListener(LineListener listener) { this.lineListeners.add(listener); } @@ -30,14 +61,9 @@ abstract class PulseAudioLine { lineListener.update(e); } } - + public boolean isOpen() { return isOpen; } - - - - - } diff -r fd7d965da555 -r 52c81c12f7d0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Tue Sep 02 14:02:34 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Tue Sep 02 17:23:01 2008 -0400 @@ -63,7 +63,6 @@ import javax.sound.sampled.TargetDataLin import javax.sound.sampled.TargetDataLine; import javax.sound.sampled.AudioFormat.Encoding; import javax.sound.sampled.Control.Type; -import javax.sound.sampled.Port.Info; public class PulseAudioMixer implements javax.sound.sampled.Mixer { // singleton @@ -82,17 +81,15 @@ public class PulseAudioMixer implements private boolean isOpen = false; - private final List sourceLines = new ArrayList(); - private final List targetLines = new ArrayList(); - private final List clips = new ArrayList(); + private final List sourceLines = new ArrayList(); + private final List targetLines = new ArrayList(); private final List lineListeners = new ArrayList(); private PulseAudioMixer() { AudioFormat[] formats = getSupportedFormats(); List sourceLineInfoList = new ArrayList(); - sourceLineInfoList.add(new DataLine.Info( - SourceDataLine.class, formats, + sourceLineInfoList.add(new DataLine.Info(SourceDataLine.class, formats, StreamBufferAttributes.MIN_VALUE, StreamBufferAttributes.MAX_VALUE)); sourceLineInfos = new Line.Info[] { new DataLine.Info( @@ -331,25 +328,22 @@ public class PulseAudioMixer implements } if ((info.getLineClass() == Clip.class)) { - Clip clip = new PulseAudioClip(eventLoop, formats, defaultFormat); - clips.add((PulseAudioClip) clip); - return clip; - } - + return new PulseAudioClip(eventLoop, formats, defaultFormat); + } + String portName; boolean isSource; - + if (Port.Info.class.isInstance(info)) { Port.Info portInfo = (Port.Info) info; portName = portInfo.getName(); - if(portInfo.isSource()){ + if (portInfo.isSource()) { return new PulseAudioSourcePort(portInfo.getName(), eventLoop); } else { return new PulseAudioTargetPort(portInfo.getName(), eventLoop); } } - - + throw new IllegalArgumentException(); } @@ -386,7 +380,7 @@ public class PulseAudioMixer implements @Override public Line[] getSourceLines() { - return (Line[]) sourceLines.toArray(new PulseAudioSourceDataLine[0]); + return (Line[]) sourceLines.toArray(new Line[0]); } @@ -482,7 +476,16 @@ public class PulseAudioMixer implements // System.out.println(this.getClass().getName() + ": closed"); - this.isOpen = false; + isOpen = false; + + if (sourceLines.size() > 0) { + System.out.println("DEBUG: some source lines have not been closed"); + assert (sourceLines.size() < 0); + } + if (targetLines.size() > 0) { + System.out.println("DEBUG: some target lines have not been closed"); + assert (targetLines.size() < 0); + } synchronized (lineListeners) { lineListeners.clear(); @@ -522,23 +525,23 @@ public class PulseAudioMixer implements @Override public void open() throws LineUnavailableException { openLocal(); - //the sourceLineInfo and targetLineInfo arrays need to be updated with - //port infos, which can only be obtained after EventLoop had started - + // the sourceLineInfo and targetLineInfo arrays need to be updated with + // port infos, which can only be obtained after EventLoop had started + ArrayList sourceLineInfoList = new ArrayList(); sourceLineInfoList.add(sourceLineInfos[0]); - for(String portName : eventLoop.updateSourcePortNameList()){ + for (String portName : eventLoop.updateSourcePortNameList()) { sourceLineInfoList.add(new Port.Info(Port.class, portName, true)); } sourceLineInfos = sourceLineInfoList.toArray(new Line.Info[0]); - + ArrayList targetLineInfoList = new ArrayList(); targetLineInfoList.add(targetLineInfos[0]); - for(String portName : eventLoop.updateTargetPortNameList()){ + for (String portName : eventLoop.updateTargetPortNameList()) { targetLineInfoList.add(new Port.Info(Port.class, portName, false)); } targetLineInfos = targetLineInfoList.toArray(new Line.Info[0]); - + } public void open(String appName, String host) throws UnknownHostException, @@ -689,38 +692,38 @@ public class PulseAudioMixer implements AudioInputStream audioInputStream = AudioSystem .getAudioInputStream(soundFile); AudioFormat audioFormat = audioInputStream.getFormat(); From omajid at redhat.com Wed Sep 3 07:59:35 2008 From: omajid at redhat.com (Omair Majid) Date: Wed, 03 Sep 2008 14:59:35 +0000 Subject: changeset in /hg/pulseaudio: 2008-09-03 Omair Majid changeset b191c8f8cb2d in /hg/pulseaudio details: http://icedtea.classpath.org/hg/pulseaudio?cmd=changeset;node=b191c8f8cb2d description: 2008-09-03 Omair Majid * src/java/org/classpath/icedtea/pulseaudio/Eventloop.java (nativeUpdateTargetPortNameList): Changed return type to long. (nativeUpdateSourcePortNameList): Likewise. * src/native/org_classpath_icedtea_pulseaudio_Eventloop.c (sink_list_success_cb): Added asserts to fail nosily on error. (source_list_success_cb): Likewise. (context_change_callback): Likewise. (poll_function): Likewise. (Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateTargetPortNameList): Changed return type to jlong from jint. Added asserts. (Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateSourcePortNameList): Likewise. (Java_org_classpath_icedtea_pulseaudio_EventLoop_native_1shutdown): Set pointer to NULL on cleanup. (Java_org_classpath_icedtea_pulseaudio_EventLoop_native_1set_1sink_1volume): Added asserts. * src/native/org_classpath_icedtea_pulseaudio_Operation.c (Java_org_classpath_icedtea_pulseaudio_Operation_native_1ref): Added asserts. (Java_org_classpath_icedtea_pulseaudio_Operation_native_1unref): Likewise. (Java_org_classpath_icedtea_pulseaudio_Operation_native_1get_1state): Likewise. * src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c (source_callback): Added asserts. (get_source_volume_callback): Likewise. (Java_org_classpath_icedtea_pulseaudio_PulseAudioSourcePort_native_1updateVolumeInfo): Added checks for error conditions and asserts. (Java_org_classpath_icedtea_pulseaudio_PulseAudioSourcePort_native_1setVolume): Likewise. * src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c (get_sink_volume_callback): Added asserts. (Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetPort_native_1updateVolumeInfo): Added asserts and checks for errors. (Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetPort_native_1setVolume): Likewise. * src/native/org_classpath_icedtea_pulseaudio_Stream.c (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1read): Added asserts. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1peek): Likewise. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1drop): Likewise. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1writable_1size): Likewise. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1readable_1size): Likewise. (drain_callback): Likewise. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1drain): Likewise. (cork_callback): Likewise. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1cork): Likewise. (flush_callback): Likewise. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1flush): Likewise. (trigger_callback): Likewise. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1trigger): Likewise. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1set_1name): Likewise. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1get_1sample_1spec): Added code for error checking and asserts. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1get_1buffer_1attr): Adde asserts. (set_buffer_attr_callback): Likewise. (update_sample_rate_callback): Likewise. (Java_org_classpath_icedtea_pulseaudio_Stream_native_1setVolume): Likewise. diffstat: 6 files changed, 193 insertions(+), 60 deletions(-) src/java/org/classpath/icedtea/pulseaudio/EventLoop.java | 6 src/native/org_classpath_icedtea_pulseaudio_EventLoop.c | 90 ++++++---- src/native/org_classpath_icedtea_pulseaudio_Operation.c | 3 src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c | 50 ++++- src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c | 51 +++++ src/native/org_classpath_icedtea_pulseaudio_Stream.c | 53 ++++- diffs (truncated from 606 to 500 lines): diff -r 52c81c12f7d0 -r b191c8f8cb2d src/java/org/classpath/icedtea/pulseaudio/EventLoop.java --- a/src/java/org/classpath/icedtea/pulseaudio/EventLoop.java Tue Sep 02 17:23:01 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/EventLoop.java Wed Sep 03 10:47:27 2008 -0400 @@ -244,9 +244,9 @@ public class EventLoop implements Runnab return mainloopPointer; } - private native int nativeUpdateTargetPortNameList(); - - private native int nativeUpdateSourcePortNameList(); + private native long nativeUpdateTargetPortNameList(); + + private native long nativeUpdateSourcePortNameList(); protected synchronized List updateTargetPortNameList() { targetPortNameList = new ArrayList(); diff -r 52c81c12f7d0 -r b191c8f8cb2d src/native/org_classpath_icedtea_pulseaudio_EventLoop.c --- a/src/native/org_classpath_icedtea_pulseaudio_EventLoop.c Tue Sep 02 17:23:01 2008 -0400 +++ b/src/native/org_classpath_icedtea_pulseaudio_EventLoop.c Wed Sep 03 10:47:27 2008 -0400 @@ -49,27 +49,43 @@ static java_context_t* java_context = NU JNIEnv* pulse_thread_env = NULL; -void sink_list_success_cb(pa_context *context, const pa_sink_info *i, int eol, void *userdata) { - +void sink_list_success_cb(pa_context *context, const pa_sink_info *i, int eol, + void *userdata) { + if (eol == 0) { - jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env, java_context->obj); + jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env, + java_context->obj); + assert(cls); jstring name = (*pulse_thread_env)->NewStringUTF(pulse_thread_env, i->name); - jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, "sink_callback", "(Ljava/lang/String;)V"); - (*pulse_thread_env)->CallVoidMethod(pulse_thread_env, java_context->obj, mid1, name) ; - } else { + assert(name); + jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, + "sink_callback", "(Ljava/lang/String;)V"); + assert(mid1); + (*pulse_thread_env)->CallVoidMethod(pulse_thread_env, + java_context->obj, mid1, name) ; + } else { + assert(pulse_thread_env); notifyWaitingOperations(pulse_thread_env); } } -void source_list_success_cb(pa_context *context, const pa_source_info *i, int eol, void *userdata) { - +void source_list_success_cb(pa_context *context, const pa_source_info *i, + int eol, void *userdata) { + if (eol == 0) { - jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env, java_context->obj); + jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env, + java_context->obj); + assert(cls); jstring name = (*pulse_thread_env)->NewStringUTF(pulse_thread_env, i->name); - jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, "source_callback", "(Ljava/lang/String;)V"); - (*pulse_thread_env)->CallVoidMethod(pulse_thread_env, java_context->obj, mid1, name) ; - } else { + assert(name); + jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, + "source_callback", "(Ljava/lang/String;)V"); + assert(mid1); + (*pulse_thread_env)->CallVoidMethod(pulse_thread_env, + java_context->obj, mid1, name) ; + } else { + assert(pulse_thread_env); notifyWaitingOperations(pulse_thread_env); } @@ -85,20 +101,13 @@ static void context_change_callback(pa_c // printf("context state changed to %d\n", pa_context_get_state(context)); - /* Call the 'update' method in java + /* Call the EventLoop.update method in java * to handle all java-side events */ jclass cls = (*env)->GetObjectClass(env, obj); - if (cls == NULL) { - printf("unable to get class of object"); - return; - } + assert(cls); jmethodID mid = (*env)->GetMethodID(env, cls, "update", "(I)V"); - if (mid == NULL) { - printf("unable to get callback method\n"); - return; - - } + assert(mid); (*env)->CallVoidMethod(env, obj, mid, pa_context_get_state(context)); return; @@ -108,6 +117,7 @@ static int poll_function(struct pollfd * void *userdata) { JNIEnv* env = pulse_thread_env; + assert(env); jobject lockObject = getLockObject(env); (*env)->MonitorExit(env, lockObject); @@ -213,17 +223,21 @@ JNIEXPORT jint JNICALL Java_org_classpat } -JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateTargetPortNameList(JNIEnv *env, jobject obj) { - pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer"); +JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateTargetPortNameList(JNIEnv *env, jobject obj) { + pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer"); + assert(context); pa_operation *o = pa_context_get_sink_info_list(context, sink_list_success_cb, NULL); - return (jint) o; - } - - JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateSourcePortNameList(JNIEnv *env, jobject obj) { - pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer"); + assert(o); + return convertPointerToJavaLong(o); +} + +JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateSourcePortNameList(JNIEnv *env, jobject obj) { + pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer"); + assert(context); pa_operation *o = pa_context_get_source_info_list(context, source_list_success_cb, NULL); - return (jint) o; - } + assert(o); + return convertPointerToJavaLong(o); +} static void context_drain_complete_callback(pa_context* context, void* userdata) { pa_context_disconnect(context); @@ -257,6 +271,7 @@ JNIEXPORT void JNICALL Java_org_classpat (*env)->DeleteGlobalRef(env, java_context->obj); free(java_context); + java_context = NULL; setJavaPointer(env, obj, "mainloopPointer", NULL); setJavaPointer(env, obj, "contextPointer", NULL); @@ -272,7 +287,6 @@ static void sink_input_volume_change_com assert(userdata); free(userdata); assert(success); - printf("volume change complete\n"); } @@ -280,7 +294,6 @@ static void sink_input_change_volume(pa_ const pa_sink_input_info* i, int eol, void* userdata) { assert(c); - // end of list ? if (eol) { return; } @@ -317,10 +330,17 @@ static void sink_input_change_volume(pa_ */ JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_EventLoop_native_1set_1sink_1volume (JNIEnv* env, jobject obj, jlong streamPointer, jint volume) { + + pa_stream* stream = (pa_stream*) convertJavaLongToPointer(streamPointer); + assert(stream); + pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer"); + assert(context); + int* new_volume = malloc(sizeof(int)); *new_volume = volume; - int stream_id = pa_stream_get_index((pa_stream*) convertJavaLongToPointer(streamPointer)); - pa_context_get_sink_input_info((pa_context*) getJavaPointer(env, obj,"contextPointer") ,stream_id,sink_input_change_volume, new_volume); + + int stream_id = pa_stream_get_index(stream); + pa_context_get_sink_input_info(context, stream_id,sink_input_change_volume, new_volume); return; } diff -r 52c81c12f7d0 -r b191c8f8cb2d src/native/org_classpath_icedtea_pulseaudio_Operation.c --- a/src/native/org_classpath_icedtea_pulseaudio_Operation.c Tue Sep 02 17:23:01 2008 -0400 +++ b/src/native/org_classpath_icedtea_pulseaudio_Operation.c Wed Sep 03 10:47:27 2008 -0400 @@ -49,6 +49,7 @@ JNIEXPORT void JNICALL Java_org_classpat (JNIEnv* env, jobject obj) { pa_operation* operation = (pa_operation*) getJavaPointer(env, obj, "operationPointer"); + assert(operation); pa_operation_ref(operation); } @@ -62,6 +63,7 @@ JNIEXPORT void JNICALL Java_org_classpat (JNIEnv* env, jobject obj) { pa_operation* operation = (pa_operation*) getJavaPointer(env, obj, "operationPointer"); + assert(operation); pa_operation_unref(operation); } @@ -75,6 +77,7 @@ JNIEXPORT jint JNICALL Java_org_classpat (JNIEnv *env, jobject obj) { pa_operation* operation = (pa_operation*) getJavaPointer(env, obj, "operationPointer"); + assert(operation); int state = pa_operation_get_state(operation); return state; } diff -r 52c81c12f7d0 -r b191c8f8cb2d src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c --- a/src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c Tue Sep 02 17:23:01 2008 -0400 +++ b/src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c Wed Sep 03 10:47:27 2008 -0400 @@ -1,4 +1,3 @@ - #include "org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.h" #include "jni-common.h" #include @@ -12,43 +11,80 @@ extern JNIEnv* pulse_thread_env; extern JNIEnv* pulse_thread_env; void source_callback(pa_context *context, int success, void *userdata) { + assert(context); + assert(pulse_thread_env); notifyWaitingOperations(pulse_thread_env); } -void get_source_volume_callback(pa_context *context, const pa_source_info *i, int eol, void *userdata) { - if(eol == 0) { - printf("%s\n", i->name); +void get_source_volume_callback(pa_context *context, const pa_source_info *i, + int eol, void *userdata) { + assert(context); + assert(pulse_thread_env); + + if (eol == 0) { + // printf("%s\n", i->name); jobject obj = (jobject) userdata; + assert(obj); jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env, obj); - jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, "update_channels_and_volume", "(IF)V"); - (*pulse_thread_env)->CallVoidMethod(pulse_thread_env, obj, mid1, (int) (i->volume).channels, (float) (i->volume).values[0]) ; + assert(cls); + jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, + "update_channels_and_volume", "(IF)V"); + assert(mid1); + (*pulse_thread_env)->CallVoidMethod(pulse_thread_env, obj, mid1, + (int) (i->volume).channels, (float) (i->volume).values[0]) ; } else { notifyWaitingOperations(pulse_thread_env); } } - + JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourcePort_native_1updateVolumeInfo(JNIEnv *env, jobject obj) { jclass cls = (*env)->GetObjectClass(env, obj); + assert(cls); jfieldID fid = (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;"); + assert(fid); jstring jstr = (*env)->GetObjectField(env, obj, fid); + assert(jstr); const char *name = (*env)->GetStringUTFChars(env, jstr, NULL); + if (name == NULL) { + return convertPointerToJavaLong(NULL); // oome + } + pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer"); + assert(context); obj = (*env)->NewGlobalRef(env, obj); pa_operation *o = pa_context_get_source_info_by_name (context, (char*) name, get_source_volume_callback, obj); + assert(o); return convertPointerToJavaLong(o); } JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourcePort_native_1setVolume(JNIEnv *env, jobject obj, jfloat value) { jclass cls = (*env)->GetObjectClass(env, obj); + assert(cls); + jfieldID fid = (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;"); + assert(fid); + jstring jstr = (*env)->GetObjectField(env, obj, fid); + assert(jstr); + const char *name = (*env)->GetStringUTFChars(env, jstr, NULL); + if (name == NULL) { + return convertPointerToJavaLong(NULL); // oome + } + pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer"); + assert(context); + obj = (*env)->NewGlobalRef(env, obj); fid = (*env)->GetFieldID(env, cls, "channels", "I"); + assert(fid); + jint channels = (*env)->GetIntField(env, obj, fid); pa_cvolume cv; + pa_operation *o = pa_context_set_source_volume_by_name (context, (char*) name,pa_cvolume_set(&cv, channels, value), source_callback, obj); + assert(o); + return convertPointerToJavaLong(o); } diff -r 52c81c12f7d0 -r b191c8f8cb2d src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c --- a/src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c Tue Sep 02 17:23:01 2008 -0400 +++ b/src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c Wed Sep 03 10:47:27 2008 -0400 @@ -15,41 +15,80 @@ void sink_callback(pa_context *context, notifyWaitingOperations(pulse_thread_env); } -void get_sink_volume_callback(pa_context *context, const pa_sink_info *i, int eol, void *userdata) { - if(eol == 0) { - printf("%s\n", i->name); +void get_sink_volume_callback(pa_context *context, const pa_sink_info *i, + int eol, void *userdata) { + assert(context); + assert(pulse_thread_env); + + if (eol == 0) { + // printf("%s\n", i->name); jobject obj = (jobject) userdata; + assert(obj); jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env, obj); - jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, "update_channels_and_volume", "(IF)V"); - (*pulse_thread_env)->CallVoidMethod(pulse_thread_env, obj, mid1, (int) (i->volume).channels, (float) (i->volume).values[0]) ; + assert(cls); + jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, + "update_channels_and_volume", "(IF)V"); + assert(mid1); + (*pulse_thread_env)->CallVoidMethod(pulse_thread_env, obj, mid1, + (int) (i->volume).channels, (float) (i->volume).values[0]) ; } else { notifyWaitingOperations(pulse_thread_env); } - } JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetPort_native_1updateVolumeInfo(JNIEnv *env, jobject obj) { jclass cls = (*env)->GetObjectClass(env, obj); + assert(cls); + jfieldID fid = (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;"); + assert(fid); + jstring jstr = (*env)->GetObjectField(env, obj, fid); + assert(jstr); + const char *name = (*env)->GetStringUTFChars(env, jstr, NULL); + if (name == NULL) { + return convertPointerToJavaLong(NULL); // oome + } + pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer"); + assert(context); + obj = (*env)->NewGlobalRef(env, obj); + pa_operation *o = pa_context_get_sink_info_by_name (context, (char*) name, get_sink_volume_callback, obj); + assert(o); + return convertPointerToJavaLong(o); } JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetPort_native_1setVolume(JNIEnv *env, jobject obj, jfloat value) { jclass cls = (*env)->GetObjectClass(env, obj); + assert(cls); + jfieldID fid = (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;"); + assert(fid); + jstring jstr = (*env)->GetObjectField(env, obj, fid); + assert(jstr); + const char *name = (*env)->GetStringUTFChars(env, jstr, NULL); + if (name == NULL) { + return convertPointerToJavaLong(NULL); // return oome + } + pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer"); + assert(context); + obj = (*env)->NewGlobalRef(env, obj); fid = (*env)->GetFieldID(env, cls, "channels", "I"); + assert(fid); + jint channels = (*env)->GetIntField(env, obj, fid); pa_cvolume cv; pa_operation *o = pa_context_set_sink_volume_by_name (context, (char*) name,pa_cvolume_set(&cv, channels, value), sink_callback, obj); + assert(o); + return convertPointerToJavaLong(o); } diff -r 52c81c12f7d0 -r b191c8f8cb2d src/native/org_classpath_icedtea_pulseaudio_Stream.c --- a/src/native/org_classpath_icedtea_pulseaudio_Stream.c Tue Sep 02 17:23:01 2008 -0400 +++ b/src/native/org_classpath_icedtea_pulseaudio_Stream.c Wed Sep 03 10:47:27 2008 -0400 @@ -11,12 +11,11 @@ typedef struct java_context { extern JNIEnv* pulse_thread_env; -static void set_sink_input_volume_callback(pa_context* context, int success,void* userdata) { +static void set_sink_input_volume_callback(pa_context* context, int success, + void* userdata) { notifyWaitingOperations(pulse_thread_env); } - - const char* getStringFromFormat(pa_sample_format_t format) { @@ -499,6 +498,7 @@ JNIEXPORT jint JNICALL Java_org_classpat JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1read (JNIEnv *env, jobject obj, jbyteArray array, jint length, jint offset) { pa_stream *stream = getJavaPointer(env, obj, "streamPointer"); + assert(stream); const void *read_data = NULL; size_t read_length = 0; pa_stream_peek(stream, &read_data, &read_length); @@ -520,6 +520,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_cl (JNIEnv* env, jobject obj) { pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer"); + assert(stream); const void* startLocation; size_t count; @@ -546,6 +547,7 @@ JNIEXPORT jint JNICALL Java_org_classpat JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1drop (JNIEnv* env, jobject obj) { pa_stream* stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer"); + assert(stream); return pa_stream_drop(stream); } @@ -557,6 +559,7 @@ JNIEXPORT jint JNICALL Java_org_classpat JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1writable_1size (JNIEnv* env, jobject obj) { pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer"); + assert(stream); size_t size = pa_stream_writable_size(stream); return size; @@ -570,6 +573,7 @@ JNIEXPORT jint JNICALL Java_org_classpat JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1readable_1size (JNIEnv* env, jobject obj) { pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer"); + assert(stream); return pa_stream_readable_size(stream); } @@ -577,6 +581,7 @@ static void drain_callback(pa_stream* st assert(success); JNIEnv* env = pulse_thread_env; + assert(env); notifyWaitingOperations(env); } @@ -589,13 +594,16 @@ JNIEXPORT jlong JNICALL Java_org_classpa JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1drain (JNIEnv* env, jobject obj) { pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer"); + assert(stream); pa_operation* operation = pa_stream_drain(stream, drain_callback, NULL); + assert(operation); return convertPointerToJavaLong(operation); } static void cork_callback(pa_stream* stream, int success, void* userdata) { assert(success); JNIEnv* env = pulse_thread_env; + assert(env); notifyWaitingOperations(env); } @@ -608,13 +616,16 @@ JNIEXPORT jlong JNICALL Java_org_classpa JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1cork (JNIEnv* env, jobject obj, jint yes) { pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer"); + assert(stream); pa_operation* operation = pa_stream_cork(stream, yes, cork_callback, NULL); + assert(operation); return convertPointerToJavaLong(operation); } static void flush_callback(pa_stream* stream, int success, void* userdata) { assert(success); JNIEnv* env = pulse_thread_env; + assert(env); notifyWaitingOperations(env); } @@ -627,13 +638,16 @@ JNIEXPORT jlong JNICALL Java_org_classpa JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1flush (JNIEnv* env, jobject obj) { pa_stream* stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer"); + assert(stream); pa_operation* operation = pa_stream_flush(stream, flush_callback, NULL); From cky944 at gmail.com Wed Sep 3 08:09:49 2008 From: cky944 at gmail.com (C. K. Jester-Young) Date: Thu, 4 Sep 2008 03:09:49 +1200 Subject: [patch] Support New NIO in IcedTea In-Reply-To: <17c6771e0809020825y1ca96d87g828ff903e7eb1da2@mail.gmail.com> References: <20080831004043.GA19370@bamboo.destinee.acro.gen.nz> <1220193693.3524.24.camel@hermans.wildebeest.org> <20080901064900.GC19370@bamboo.destinee.acro.gen.nz> <17c6771e0809011016y7755358dm5bd9cd7b6eb412ea@mail.gmail.com> <20080902003845.GE19370@bamboo.destinee.acro.gen.nz> <17c6771e0809020825y1ca96d87g828ff903e7eb1da2@mail.gmail.com> Message-ID: <20080903150949.GA24121@bamboo.destinee.acro.gen.nz> Attached are some patches that help the current nio2 tip build with the current IcedTea tip. :-) The rest of the message is my reply to Andrew, which other readers probably won't care about. :-P On Tue, Sep 02, 2008 at 04:25:49PM +0100, Andrew John Hughes wrote: > >> Could be the opening " after bootclasspath without a closing one. > > > > That's two single quotes, not a double quote, so it should represent an > > empty string. > > Sorry, hard to tell with whatever font GMail is using... Yeah, it's a bit a shame that you can't choose to use a monospace font with Gmail...I personally use Mutt to do all my mailing list stuff, just because no webmail system I've seen does proper (strict) threading, list header fields (Mail-Followup-To, etc.), inline attachments, customisable attachment content types, or the like. I sang with joy the day I heard that Gmail supported IMAP access. > Well that's actually IcedTea. I'm not sure what the difference is > between --with-openjdk > and --with-icedtea except that the latter is probably more well-tested. >From what I can see, there isn't a difference between the two except the default directories that get used for each. > > I'm doing my testing with ecj now; once I have the fixes for that, I'll > > be posting another patch! (The nio2 repository has had more updates > > since, so my new patches are tracking those updates, as well as the > > recent IcedTea6 merges that have occurred---oh, and by the way, thanks > > for applying my implicit-enable-hg patch!) > > These merges are fun aren't they... at least we aren't stuck with CVS! True, true...well, I finally got them completed (at 3 am, no less: I'll be away for a whole week in 5 hours' time, and I wanted these changes to go through before the nio2 tip gets updated again and all my work has to be redone :-P). The @Override-stripping patch is quite large, and the nio2 updates have caused the gensrc changes to triple in size, so I've zipped those up. (Again, these both apply to the nio2 tip as of current writing, so you may need to repull your sources.) The main build script changes remain inline so they can be easily reviewed. So, hope you and Mark and maybe other interested parties have fun with them! Hopefully there won't be too many changes to the nio2 tip before I return.... :-) Enjoy, ---Chris K. -------------- next part -------------- A non-text attachment was scrubbed... Name: icedtea-nio2-20080904.diff Type: text/x-diff Size: 1951 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20080904/0f8a4d2a/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: icedtea-nio2-patches.zip Type: application/zip Size: 13847 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20080904/0f8a4d2a/attachment.zip From omajid at redhat.com Wed Sep 3 12:12:02 2008 From: omajid at redhat.com (Omair Majid) Date: Wed, 03 Sep 2008 19:12:02 +0000 Subject: changeset in /hg/pulseaudio: 2008-09-03 Omair Majid changeset 8ddfb8d274c7 in /hg/pulseaudio details: http://icedtea.classpath.org/hg/pulseaudio?cmd=changeset;node=8ddfb8d274c7 description: 2008-09-03 Omair Majid * src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Moved controls to PulseAudioDataLine. (PulseAudioClip): Removed lineListeners and controls - They are in a superclass of PulseAudioClip. (getBufferSize): Moved method to PulseAudioDataLine. (getControl): Moved method to PulseAudioLine. (getControls): Likewise. (getFormat): Moved method to PulseAudioDataLine. (getLevel): Likewise. (getLineInfo): Likewise. (isControlSupported): Moved to PulseAudioLine. (isOpen): Likewise. (isRunning): Moved to PulseAudioDataLine. (removeLineListeners): Moved to PulseAudioLine. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java (open): Now sets isEngagedInIo when playback starts or stops. (close): Calls super.close and throws an exception if interrupted. (start): Removed comments. (stop): Likewise. (getBufferSize): New function. Moved from derived class to this class. (getLineInfo): Likewise. (getFormat): Likewise. (getLevel): Likewise. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioLine.java Added controls. (close): New function. Moved from derived class to this class. (getControl): Likewise. (getControls): Likewise. (isControlSupported): Likewise. (open): Likewise. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java (getSupportedFormats): Removed redundant comments. (getLine): Removed unused variables. (addTargetLine): Renamed from addTargetDataLine. (removeTargetLine): Renamed from removeTargetDataLine. * src/java/org/classpath/icedtea/pulseaudio/PulseAduioPort.java Removed controls (open): Use the controls List from the parent class. (getControl): Moved to superclass. (getControls): Likewise. (isControlSupported): Likewise. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java Removed controls array. Uses the one from parent class. (open): Fixed to use the controls List. (write): Added an extra check. (getBufferSize): Moved to parent class. (getFormat): Likewise. (getLevel): Likewise. (getControl): Likewise. (getControls): Likewise. (getLineInfo): Likewise. (isControlSupported): Likewise. * src/java/org/classpath/icedate/pulseaudio/PulseAudioTargetDataLine.java (PulseAudioTargetDataLine): Use lineListeners from parent class. (close): Fixed function name to call in Mixer. (open): Likewise. (read): Added an extra check. (getBufferSize): Moved to parent class. (getFormat): Likewise. (getLevel): Likewise. (getControl): Likewise. (getControls): Likewise. (getLIneInfo): Likewise. (isControlSupported): Likewise. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioVolumeControl.java Formatting fixes. * src/java/org/classpath/icedtea/pulseaudio/Stream.java (underflowCallback): Removed debug output. * unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java (testOpenEvent): New test. Checks the OPEN event from PulseAudioClip (testCloseEvent): New test. Check the CLOSE event from PulseAudioClip (testPlayTwoClips): Removed redundant try/catch block. (testSupportedControls): New test. Checks that PulseAudioClip supports at least two controls. (testMixerKnowsAboutOpenClips): New test. Checks that open clips are added to the mixer's list of open source lines. * unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerRawTest.java Fixed formatting. * unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java (testOpeneingAgain): Fixed test to detect the IllegalStateException thrown. * unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourcePortTest.java (tearDown): New function. Close the mixer at the end of the test. * unittests/org/classpath/icedtea/pulseaudio/PulseSourceDataLineTest.java (testMixerKnowsAoubtOpenLines): Modified the test to check that the lines are actually the same. diffstat: 16 files changed, 364 insertions(+), 415 deletions(-) src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java | 88 ----- src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java | 72 ++-- src/java/org/classpath/icedtea/pulseaudio/PulseAudioLine.java | 62 +++ src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java | 61 --- src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java | 53 --- src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java | 71 ---- src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java | 57 --- src/java/org/classpath/icedtea/pulseaudio/PulseAudioVolumeControl.java | 22 - src/java/org/classpath/icedtea/pulseaudio/Stream.java | 1 unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java | 166 ++++++++-- unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerRawTest.java | 18 - unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java | 5 unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourcePortTest.java | 38 +- unittests/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLineTest.java | 24 + unittests/org/classpath/icedtea/pulseaudio/PulseAudioTargetPortTest.java | 37 +- unittests/org/classpath/icedtea/pulseaudio/PulseSourceDataLineTest.java | 4 diffs (truncated from 1446 to 500 lines): diff -r b191c8f8cb2d -r 8ddfb8d274c7 src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Wed Sep 03 10:47:27 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Wed Sep 03 15:11:46 2008 -0400 @@ -38,21 +38,13 @@ package org.classpath.icedtea.pulseaudio package org.classpath.icedtea.pulseaudio; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.Semaphore; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.BooleanControl; import javax.sound.sampled.Clip; -import javax.sound.sampled.Control; -import javax.sound.sampled.DataLine; -import javax.sound.sampled.FloatControl; -import javax.sound.sampled.LineListener; import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.Control.Type; import org.classpath.icedtea.pulseaudio.Stream.WriteListener; @@ -72,8 +64,6 @@ public class PulseAudioClip extends Puls private int framesSinceOpen = 0; public static final String DEFAULT_CLIP_NAME = "Clip"; - - private List controls = null; private Object clipLock = new Object(); private boolean clipThreadStarted; @@ -176,12 +166,11 @@ public class PulseAudioClip extends Puls AudioFormat defaultFormat) { supportedFormats = formats; this.eventLoop = eventLoop; - this.lineListeners = new ArrayList(); this.defaultFormat = defaultFormat; this.currentFormat = defaultFormat; + this.volume = PulseAudioVolumeControl.MAX_VOLUME; + clipThread = new ClipThread(); - this.volume = PulseAudioVolumeControl.MAX_VOLUME; - controls = new ArrayList(); } @@ -241,46 +230,6 @@ public class PulseAudioClip extends Puls } @Override - public int getBufferSize() { - if (!isOpen) { - return DEFAULT_BUFFER_SIZE; - } - return bufferSize; - } - - @Override - public Control getControl(Type control) { - if (isOpen) { - if (control.getClass() == BooleanControl.Type.MUTE.getClass()) { - return controls.get(1); - } - - if (control.getClass() == FloatControl.Type.VOLUME.getClass()) { - return controls.get(0); - } - } - throw new IllegalArgumentException(control.toString() - + " not supported"); - } - - @Override - public Control[] getControls() { - if (!isOpen) { - return new Control[] {}; - } - - return (Control[]) controls.toArray(new Control[0]); - } - - @Override - public AudioFormat getFormat() { - if (!isOpen) { - return defaultFormat; - } - return currentFormat; - } - - @Override public int getFrameLength() { return frameCount; } @@ -288,18 +237,6 @@ public class PulseAudioClip extends Puls @Override public int getFramePosition() { return (int) framesSinceOpen; - } - - @Override - public float getLevel() { - return AudioSystem.NOT_SPECIFIED; - } - - @Override - public javax.sound.sampled.Line.Info getLineInfo() { - return new DataLine.Info(this.getClass(), supportedFormats, - StreamBufferAttributes.MIN_VALUE, - StreamBufferAttributes.MAX_VALUE); } @Override @@ -324,22 +261,6 @@ public class PulseAudioClip extends Puls synchronized (clipLock) { return framesSinceOpen / currentFormat.getFrameSize(); } - } - - @Override - public boolean isControlSupported(Type control) { - return false; - } - - @Override - public boolean isOpen() { - return isOpen; - } - - @Override - public boolean isRunning() { - // really confused about what this is supposed to do - return isActive(); } @Override @@ -429,11 +350,6 @@ public class PulseAudioClip extends Puls } @Override - public void removeLineListener(LineListener listener) { - lineListeners.remove(listener); - } - - @Override public void setFramePosition(int frames) { if (frames > frameCount) { diff -r b191c8f8cb2d -r 8ddfb8d274c7 src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Wed Sep 03 10:47:27 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Wed Sep 03 15:11:46 2008 -0400 @@ -53,9 +53,6 @@ public abstract class PulseAudioDataLine protected String streamName = "Java Stream"; - // true between open() and close(). ie represents when a line has acquire - // resources - // true between start() and stop() protected boolean isStarted = false; @@ -76,9 +73,6 @@ public abstract class PulseAudioDataLine public void open(AudioFormat format, int bufferSize) throws LineUnavailableException { - if (isOpen) { - throw new IllegalStateException("Line is already open"); - } for (AudioFormat myFormat : supportedFormats) { if (format.matches(myFormat)) { @@ -90,7 +84,7 @@ public abstract class PulseAudioDataLine } currentFormat = format; - isOpen = true; + super.open(); } } // no matches found @@ -122,6 +116,7 @@ public abstract class PulseAudioDataLine Stream.UnderflowListener stoppedListener = new Stream.UnderflowListener() { @Override public void update() { + isEngagedInIo = false; fireLineEvent(new LineEvent(PulseAudioDataLine.this, LineEvent.Type.STOP, AudioSystem.NOT_SPECIFIED)); } @@ -131,6 +126,7 @@ public abstract class PulseAudioDataLine Stream.PlaybackStartedListener startedListener = new Stream.PlaybackStartedListener() { @Override public void update() { + isEngagedInIo = true; fireLineEvent(new LineEvent(PulseAudioDataLine.this, LineEvent.Type.START, AudioSystem.NOT_SPECIFIED)); } @@ -170,51 +166,31 @@ public abstract class PulseAudioDataLine } public void close() { - // FIXME what should be done here - assert (isOpen); + + super.close(); synchronized (eventLoop.threadLock) { - // drain(); + drain(); stream.disconnect(); } try { semaphore.acquire(); } catch (InterruptedException e) { - // throw new LineUnavailableException("unable to prepare - // stream"); - } - - isOpen = false; + throw new RuntimeException("unable to prepare stream"); + } } public void start() { - // if (isPaused) { - // synchronized (eventLoop.threadLock) { - // stream.cork(false); - // } - // isPaused = false; - // } - isStarted = true; - - /* - * for(LineListener l :listeners) { l.update(new LineEvent(this, - * LineEvent.Type.START, 0)); } - */ - } public void stop() { - // synchronized (eventLoop.threadLock) { - // stream.cork(true); - // } - // isPaused = true; - isStarted = false; - - } + } + + // A BIG FIXME ! /* * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4791152 : @@ -245,4 +221,30 @@ public abstract class PulseAudioDataLine return stream; } + @Override + public int getBufferSize() { + if (!isOpen) { + return DEFAULT_BUFFER_SIZE; + } + return bufferSize; + } + + public javax.sound.sampled.Line.Info getLineInfo() { + return new DataLine.Info(this.getClass(), supportedFormats, + StreamBufferAttributes.MIN_VALUE, + StreamBufferAttributes.MAX_VALUE); + } + + @Override + public AudioFormat getFormat() { + if (!isOpen) { + return defaultFormat; + } + return currentFormat; + } + + public float getLevel() { + return AudioSystem.NOT_SPECIFIED; + } + } diff -r b191c8f8cb2d -r 8ddfb8d274c7 src/java/org/classpath/icedtea/pulseaudio/PulseAudioLine.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioLine.java Wed Sep 03 10:47:27 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioLine.java Wed Sep 03 15:11:46 2008 -0400 @@ -40,20 +40,33 @@ import java.util.ArrayList; import java.util.ArrayList; import java.util.List; +import javax.sound.sampled.Control; +import javax.sound.sampled.Line; import javax.sound.sampled.LineEvent; import javax.sound.sampled.LineListener; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.Control.Type; -abstract class PulseAudioLine { +abstract class PulseAudioLine implements Line { protected List lineListeners = new ArrayList(); + protected List controls = new ArrayList(); + + // true between open() and close(). ie represents when a line has acquire + // resources protected boolean isOpen = false; public void addLineListener(LineListener listener) { this.lineListeners.add(listener); } - public void removeLineListener(LineListener listener) { - this.lineListeners.remove(listener); + @Override + public void close() { + if (!isOpen) { + throw new IllegalStateException("Line is not open"); + } + + isOpen = false; } protected void fireLineEvent(LineEvent e) { @@ -62,8 +75,51 @@ abstract class PulseAudioLine { } } + @Override + public Control getControl(Type control) { + if (isOpen) { + for (Control aControl : controls) { + if (aControl.getType() == control) { + return aControl; + } + } + } + throw new IllegalArgumentException(control.toString() + + " not supported"); + } + + @Override + public Control[] getControls() { + if (!isOpen) { + return new Control[] {}; + } + + return (Control[]) controls.toArray(new Control[0]); + } + + public boolean isControlSupported(Type control) { + for (Control myControl : controls) { + if (myControl.getType().getClass() == control.getClass()) { + return true; + } + } + return false; + } + public boolean isOpen() { return isOpen; } + @Override + public void open() throws LineUnavailableException { + if (isOpen) { + throw new IllegalStateException("Line is already open"); + } + isOpen = true; + } + + public void removeLineListener(LineListener listener) { + lineListeners.remove(listener); + } + } diff -r b191c8f8cb2d -r 8ddfb8d274c7 src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Wed Sep 03 10:47:27 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Wed Sep 03 15:11:46 2008 -0400 @@ -119,15 +119,17 @@ public class PulseAudioMixer implements Map properties; - int[] channelSizes = new int[] { 1, 2, 5 }; + /* + * frameSize = sample size (in bytes, not bits) x # of channels ^ From + * PulseAudio's sources + * http://git.0pointer.de/?p=pulseaudio.git;a=blob;f=src/pulse/sample.c;h=93da2465f4301e27af4976e82737c3a048124a68;hb=82ea8dde8abc51165a781c69bc3b38034d62d969#l63 + */ + + int[] channelSizes = new int[] { 1, 2, 5, 6, 8 }; for (int channelSize : channelSizes) { properties = new HashMap(); properties.put(PULSEAUDIO_FORMAT_KEY, "PA_SAMPLE_U8"); - // frameSize = sample size (in bytes, not bits) x # of channels - // ^ that's from PulseAudio sources, so it will pretty much break - // as soon as they change something - // FIXME ^ int sampleSize = 8; // in bits AudioFormat PA_SAMPLE_U8 = new AudioFormat(Encoding.PCM_UNSIGNED, // encoding AudioSystem.NOT_SPECIFIED, // sample rate @@ -145,11 +147,6 @@ public class PulseAudioMixer implements properties = new HashMap(); properties.put(PULSEAUDIO_FORMAT_KEY, "PA_SAMPLE_ALAW"); - // frameSize = sample size (in bytes, not bits) x # of channels - // ^ that's from PulseAudio sources, so it will pretty much break - // as soon as they change something - // FIXME ^ - int sampleSize = 8; final AudioFormat PA_SAMPLE_ALAW = new AudioFormat(Encoding.ALAW, // encoding AudioSystem.NOT_SPECIFIED, // sample rate @@ -167,11 +164,6 @@ public class PulseAudioMixer implements properties = new HashMap(); properties.put(PULSEAUDIO_FORMAT_KEY, "PA_SAMPLE_ULAW"); - // frameSize = sample size (in bytes, not bits) x # of channels - // ^ that's from PulseAudio sources, so it will pretty much break - // as soon as they change something - // FIXME ^ - int sampleSize = 8; final AudioFormat PA_SAMPLE_ULAW = new AudioFormat(Encoding.ULAW, // encoding AudioSystem.NOT_SPECIFIED, // sample rate @@ -188,11 +180,6 @@ public class PulseAudioMixer implements for (int channelSize : channelSizes) { properties = new HashMap(); properties.put(PULSEAUDIO_FORMAT_KEY, "PA_SAMPLE_S16BE"); - - // frameSize = sample size (in bytes, not bits) x # of channels - // ^ that's from PulseAudio sources, so it will pretty much break - // as soon as they change something - // FIXME ^ int sampleSize = 16; final AudioFormat PA_SAMPLE_S16BE = new AudioFormat( @@ -212,11 +199,6 @@ public class PulseAudioMixer implements properties = new HashMap(); properties.put(PULSEAUDIO_FORMAT_KEY, "PA_SAMPLE_S16LE"); - // frameSize = sample size (in bytes, not bits) x # of channels - // ^ that's from PulseAudio sources, so it will pretty much break - // as soon as they change something - // FIXME ^ - int sampleSize = 16; final AudioFormat A_SAMPLE_S16LE = new AudioFormat( Encoding.PCM_SIGNED, // encoding @@ -235,11 +217,6 @@ public class PulseAudioMixer implements properties = new HashMap(); properties.put(PULSEAUDIO_FORMAT_KEY, "PA_SAMPLE_S32BE"); - // frameSize = sample size (in bytes, not bits) x # of channels - // ^ that's from PulseAudio sources, so it will pretty much break - // as soon as they change something - // FIXME ^ - int sampleSize = 32; final AudioFormat PA_SAMPLE_S32BE = new AudioFormat( Encoding.PCM_SIGNED, // encoding @@ -258,11 +235,6 @@ public class PulseAudioMixer implements properties = new HashMap(); properties.put(PULSEAUDIO_FORMAT_KEY, "PA_SAMPLE_S32LE"); - // frameSize = sample size (in bytes, not bits) x # of channels - // ^ that's from PulseAudio sources, so it will pretty much break - // as soon as they change something - // FIXME ^ - int sampleSize = 32; final AudioFormat PA_SAMPLE_S32LE = new AudioFormat( Encoding.PCM_SIGNED, // encoding @@ -284,7 +256,7 @@ public class PulseAudioMixer implements public Line getLine(javax.sound.sampled.Line.Info info) throws LineUnavailableException { - if (!this.isOpen) { + if (!isOpen) { throw new LineUnavailableException(); } @@ -331,12 +303,8 @@ public class PulseAudioMixer implements return new PulseAudioClip(eventLoop, formats, defaultFormat); } - String portName; - boolean isSource; - if (Port.Info.class.isInstance(info)) { Port.Info portInfo = (Port.Info) info; - portName = portInfo.getName(); if (portInfo.isSource()) { return new PulseAudioSourcePort(portInfo.getName(), eventLoop); From gnu_andrew at member.fsf.org Thu Sep 4 01:45:15 2008 From: gnu_andrew at member.fsf.org (Andrew John Hughes) Date: Thu, 4 Sep 2008 09:45:15 +0100 Subject: [patch] Support New NIO in IcedTea In-Reply-To: <20080903150949.GA24121@bamboo.destinee.acro.gen.nz> References: <20080831004043.GA19370@bamboo.destinee.acro.gen.nz> <1220193693.3524.24.camel@hermans.wildebeest.org> <20080901064900.GC19370@bamboo.destinee.acro.gen.nz> <17c6771e0809011016y7755358dm5bd9cd7b6eb412ea@mail.gmail.com> <20080902003845.GE19370@bamboo.destinee.acro.gen.nz> <17c6771e0809020825y1ca96d87g828ff903e7eb1da2@mail.gmail.com> <20080903150949.GA24121@bamboo.destinee.acro.gen.nz> Message-ID: <17c6771e0809040145x1dd8a42dsa20e7df0e52509b6@mail.gmail.com> 2008/9/3 C. K. Jester-Young : > Attached are some patches that help the current nio2 tip build with the > current IcedTea tip. :-) The rest of the message is my reply to Andrew, > which other readers probably won't care about. :-P > > On Tue, Sep 02, 2008 at 04:25:49PM +0100, Andrew John Hughes wrote: >> >> Could be the opening " after bootclasspath without a closing one. >> > >> > That's two single quotes, not a double quote, so it should represent an >> > empty string. >> >> Sorry, hard to tell with whatever font GMail is using... > > Yeah, it's a bit a shame that you can't choose to use a monospace font > with Gmail...I personally use Mutt to do all my mailing list stuff, just > because no webmail system I've seen does proper (strict) threading, list > header fields (Mail-Followup-To, etc.), inline attachments, customisable > attachment content types, or the like. I sang with joy the day I heard > that Gmail supported IMAP access. > Yes, I have a bug list for it as long as my arm, trying to force top-posting being the main one. I reported this but they seem to have done nothing to fix it. I use Mutt for my university IMAP account but it's far too slow to use with the amount of mail I get and unsecured - this is probably down to the University's choice of mail server rather than IMAP itself. Is Google's IMAP access SSL-encrypted? >> Well that's actually IcedTea. I'm not sure what the difference is >> between --with-openjdk >> and --with-icedtea except that the latter is probably more well-tested. > > >From what I can see, there isn't a difference between the two except > the default directories that get used for each. > Yeah, there is still a lot of oddities in IcedTea that I don't really understand and pre-date its public availability. Another is that an ecj binary is detected, but I'm not sure it's even used any more. The ecj used by ecj builds is from javac.in which means it's always interpreted; this is actually what slows my build down the most noticeably, and I've been meaning to look into getting it to pre-compile ecj if gcj is detected. Using the system ecj would fix this too, but I guess there are some broken versions out there in various distros. >> > I'm doing my testing with ecj now