@@ -405,6 +405,7 @@ long nextframe(long seekpos)
405
405
{
406
406
long oldseekpos = seekpos ; /* remember seekpos */
407
407
unsigned char a ,b ,c ,d ;
408
+ unsigned int framesz = 0 ;
408
409
409
410
if (seekpos >=filesize ) return filesize ;
410
411
@@ -415,7 +416,8 @@ long nextframe(long seekpos)
415
416
b = fgetc (mp3file );
416
417
c = fgetc (mp3file );
417
418
d = fgetc (mp3file );
418
- if (a == 255 && framesize (b ,c ,d )!= 1 && sampfreq (b ,c )!= 1 ) seekpos = seekpos + framesize (b ,c ,d );
419
+
420
+ if (a == 255 && (framesz = framesize (b ,c ,d ))!= 1 && sampfreq (b ,c )!= 1 ) seekpos = seekpos + framesz ;
419
421
else seekpos = oldseekpos + 1 ;
420
422
421
423
/* find next possible header, start right at seekpos */
@@ -431,15 +433,15 @@ long nextframe(long seekpos)
431
433
b = fgetc (mp3file );
432
434
c = fgetc (mp3file );
433
435
d = fgetc (mp3file );
434
- if (framesize (b ,c ,d )!= 1 && sampfreq (b ,c )!= 1 ) break ; /* next header found */
436
+ if (( framesz = framesize (b ,c ,d ) )!= 1 && sampfreq (b ,c )!= 1 ) break ; /* next header found */
435
437
}
436
438
seekpos ++ ;
437
439
}
438
440
439
441
/* also check next frame if possible */
440
- if (seekpos + framesize ( b , c , d ) + 4 < filesize )
442
+ if (seekpos + framesz + 4 < filesize )
441
443
{
442
- fseek (mp3file , seekpos + framesize ( b , c , d ) , SEEK_SET );
444
+ fseek (mp3file , seekpos + framesz , SEEK_SET );
443
445
a = fgetc (mp3file );
444
446
b = fgetc (mp3file );
445
447
c = fgetc (mp3file );
@@ -716,14 +718,13 @@ real avbitrate(void)
716
718
of one frame. Taken from mpglib and mpcut. */
717
719
unsigned int volume (long playpos )
718
720
{
719
- // unsigned char a,b,c,d;
720
- unsigned char b ,c ,d ;
721
+ unsigned char a ,b ,c ,d ;
721
722
unsigned int level , framenum = 4 ;
722
723
unsigned int i , frsize ;
723
724
long pos ;
724
725
725
726
FILE * volfile ;
726
- char volname [15 ] = "/tmp /volXXXXXX" ;
727
+ static char volname [] = "/dev/shm /volXXXXXX" ;
727
728
int fd = -1 ;
728
729
729
730
DBGPRINT (1 , "\nvolume(): before prevframe(playpos)" );
@@ -732,9 +733,16 @@ unsigned int volume(long playpos)
732
733
733
734
DBGPRINT (1 , "\nvolume(): after %ux prevframe %ld \n" ,framenum ,playpos );
734
735
735
- if ((fd = mkstemp (volname )) == -1 || (NULL == ( volfile = fdopen (fd , "w+b" ))) )
736
+ if ((fd = mkstemp (volname )) == -1 || (volfile = fdopen (fd , "w+b" )) == NULL )
736
737
{
737
- perror ("\ncutmp3: failed writing temporary volume mp3 in /tmp" );exitseq (6 ); /* open temp.vol.file read-writable zero length */
738
+ DBGPRINT (1 , "\nvolume(): /dev/shm not writable\n" );
739
+ strcpy (volname , "/tmp/volXXXXXX" );
740
+ if ((fd = mkstemp (volname )) == -1 || (volfile = fdopen (fd , "w+b" )) == NULL )
741
+ {
742
+ /* open temp.vol.file read-writable zero length */
743
+ perror ("\ncutmp3: failed writing temporary volume mp3 in /tmp" );
744
+ exitseq (6 );
745
+ }
738
746
}
739
747
740
748
frsize = 1 ;
@@ -749,12 +757,13 @@ unsigned int volume(long playpos)
749
757
pos = nextframe (pos );
750
758
DBGPRINT (1 , "\nvolume(): pos=%ld\n" ,pos );
751
759
fseek (mp3file , pos , SEEK_SET );
752
- // a=fgetc(mp3file);
753
- fgetc (mp3file );
754
- b = fgetc (mp3file );
755
- c = fgetc (mp3file );
756
- d = fgetc (mp3file );
757
- frsize = framesize (b ,c ,d );
760
+ a = fgetc (mp3file );
761
+ if (a == 255 ) {
762
+ b = fgetc (mp3file );
763
+ c = fgetc (mp3file );
764
+ d = fgetc (mp3file );
765
+ frsize = framesize (b ,c ,d );
766
+ }
758
767
}
759
768
DBGPRINT (1 , "\nvolume(): frsize=%u\n" ,frsize );
760
769
/* write this frame */
0 commit comments