alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH TINYCOMPRESS 1/14] compress: Add function to get timestamp in samples
@ 2013-02-10  0:02 Richard Fitzgerald
  2013-02-11  6:34 ` Vinod Koul
  2013-02-22 15:56 ` [PATCH TINYCOMPRESS 1/14 v2] " Richard Fitzgerald
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Fitzgerald @ 2013-02-10  0:02 UTC (permalink / raw)
  To: vinod.koul; +Cc: alsa-devel

The compress_get_hpointer() converts the timestamp into actual
time. But Android needs it in samples. To avoid the inefficiency
of using compress_get_hpointer() and converting into time and then
back into samples, this change adds compress_get_tstamp() which
returns the raw struct snd_compr_tstamp.

diff --git a/compress.c b/compress.c
index faef982..19b9366 100644
--- a/compress.c
+++ b/compress.c
@@ -287,6 +287,18 @@ int compress_get_hpointer(struct compress *compress,
 	return 0;
 }

+int compress_get_tstamp(struct compress *compress,
+			struct snd_compr_tstamp *tstamp )
+{
+	if (!is_compress_ready(compress))
+		return oops(compress, -ENODEV, "device not ready");
+
+	if (ioctl(compress->fd, SNDRV_COMPRESS_TSTAMP, tstamp))
+		return oops(compress, errno, "cannot get avail");
+
+	return 0;
+}
+
 int compress_write(struct compress *compress, char *buf, unsigned int size)
 {
 	struct snd_compr_avail avail;
diff --git a/include/tinycompress/tinycompress.h b/include/tinycompress/tinycompress.h
index 13dea3e..8a98527 100644
--- a/include/tinycompress/tinycompress.h
+++ b/include/tinycompress/tinycompress.h
@@ -73,6 +73,7 @@ struct compr_config {
 #define COMPRESS_IN         0x10000000

 struct compress;
+struct snd_compr_tstamp;

 /*
  * compress_open: open a new compress stream
@@ -103,6 +104,18 @@ void compress_close(struct compress *compress);
  */
 int compress_get_hpointer(struct compress *compress,
 		unsigned int *avail, struct timespec *tstamp);
+
+
+/*
+ * compress_get_tstamp: get the raw hw timestamp
+ * return 0 on success, negative on error
+ *
+ * @compress: compress stream on which query is made
+ * @tstamp: timestamp information
+ */
+int compress_get_tstamp(struct compress *compress,
+						struct snd_compr_tstamp *tstamp );
+
 /*
  * compress_write: write data to the compress stream
  * return bytes written on success, negative on error
--
1.7.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-02-22 18:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-10  0:02 [PATCH TINYCOMPRESS 1/14] compress: Add function to get timestamp in samples Richard Fitzgerald
2013-02-11  6:34 ` Vinod Koul
2013-02-11 14:11   ` Pierre-Louis Bossart
2013-02-19 17:18     ` Richard Fitzgerald
2013-02-19 17:24   ` Richard Fitzgerald
2013-02-20  5:50     ` Vinod Koul
2013-02-22 15:56 ` [PATCH TINYCOMPRESS 1/14 v2] " Richard Fitzgerald
2013-02-22 18:09   ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).