Skip to content

Commit 5711b99

Browse files
committed
removed 'force power size stdin buffer'
1 parent 1bb6e3e commit 5711b99

File tree

1 file changed

+24
-42
lines changed

1 file changed

+24
-42
lines changed

src/tinyplayer.cpp

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static void V2mPlayerUsage()
3737
{
3838
printf("Usage : v2mplayer [options] <input_file_v2m>\n\n");
3939
printf("options:\n");
40-
printf(" -b N force power size stdin buffer (int, optional, [0..10])\n");
4140
printf(" -s N.N start at position (float, optional, in s., default = 0.0)\n");
4241
printf(" -g N.N gain (float, optional, default = 0.0)\n");
4342
printf(" -k key/auto stop (bool, optional, default = false)\n");
@@ -111,18 +110,14 @@ int main(int argc, char** argv)
111110
V2mPlayerTitle();
112111
int opt;
113112
int startPos = 0;
114-
int fbuf = -1;
115113
int fouts = 0;
116114
int fkey = 0;
117115
int fhelp = 0;
118116
char *foutput;
119-
while ((opt = getopt(argc, argv, ":b:ko:hs:g:")) != -1)
117+
while ((opt = getopt(argc, argv, "ko:hs:g:")) != -1)
120118
{
121119
switch(opt)
122120
{
123-
case 'b':
124-
fbuf = atoi(optarg);
125-
break;
126121
case 'k':
127122
fkey = 1;
128123
break;
@@ -162,48 +157,35 @@ int main(int argc, char** argv)
162157
if(optind + 1 > argc)
163158
{
164159
file = stdin;
165-
if (fbuf < 0)
160+
eofcnt = 0;
161+
size = blksz;
162+
theTune = (unsigned char*) calloc(1, size);
163+
if (theTune == NULL)
166164
{
167-
eofcnt = 0;
168-
size = blksz;
169-
theTune = (unsigned char*) calloc(1, size);
170-
if (theTune == NULL)
171-
{
172-
fprintf(stderr, "Error memory allocator: %Ld b\n", size);
173-
exit(1);
174-
}
175-
ch = getc(stdin);
176-
while (ch != EOF || eofcnt < blksz)
165+
fprintf(stderr, "Error memory allocator: %Ld b\n", size);
166+
exit(1);
167+
}
168+
ch = getc(stdin);
169+
while (ch != EOF || eofcnt < blksz)
170+
{
171+
if (ch != EOF) {eofcnt = 0;} else {eofcnt++;}
172+
if (read == size)
177173
{
178-
if (ch != EOF) {eofcnt = 0;} else {eofcnt++;}
179-
if (read == size)
174+
size += blksz;
175+
theTune = (unsigned char*)realloc(theTune, size * sizeof(unsigned char));
176+
if (theTune == NULL)
180177
{
181-
size += blksz;
182-
theTune = (unsigned char*)realloc(theTune, size * sizeof(unsigned char));
183-
if (theTune == NULL)
184-
{
185-
fprintf(stderr, "Error memory allocator: %Ld b\n", size);
186-
exit(1);
187-
}
178+
fprintf(stderr, "Error memory allocator: %lu b\n", size);
179+
exit(1);
188180
}
189-
theTune[read] = ch;
190-
read++;
191-
ch = getc(stdin);
192181
}
193-
read -= eofcnt;
194-
} else {
195-
if (fbuf < 0 || fbuf > 10) fbuf = 4;
196-
fbuf += 20;
197-
size = 1 << fbuf;
198-
theTune = (unsigned char*) calloc(1, size);
199-
if (theTune == NULL)
200-
{
201-
fprintf(stderr, "Error memory allocator: %Ld b\n", size);
202-
exit(1);
203-
}
204-
read = fread(theTune, 1, size, file);
182+
theTune[read] = ch;
183+
read++;
184+
ch = getc(stdin);
205185
}
206-
printf("Now Playing: stdin(%d[%Ld])\n", read, size);
186+
read -= eofcnt;
187+
188+
printf("Now Playing: stdin(%d[%lu])\n", read, size);
207189
size = read;
208190
} else {
209191
const char *v2m_filename = argv[optind];

0 commit comments

Comments
 (0)