[xiph-commits] r10419 - in trunk/maemo/OggPlay: . debian src
mgrimme at svn.xiph.org
mgrimme at svn.xiph.org
Mon Nov 21 02:46:32 PST 2005
Author: mgrimme
Date: 2005-11-21 02:46:23 -0800 (Mon, 21 Nov 2005)
New Revision: 10419
Modified:
trunk/maemo/OggPlay/ChangeLog
trunk/maemo/OggPlay/configure.ac
trunk/maemo/OggPlay/debian/changelog
trunk/maemo/OggPlay/debian/files
trunk/maemo/OggPlay/oggplay.desktop
trunk/maemo/OggPlay/src/decoder.c
trunk/maemo/OggPlay/src/decoder.h
trunk/maemo/OggPlay/src/gui.c
trunk/maemo/OggPlay/src/gui.h
trunk/maemo/OggPlay/src/main.c
Log:
added [play] and [stop] buttons
Modified: trunk/maemo/OggPlay/ChangeLog
===================================================================
--- trunk/maemo/OggPlay/ChangeLog 2005-11-21 02:49:28 UTC (rev 10418)
+++ trunk/maemo/OggPlay/ChangeLog 2005-11-21 10:46:23 UTC (rev 10419)
@@ -1,6 +1,7 @@
2005-11-21 Martin Grimme <martin at pycage.de>
* src/gui.c: Implemented fullscreen mode.
+ Added [Play] and [Stop] buttons.
* src/decoder.c: Applied patch by Ralph Giles <giles at xiph.org> for
case insensitive comment tag names.
Modified: trunk/maemo/OggPlay/configure.ac
===================================================================
--- trunk/maemo/OggPlay/configure.ac 2005-11-21 02:49:28 UTC (rev 10418)
+++ trunk/maemo/OggPlay/configure.ac 2005-11-21 10:46:23 UTC (rev 10419)
@@ -1,5 +1,5 @@
AC_INIT(Makefile.am)
-AM_INIT_AUTOMAKE(OggPlay, 0.12)
+AM_INIT_AUTOMAKE(OggPlay, 0.20)
AC_PROG_CPP
AC_PROG_INSTALL
Modified: trunk/maemo/OggPlay/debian/changelog
===================================================================
--- trunk/maemo/OggPlay/debian/changelog 2005-11-21 02:49:28 UTC (rev 10418)
+++ trunk/maemo/OggPlay/debian/changelog 2005-11-21 10:46:23 UTC (rev 10419)
@@ -1,12 +1,18 @@
+oggplay (0.20) unstable; urgency=low
+
+ * see ChangeLog for details
+
+ -- Martin Grimme <martin.grimme at lintegra.de> Mon, 21 Nov 2005 11:42:39 +0100
+
oggplay (0.12) unstable; urgency=low
- * see Changelog for details
+ * 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
+ * see ChangeLog for details
-- Martin Grimme <martin.grimme at lintegra.de> Tue, 15 Nov 2005 23:32:19 +0100
Modified: trunk/maemo/OggPlay/debian/files
===================================================================
--- trunk/maemo/OggPlay/debian/files 2005-11-21 02:49:28 UTC (rev 10418)
+++ trunk/maemo/OggPlay/debian/files 2005-11-21 10:46:23 UTC (rev 10419)
@@ -1 +1 @@
-oggplay_0.12_arm.deb unknown optional
+oggplay_0.20_arm.deb unknown optional
Modified: trunk/maemo/OggPlay/oggplay.desktop
===================================================================
--- trunk/maemo/OggPlay/oggplay.desktop 2005-11-21 02:49:28 UTC (rev 10418)
+++ trunk/maemo/OggPlay/oggplay.desktop 2005-11-21 10:46:23 UTC (rev 10419)
@@ -1,6 +1,6 @@
[Desktop Entry]
Encoding=UTF-8
-Version=0.12
+Version=0.20
Type=Application
Name=Ogg Vorbis Player
Exec=/var/lib/install/usr/bin/oggplay
Modified: trunk/maemo/OggPlay/src/decoder.c
===================================================================
--- trunk/maemo/OggPlay/src/decoder.c 2005-11-21 02:49:28 UTC (rev 10418)
+++ trunk/maemo/OggPlay/src/decoder.c 2005-11-21 10:46:23 UTC (rev 10419)
@@ -32,7 +32,6 @@
char pcmout[128];
long ret = 1;
int current_section;
- int cnt = 0;
gboolean running = TRUE;
while (running) {
@@ -55,11 +54,12 @@
if (ret == 0) {
fprintf(stderr, "End of stream.\n");
dec->is_playing = FALSE;
+ audio_play(dec->audio, pcmout, 0, 0);
} 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);
+ audio_play(dec->audio, pcmout, (int) ret, dec->millisecs);
}
}
@@ -184,7 +184,6 @@
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);
@@ -237,15 +236,38 @@
}
+gboolean
+decoder_is_playing(Decoder *dec) {
+
+ return dec->is_playing;
+
+}
+
+
void
-decoder_seek(Decoder *dec, long millisecs) {
+decoder_play(Decoder *dec) {
+ dec->is_playing = TRUE;
+
+}
+
+
+void
+decoder_stop(Decoder *dec) {
+
+ dec->is_playing = FALSE;
+
+}
+
+
+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);
Modified: trunk/maemo/OggPlay/src/decoder.h
===================================================================
--- trunk/maemo/OggPlay/src/decoder.h 2005-11-21 02:49:28 UTC (rev 10418)
+++ trunk/maemo/OggPlay/src/decoder.h 2005-11-21 10:46:23 UTC (rev 10419)
@@ -62,5 +62,8 @@
long decoder_get_total(Decoder *dec);
long decoder_get_position(Decoder *dec);
void decoder_set_volume(Decoder *dec, int volume);
+gboolean decoder_is_playing(Decoder *dec);
+void decoder_play(Decoder *dec);
+void decoder_stop(Decoder *dec);
void decoder_seek(Decoder *dec, long millisecs);
#endif
Modified: trunk/maemo/OggPlay/src/gui.c
===================================================================
--- trunk/maemo/OggPlay/src/gui.c 2005-11-21 02:49:28 UTC (rev 10418)
+++ trunk/maemo/OggPlay/src/gui.c 2005-11-21 10:46:23 UTC (rev 10419)
@@ -114,7 +114,25 @@
}
+static void
+play_cb(GtkWidget *src,
+ Gui *gui) {
+ (gui->control_cb)(gui->control_cb_data, PLAY);
+
+}
+
+
+static void
+stop_cb(GtkWidget *src,
+ Gui *gui) {
+
+ (gui->control_cb)(gui->control_cb_data, STOP);
+
+}
+
+
+
Gui *
gui_new() {
@@ -122,6 +140,8 @@
GtkWidget *hbox;
GtkWidget *toolbar;
GtkToolItem *tb_open;
+ GtkToolItem *tb_play;
+ GtkToolItem *tb_stop;
GtkToolItem *tb_seekbar;
GtkToolItem *tb_timelabel;
@@ -146,6 +166,8 @@
gtk_box_pack_end(GTK_BOX(gui->appview->vbox), toolbar, TRUE, TRUE, 0);
tb_open = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
+ gui->tb_play = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PLAY);
+ tb_stop = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_STOP);
gui->seekbar = hildon_seekbar_new();
gtk_widget_set_size_request(gui->seekbar, 400, -1);
@@ -156,7 +178,9 @@
tb_timelabel = gtk_tool_item_new();
gtk_container_add(GTK_CONTAINER(tb_timelabel), gui->timelabel);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_open, -1);
+ gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_open, -1);
+ gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gui->tb_play, -1);
+ gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_stop, -1);
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_seekbar, -1);
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_timelabel, -1);
@@ -177,6 +201,12 @@
g_signal_connect(G_OBJECT(tb_open), "clicked",
G_CALLBACK(open_cb), gui);
+ g_signal_connect(G_OBJECT(gui->tb_play), "clicked",
+ G_CALLBACK(play_cb), gui);
+
+ g_signal_connect(G_OBJECT(tb_stop), "clicked",
+ G_CALLBACK(stop_cb), gui);
+
gtk_widget_show_all(GTK_WIDGET(gui->appwindow));
@@ -235,6 +265,17 @@
void
+gui_set_control_cb(Gui *gui,
+ CONTROL_CB,
+ void *userdata) {
+
+ gui->control_cb = control_cb;
+ gui->control_cb_data = userdata;
+
+}
+
+
+void
gui_set_title(Gui *gui,
const char *title,
const char *artist,
@@ -270,3 +311,17 @@
g_free(time);
}
+
+
+void
+gui_set_paused(Gui *gui,
+ gboolean value) {
+
+ if (value)
+ gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(gui->tb_play),
+ GTK_STOCK_MEDIA_PAUSE);
+ else
+ gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(gui->tb_play),
+ GTK_STOCK_MEDIA_PLAY);
+
+}
Modified: trunk/maemo/OggPlay/src/gui.h
===================================================================
--- trunk/maemo/OggPlay/src/gui.h 2005-11-21 02:49:28 UTC (rev 10418)
+++ trunk/maemo/OggPlay/src/gui.h 2005-11-21 10:46:23 UTC (rev 10419)
@@ -34,10 +34,12 @@
#include "decoder.h"
-#define OPEN_CB void (*open_cb) (void *userdata, const char *uri)
-#define SEEK_CB void (*seek_cb) (void *userdata, int seconds)
-#define VOLUME_CB void (*volume_cb) (void *userdata, int volume)
+#define OPEN_CB void (*open_cb) (void *userdata, const char *uri)
+#define SEEK_CB void (*seek_cb) (void *userdata, int seconds)
+#define VOLUME_CB void (*volume_cb) (void *userdata, int volume)
+#define CONTROL_CB void (*control_cb) (void *userdata, int command)
+enum Command { PLAY, STOP };
struct _Gui {
@@ -48,7 +50,10 @@
void *seek_cb_data;
VOLUME_CB;
void *volume_cb_data;
+ CONTROL_CB;
+ void *control_cb_data;
+
int seek_position;
HildonApp *appwindow;
@@ -57,6 +62,7 @@
GtkWidget *songlabel;
GtkWidget *seekbar;
GtkWidget *timelabel;
+ GtkWidget *tb_play;
};
typedef struct _Gui Gui;
@@ -69,11 +75,11 @@
void gui_set_open_cb(Gui *gui, OPEN_CB, void *userdata);
void gui_set_seek_cb(Gui *gui, SEEK_CB, void *userdata);
void gui_set_volume_cb(Gui *gui, VOLUME_CB, void *userdata);
+void gui_set_control_cb(Gui *gui, CONTROL_CB, void *userdata);
void gui_set_title(Gui *gui, const char *title, const char *artist,
const char *album);
void gui_set_time(Gui *gui, int seconds, int total);
+void gui_set_paused(Gui *gui, gboolean value);
-
-
#endif
Modified: trunk/maemo/OggPlay/src/main.c
===================================================================
--- trunk/maemo/OggPlay/src/main.c 2005-11-21 02:49:28 UTC (rev 10418)
+++ trunk/maemo/OggPlay/src/main.c 2005-11-21 10:46:23 UTC (rev 10419)
@@ -26,7 +26,7 @@
#define SERVICE_NAME "oggplay"
-#define VERSION "0.12"
+#define VERSION "0.20"
struct _AppData {
@@ -48,9 +48,11 @@
int p, t;
- p = decoder_get_position(appdata->decoder);
- t = decoder_get_total(appdata->decoder);
- gui_set_time(appdata->gui, p, t);
+ if (decoder_is_playing(appdata->decoder)) {
+ p = decoder_get_position(appdata->decoder);
+ t = decoder_get_total(appdata->decoder);
+ gui_set_time(appdata->gui, p, t);
+ }
return TRUE;
@@ -70,12 +72,14 @@
/* open new stream */
appdata->stream = stream_new_from_uri(uri);
decoder_open_stream(appdata->decoder, appdata->stream);
+ decoder_play(appdata->decoder);
gui_set_title(appdata->gui,
appdata->decoder->tag_title,
appdata->decoder->tag_artist,
appdata->decoder->tag_album);
+
}
@@ -85,6 +89,8 @@
int seconds) {
decoder_seek(appdata->decoder, seconds * 1000);
+ decoder_play(appdata->decoder);
+ gui_set_paused(appdata->gui, FALSE);
}
@@ -99,7 +105,38 @@
}
+/* callback for control buttons */
+static void
+control_cb(AppData *appdata,
+ int command) {
+ switch (command) {
+ case (PLAY):
+ if (decoder_is_playing(appdata->decoder)) {
+ decoder_stop(appdata->decoder);
+ gui_set_paused(appdata->gui, TRUE);
+ } else {
+ decoder_play(appdata->decoder);
+ gui_set_paused(appdata->gui, FALSE);
+ }
+ break;
+
+ case (STOP):
+ decoder_stop(appdata->decoder);
+ decoder_seek(appdata->decoder, 0);
+ appdata->current_position = decoder_get_position(appdata->decoder);
+ gui_set_time(appdata->gui, 0, decoder_get_total(appdata->decoder));
+ gui_set_paused(appdata->gui, FALSE);
+ break;
+
+ default:
+ break;
+ }
+
+}
+
+
+
int
main(int argc,
char *argv[]) {
@@ -123,6 +160,7 @@
gui_set_open_cb(appdata->gui, open_cb, (void *) appdata);
gui_set_volume_cb(appdata->gui, volume_cb, (void *) appdata);
gui_set_seek_cb(appdata->gui, seek_cb, (void *) appdata);
+ gui_set_control_cb(appdata->gui, control_cb, (void *) appdata);
g_timeout_add(500, (GSourceFunc) status_cb, appdata);
More information about the commits
mailing list