Skip to content

Commit 385ad69

Browse files
authored
Merge pull request jgilje#19 from Sound-Linux-More/master
0.20250301: option frame size for SDL init
2 parents c797efd + ead93dd commit 385ad69

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
cmake_minimum_required(VERSION 3.5)
22

33
set(MAJOR_VERSION 0)
4-
set(DATE_VERSION 20211104)
5-
set(V2M_MAN_DATE "04 Nov 2021")
4+
set(DATE_VERSION 20250301)
5+
set(V2M_MAN_DATE "01 Mar 2025")
66
set(V2M_VERSION ${MAJOR_VERSION}.${DATE_VERSION})
77
project(v2mplayer VERSION ${V2M_VERSION})
88

src/tinyplayer.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ static void V2mPlayerUsage()
3939
printf("options:\n");
4040
printf(" -s N.N start at position (float, optional, in s., default = 0.0)\n");
4141
printf(" -g N.N gain (float, optional, default = 1.0)\n");
42+
printf(" -f N frame size for SDL (int, optional, default = 1024)\n");
4243
printf(" -k key/auto stop (bool, optional, default = false)\n");
4344
printf(" -o str output v2m newest version (string, optional, default = none)\n");
4445
printf(" -h this help\n");
4546
}
4647

4748
static float gain = 1.0f;
49+
static int frame_size = 1024;
4850
static void sdl_callback(void *userdata, Uint8 * stream, int len) {
4951
float* buf = (float*) stream;
5052
player.Render(buf, len / 8);
@@ -65,7 +67,7 @@ static bool init_sdl()
6567
SDL_AudioSpec desired, actual;
6668
desired.channels = 2;
6769
desired.freq = 44100;
68-
desired.samples = 1024;
70+
desired.samples = frame_size;
6971
desired.format = AUDIO_F32;
7072
desired.callback = sdl_callback;
7173

@@ -114,7 +116,7 @@ int main(int argc, char** argv)
114116
int fkey = 0;
115117
int fhelp = 0;
116118
char *foutput;
117-
while ((opt = getopt(argc, argv, "ko:hs:g:")) != -1)
119+
while ((opt = getopt(argc, argv, "ko:hs:g:f:")) != -1)
118120
{
119121
switch(opt)
120122
{
@@ -131,9 +133,13 @@ int main(int argc, char** argv)
131133
case 'g':
132134
gain = atof(optarg);
133135
break;
136+
case 'f':
137+
frame_size = atoi(optarg);
138+
frame_size = (frame_size < 64) ? 64 : ((frame_size < 16384) ? frame_size : 16384);
139+
break;
134140
case 's':
135141
startPos = (int)(atof(optarg) * 1000);
136-
startPos = (startPos > 0) ? startPos : 0;
142+
startPos = (startPos < 0) ? 0 : startPos;
137143
break;
138144
case ':':
139145
printf("option needs a value\n");

0 commit comments

Comments
 (0)