[xiph-cvs] cvs commit: vorbis-tools/ogg123 audio.c ogg123.c oggvorbis_format.c status.c status.h
Stan Seibert
volsung at xiph.org
Sat Dec 8 19:45:28 PST 2001
volsung 01/12/08 19:45:28
Modified: ogg123 Tag: volsung_kc_20011011 audio.c ogg123.c
oggvorbis_format.c status.c status.h
Log:
Expanded status interface to take variable arguments or a va_list argument
(like printf/vprintf). Created non-buffer callbacks for decoder errors
and metadata. Tinkered with some output formatting.
Revision Changes Path
No revision
No revision
1.1.2.2 +2 -3 vorbis-tools/ogg123/Attic/audio.c
Index: audio.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/audio.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- audio.c 2001/12/08 23:59:24 1.1.2.1
+++ audio.c 2001/12/09 03:45:26 1.1.2.2
@@ -11,7 +11,7 @@
* *
********************************************************************
- last mod: $Id: audio.c,v 1.1.2.1 2001/12/08 23:59:24 volsung Exp $
+ last mod: $Id: audio.c,v 1.1.2.2 2001/12/09 03:45:26 volsung Exp $
********************************************************************/
@@ -50,7 +50,6 @@
int audio_devices_write(audio_device_t *d, void *ptr, int nbytes)
{
- int i;
audio_device_t *start = d;
d = start;
@@ -158,7 +157,7 @@
while (current != NULL) {
ao_info *info = ao_driver_info(current->driver_id);
- status_message(1, "Device: %s", info->name);
+ status_message(1, "\nDevice: %s", info->name);
status_message(1, "Author: %s", info->author);
status_message(1, "Comments: %s\n", info->comment);
1.39.2.30.2.13 +27 -5 vorbis-tools/ogg123/ogg123.c
Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.39.2.30.2.12
retrieving revision 1.39.2.30.2.13
diff -u -r1.39.2.30.2.12 -r1.39.2.30.2.13
--- ogg123.c 2001/12/08 23:59:25 1.39.2.30.2.12
+++ ogg123.c 2001/12/09 03:45:26 1.39.2.30.2.13
@@ -14,7 +14,7 @@
* *
********************************************************************
- last mod: $Id: ogg123.c,v 1.39.2.30.2.12 2001/12/08 23:59:25 volsung Exp $
+ last mod: $Id: ogg123.c,v 1.39.2.30.2.13 2001/12/09 03:45:26 volsung Exp $
********************************************************************/
@@ -144,13 +144,33 @@
opts->devices = NULL;
}
+/* ----------------------------- callbacks ------------------------------ */
+
+void decoder_error_callback (void *arg, int severity, char *message, ...)
+{
+ va_list ap;
+
+ va_start(ap, message);
+ vstatus_error(message, ap);
+ va_end(ap);
+}
+
+void decoder_metadata_callback (void *arg, int verbosity, char *message, ...)
+{
+ va_list ap;
+
+ va_start(ap, message);
+ vstatus_message(verbosity, message, ap);
+ va_end(ap);
+}
+
+
/* --------------------------- main code -------------------------------- */
int main(int argc, char **argv)
{
- int ret;
int optind;
ao_initialize();
@@ -228,7 +248,9 @@
format_t *format;
data_source_t *source;
decoder_t *decoder;
-
+ decoder_callbacks_t decoder_callbacks = { &decoder_error_callback,
+ &decoder_metadata_callback };
+
/* Preserve between calls so we only open the audio device when we
have to */
static audio_format_t old_audio_fmt = { 0, 0, 0, 0, 0 };
@@ -261,7 +283,8 @@
return;
}
- if ( (decoder = format->init(source, &new_audio_fmt, NULL, NULL)) == NULL ) {
+ if ( (decoder = format->init(source, &new_audio_fmt, &decoder_callbacks,
+ NULL)) == NULL ) {
status_error("Error opening %s using the %s module."
" The file may be corrupted.\n", source_string,
format->name);
@@ -288,7 +311,6 @@
/* Main loop: Iterates over all of the logical bitstreams in the file */
while (!eof && !sig_request.exit) {
- int i;
/* Loop through data within a logical bitstream */
eos = 0;
1.1.2.2 +5 -5 vorbis-tools/ogg123/Attic/oggvorbis_format.c
Index: oggvorbis_format.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/oggvorbis_format.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- oggvorbis_format.c 2001/12/08 23:59:25 1.1.2.1
+++ oggvorbis_format.c 2001/12/09 03:45:26 1.1.2.2
@@ -11,7 +11,7 @@
* *
********************************************************************
- last mod: $Id: oggvorbis_format.c,v 1.1.2.1 2001/12/08 23:59:25 volsung Exp $
+ last mod: $Id: oggvorbis_format.c,v 1.1.2.2 2001/12/09 03:45:26 volsung Exp $
********************************************************************/
@@ -308,23 +308,23 @@
cb->printf_metadata(decoder->callback_arg, 3,
- "Version is %d\n",
+ "Version is %d",
priv->vi->version);
cb->printf_metadata(decoder->callback_arg, 3,
"Bitrate hints: upper=%ld nominal=%ld lower=%ld "
- "window=%ld\n",
+ "window=%ld",
priv->vi->bitrate_upper,
priv->vi->bitrate_nominal,
priv->vi->bitrate_lower,
priv->vi->bitrate_window);
cb->printf_metadata(decoder->callback_arg, 2,
- "Bitstream is %d channel, %ldHz\n",
+ "Bitstream is %d channel, %ldHz",
priv->vi->channels,
priv->vi->rate);
cb->printf_metadata(decoder->callback_arg, 2,
- "Encoded by: %s\n", priv->vc->vendor);
+ "Encoded by: %s", priv->vc->vendor);
}
1.1.2.7.2.3 +35 -14 vorbis-tools/ogg123/Attic/status.c
Index: status.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/status.c,v
retrieving revision 1.1.2.7.2.2
retrieving revision 1.1.2.7.2.3
diff -u -r1.1.2.7.2.2 -r1.1.2.7.2.3
--- status.c 2001/12/08 23:59:25 1.1.2.7.2.2
+++ status.c 2001/12/09 03:45:26 1.1.2.7.2.3
@@ -11,7 +11,7 @@
* *
********************************************************************
- last mod: $Id: status.c,v 1.1.2.7.2.2 2001/12/08 23:59:25 volsung Exp $
+ last mod: $Id: status.c,v 1.1.2.7.2.3 2001/12/09 03:45:26 volsung Exp $
********************************************************************/
@@ -147,6 +147,19 @@
}
+void vstatus_print_nolock (const char *fmt, va_list ap)
+{
+ if (last_line_len != 0)
+ fputc ('\n', stderr);
+
+ vfprintf (stderr, fmt, ap);
+
+ fputc ('\n', stderr);
+
+ last_line_len = 0;
+}
+
+
/* ------------------- Public interface -------------------- */
#define TIME_STR_SIZE 20
@@ -335,7 +348,6 @@
}
-
void status_message (int verbosity, const char *fmt, ...)
{
va_list ap;
@@ -345,19 +357,24 @@
pthread_mutex_lock(&output_lock);
- if (last_line_len != 0)
- fputc ('\n', stderr);
-
va_start (ap, fmt);
- vfprintf (stderr, fmt, ap);
+ vstatus_print_nolock(fmt, ap);
va_end (ap);
- fputc ('\n', stderr);
+ pthread_mutex_unlock(&output_lock);
+}
- last_line_len = 0;
- pthread_mutex_unlock(&output_lock);
+void vstatus_message (int verbosity, const char *fmt, va_list ap)
+{
+ if (verbosity > max_verbosity)
+ return;
+ pthread_mutex_lock(&output_lock);
+
+ vstatus_print_nolock(fmt, ap);
+
+ pthread_mutex_unlock(&output_lock);
}
@@ -367,15 +384,19 @@
pthread_mutex_lock(&output_lock);
- fputc ('\n', stderr);
-
va_start (ap, fmt);
- vfprintf (stderr, fmt, ap);
+ vstatus_print_nolock (fmt, ap);
va_end (ap);
- fputc ('\n', stderr);
+ pthread_mutex_unlock(&output_lock);
+}
- last_line_len = 0;
+
+void vstatus_error (const char *fmt, va_list ap)
+{
+ pthread_mutex_lock(&output_lock);
+
+ vstatus_print_nolock (fmt, ap);
pthread_mutex_unlock(&output_lock);
}
1.1.2.4.2.3 +3 -1 vorbis-tools/ogg123/Attic/status.h
Index: status.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/status.h,v
retrieving revision 1.1.2.4.2.2
retrieving revision 1.1.2.4.2.3
diff -u -r1.1.2.4.2.2 -r1.1.2.4.2.3
--- status.h 2001/12/08 23:59:25 1.1.2.4.2.2
+++ status.h 2001/12/09 03:45:26 1.1.2.4.2.3
@@ -11,7 +11,7 @@
* *
********************************************************************
- last mod: $Id: status.h,v 1.1.2.4.2.2 2001/12/08 23:59:25 volsung Exp $
+ last mod: $Id: status.h,v 1.1.2.4.2.3 2001/12/09 03:45:26 volsung Exp $
********************************************************************/
@@ -62,6 +62,8 @@
void status_clear_line ();
void status_print_statistics (stat_t *stats);
void status_message (int verbosity, const char *fmt, ...);
+void vstatus_message (int verbosity, const char *fmt, va_list ap);
void status_error (const char *fmt, ...);
+void vstatus_error (const char *fmt, va_list);
#endif /* __STATUS_H__ */
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list