[xiph-commits] r10414 - in trunk/maemo/OggPlay: . debian src
mgrimme at svn.xiph.org
mgrimme at svn.xiph.org
Sun Nov 20 08:02:54 PST 2005
Author: mgrimme
Date: 2005-11-20 08:02:39 -0800 (Sun, 20 Nov 2005)
New Revision: 10414
Added:
trunk/maemo/OggPlay/AUTHORS
trunk/maemo/OggPlay/COPYING
trunk/maemo/OggPlay/ChangeLog
trunk/maemo/OggPlay/Makefile.am
trunk/maemo/OggPlay/README
trunk/maemo/OggPlay/TODO
trunk/maemo/OggPlay/autogen.sh
trunk/maemo/OggPlay/configure.ac
trunk/maemo/OggPlay/debian/
trunk/maemo/OggPlay/debian/changelog
trunk/maemo/OggPlay/debian/compat
trunk/maemo/OggPlay/debian/control
trunk/maemo/OggPlay/debian/copyright
trunk/maemo/OggPlay/debian/files
trunk/maemo/OggPlay/debian/oggplay.links
trunk/maemo/OggPlay/debian/rules
trunk/maemo/OggPlay/oggplay.desktop
trunk/maemo/OggPlay/oggplay.service
trunk/maemo/OggPlay/src/
trunk/maemo/OggPlay/src/Makefile.am
trunk/maemo/OggPlay/src/audio.c
trunk/maemo/OggPlay/src/audio.h
trunk/maemo/OggPlay/src/decoder.c
trunk/maemo/OggPlay/src/decoder.h
trunk/maemo/OggPlay/src/gui.c
trunk/maemo/OggPlay/src/ringbuffer.c
trunk/maemo/OggPlay/src/ringbuffer.h
trunk/maemo/OggPlay/src/stream.c
trunk/maemo/OggPlay/src/stream.h
Log:
imported files
Added: trunk/maemo/OggPlay/AUTHORS
===================================================================
--- trunk/maemo/OggPlay/AUTHORS 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/AUTHORS 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1 @@
+Martin Grimme <martin.grimme at lintegra.de>
Added: trunk/maemo/OggPlay/COPYING
===================================================================
--- trunk/maemo/OggPlay/COPYING 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/COPYING 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Added: trunk/maemo/OggPlay/ChangeLog
===================================================================
--- trunk/maemo/OggPlay/ChangeLog 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/ChangeLog 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,28 @@
+2005-11-19 Martin Grimme <martin at pycage.de>
+
+ * src/decoder.c: Fixed some bugs.
+
+ * src/stream.c: Implemented seeking in the stream.
+
+2005-11-17 Martin Grimme <martin at pycage.de>
+
+ * src/audio.c: Implemented time tagging of the audio data. This is
+ needed for reporting the correct position of the audio playback
+ instead of the current decoding position, which is some seconds ahead.
+
+2005-11-16 Martin Grimme <martin at pycage.de>
+
+ * src/audio.c: Switched to SDL for audio output.
+ Implemented volume control.
+
+2005-11-15 Martin Grimme <martin at pycage.de>
+
+ * src/decoder.c: Go to sleep when there's no data to play.
+
+ * oggplay.desktop (X-Osso-Service):
+ * oggplay.service (Name): Changes service name since OSSO currently
+ only accepts com.nokia.
+
+2005-11-05 Martin Grimme <martin at pycage.de>
+
+ * Initial Release 0.10
Added: trunk/maemo/OggPlay/Makefile.am
===================================================================
--- trunk/maemo/OggPlay/Makefile.am 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/Makefile.am 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,25 @@
+SUBDIRS = \
+ src
+
+
+desktopdir = $(datadir)/applications/hildon
+desktop_DATA = oggplay.desktop
+
+servicedir = $(libdir)/dbus-1.0/services
+service_DATA = oggplay.service
+
+
+EXTRA_DIST = \
+ autogen.sh \
+ README \
+ AUTHORS \
+ ChangeLog \
+ COPYING \
+ debian/changelog \
+ debian/compat \
+ debian/copyright \
+ debian/control \
+ debian/rules \
+ debian/oggplay.links \
+ oggplay.desktop \
+ oggplay.service
Added: trunk/maemo/OggPlay/README
===================================================================
--- trunk/maemo/OggPlay/README 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/README 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,12 @@
+Player for Ogg Vorbis
+=====================
+
+This music player began as a proof-of-concept for Ogg Vorbis playback on the
+Nokia 770 device. As such, there are not many features at the moment, but that
+might change in the near future.
+
+Enjoy Ogg Vorbis on your nifty Nokia 770!
+
+
+---
+(c) 2005, Martin Grimme <martin.grimme at lintegra.de>
Added: trunk/maemo/OggPlay/TODO
===================================================================
--- trunk/maemo/OggPlay/TODO 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/TODO 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,5 @@
+- add some buttons such as PLAY, STOP, PAUSE, PREVIOUS, NEXT
+- add playlist support
+- implement an additional backend so that MP3 and other formats can be played
+ as well
+- integrate well with the maemo look'n feel
Added: trunk/maemo/OggPlay/autogen.sh
===================================================================
--- trunk/maemo/OggPlay/autogen.sh 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/autogen.sh 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -x
+aclocal-1.7
+autoconf
+libtoolize
+automake-1.7 --add-missing --foreign
Property changes on: trunk/maemo/OggPlay/autogen.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/maemo/OggPlay/configure.ac
===================================================================
--- trunk/maemo/OggPlay/configure.ac 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/configure.ac 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,20 @@
+AC_INIT(Makefile.am)
+AM_INIT_AUTOMAKE(OggPlay, 0.12)
+
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+
+PKG_CHECK_MODULES(GTK, gtk+-2.0)
+AC_SUBST(GTK_LIBS)
+AC_SUBST(GTK_CFLAGS)
+
+PKG_CHECK_MODULES(OSSO, libosso >= 0.8.4 hildon-libs glib-2.0 gnome-vfs-2.0)
+AC_SUBST(OSSO_LIBS)
+AC_SUBST(OSSO_CFLAGS)
+
+
+AC_OUTPUT([
+src/Makefile
+Makefile
+])
Added: trunk/maemo/OggPlay/debian/changelog
===================================================================
--- trunk/maemo/OggPlay/debian/changelog 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/debian/changelog 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,18 @@
+oggplay (0.12) unstable; urgency=low
+
+ * see Changelog for details
+
+ -- Martin Grimme <martin.grimme at lintegra.de> Sat, 19 Nov 2005 20:53:20 +0100
+
+oggplay (0.11) unstable; urgency=low
+
+ * see Changelog for details
+
+ -- Martin Grimme <martin.grimme at lintegra.de> Tue, 15 Nov 2005 23:32:19 +0100
+
+oggplay (0.10) unstable; urgency=low
+
+ * Initial release 0.10
+
+ -- Martin Grimme <martin.grimme at lintegra.de> Fri, 5 Nov 2005 01:21:03 +0100
+
Added: trunk/maemo/OggPlay/debian/compat
===================================================================
--- trunk/maemo/OggPlay/debian/compat 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/debian/compat 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1 @@
+4
Added: trunk/maemo/OggPlay/debian/control
===================================================================
--- trunk/maemo/OggPlay/debian/control 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/debian/control 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,11 @@
+Source: oggplay
+Section: unknown
+Priority: optional
+Maintainer: Martin Grimme <martin.grimme at lintegra.de>
+Build-Depends: debhelper (>= 4.0.0)
+Standards-Version: 3.6.0
+
+Package: oggplay
+Architecture: any
+Depends: maemo
+Description: Ogg Vorbis player for Nokia 770
Added: trunk/maemo/OggPlay/debian/copyright
===================================================================
--- trunk/maemo/OggPlay/debian/copyright 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/debian/copyright 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,3 @@
+Copyright (c) 2005 Martin Grimme
+
+OggPlay is licensed under the terms of the GNU GPL.
Added: trunk/maemo/OggPlay/debian/files
===================================================================
--- trunk/maemo/OggPlay/debian/files 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/debian/files 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1 @@
+oggplay_0.12_arm.deb unknown optional
Added: trunk/maemo/OggPlay/debian/oggplay.links
===================================================================
--- trunk/maemo/OggPlay/debian/oggplay.links 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/debian/oggplay.links 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1 @@
+/var/lib/install/usr/share/applications/hildon/oggplay.desktop /etc/others-menu/extra_applications/0112_oggplay.desktop
Added: trunk/maemo/OggPlay/debian/rules
===================================================================
--- trunk/maemo/OggPlay/debian/rules 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/debian/rules 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,97 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=1
+
+
+
+
+CFLAGS = -Wall
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+ INSTALL_PROGRAM += -s
+endif
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+ CFLAGS="$(CFLAGS)" ./configure --prefix=/usr
+ touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ $(MAKE)
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ -$(MAKE) clean
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package
+ $(MAKE) install DESTDIR=$(CURDIR)/debian/oggplay
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+# dh_installchangelogs
+# dh_installdocs
+# dh_installexamples
+# dh_install
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+# dh_installman
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+# dh_perl
+# dh_python
+# dh_makeshlibs
+ dh_installdeb
+# dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
\ No newline at end of file
Added: trunk/maemo/OggPlay/oggplay.desktop
===================================================================
--- trunk/maemo/OggPlay/oggplay.desktop 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/oggplay.desktop 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=0.12
+Type=Application
+Name=Ogg Vorbis Player
+Exec=/var/lib/install/usr/bin/oggplay
+Icon=qgn_list_gene_music_file
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Service=com.nokia.oggplay
+X-Osso-Type=application/x-executable
+Terminal=false
Added: trunk/maemo/OggPlay/oggplay.service
===================================================================
--- trunk/maemo/OggPlay/oggplay.service 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/oggplay.service 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=com.nokia.oggplay
+Exec=/var/lib/install/usr/bin/oggplay
Added: trunk/maemo/OggPlay/src/Makefile.am
===================================================================
--- trunk/maemo/OggPlay/src/Makefile.am 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/src/Makefile.am 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,11 @@
+bin_PROGRAMS = oggplay
+
+oggplay_SOURCES = gui.c \
+ decoder.c decoder.h \
+ audio.c audio.h \
+ stream.c stream.h \
+ ringbuffer.c ringbuffer.h
+oggplay_CFLAGS = $(GTK_CFLAGS) $(OSSO_CFLAGS)
+oggplay_LDADD = $(GTK_LIBS) $(OSSO_LIBS) \
+ /usr/lib/libvorbisidec.la \
+ -lSDL
Added: trunk/maemo/OggPlay/src/audio.c
===================================================================
--- trunk/maemo/OggPlay/src/audio.c 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/src/audio.c 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,178 @@
+/*
+ * This program 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 of the License. The original
+ * author of the programm (Tino H. Seifert) will decide if later versions
+ * are also acceptable.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#include "audio.h"
+
+
+/* Audio callback for SDL */
+static void
+audio_cb(void *userdata,
+ Uint8 *stream,
+ int size) {
+
+ Audio *audio = (Audio *) userdata;
+ Uint8 *buffer;
+ char *tmp;
+ int filled = 0;
+
+ buffer = g_new0(Uint8, size);
+ tmp = g_new0(char, 8);
+
+ while (filled < size) {
+ /* don't hang here if audio buffer became empty */
+ if (! ringbuffer_is_empty(audio->buffer)) {
+
+ /* read time tag */
+ ringbuffer_get(audio->buffer, tmp);
+ audio->timetag = ((long *) tmp)[0];
+
+ /* read audio data */
+ filled += ringbuffer_get(audio->buffer, buffer + filled);
+
+ } else {
+ break;
+ }
+ }
+
+ /* mix audio stream with volume settings */
+ if (filled == size)
+ SDL_MixAudio(stream, buffer, size, audio->volume);
+
+ g_free(buffer);
+ g_free(tmp);
+
+}
+
+
+Audio *
+audio_new() {
+
+ Audio *audio = g_new0(Audio, 1);
+ audio->buffer = ringbuffer_new(1000, 128);
+ audio->opened = FALSE;
+ audio->volume = 64;
+
+ if (SDL_Init(SDL_INIT_AUDIO) < 0) {
+ fprintf(stderr, "Could not initialize audio: %s\n", SDL_GetError());
+ exit(1);
+ }
+ atexit(SDL_Quit);
+
+ return audio;
+
+}
+
+
+void
+audio_free(Audio *audio) {
+
+ ringbuffer_free(audio->buffer);
+ g_free(audio);
+
+}
+
+
+void
+audio_open_device(Audio *audio,
+ int channels,
+ int rate) {
+
+ SDL_AudioSpec format;
+
+ audio->channels = channels;
+ audio->rate = rate;
+
+ format.freq = rate;
+ format.format = AUDIO_S16;
+ format.channels = channels;
+ format.samples = 1024;
+ format.callback = audio_cb;
+ format.userdata = (void *) audio;
+
+ /* clear buffer for loading a new stream */
+ audio_flush(audio);
+
+ /* open audio device */
+ if (SDL_OpenAudio(&format, NULL) < 0) {
+ fprintf(stderr, "Could not open audio device: %s\n", SDL_GetError());
+ } else {
+ audio->opened = TRUE;
+ SDL_PauseAudio(0);
+ }
+
+}
+
+
+void
+audio_close_device(Audio *audio) {
+
+ if (audio->opened) {
+ SDL_CloseAudio();
+ audio->opened = FALSE;
+ }
+
+}
+
+
+/* Schedules the given stream for playback. */
+void
+audio_play(Audio *audio,
+ const char *data,
+ int size,
+ long timetag) {
+
+ char *tmp;
+
+ /* quite a hack for transmitting the time tag, but it works well */
+ tmp = g_new0(char, 8);
+ ((long *) tmp)[0] = timetag;
+
+ /* transmit the time tag and the audio data */
+ ringbuffer_put(audio->buffer, tmp, 8);
+ ringbuffer_put(audio->buffer, data, size);
+
+ g_free(tmp);
+
+}
+
+
+/* flushs the audio buffer instantly */
+void
+audio_flush(Audio *audio) {
+
+ ringbuffer_clear(audio->buffer);
+
+}
+
+
+void
+audio_set_volume(Audio *audio,
+ int volume) {
+
+ audio->volume = SDL_MIX_MAXVOLUME * (volume / 100.0);
+
+}
+
+
+long
+audio_get_timetag(Audio *audio) {
+
+ return audio->timetag;
+
+}
Added: trunk/maemo/OggPlay/src/audio.h
===================================================================
--- trunk/maemo/OggPlay/src/audio.h 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/src/audio.h 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,53 @@
+/*
+ * This program 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 of the License. The original
+ * author of the programm (Tino H. Seifert) will decide if later versions
+ * are also acceptable.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#ifndef AUDIO_H
+#define AUDIO_H
+
+#include <SDL/SDL.h>
+#include <glib.h>
+#include <stdio.h>
+#include "ringbuffer.h"
+
+
+struct _Audio {
+
+ RingBuffer *buffer;
+
+ gboolean opened;
+ int volume;
+ int channels;
+ int rate;
+ long timetag;
+
+};
+typedef struct _Audio Audio;
+
+
+
+Audio* audio_new();
+void audio_free(Audio *audio);
+void audio_open_device(Audio *audio, int channels, int rate);
+void audio_close_device(Audio *audio);
+void audio_play(Audio *audio, const char *data, int size, long timetag);
+void audio_flush(Audio *audio);
+void audio_set_volume(Audio *audio, int volume);
+long audio_get_timetag(Audio *audio);
+
+#endif
Added: trunk/maemo/OggPlay/src/decoder.c
===================================================================
--- trunk/maemo/OggPlay/src/decoder.c 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/src/decoder.c 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,250 @@
+/*
+ * This program 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 of the License. The original
+ * author of the programm (Tino H. Seifert) will decide if later versions
+ * are also acceptable.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#include "decoder.h"
+
+
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t cmdmutex = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+decoder_thread(Decoder *dec) {
+
+ char pcmout[128];
+ long ret = 1;
+ int current_section;
+ int cnt = 0;
+ gboolean running = TRUE;
+
+ while (running) {
+ /* process commands */
+ pthread_mutex_lock(&mutex);
+ switch (dec->cmd) {
+ case (DECODER_SET_AUDIO):
+ audio_close_device(dec->audio);
+ audio_open_device(dec->audio, dec->channels, dec->rate);
+ break;
+ default:
+ ;
+ }
+ dec->cmd = DECODER_NONE;
+ pthread_mutex_unlock(&cmdmutex);
+
+ if (dec->is_playing) {
+ ret = ov_read(&(dec->vf), pcmout, sizeof(pcmout), ¤t_section);
+
+ if (ret == 0) {
+ fprintf(stderr, "End of stream.\n");
+ dec->is_playing = FALSE;
+ } else if (ret < 0) {
+ //fprintf(stderr, "Error in stream %d.\n", current_section);
+ } else {
+ dec->millisecs = (long) ov_time_tell(&(dec->vf));
+ audio_play(dec->audio, pcmout, (int) ret, dec->millisecs);
+ }
+ }
+
+ pthread_mutex_unlock(&mutex);
+
+ if (! dec->is_playing) usleep(1000);
+ }
+
+}
+
+
+/* read callback function */
+static size_t
+read_func(void *buffer,
+ size_t size,
+ size_t nmemb,
+ void *stream) {
+
+ size_t bytes_read;
+
+ bytes_read = stream_read((Stream *) stream, (char *) buffer, size * nmemb);
+ return bytes_read;
+
+}
+
+
+/* seek callback function */
+static int
+seek_func(void *stream, ogg_int64_t offset, int whence) {
+
+ stream_seek((Stream *) stream, (long) offset, whence);
+ return 0;
+
+}
+
+
+/* tell callback function */
+static long
+tell_func(void *stream) {
+
+ return stream_tell((Stream *) stream);
+
+}
+
+
+/* close callback function */
+static int
+close_func(void *stream) {
+
+ stream_free((Stream *) stream);
+ return 1;
+
+}
+
+
+/* Parses Vorbis tag comments */
+static void
+parse_comments(Decoder *dec, vorbis_comment *comment) {
+
+ int i = 0;
+ char **parts;
+
+ for (i = 0; i < comment->comments; i++) {
+ printf("%s\n", comment->user_comments[i]);
+ parts = g_strsplit(comment->user_comments[i], "=", 0);
+ if (g_str_equal(parts[0], "TITLE"))
+ dec->tag_title = g_strdup(parts[1]);
+ else if (g_str_equal(parts[0], "ARTIST"))
+ dec->tag_artist = g_strdup(parts[1]);
+ else if (g_str_equal(parts[0], "ALBUM"))
+ dec->tag_album = g_strdup(parts[1]);
+
+ g_strfreev(parts);
+ }
+
+}
+
+
+
+Decoder *
+decoder_new() {
+
+ pthread_t th;
+ Decoder *dec = g_new0(Decoder, 1);
+ dec->vf.datasource = NULL;
+ dec->audio = audio_new();
+ dec->is_playing = FALSE;
+
+ /* spawn decoder thread */
+ pthread_create(&th, NULL, decoder_thread, (void *) dec);
+
+ return dec;
+
+}
+
+
+
+gboolean
+decoder_open_stream(Decoder *dec, Stream *stream) {
+
+ ov_callbacks ov_cb;
+ vorbis_info *vi;
+
+ ov_cb.read_func = &read_func;
+ ov_cb.seek_func = &seek_func;
+ ov_cb.tell_func = &tell_func;
+ ov_cb.close_func = &close_func;
+
+
+ pthread_mutex_lock(&mutex);
+
+ if (ov_open_callbacks((void *) stream, &(dec->vf), NULL, 0, ov_cb) > 0) {
+ fprintf(stderr, "Could not open stream.\n");
+ return FALSE;
+ }
+
+ pthread_mutex_lock(&cmdmutex);
+ vi = ov_info(&(dec->vf), -1);
+ dec->channels = vi->channels;
+ dec->rate = vi->rate;
+ dec->cmd = DECODER_SET_AUDIO;
+
+ parse_comments(dec, ov_comment(&(dec->vf), -1));
+ dec->total = (long) ov_time_total(&(dec->vf), -1);
+ dec->is_playing = TRUE;
+
+ pthread_mutex_unlock(&mutex);
+ decoder_seek(dec, 0);
+
+ return TRUE;
+
+}
+
+
+void
+decoder_close_stream(Decoder *dec) {
+
+ pthread_mutex_lock(&mutex);
+ dec->is_playing = FALSE;
+ g_free(dec->tag_title);
+ g_free(dec->tag_artist);
+ g_free(dec->tag_album);
+
+ if (dec->vf.datasource) {
+ ov_clear(&(dec->vf));
+ dec->vf.datasource = NULL;
+ }
+ pthread_mutex_unlock(&mutex);
+
+}
+
+
+long
+decoder_get_total(Decoder *dec) {
+
+ return dec->total / 1000;
+
+}
+
+
+long
+decoder_get_position(Decoder *dec) {
+
+ return audio_get_timetag(dec->audio) / 1000;
+
+}
+
+
+void
+decoder_set_volume(Decoder *dec,
+ int volume) {
+
+ audio_set_volume(dec->audio, volume);
+
+}
+
+
+void
+decoder_seek(Decoder *dec, long millisecs) {
+
+ int success;
+
+ pthread_mutex_lock(&mutex);
+ printf ("SEEK TO %d ===========================\n", (ogg_int64_t) millisecs);
+ success = ov_time_seek_page(&(dec->vf), (ogg_int64_t) millisecs);
+ printf ("SUCCESS %d\n", success);
+ audio_flush(dec->audio);
+ pthread_mutex_unlock(&mutex);
+
+}
Added: trunk/maemo/OggPlay/src/decoder.h
===================================================================
--- trunk/maemo/OggPlay/src/decoder.h 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/src/decoder.h 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,67 @@
+/*
+ * This program 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 of the License. The original
+ * author of the programm (Tino H. Seifert) will decide if later versions
+ * are also acceptable.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#ifndef DECODER_H
+#define DECODER_H
+
+#include <tremor/ivorbiscodec.h>
+#include <tremor/ivorbisfile.h>
+#include <tremor/ogg.h>
+#include <glib.h>
+#include <pthread.h>
+#include "ringbuffer.h"
+#include "stream.h"
+#include "audio.h"
+
+
+enum decodercommand { DECODER_NONE, DECODER_SET_AUDIO };
+
+struct _Decoder {
+
+ OggVorbis_File vf;
+ Audio *audio;
+
+ enum decodercommand cmd;
+
+ long millisecs;
+ long total;
+ int channels;
+ int rate;
+ gboolean is_playing;
+
+ /* Ogg comment tags */
+ char *tag_title;
+ char *tag_artist;
+ char *tag_album;
+
+};
+typedef struct _Decoder Decoder;
+
+
+
+Decoder *decoder_new();
+void decoder_free(Decoder *dec);
+gboolean decoder_open_stream(Decoder *dec, Stream *stream);
+void decoder_close_stream(Decoder *dec);
+void decoder_decode(Decoder *dec, const char *data, int size);
+long decoder_get_total(Decoder *dec);
+long decoder_get_position(Decoder *dec);
+void decoder_set_volume(Decoder *dec, int volume);
+void decoder_seek(Decoder *dec, long millisecs);
+#endif
Added: trunk/maemo/OggPlay/src/gui.c
===================================================================
--- trunk/maemo/OggPlay/src/gui.c 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/src/gui.c 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,238 @@
+/*
+ * This program 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 of the License. The original
+ * author of the programm (Tino H. Seifert) will decide if later versions
+ * are also acceptable.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <hildon-widgets/hildon-app.h>
+#include <hildon-widgets/hildon-appview.h>
+#include <hildon-widgets/hildon-file-chooser-dialog.h>
+#include <hildon-widgets/hildon-seekbar.h>
+#include <hildon-widgets/hildon-vvolumebar.h>
+#include <gtk/gtk.h>
+
+#include <libosso.h>
+
+#include "stream.h"
+#include "decoder.h"
+
+
+#define SERVICE_NAME "oggplay"
+#define VERSION "0.12"
+
+
+struct _AppData {
+
+ Decoder *decoder;
+ Stream *stream;
+ HildonApp *app;
+ HildonAppView *appview;
+ GtkWidget *seekbar;
+ GtkWidget *songlabel;
+ GtkWidget *timelabel;
+ int current_position;
+
+};
+typedef struct _AppData AppData;
+
+
+
+static int
+idle_cb(AppData *appdata) {
+
+ gint p, t;
+ int mins, secs;
+ char *time;
+
+ p = decoder_get_position(appdata->decoder);
+ t = decoder_get_total(appdata->decoder);
+
+ appdata->current_position = p;
+ hildon_seekbar_set_total_time(HILDON_SEEKBAR(appdata->seekbar), t);
+ hildon_seekbar_set_position(HILDON_SEEKBAR(appdata->seekbar), p);
+ hildon_seekbar_set_fraction(HILDON_SEEKBAR(appdata->seekbar), t);
+
+ secs = p % 60;
+ p /= 60;
+ mins = p;
+ time = g_strdup_printf(" %2d:%02d", mins, secs);
+ gtk_label_set_text(GTK_LABEL(appdata->timelabel), time);
+ g_free(time);
+
+ return TRUE;
+
+}
+
+static void
+open_cb(GtkWidget *src,
+ AppData *appdata) {
+
+ GtkWidget *dialog;
+ gchar *filename;
+ char *text;
+
+ dialog = hildon_file_chooser_dialog_new(GTK_WINDOW(appdata->app),
+ GTK_FILE_CHOOSER_ACTION_OPEN);
+ gtk_widget_show_all(dialog);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+
+ if (appdata->stream) {
+ decoder_close_stream(appdata->decoder);
+ }
+
+ appdata->current_position = 0;
+ hildon_seekbar_set_position(HILDON_SEEKBAR(appdata->seekbar), 0);
+ appdata->stream = stream_new_from_uri(filename);
+ decoder_open_stream(appdata->decoder, appdata->stream);
+ text = g_strdup_printf("%s\n<b>%s</b>\n%s",
+ appdata->decoder->tag_artist,
+ appdata->decoder->tag_title,
+ appdata->decoder->tag_album);
+ gtk_label_set_markup(appdata->songlabel, text);
+ g_free(text);
+ }
+ gtk_widget_destroy(dialog);
+
+}
+
+
+static void
+volume_cb(GtkWidget *src,
+ AppData *appdata) {
+
+ decoder_set_volume(appdata->decoder,
+ (int) hildon_volumebar_get_level(HILDON_VOLUMEBAR(src)));
+
+}
+
+
+static void
+mute_cb(GtkWidget *src,
+ AppData *appdata) {
+
+ if (hildon_volumebar_get_mute(HILDON_VOLUMEBAR(src))) {
+ decoder_set_volume(appdata->decoder, 0);
+ } else {
+ decoder_set_volume(appdata->decoder,
+ (int) hildon_volumebar_get_level(HILDON_VOLUMEBAR(src)));
+ }
+
+}
+
+
+static void
+seek_cb(GtkWidget *src,
+ AppData *appdata) {
+
+ int position;
+
+ position = hildon_seekbar_get_position(HILDON_SEEKBAR(appdata->seekbar));
+ if (position != appdata->current_position) {
+ appdata->current_position = position;
+ decoder_seek(appdata->decoder, position * 1000);
+ }
+
+}
+
+
+
+int main(int argc, char *argv[]) {
+
+ osso_context_t *osso_context;
+
+ HildonApp *app;
+ HildonAppView *appview;
+ GtkWidget *hbox;
+ GtkWidget *volumebar;
+ GtkWidget *songlabel;
+ GtkWidget *toolbar;
+ GtkToolItem *tb_open;
+ GtkToolItem *tb_seekbar;
+ GtkToolItem *tb_timelabel;
+ GtkWidget *seekbar;
+
+ AppData *appdata;
+
+ gtk_init(&argc, &argv);
+
+ app = HILDON_APP(hildon_app_new());
+
+ hildon_app_set_title(app, "OggPlay");
+ hildon_app_set_two_part_title(app, FALSE);
+
+ appdata = g_new(AppData, 1);
+ appdata->app = app;
+ appdata->decoder = decoder_new();
+ appdata->stream = NULL;
+
+ appview = HILDON_APPVIEW(hildon_appview_new(NULL));
+ appdata->appview = appview;
+ hildon_app_set_appview(app, appview);
+
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(appview), hbox);
+
+ volumebar = hildon_vvolumebar_new();
+ g_signal_connect(G_OBJECT(volumebar), "level-changed",
+ G_CALLBACK(volume_cb), appdata);
+ g_signal_connect(G_OBJECT(volumebar), "mute-toggled",
+ G_CALLBACK(mute_cb), appdata);
+ gtk_box_pack_start(GTK_BOX(hbox), volumebar, FALSE, FALSE, 0);
+
+ songlabel = gtk_label_new("");
+ gtk_box_pack_start(GTK_BOX(hbox), songlabel, TRUE, TRUE, 0);
+ appdata->songlabel = songlabel;
+
+ toolbar = gtk_toolbar_new();
+ tb_open = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
+ g_signal_connect(G_OBJECT(tb_open), "clicked",
+ G_CALLBACK(open_cb), appdata);
+
+ seekbar = hildon_seekbar_new();
+ appdata->seekbar = seekbar;
+ g_signal_connect(G_OBJECT(seekbar), "value-changed",
+ G_CALLBACK(seek_cb), appdata);
+ tb_seekbar = gtk_tool_item_new();
+ gtk_container_add(GTK_CONTAINER(tb_seekbar), seekbar);
+ gtk_widget_set_size_request(seekbar, 400, -1);
+
+ appdata->timelabel = gtk_label_new("");
+ tb_timelabel = gtk_tool_item_new();
+ gtk_container_add(GTK_CONTAINER(tb_timelabel), appdata->timelabel);
+
+ gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_open, -1);
+ gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_seekbar, -1);
+ gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_timelabel, -1);
+
+ gtk_box_pack_end(GTK_BOX(appview->vbox), toolbar, TRUE, TRUE, 0);
+
+ gtk_widget_show_all(GTK_WIDGET(app));
+
+
+ osso_context = osso_initialize(SERVICE_NAME, VERSION, TRUE, NULL);
+ if (! osso_context)
+ fprintf(stderr, "Could not initialize OSSO.");
+
+ g_timeout_add(500, (GSourceFunc) idle_cb, appdata);
+
+
+ gtk_main();
+
+ return 0;
+
+}
Added: trunk/maemo/OggPlay/src/ringbuffer.c
===================================================================
--- trunk/maemo/OggPlay/src/ringbuffer.c 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/src/ringbuffer.c 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,131 @@
+/*
+ * This program 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 of the License. The original
+ * author of the programm (Tino H. Seifert) will decide if later versions
+ * are also acceptable.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#include "ringbuffer.h"
+
+
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+
+/*
+ * Creates and returns a new ring buffer object.
+ */
+RingBuffer *
+ringbuffer_new(int n,
+ int capacity) {
+
+ RingBuffer *rb;
+ int i;
+
+ rb = g_new(RingBuffer, 1);
+ rb->n = n;
+
+ rb->buffer = g_new0(char*, n);
+ for (i = 0; i < n; i++)
+ rb->buffer[i] = g_new0(char, capacity);
+
+ rb->lengths = g_new0(int, n);
+
+ rb->consumer_idx = 0;
+ rb->producer_idx = 0;
+
+ return rb;
+
+}
+
+
+void
+ringbuffer_free(RingBuffer *rb) {
+
+ int i;
+
+ for (i = 0; i < rb->n; i++)
+ g_free(rb->buffer[i]);
+ g_free(rb->buffer);
+ g_free(rb->lengths);
+ g_free(rb);
+
+}
+
+
+void
+ringbuffer_put(RingBuffer *rb,
+ char *data,
+ int size) {
+
+ /* the producer must not write over parts which the consumer has not
+ read yet */
+ while ((rb->producer_idx + 1) % rb->n == rb->consumer_idx) {
+ usleep(100);
+ }
+
+ pthread_mutex_lock(&mutex);
+ memcpy(rb->buffer[rb->producer_idx], data, size);
+ rb->lengths[rb->producer_idx] = size;
+ rb->producer_idx = (rb->producer_idx + 1) % rb->n;
+ pthread_mutex_unlock(&mutex);
+
+}
+
+
+int
+ringbuffer_get(RingBuffer *rb,
+ char *data) {
+
+ int size;
+
+ /* the consumer must not overtake the producer */
+ while (rb->consumer_idx == rb->producer_idx)
+ usleep(100);
+
+ pthread_mutex_lock(&mutex);
+ size = rb->lengths[rb->consumer_idx];
+ memcpy(data, rb->buffer[rb->consumer_idx], size);
+ rb->consumer_idx = (rb->consumer_idx + 1) % rb->n;
+ pthread_mutex_unlock(&mutex);
+
+ return size;
+
+}
+
+
+void
+ringbuffer_clear(RingBuffer *rb) {
+
+ //pthread_mutex_lock(&mutex);
+ rb->consumer_idx = rb->producer_idx;
+ //pthread_mutex_unlock(&mutex);
+
+}
+
+
+gboolean
+ringbuffer_is_full(RingBuffer *rb) {
+
+ return (rb->producer_idx + 2) % rb->n == rb->consumer_idx;
+
+}
+
+
+gboolean
+ringbuffer_is_empty(RingBuffer *rb) {
+
+ return (rb->consumer_idx == rb->producer_idx);
+
+}
Added: trunk/maemo/OggPlay/src/ringbuffer.h
===================================================================
--- trunk/maemo/OggPlay/src/ringbuffer.h 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/src/ringbuffer.h 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,51 @@
+/*
+ * This program 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 of the License. The original
+ * author of the programm (Tino H. Seifert) will decide if later versions
+ * are also acceptable.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#ifndef RINGBUFFER_H
+#define RINGBUFFER_H
+
+#include <pthread.h>
+#include <unistd.h>
+#include <glib.h>
+
+
+struct _RingBuffer {
+
+ int n;
+
+ char **buffer;
+ int *lengths;
+
+ int consumer_idx;
+ int producer_idx;
+
+};
+
+typedef struct _RingBuffer RingBuffer;
+
+
+RingBuffer *ringbuffer_new(int n, int capacity);
+void ringbuffer_free(RingBuffer *rb);
+void ringbuffer_put(RingBuffer *rb, char *data, int size);
+int ringbuffer_get(RingBuffer *rb, char *data);
+void ringbuffer_clear(RingBuffer *rb);
+gboolean ringbuffer_is_full(RingBuffer *rb);
+gboolean ringbuffer_is_empty(RingBuffer *rb);
+
+#endif
Added: trunk/maemo/OggPlay/src/stream.c
===================================================================
--- trunk/maemo/OggPlay/src/stream.c 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/src/stream.c 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,188 @@
+/*
+ * This program 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 of the License. The original
+ * author of the programm (Tino H. Seifert) will decide if later versions
+ * are also acceptable.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#include "stream.h"
+
+#define BUFFER_SIZE 1024
+
+static pthread_mutex_t cmdmutex = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+reader_thread(Stream *stream) {
+
+ char buffer[BUFFER_SIZE];
+ char *tmp;
+
+ GnomeVFSHandle *handle;
+ gboolean is_open = FALSE;
+ gboolean running = TRUE;
+ long position = 0;
+ GnomeVFSSeekPosition vfswhence;
+
+ GnomeVFSResult result;
+ GnomeVFSFileSize bytes_read;
+
+ tmp = g_new0(char, 8);
+
+ while (running) {
+ /* process commands */
+ switch (stream->cmd) {
+ case (STREAM_OPEN):
+ printf("Opening stream %s\n", stream->uri);
+ result = gnome_vfs_open(&handle, stream->uri, GNOME_VFS_OPEN_READ);
+ if (result == GNOME_VFS_OK) {
+ is_open = TRUE;
+ position = 0;
+ }
+ break;
+ case (STREAM_CLOSE):
+ printf("Closing stream %s\n", stream->uri);
+ gnome_vfs_close(handle);
+ is_open = FALSE;
+ running = FALSE;
+ break;
+ case (STREAM_SEEK):
+ printf("Seeking %d %d\n", stream->seek_whence, stream->seek_position);
+ if (is_open) {
+ if (stream->seek_whence == SEEK_SET)
+ vfswhence = GNOME_VFS_SEEK_START;
+ else if (stream->seek_whence == SEEK_CUR)
+ vfswhence = GNOME_VFS_SEEK_CURRENT;
+ else if (stream->seek_whence == SEEK_END)
+ vfswhence = GNOME_VFS_SEEK_END;
+
+ result = gnome_vfs_seek(handle, vfswhence,
+ (GnomeVFSFileOffset) stream->seek_position);
+ ringbuffer_clear(stream->buffer);
+ gnome_vfs_tell(handle, &bytes_read);
+ position = (long) bytes_read;
+ stream->positiontag = position;
+ }
+ break;
+ default:
+ break;
+ }
+ stream->cmd = STREAM_NONE;
+ pthread_mutex_unlock(&cmdmutex);
+
+
+ if (is_open && ! ringbuffer_is_full(stream->buffer)) {
+ result = gnome_vfs_read(handle, buffer, sizeof(buffer), &bytes_read);
+ if (result == GNOME_VFS_OK) {
+
+ position += (long) bytes_read;
+ ((long *) tmp)[0] = position;
+ ringbuffer_put(stream->buffer, tmp, 8);
+ ringbuffer_put(stream->buffer, buffer, (int) bytes_read);
+
+ } else {
+
+ ringbuffer_put(stream->buffer, tmp, 8);
+ ringbuffer_put(stream->buffer, "", 0);
+
+ }
+ }
+
+ usleep(1000);
+ }
+
+ pthread_mutex_unlock(&cmdmutex);
+
+}
+
+
+Stream *
+stream_new_from_uri(const char *uri) {
+
+ pthread_t th;
+ Stream *stream = g_new(Stream, 1);
+ GnomeVFSResult result;
+
+ if (! gnome_vfs_initialized())
+ gnome_vfs_init();
+
+ stream->uri = (char *) uri;
+ stream->buffer = ringbuffer_new(10, BUFFER_SIZE);
+ stream->cmd = STREAM_OPEN;
+ stream->positiontag = 0;
+
+ pthread_mutex_lock(&cmdmutex);
+ pthread_create(&th, NULL, reader_thread, (void *) stream);
+
+ return stream;
+
+}
+
+void
+stream_free(Stream *stream) {
+
+ pthread_mutex_lock(&cmdmutex);
+ stream->cmd = STREAM_CLOSE;
+
+ pthread_mutex_lock(&cmdmutex);
+ g_free(stream->uri);
+ ringbuffer_free(stream->buffer);
+ g_free(stream);
+
+}
+
+
+int
+stream_read(Stream *stream,
+ char *buffer,
+ int size) {
+
+ pthread_mutex_lock(&cmdmutex);
+ stream->cmd = STREAM_READ; /* just to ensure the correct order */
+ ringbuffer_get(stream->buffer, buffer);
+ stream->positiontag = ((long *) buffer)[0];
+
+ return ringbuffer_get(stream->buffer, buffer);
+
+}
+
+
+long
+stream_tell(Stream *stream) {
+
+ pthread_mutex_lock(&cmdmutex);
+ printf("Tell %d\n", stream->positiontag);
+ return stream->positiontag;
+
+}
+
+
+void
+stream_seek(Stream *stream,
+ long position,
+ int whence) {
+
+ pthread_mutex_lock(&cmdmutex);
+
+ if (whence == SEEK_CUR) {
+ whence = SEEK_SET;
+ position = stream->positiontag + position;
+ }
+
+ stream->seek_position = position;
+ stream->seek_whence = whence;
+ stream->cmd = STREAM_SEEK;
+
+}
Added: trunk/maemo/OggPlay/src/stream.h
===================================================================
--- trunk/maemo/OggPlay/src/stream.h 2005-11-20 15:55:55 UTC (rev 10413)
+++ trunk/maemo/OggPlay/src/stream.h 2005-11-20 16:02:39 UTC (rev 10414)
@@ -0,0 +1,57 @@
+/*
+ * This program 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 of the License. The original
+ * author of the programm (Tino H. Seifert) will decide if later versions
+ * are also acceptable.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#ifndef STREAM_H
+#define STREAM_H
+
+#include <libgnomevfs/gnome-vfs.h>
+#include <stdio.h>
+#include <glib.h>
+#include <pthread.h>
+
+#include "ringbuffer.h"
+
+
+enum streamcommand { STREAM_NONE, STREAM_OPEN, STREAM_CLOSE,
+ STREAM_SEEK, STREAM_READ };
+
+struct _Stream {
+
+ char *uri;
+ GnomeVFSHandle *handle;
+ enum streamcommand cmd;
+
+ long positiontag;
+ long seek_position;
+ int seek_whence;
+
+ RingBuffer *buffer;
+
+};
+
+typedef struct _Stream Stream;
+
+
+Stream *stream_new_from_uri(const char *uri);
+void stream_free(Stream *stream);
+int stream_read(Stream *stream, char *buffer, int size);
+long stream_tell(Stream *stream);
+void stream_seek(Stream *stream, long position, int whence);
+
+#endif
More information about the commits
mailing list