[LIBMPG123]
[reactos.git] / reactos / sdk / lib / 3rdparty / libmpg123 / libmpg123.c
index 26486df..4f8329e 100644 (file)
@@ -382,9 +382,9 @@ int attribute_align_arg mpg123_getstate(mpg123_handle *mh, enum mpg123_state key
 
        return ret;
 }
-
 int attribute_align_arg mpg123_eq(mpg123_handle *mh, enum mpg123_channels channel, int band, double val)
 {
+#ifndef NO_EQUALIZER
        if(mh == NULL) return MPG123_BAD_HANDLE;
        if(band < 0 || band > 31){ mh->err = MPG123_BAD_BAND; return MPG123_ERR; }
        switch(channel)
@@ -399,12 +399,14 @@ int attribute_align_arg mpg123_eq(mpg123_handle *mh, enum mpg123_channels channe
                        return MPG123_ERR;
        }
        mh->have_eq_settings = TRUE;
+#endif
        return MPG123_OK;
 }
 
 double attribute_align_arg mpg123_geteq(mpg123_handle *mh, enum mpg123_channels channel, int band)
 {
        double ret = 0.;
+#ifndef NO_EQUALIZER
 
        /* Handle this gracefully. When there is no band, it has no volume. */
        if(mh != NULL && band > -1 && band < 32)
@@ -417,11 +419,10 @@ double attribute_align_arg mpg123_geteq(mpg123_handle *mh, enum mpg123_channels
                case MPG123_RIGHT: ret = REAL_TO_DOUBLE(mh->equalizer[1][band]); break;
                /* Default case is already handled: ret = 0 */
        }
-
+#endif
        return ret;
 }
 
-
 /* plain file access, no http! */
 int attribute_align_arg mpg123_open(mpg123_handle *mh, const char *path)
 {
@@ -1311,6 +1312,31 @@ int attribute_align_arg mpg123_set_filesize(mpg123_handle *mh, off_t size)
        return MPG123_OK;
 }
 
+off_t attribute_align_arg mpg123_framelength(mpg123_handle *mh)
+{
+       int b;
+       if(mh == NULL)
+               return MPG123_ERR;
+       b = init_track(mh);
+       if(b<0)
+               return b;
+       if(mh->track_frames > 0)
+               return mh->track_frames;
+       if(mh->rdat.filelen > 0)
+       { /* A bad estimate. Ignoring tags 'n stuff. */
+               double bpf = mh->mean_framesize > 0.
+                       ? mh->mean_framesize
+                       : compute_bpf(mh);
+               return (off_t)((double)(mh->rdat.filelen)/bpf+0.5);
+       }
+       /* Last resort: No view of the future, can at least count the frames that
+          were already parsed. */
+       if(mh->num > -1)
+               return mh->num+1;
+       /* Giving up. */
+       return MPG123_ERR;
+}
+
 off_t attribute_align_arg mpg123_length(mpg123_handle *mh)
 {
        int b;
@@ -1338,6 +1364,7 @@ off_t attribute_align_arg mpg123_length(mpg123_handle *mh)
        return length;
 }
 
+
 int attribute_align_arg mpg123_scan(mpg123_handle *mh)
 {
        int b;